/* ===================================================================
   ATLAS — operator shell design tokens
   Distinct from Threshold (tenant admin) + Compass (applicant).
   Character: flight deck, calm under stress, dense w/ rhythm.

   Ported VERBATIM from the design handoff
   (docs/design-references/design_handoff_atlas/source/src/tokens.css)
   per atlas-base-implementation-spec.md §3 — do not alter the values,
   the palette is calibrated. These calibrated bg / fg / cyan / ... token
   names supersede the --atlas- names sketched in ADR-0033 (the
   canon-refines-ADR reconciliation, spec §3).
   =================================================================== */

:root {
  /* type stacks — overridden by tweaks */
  --font-sans: "IBM Plex Sans", "Söhne", -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "Berkeley Mono", "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
  --font-display: var(--font-sans);

  /* density — overridden by tweaks */
  --row-h: 36px;
  --row-h-compact: 30px;
  --row-h-cozy: 42px;
  --pad-x: 16px;
  --pad-y: 12px;
  --gap: 12px;

  /* radii — small, hairline, never pill */
  --r-1: 2px;
  --r-2: 3px;
  --r-3: 5px;

  /* type scale */
  --t-meta: 11px;     /* small caps status / chrome labels */
  --t-micro: 12px;    /* table dense */
  --t-body: 13px;     /* row text */
  --t-base: 14px;     /* default UI */
  --t-h6: 15px;
  --t-h5: 17px;
  --t-h4: 20px;
  --t-h3: 24px;
  --t-h2: 30px;
  --t-h1: 38px;

  /* DARK (default) — near-black with hint of navy (matches logo dark) */
  --bg-0:  #05080c;          /* deepest — page edge / wells */
  --bg-1:  #0a0f15;          /* canvas */
  --bg-2:  #10161f;          /* surface */
  --bg-3:  #161e29;          /* raised */
  --bg-4:  #1d2734;          /* overlay / hover */
  --bg-tint-cyan: rgba(43, 180, 230, 0.06);
  --bg-tint-amber: rgba(232, 168, 56, 0.07);
  --bg-tint-red:   rgba(228, 80, 70, 0.08);
  --bg-tint-green: rgba(86, 199, 132, 0.06);

  --line:        rgba(255, 255, 255, 0.05);
  --line-strong: rgba(255, 255, 255, 0.10);
  --line-bright: rgba(255, 255, 255, 0.18);

  --fg-1: #e8eef6;   /* primary text */
  --fg-2: #b3bdca;   /* secondary */
  --fg-3: #7d8a9a;   /* tertiary / labels */
  --fg-4: #56616f;   /* quaternary / disabled */
  --fg-5: #3a4451;   /* reserved-but-not-built */

  /* ACCENTS — single chroma family */
  /* cyan: selection / focus / link — NEVER "good" */
  --cyan:        oklch(0.78 0.13 220);
  --cyan-dim:    oklch(0.58 0.12 220);
  --cyan-tint:   rgba(52, 199, 240, 0.12);
  --cyan-ink:    oklch(0.92 0.07 220);

  /* green: terminal-positive ONLY (Submitted, Completed, Resolved) */
  --green:       oklch(0.74 0.13 148);
  --green-dim:   oklch(0.55 0.10 148);
  --green-tint:  rgba(86, 199, 132, 0.14);

  /* amber: in-progress with friction, soft warning */
  --amber:       oklch(0.80 0.13 78);
  --amber-dim:   oklch(0.60 0.11 78);
  --amber-tint:  rgba(232, 168, 56, 0.16);

  /* red: operator intervention ONLY */
  --red:         oklch(0.68 0.20 24);
  --red-dim:     oklch(0.52 0.16 24);
  --red-tint:    rgba(228, 80, 70, 0.16);

  /* neutral status (queued / unstarted) */
  --neutral:     #7d8a9a;
  --neutral-tint: rgba(125, 138, 154, 0.14);

  /* shadows (very subtle — no SaaS soft-cloud) */
  --shadow-1: 0 1px 0 rgba(255,255,255,0.02) inset, 0 1px 0 rgba(0,0,0,0.4);
  --shadow-overlay: 0 24px 48px -12px rgba(0,0,0,0.6), 0 8px 16px -8px rgba(0,0,0,0.4);

  /* selection */
  --sel: rgba(52, 199, 240, 0.18);
  --sel-line: oklch(0.78 0.13 220);

  /* impersonation chrome */
  --impersonation: oklch(0.80 0.13 78);
  --impersonation-bg: #2a1f0a;
}

