/* Job Search Dashboard.
   Palette lifted from the Gen-Metrics brand (company/design-system/src/tokens/
   brand-genmetrics.css, itself lifted from company/website/assets/css/styles.css):
   dark is the default, light follows prefers-color-scheme.
   iPhone Safari first: no horizontal page scroll, tap targets >= 44px, safe-area
   insets, 16px inputs so focus never triggers a zoom.

   Chart colours (dataviz skill, validated with its validate_palette.js):
     status trio, dark  #5eead4 / #fbbf24 / #f87171  (only the light-band check
     fails, which is calibrated for light-mode fills; bright-on-dark is correct)
     status trio, light #047857 / #a16207 / #b91c1c  (amber and red sit close in
     CVD terms at AA lightness, so every badge always carries its word: fresh /
     aging / stale, never colour alone)
     bar fill vs track: separation passes in both modes; the track is deliberately
     low-contrast and every bar carries a printed value, which is the relief the
     validator asks for. */

:root {
  /* brand: dark */
  --bg: #1c1c1e;
  --surface: #252528;
  --surface-2: #2e2e33;
  --border: #333333;
  --border-strong: #6e6e73;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.70);
  --accent: #cddc39;             /* lime, the brand signal */
  --accent-ink: #cddc39;         /* accent used as text */
  --on-accent: #1c1c1e;
  --teal: #14b8a6;
  --track: #46464f;
  --good: #5eead4;
  --warn: #fbbf24;
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, 0.14);
  --warn-bg: rgba(251, 191, 36, 0.14);
  --good-bg: rgba(94, 234, 212, 0.14);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --gap: 14px;
  --tap: 44px;
  --pad-left: max(16px, env(safe-area-inset-left));
  --pad-right: max(16px, env(safe-area-inset-right));
  --pad-top: max(12px, env(safe-area-inset-top));
  --pad-bottom: max(28px, env(safe-area-inset-bottom));
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f2ef;
    --surface: #ffffff;
    --surface-2: #f6f6f2;
    --border: #e5e5e0;
    --border-strong: #8c8c8c;
    --text: #1c1c1e;
    --muted: rgba(28, 28, 30, 0.65);
    --accent: #cddc39;
    --accent-ink: #4a7c22;
    --on-accent: #1c1c1e;
    --teal: #0f766e;
    --track: #d6d6ce;
    --good: #047857;
    --warn: #a16207;
    --bad: #b91c1c;
    --bad-bg: rgba(185, 28, 28, 0.10);
    --warn-bg: rgba(161, 98, 7, 0.10);
    --good-bg: rgba(4, 120, 87, 0.10);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* Long unbroken company names and pasted URLs are the usual cause of a page-level
   horizontal scroll at 390px. */
.row-company, .row-role, .row-action, .row-note, .row-meta-line,
.tier-name, .kv dd, .warn-list li, .bar-label { overflow-wrap: anywhere; }

/* ---------- shell ---------- */

.banner {
  padding: 10px var(--pad-right) 10px var(--pad-left);
  background: var(--warn-bg);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: var(--pad-top) var(--pad-right) 12px var(--pad-left);
}

.topbar-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

main {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 0 var(--pad-right) var(--pad-bottom) var(--pad-left);
}

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  max-width: 100%;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.count {
  display: inline-block;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-align: center;
}

