/* ===========================================================================
   iJoin design tokens — single source of truth for color, type, and radius.

   Lifted from OTP's system (src/styles/tokens.css) and its principles:
     - Layered: primitives -> semantic roles. Pages reference roles, never
       primitives, and never a raw hex.
     - Hairlines are TINTED INK at low alpha, not gray. They sit on any surface.
     - Color is STATUS, not decoration. A page with nothing wrong is nearly
       monochrome.
     - Light, editorial. No dark mode.
     - Primitives in OKLCH: perceptually uniform, so a hover or muted state is
       the same hue at lower lightness instead of an eyeballed second color.

   WHAT IS DELIBERATELY NOT LIFTED
   Ollie lime (--otp-green*). That is OTP's brand and does not belong here.

   THE ACCENT IS ONE DECISION
   iJoin's accent lives in --ij-accent* below. It is currently a deep teal:
   distinct from Ollie lime and from Sneeze It magenta, and it reads as
   infrastructure rather than personality. Changing those four values re-skins
   the entire app — nothing else references a brand color.
   =========================================================================== */

:root {
  /* -- LAYER 1: primitives. The only place a color literal may appear. ----- */

  /* Ink ramp */
  --ij-ink-900: oklch(0.2008 0.0124 270.73);   /* #14161c */
  --ij-ink-600: oklch(0.4203 0.0174 268.26);   /* #494d57 */
  --ij-ink-400: oklch(0.6400 0.0156 268.42);   /* #888c96 */

  /* Surfaces */
  --ij-surface:        oklch(1.0000 0.0000 89.88);    /* #ffffff */
  --ij-surface-offset: oklch(0.9913 0.0013 286.38);   /* #fcfcfd */
  --ij-surface-sunken: oklch(0.9579 0.0029 264.54);   /* #f0f1f3 */
  --ij-canvas:         oklch(0.9755 0.0045 258.32);   /* #f5f7fa */

  /* Hairlines: tinted ink, translucent. */
  --ij-hairline:      oklch(0.2008 0.0124 270.73 / 0.10);
  --ij-hairline-soft: oklch(0.2008 0.0124 270.73 / 0.06);

  /* Accent — the one brand decision. Deep teal. */
  --ij-accent:      oklch(0.5900 0.1100 195.00);
  --ij-accent-deep: oklch(0.5100 0.1000 195.00);
  --ij-accent-soft: oklch(0.9550 0.0270 195.00);
  --ij-accent-line: oklch(0.9000 0.0500 195.00);

  /* Status. Saturated = the mark, soft = the fill it sits on. */
  --ij-ok:        oklch(0.6271 0.1699 149.21);   /* #16a34a */
  --ij-ok-soft:   oklch(0.9624 0.0434 156.74);   /* #dcfce7 */
  --ij-bad:       oklch(0.5771 0.2152 27.33);    /* #dc2626 */
  --ij-bad-soft:  oklch(0.9356 0.0309 17.72);    /* #fee2e2 */
  --ij-warn:      oklch(0.6658 0.1574 58.32);    /* #d97706 */
  --ij-warn-soft: oklch(0.9619 0.0580 95.62);    /* #fef3c7 */

  /* -- LAYER 2: semantic roles. Pages use these. -------------------------- */
  --ink:         var(--ij-ink-900);
  --ink-muted:   var(--ij-ink-600);
  --ink-faint:   var(--ij-ink-400);
  --surface:     var(--ij-surface);
  --surface-2:   var(--ij-surface-offset);
  --surface-3:   var(--ij-surface-sunken);
  --canvas:      var(--ij-canvas);
  --line:        var(--ij-hairline);
  --line-soft:   var(--ij-hairline-soft);
  --accent:      var(--ij-accent);
  --accent-deep: var(--ij-accent-deep);
  --accent-soft: var(--ij-accent-soft);
  --accent-line: var(--ij-accent-line);

  /* Radius and spacing — OTP's scale. */
  --r-sm: 3px;  --r-md: 7px;  --r-lg: 12px;
  --s-xs: 6px;  --s-sm: 12px; --s-md: 24px; --s-lg: 48px;

  /* Type */
  --font-display: Archivo, "Helvetica Neue", Arial, sans-serif;
  --font-body: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* --------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 1.75rem; line-height: 1.15; }
h2 { font-size: 1.15rem; line-height: 1.2; }
h3 { font-size: 0.95rem; line-height: 1.3; }

/* The mono micro-label. OTP's most recognizable texture. */
.label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.mono { font-family: var(--font-mono); font-size: 12px; }
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------- layout */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: var(--s-md) 0;
  display: flex; flex-direction: column;
}
.brand {
  font-family: var(--font-display); font-weight: 900;
  font-size: 1.3rem; letter-spacing: -0.03em;
  padding: 0 var(--s-md) var(--s-md);
}
.brand span { color: var(--accent); }

.nav { display: flex; flex-direction: column; gap: 1px; padding: 0 var(--s-sm); }
.nav a {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-sm);
  padding: 8px 12px; border-radius: var(--r-md);
  color: var(--ink-muted); font-size: 14px;
}
.nav a:hover { background: var(--surface-3); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
.nav .sec { padding: var(--s-md) 12px 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-md);
  padding: var(--s-sm) var(--s-lg);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.content { padding: var(--s-md) var(--s-lg) var(--s-lg); }
.page-head { margin-bottom: var(--s-md); }
.page-head p { margin: 4px 0 0; color: var(--ink-muted); font-size: 14px; max-width: 68ch; }

/* -------------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-md);
}
.card + .card { margin-top: var(--s-sm); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-sm); margin-bottom: var(--s-sm);
}
.grid { display: grid; gap: var(--s-sm); }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* Stat tile */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px var(--s-sm); }
.stat .v { font-family: var(--font-mono); font-size: 1.5rem; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; display: block; margin-top: 2px; }
.stat .d { font-size: 12px; color: var(--ink-faint); }