/* LIGHT variant — sober, cool-tinted paper */
:root[data-theme="light"] {
  --bg-0:  #e7ebf0;
  --bg-1:  #eef1f5;
  --bg-2:  #f7f8fa;
  --bg-3:  #ffffff;
  --bg-4:  #f0f3f7;

  --bg-tint-cyan:  rgba(20, 130, 180, 0.07);
  --bg-tint-amber: rgba(170, 110, 20, 0.08);
  --bg-tint-red:   rgba(190, 50, 50, 0.07);
  --bg-tint-green: rgba(30, 130, 80, 0.07);

  --line:        rgba(10, 20, 35, 0.07);
  --line-strong: rgba(10, 20, 35, 0.12);
  --line-bright: rgba(10, 20, 35, 0.20);

  --fg-1: #0a0f15;
  --fg-2: #3b4654;
  --fg-3: #5d6878;
  --fg-4: #8d97a6;
  --fg-5: #b6becb;

  --cyan:       oklch(0.55 0.14 220);
  --cyan-dim:   oklch(0.72 0.09 220);
  --cyan-tint:  rgba(20, 130, 180, 0.13);
  --cyan-ink:   oklch(0.42 0.13 220);

  --green:      oklch(0.50 0.14 148);
  --green-dim:  oklch(0.70 0.08 148);
  --green-tint: rgba(30, 130, 80, 0.13);

  --amber:      oklch(0.62 0.15 70);
  --amber-dim:  oklch(0.78 0.09 70);
  --amber-tint: rgba(180, 120, 20, 0.16);

  --red:        oklch(0.52 0.20 24);
  --red-dim:    oklch(0.72 0.12 24);
  --red-tint:   rgba(190, 50, 50, 0.14);

  --neutral:    #5d6878;
  --neutral-tint: rgba(80, 95, 115, 0.12);

  --sel: rgba(20, 130, 180, 0.13);

  --impersonation: oklch(0.55 0.14 70);
  --impersonation-bg: #fff4d8;

  --shadow-1: 0 1px 0 rgba(10,20,35,0.04);
  --shadow-overlay: 0 24px 48px -12px rgba(10,20,35,0.15), 0 8px 16px -8px rgba(10,20,35,0.1);
}

/* density variants */
:root[data-density="compact"] {
  --row-h: var(--row-h-compact);
  --pad-x: 12px;
  --pad-y: 8px;
  --gap: 8px;
}
:root[data-density="cozy"] {
  --row-h: var(--row-h-cozy);
  --pad-x: 20px;
  --pad-y: 16px;
  --gap: 16px;
}

/* status intensity */
:root[data-status-intensity="subtle"] {
  --bg-tint-cyan:  rgba(52, 199, 240, 0.04);
  --bg-tint-amber: rgba(232, 168, 56, 0.04);
  --bg-tint-red:   rgba(228, 80, 70, 0.05);
  --bg-tint-green: rgba(86, 199, 132, 0.04);
}
:root[data-status-intensity="loud"] {
  --bg-tint-cyan:  rgba(52, 199, 240, 0.18);
  --bg-tint-amber: rgba(232, 168, 56, 0.22);
  --bg-tint-red:   rgba(228, 80, 70, 0.22);
  --bg-tint-green: rgba(86, 199, 132, 0.18);
}

/* base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-1);
  color: var(--fg-1);
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: 1.4;
  font-feature-settings: "ss01", "ss02", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--sel); }

/* hide native scrollbar styling but keep usable */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--line-bright); background-clip: padding-box; border: 2px solid transparent; }

button { font: inherit; color: inherit; background: transparent; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--cyan); text-decoration: none; }

/* mono utility */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tnum { font-variant-numeric: tabular-nums; }
.caps { font-size: var(--t-meta); letter-spacing: 0.10em; text-transform: uppercase; font-weight: 500; }
.dim { color: var(--fg-3); }
.dimmer { color: var(--fg-4); }

