:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --ink: #17201d;
  --muted: #66726d;
  --line: #dbe3df;
  --accent: #0f766e;
  --accent-2: #8b5cf6;
  --warn: #b45309;
  --bad: #b91c1c;
  --good: #0f7a43;
  --shadow: 0 18px 50px rgba(18, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 260px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app {
  width: min(1680px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.brand-line {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 84px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 4.2vw, 60px);
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

h1 span {
  color: var(--accent);
}

.top-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search,
.filter-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search {
  min-width: 0;
}

.filter-control {
  min-width: 0;
}

.filterbar {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 12px 32px rgba(18, 33, 29, 0.05);
}

.toggle-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  min-width: 150px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.filter-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-height: 44px;
}

.toggle-filter input {
  width: 16px;
  height: 16px;
}

.ghost-button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 800;
  min-width: 96px;
}

input,
select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  width: 100%;
}

input {
  padding: 0 12px;
}

select {
  padding: 0 34px 0 12px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 14px;
  box-shadow: 0 10px 24px rgba(18, 33, 29, 0.04);
}

.metric .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric .value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 850;
}

.metric-wide {
  grid-column: span 2;
}

.metric-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.metric-mini {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbfa;
  padding: 9px;
}

.metric-mini span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
}

.metric-mini strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(560px, 0.96fr) minmax(520px, 1.04fr);
  gap: 14px;
  align-items: stretch;
}

.job-list,
.detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.job-list {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 182px);
  overflow: hidden;
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 58px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.list-head h2,
.detail-title h2 {
  margin-bottom: 0;
  font-size: 18px;
}

#jobCount {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8faf9;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

td {
  color: #24302c;
  font-size: 13px;
  vertical-align: top;
}

tr.job-row {
  cursor: pointer;
}

tr.job-row:hover,
tr.job-row.active {
  background: #edf7f5;
}

.company {
  font-weight: 800;
}

.company-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.role {
  max-width: 250px;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #365049;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.applied {
  background: #e3f5eb;
  color: var(--good);
}

.pill.failed,
.pill.closed {
  background: #fff1e6;
  color: var(--warn);
}

.source-tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef3f1;
  color: #365049;
  padding: 0 7px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  vertical-align: middle;
  white-space: nowrap;
}

.source-tag.manual {
  border-color: #c6bdf7;
  background: #f1efff;
  color: var(--accent-2);
}

.source-tag.automated {
  border-color: #a9d7cf;
  background: #ecfbf8;
  color: var(--accent);
}

.detail {
  min-height: calc(100vh - 182px);
  overflow: hidden;
}

.empty {
  display: grid;
  place-content: center;
  min-height: 360px;
  padding: 36px;
  text-align: center;
}

.empty p {
  color: var(--muted);
}

.detail-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.detail-title p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.detail-title h2 .source-tag {
  margin-left: 8px;
  transform: translateY(-2px);
}

.confidence {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border: 1px solid #b7ddd6;
  border-radius: 50%;
  background: #ecfbf8;
  color: var(--accent);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  flex: 0 0 auto;
}

.meta-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.meta-item {
  background: #fbfcfc;
  padding: 12px 14px;
}

.meta-item span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.meta-item strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 14px 0;
  border-bottom: 1px solid var(--line);
}

.tab {
  height: 36px;
  border: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 800;
}

.tab.active {
  background: var(--ink);
  color: white;
}

.panel {
  padding: 16px 18px 18px;
}

.summary {
  color: #2f3f3a;
  line-height: 1.55;
}

.summary-block {
  margin-top: 14px;
}

.summary-block h3 {
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 15px;
}

.summary-block .summary {
  margin-bottom: 0;
}

.timeline-card {
  margin-top: 18px;
}

.timeline-card h3 {
  margin-bottom: 14px;
  color: var(--ink);
  font-size: 15px;
}

.timeline {
  --timeline-progress: 0;
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding-top: 2px;
}

.timeline::before,
.timeline::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 12.5%;
  right: 12.5%;
  height: 4px;
  border-radius: 999px;
}

.timeline::before {
  background: var(--line);
}

.timeline::after {
  width: 75%;
  background: var(--accent);
  transform: scaleX(var(--timeline-progress));
  transform-origin: left;
}

.timeline-item {
  position: relative;
  z-index: 1;
  min-height: 84px;
  padding: 34px 10px 0;
  text-align: center;
}