/* ------------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-family: var(--font-mono); font-size: 11px;
  font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint); padding: 0 12px 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.row:hover { background: var(--surface-2); }
td.r, th.r { text-align: right; }

/* -------------------------------------------------------------------- pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 100px; white-space: nowrap;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 100px; background: currentColor; }
.pill.ok   { background: var(--ij-ok-soft);   color: var(--ij-ok); }
.pill.bad  { background: var(--ij-bad-soft);  color: var(--ij-bad); }
.pill.warn { background: var(--ij-warn-soft); color: var(--ij-warn); }
.pill.off  { background: var(--surface-3);    color: var(--ink-faint); }
.pill.test { background: var(--accent-soft);  color: var(--accent-deep); }
.pill.flat::before { display: none; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.sm { font-size: 12px; padding: 5px 10px; }

/* ------------------------------------------------------------------ details */
.kv { display: grid; grid-template-columns: 168px 1fr; gap: 10px var(--s-sm); font-size: 14px; }
.kv dt { color: var(--ink-faint); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; padding-top: 3px; }
.kv dd { margin: 0; }

/* Code / key display */
.code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--surface-3); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); padding: 10px 12px;
  overflow-x: auto; white-space: pre; color: var(--ink);
}
.key { font-family: var(--font-mono); font-size: 12px; background: var(--surface-3); border-radius: var(--r-sm); padding: 2px 7px; }

/* Meter bar */
.meter { height: 6px; border-radius: 100px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); }
.meter.warn > i { background: var(--ij-warn); }
.meter.bad > i { background: var(--ij-bad); }

/* Test-mode banner — must be impossible to miss. */
.testbar {
  background: var(--accent-soft); border-bottom: 1px solid var(--accent-line);
  color: var(--accent-deep); padding: 7px var(--s-lg);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
}
.empty { text-align: center; padding: var(--s-lg) var(--s-md); color: var(--ink-faint); }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .content, .topbar, .testbar { padding-left: var(--s-md); padding-right: var(--s-md); }
  .kv { grid-template-columns: 1fr; gap: 2px var(--s-sm); }
  .kv dd { margin-bottom: 10px; }
}

/* Admin tag on the wordmark — makes the side you are on unmistakable. */
.brand .admintag {
  font-family: var(--font-mono); font-style: normal; font-size: 9px;
  font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-faint); background: var(--surface-3);
  border-radius: var(--r-sm); padding: 2px 6px; margin-left: 7px;
  vertical-align: middle;
}
/* Horizontal bar chart used in the reporting view. */
.bar { height: 6px; border-radius: 100px; background: var(--surface-3); overflow: hidden; min-width: 40px; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* Reporting filter bar. */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select {
  font-family: var(--font-body); font-size: 13px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); max-width: 220px;
}
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-muted); }
.legend i { width: 14px; height: 2px; border-radius: 2px; display: inline-block; }

/* Forms. */
.field { margin-bottom: var(--s-sm); display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select {
  font-family: var(--font-body); font-size: 14px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); width: 100%;
}
.field input:focus { outline: 2px solid var(--accent-line); outline-offset: -1px; border-color: var(--accent); }
.field .hint { font-size: 12px; color: var(--ink-faint); line-height: 1.5; }
.field .err { font-size: 12px; color: var(--ij-bad); font-weight: 500; }
.field input[aria-invalid="true"] { border-color: var(--ij-bad); }

/* Inline notices. */
.notice {
  border-radius: var(--r-lg); padding: 12px 16px; font-size: 14px;
  margin-bottom: var(--s-sm); border: 1px solid;
}
.notice.warn { background: var(--ij-warn-soft); border-color: var(--ij-warn-soft); color: var(--ij-warn); }
.notice.bad  { background: var(--ij-bad-soft);  border-color: var(--ij-bad-soft);  color: var(--ij-bad); }
.notice > div + div { margin-top: 6px; }

/* Tabs on the connect card. */
.tabs { display: flex; gap: 4px; margin-bottom: var(--s-sm); border-bottom: 1px solid var(--line); }
.tab {
  font-family: var(--font-body); font-size: 13px; font-weight: 500;
  padding: 7px 12px; border: 0; background: none; color: var(--ink-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--accent-deep); border-bottom-color: var(--accent); font-weight: 600; }

/* Copy affordance sitting on a code block. */
.copywrap { position: relative; }
.copywrap .code { margin: 0; padding-right: 84px; white-space: pre-wrap; word-break: break-word; }
.copywrap .copy { position: absolute; top: 8px; right: 8px; }
.btn.copy.ok { background: var(--ij-ok-soft); border-color: var(--ij-ok-soft); color: var(--ij-ok); }

/* Copy-paste prompt blocks — the activation moment, so they get real weight. */
.prompt { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; margin-bottom: var(--s-sm); }
.prompt:last-child { margin-bottom: 0; }
.prompt-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-sm);
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}
.prompt-body {
  margin: 0; border: 0; border-radius: 0; background: var(--surface);
  white-space: pre-wrap; line-height: 1.6; font-size: 12.5px; padding: 14px;
}
.steps { margin: 0 0 12px; padding-left: 20px; font-size: 14px; color: var(--ink-muted); line-height: 1.9; }

/* Checkbox label used in settings rows. */
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-muted); }
.chk input { accent-color: var(--accent); }