/* status text — small caps, integrated into row rhythm */
.st {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.st::before {
  content: "";
  width: 6px;
  height: 6px;
  background: currentColor;
  flex-shrink: 0;
}
.st--queued   { color: var(--fg-3); }
.st--running  { color: var(--amber); }
.st--running::before { animation: pulse 1.4s ease-in-out infinite; }
.st--done     { color: var(--green); }
.st--failed   { color: var(--red); }
.st--paused   { color: var(--fg-3); }
.st--paused::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.st--info     { color: var(--cyan); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* hairline divider */
.hr { border-top: 1px solid var(--line); }
.vr { border-left: 1px solid var(--line); }

/* keyboard key */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-2);
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  border-bottom-width: 2px;
}

/* hairline border helpers */
.box {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
}
.box-h {
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}
.box-h h3 {
  margin: 0;
  font-size: var(--t-body);
  font-weight: 550;
  color: var(--fg-1);
  letter-spacing: -0.005em;
}

/* link-button (inline action) */
.lbtn {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-3);
  padding: 4px 8px;
  border-radius: var(--r-1);
  border: 1px solid transparent;
  transition: color 120ms, border-color 120ms;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lbtn:hover { color: var(--fg-1); background: var(--bg-3); }
.lbtn--primary { color: var(--cyan-ink); border-color: var(--cyan-dim); }
.lbtn--primary:hover { background: var(--cyan-tint); color: var(--cyan); border-color: var(--cyan); }
.lbtn--danger { color: var(--red); }
.lbtn--danger:hover { background: var(--red-tint); border-color: var(--red); color: var(--red); }

/* primary button */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 12px;
  background: var(--bg-3);
  color: var(--fg-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  font-size: var(--t-body);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 120ms, color 120ms;
}
.btn:hover { background: var(--bg-4); border-color: var(--line-bright); }
.btn--primary {
  background: var(--cyan-tint);
  color: var(--cyan-ink);
  border-color: var(--cyan-dim);
}
.btn--primary:hover { background: rgba(52, 199, 240, 0.22); border-color: var(--cyan); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn--ghost:hover { background: var(--bg-3); color: var(--fg-1); }
.btn--icon { width: 28px; height: 28px; padding: 0; justify-content: center; }

/* search input */
.input {
  height: 28px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: 0 10px;
  color: var(--fg-1);
  font-size: var(--t-body);
  outline: none;
  transition: border-color 120ms;
}
.input:focus { border-color: var(--cyan); background: var(--bg-2); }
.input::placeholder { color: var(--fg-4); }

/* table */
table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-body);
}
table.t th {
  text-align: left;
  font-weight: 500;
  font-size: var(--t-meta);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-4);
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
table.t td {
  padding: 0 12px;
  height: var(--row-h);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
table.t tbody tr:hover { background: var(--bg-3); }
table.t tbody tr[aria-selected="true"] {
  background: var(--sel);
  box-shadow: inset 2px 0 0 var(--cyan);
}
table.t tbody tr.failed-row { background: var(--bg-tint-red); }
table.t tbody tr.failed-row:hover { background: rgba(228, 80, 70, 0.13); }

.row-actions { display: inline-flex; gap: 4px; align-items: center; opacity: 0.55; transition: opacity 120ms; }
table.t tbody tr:hover .row-actions,
table.t tbody tr[aria-selected="true"] .row-actions,
table.t tbody tr.failed-row .row-actions { opacity: 1; }

/* tabs */
.tabs { display: flex; gap: 2px; align-items: stretch; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tab {
  padding: 8px 12px;
  font-size: var(--t-body);
  color: var(--fg-3);
  border-bottom: 1.5px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 120ms, border-color 120ms;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tab:hover { color: var(--fg-1); }
.tab[aria-selected="true"] { color: var(--fg-1); border-bottom-color: var(--cyan); }
.tab-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-4);
  padding: 1px 6px;
  background: var(--bg-3);
  border-radius: var(--r-1);
}
.tab[aria-selected="true"] .tab-count { color: var(--fg-2); }
.tab .tab-count--alert { color: var(--red); background: var(--red-tint); }

/* utility */
.nowrap { white-space: nowrap; }
.flex { display: flex; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; }