.timeline-item.active {
  color: var(--accent);
}

.timeline-dot {
  position: absolute;
  top: 2px;
  left: 50%;
  width: 26px;
  height: 26px;
  border: 4px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  transform: translateX(-50%);
}

.timeline-item.active .timeline-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.timeline-item strong,
.timeline-item small {
  display: block;
}

.timeline-item strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.2;
}

.timeline-item small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.25;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.action.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.file-grid {
  display: grid;
  gap: 8px;
}

.file-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.file-row strong {
  display: block;
  font-size: 13px;
}

.file-row span {
  color: var(--muted);
  font-size: 12px;
}

.referral-grid,
.conversation-grid {
  display: grid;
  gap: 10px;
}

.referral-card,
.conversation-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 12px;
}

.referral-card[open],
.conversation-card[open] {
  border-color: rgba(15, 118, 110, 0.36);
  background: #f7fbfa;
}

.referral-head,
.conversation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.referral-head::-webkit-details-marker,
.conversation-head::-webkit-details-marker {
  display: none;
}

.referral-head strong,
.referral-head span,
.conversation-head strong,
.conversation-head span {
  display: block;
}

.referral-head strong,
.conversation-head strong {
  font-size: 14px;
}

.referral-head span,
.conversation-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.subtle-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.subtle-link:hover {
  text-decoration: underline;
}

.copy {
  margin-top: 10px;
  border-left: 3px solid var(--accent);
  background: #f4fbf9;
  padding: 12px;
  color: #33433e;
  line-height: 1.55;
}

.referral-message,
.conversation-message {
  white-space: pre-wrap;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.pipeline-step {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 10px;
}

.pipeline-step.active {
  border-color: #a9d7cf;
  background: #ecfbf8;
}

.pipeline-step span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.pipeline-step strong {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.25;
}

.pipeline-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 10px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 850;
}

.preview-shell {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8faf9;
}

.markdown-shell {
  overflow: auto;
  max-height: min(62vh, 720px);
}

.markdown-preview {
  padding: 22px;
  color: #24302c;
  font-size: 14px;
  line-height: 1.6;
}

.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4 {
  margin: 20px 0 8px;
  color: var(--ink);
  line-height: 1.2;
}

.markdown-preview h2:first-child,
.markdown-preview h3:first-child,
.markdown-preview h4:first-child {
  margin-top: 0;
}

.markdown-preview p {
  margin: 0 0 12px;
}

.markdown-preview ul {
  margin: 0 0 16px;
  padding-left: 22px;
}

.markdown-preview li {
  margin: 6px 0;
}

.markdown-preview a {
  color: var(--accent);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.markdown-preview code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef3f1;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.doc-preview {
  display: block;
  width: 100%;
  height: min(62vh, 720px);
  border: 0;
  background: white;
}

.pdf-preview {
  min-height: min(62vh, 720px);
}

.preview-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.login-page {
  min-height: 100vh;
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(100%, 430px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin-top: 4px;
  font-size: 32px;
  white-space: normal;
}

.login-brand {
  margin-bottom: 0;
  color: var(--accent);
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.login-button {
  height: 44px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
}

.login-error {
  min-height: 18px;
  margin-bottom: 0;
  color: var(--bad);
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 1120px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .filterbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-wide {
    grid-column: span 2;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    max-height: 430px;
  }
}

@media (max-width: 640px) {
  .app {
    width: min(100vw - 20px, 1680px);
    padding-top: 16px;
  }

  .metrics,
  .meta-strip,
  .pipeline,
  .timeline,
  .filterbar {
    grid-template-columns: 1fr;
  }

  .metric-wide {
    grid-column: auto;
  }

  .metric-split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: 34px;
  }

  .brand-line {
    flex-wrap: wrap;
    gap: 6px 12px;
  }

  th:nth-child(1),
  td:nth-child(1),
  th:nth-child(5),
  td:nth-child(5),
  th:nth-child(6),
  td:nth-child(6) {
    display: none;
  }

  .detail-title {
    flex-direction: column;
  }

  .filter-actions {
    justify-content: space-between;
  }

  .timeline {
    padding-top: 0;
  }

  .timeline::before,
  .timeline::after {
    display: none;
  }

  .timeline-item {
    min-height: 68px;
    padding: 14px 10px 10px 42px;
    text-align: left;
  }

  .timeline-dot {
    top: 14px;
    left: 10px;
    transform: none;
  }
}