.empty {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.lede {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

/* Wide content scrolls inside its own container, never the page. */
.scroller {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* ---------- 1. KPI strip ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  min-height: var(--tap);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.kpi-num {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

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

.kpi--alert {
  background: var(--bad-bg);
  border-color: var(--bad);
}

.kpi--alert .kpi-num { color: var(--bad); }

.kpi--muted { background: transparent; }
.kpi--muted .kpi-num { font-size: 20px; color: var(--muted); }

.warn-chip { margin-top: 10px; }

.warn-chip > summary {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: 4px 14px;
  width: fit-content;
  border: 1px solid var(--warn);
  border-radius: var(--radius-pill);
  background: var(--warn-bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.warn-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- 2. Today ---------- */

.group + .group, .group + .group--undated { margin-top: 12px; }

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.rows { list-style: none; margin: 0; padding: 0; }

.row {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.row + .row { margin-top: 8px; }

.group--overdue .row {
  border-left: 3px solid var(--bad);
  background: var(--bad-bg);
}

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.row-company { font-weight: 600; }

.row-role, .row-action, .row-note, .row-meta-line {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.row-action { color: var(--text); }

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.group--undated > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}

/* ---------- chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.chip--date { color: var(--text); }
.chip--pri { border-color: var(--border-strong); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip--filter {
  min-height: var(--tap);
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.chip--filter.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.chip-count { color: inherit; opacity: 0.7; font-variant-numeric: tabular-nums; }

.chip--verdict { border-color: var(--border-strong); color: var(--text); }
.chip--strong { border-color: var(--good); color: var(--good); background: var(--good-bg); }
.chip--probe { border-color: var(--warn); color: var(--warn); background: var(--warn-bg); }

.badge {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge--fresh { background: var(--good-bg); color: var(--good); border: 1px solid var(--good); }
.badge--aging { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
.badge--stale { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); }

/* ---------- 3. Board ---------- */

.stage {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 0 10px;
}

.stage + .stage { margin-top: 8px; }

.stage > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.stage > summary::-webkit-details-marker { display: none; }

.stage > summary::before {
  content: "\25B8";
  color: var(--muted);
  transition: transform 0.15s ease;
}

.stage[open] > summary::before { transform: rotate(90deg); }

.stage-name { flex: 1 1 auto; }

.card {
  border-top: 1px solid var(--border);
  padding: 2px 0;
}

.card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--tap);
  cursor: pointer;
  list-style: none;
}

.card > summary::-webkit-details-marker { display: none; }

.card-title { display: flex; flex-direction: column; min-width: 0; }
.card-title .row-role { margin: 0; }

.kv {
  display: grid;
  grid-template-columns: minmax(84px, auto) 1fr;
  gap: 4px 12px;
  margin: 4px 0 10px;
  font-size: 14px;
}

.kv dt { color: var(--muted); font-size: 12px; padding-top: 2px; }
.kv dd { margin: 0; }

.card-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 14px;
}

.card-link-text { color: var(--accent-ink); }

.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  min-height: var(--tap);
  margin: -10px;             /* keeps the 44px target without bloating the row */
  padding: 10px;
  color: var(--accent-ink);
  text-decoration: none;
  font-size: 18px;
}

.card-link .icon-link { margin: 0; min-width: var(--tap); }

/* ---------- 4 + 6. Bars ---------- */

.bars { list-style: none; margin: 0; padding: 0; }

.bar-row {
  display: grid;
  grid-template-columns: minmax(72px, 96px) 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.bar-label { font-size: 13px; color: var(--muted); }

.bar {
  display: block;
  height: 12px;
  border-radius: var(--radius-pill);
  background: var(--track);
  overflow: hidden;
}

.bar-fill {
  display: block;
  width: var(--w, 0%);
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--teal);
  /* 2px of surface between the fill and the rest of the track */
  box-shadow: 2px 0 0 var(--surface);
}

.bar-fill--dead, .bar-fill--other { background: var(--border-strong); }
.bar-fill--touched { background: var(--teal); }

.bar-value {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.bar-total { color: var(--muted); font-weight: 400; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.table th, .table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.table thead th { color: var(--muted); font-weight: 600; }
.table th[scope="row"] { text-align: left; white-space: normal; font-weight: 500; }
.zero { color: var(--muted); }

.rollup { margin-top: 12px; }

.rollup > summary, .tier--kill > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

/* ---------- 5. Fresh roles ---------- */

.cards { display: flex; flex-direction: column; gap: 10px; }

.card--fresh {
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card--fresh .row-role { margin-top: 4px; color: var(--text); }
.card--fresh .row-note { margin-top: 6px; }
.card--fresh .card-link { margin: 10px 0 0; }

/* ---------- 6. Coverage ---------- */

.bars--coverage { margin-bottom: 6px; }

.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
}

.tier + .tier { margin-top: 12px; }

.tier-list { list-style: none; margin: 0; padding: 0; }

.tier-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 8px;
  padding: 5px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.tick { font-size: 13px; }
.tick--on { color: var(--teal); }
.tick--off { color: var(--muted); }

.tier-state { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ---------- screens ---------- */

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 60vh;
  padding: var(--pad-top) var(--pad-right) var(--pad-bottom) var(--pad-left);
  text-align: center;
}

.screen.overlay {
  position: fixed;
  inset: 0;
  min-height: 100%;
  background: var(--bg);
  z-index: 10;
}

.screen-title { margin: 0; font-size: 20px; font-weight: 600; }
.screen-text { margin: 0; color: var(--muted); max-width: 34ch; }

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  text-align: left;
}

.login-label { font-size: 14px; color: var(--muted); }

.login-form input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font-size: 16px; /* 16px keeps iOS Safari from zooming on focus */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.login-error { margin: 0; color: var(--bad); font-size: 14px; }

.btn {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.btn:disabled { opacity: 0.6; }

.btn-ghost {
  color: var(--text);
  background: transparent;
  border-color: var(--border);
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- wider screens ---------- */

@media (min-width: 720px) {
  main {
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: var(--pad-bottom);
  }
  .kpi-grid { grid-template-columns: repeat(6, 1fr); }
  .bar-row { grid-template-columns: minmax(96px, 140px) 1fr auto; }
}
