/* ===========================================================================
   gCode design system — May 2026
   Devtool · dark · sharp · high-density. Sans + italic serif accents.
   Used by every gcode-web + kanban surface.
   =========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500;600&display=swap");

:root {
  /* Core */
  --bg:      #0a0a0a;
  --bg-2:    #141414;
  --bg-3:    #1c1c1c;
  --panel:   #111111;
  --rule:    #222222;
  --rule-2:  #2e2e2e;
  --ink:     #e0e0e0;
  --ink-2:   #b8b8b8;
  --muted:   #999999;
  --muted-2: #6f6f6f;

  /* Accent + status. `--user-primary` / `--user-secondary` / `--user-ink`
     are per-user CSS-var overrides injected at SSR time (see
     gcode-web/src/lib/user-theme.ts + UserThemeProvider). When unset
     the accent tokens keep their original dark-theme values. */
  --acc:     var(--user-primary, #00ff41);
  --acc-2:   var(--user-secondary, #00C46A);
  --acc-ink: var(--user-ink, #03130A);
  /* `--*-soft` — opaque pale-status surfaces for avatar/badge/tile fills.
     Opaque (mixed into --bg-2, not transparent) so paired text has
     deterministic WCAG contrast regardless of what sits beneath.
     Consumers pair these with the matching saturated token (--acc/--info/
     --warn), NOT with --acc-ink (acc-soft is a light surface in both
     themes; acc-ink flips white in light mode and would vanish). */
  --acc-soft:  color-mix(in oklab, var(--acc) 18%, var(--bg-2));
  --info-soft: color-mix(in oklab, var(--info) 18%, var(--bg-2));
  --warn-soft: color-mix(in oklab, var(--warn) 18%, var(--bg-2));
  --warn:    #f59e0b;
  --hot:     #fb7185;
  --info:    #60a5fa;
  --plum:    #C792EA;

  /* Typography */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Menlo", monospace;

  /* Density (compact default; --d=0 compact, --d=1 comfortable) */
  --d: 0;
  --u: calc(4px + var(--d) * 2px);          /* base unit */
  --row: calc(28px + var(--d) * 8px);       /* row height */
  --pad-x: calc(12px + var(--d) * 4px);
  --base-fs: calc(13px + var(--d) * 1px);

  --maxw: 1400px;
}

[data-density="comfortable"] { --d: 1; }

/* ===== Light theme override ===== */
:root[data-theme="light"] {
  --bg:      #f4f2ec;
  --bg-2:    #faf8f1;
  --bg-3:    #ece9dd;
  --panel:   #ffffff;
  --rule:    #e0ddd0;
  --rule-2:  #c9c5b3;
  --ink:     #0a0a0a;
  --ink-2:   #2a2a2a;
  --muted:   #6f6d63;
  --muted-2: #908e83;

  /* Light-theme accents — same `--user-*` cascade so a user-chosen colour
     applies regardless of light/dark mode. The fallbacks here are the
     light-theme defaults from before the P1-3 picker shipped.
     --acc default is #166534 (was #15803d): the lighter green measured
     4.48:1 as text on the pale --bg / --acc-soft surfaces (italic heading
     accents, marketplace tag-filter chips) — just under the WCAG 1.4.3
     4.5:1 floor. #166534 is the existing palette green (--acc-2's value),
     not a new colour: ~6.4:1 on --bg, and as a solid button fill it only
     deepens the contrast of the white --acc-ink text on top. */
  --acc:     var(--user-primary, #166534);
  --acc-2:   var(--user-secondary, #166534);
  --acc-ink: var(--user-ink, #ffffff);
  /* Light-theme `--*-soft` — pale status tints mixed into white. `--acc-ink`
     is #fff here and would be illegible ON these surfaces; consumers place
     --acc / --info / --warn (saturated) text on them, never --acc-ink. */
  --acc-soft:  color-mix(in oklab, var(--acc) 14%, #ffffff);
  --info-soft: color-mix(in oklab, var(--info) 14%, #ffffff);
  --warn-soft: color-mix(in oklab, var(--warn) 14%, #ffffff);
  --warn:    #b45309;
  --hot:     #be123c;
  --info:    #1d4ed8;
  --plum:    #7D52B5;
}

/* Smooth theme transitions */
html { transition: background-color .18s ease, color .18s ease; }
body, .topnav, .panel, .section, .card, .ctable, .ttable, .keys-table, .team-table,
input, textarea, button, .step, .agents-glance, .quote, .stats > .s, .plan, .plan-card,
.danger-card, .filter button, .toggles, .toggles button, .oauth button, .form .field input,
.form .field .input-row, .form .checkrow input[type=checkbox], .plan-pick label,
.crumbs, .sidenav, .sidenav a, .row, .ses, .ses .icn, .toggle, .model {
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--base-fs);
  line-height: 1.45;
  font-feature-settings: "ss01","cv11","tnum";
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: color-mix(in oklab, var(--acc) 35%, transparent); color: var(--ink); }

/* ===== Primitives ===== */
.wrap { max-width: var(--maxw); margin: 0 auto; padding-inline: clamp(16px, 3vw, 36px); }
.mono { font-family: var(--font-mono); }
.serif { font-family: var(--font-serif); font-style: italic; font-weight: 400; letter-spacing: -0.01em; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex; align-items: center; gap: 8px;
}
.eyebrow::before {
  content: "";
  width: 5px; height: 5px; border-radius: 999px;
  background: var(--acc);
  box-shadow: 0 0 8px var(--acc);
  display: inline-block;
}

.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--ink-2);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 12.5px;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, transform .12s;
}
.btn:active { transform: translateY(1px); }
.btn-acc { background: var(--acc); color: var(--acc-ink); }
.btn-acc:hover { background: color-mix(in oklab, var(--acc) 90%, white); }
.btn-pri { background: var(--ink); color: var(--bg); }
.btn-pri:hover { background: color-mix(in oklab, var(--ink) 90%, var(--acc)); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--rule); }
.btn-ghost:hover { color: var(--ink); border-color: var(--rule-2); background: var(--bg-2); }
.btn-icon { padding: 6px; }
.btn-sm { padding: 5px 9px; font-size: 11.5px; }
.btn-lg { padding: 11px 18px; font-size: 13.5px; }

/* ===== Pills ===== */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-2);
  letter-spacing: 0.02em;
}
.pill .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--muted); }
.pill.ok    { color: var(--acc);  border-color: color-mix(in oklab, var(--acc) 35%, var(--rule)); }
.pill.ok    .dot { background: var(--acc); box-shadow: 0 0 6px var(--acc); }
.pill.warn  { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 35%, var(--rule)); }
.pill.warn  .dot { background: var(--warn); }
.pill.hot   { color: var(--hot);  border-color: color-mix(in oklab, var(--hot) 35%, var(--rule)); }
.pill.hot   .dot { background: var(--hot); }
.pill.info  { color: var(--info); border-color: color-mix(in oklab, var(--info) 35%, var(--rule)); }
.pill.info  .dot { background: var(--info); }
.pill.solid { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill.acc   { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); }

/* ===== Cards / panels ===== */
.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.panel-body { padding: 12px; }

/* ===== Form controls ===== */
.input, .textarea, .select {
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--ink);
  width: 100%;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--acc);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--acc) 22%, transparent);
}
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ===== Top app bar (chrome) ===== */
.appbar {
  display: flex; align-items: center; gap: 12px;
  height: 40px;
  padding: 0 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--rule);
  font-size: 12.5px;
}
.appbar .traffic { display: inline-flex; gap: 6px; margin-right: 8px; }
.appbar .traffic i { width: 11px; height: 11px; border-radius: 999px; background: var(--rule-2); display: inline-block; }
.appbar .traffic i.r { background: #FF5F56; }
.appbar .traffic i.y { background: #FFBD2E; }
.appbar .traffic i.g { background: #27C93F; }

.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 13.5px; letter-spacing: -0.01em;
  color: var(--ink);
}
.brand-mark {
  width: 22px; height: 22px;
  background: var(--acc); color: var(--acc-ink);
  border-radius: 5px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-weight: 700; font-size: 12px;
  box-shadow: 0 0 14px color-mix(in oklab, var(--acc) 45%, transparent);
}
/* The header brand mark is now the Gavedu mandala (transparent PNG), not a
   letter tile — neutralise the accent fill / tile so the transparent mark
   renders cleanly instead of sitting on an indigo square. A soft gold glow
   (echoing the logo's ring) + a gentle hover lift keep it alive without
   distracting continuous motion in a persistent 22px nav element. */
img.brand-mark {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(245, 166, 35, 0.35));
  transition: transform .25s ease, filter .25s ease;
}
.brand:hover img.brand-mark {
  transform: scale(1.08);
  filter: drop-shadow(0 0 10px rgba(245, 166, 35, 0.55));
}
@media (prefers-reduced-motion: reduce) {
  img.brand-mark { transition: none; }
}

.crumbs { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.crumbs a { color: var(--ink-2); }
.crumbs .sep { color: var(--muted-2); }
.crumbs .cur { color: var(--ink); }

/* ===== Tables ===== */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th, .tbl td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.tbl thead th {
  background: var(--bg-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  position: sticky; top: 0;
}
.tbl tbody tr:hover td { background: color-mix(in oklab, var(--acc) 5%, var(--bg-2)); }
.tbl td .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ===== Status dot pulse ===== */
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.live { animation: pulse-dot 1.6s ease-in-out infinite; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--rule-2); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ===== Utility ===== */
.hr { border: 0; height: 1px; background: var(--rule); margin: 12px 0; }
.row { display: flex; align-items: center; gap: 8px; }
.gap { flex: 1; }
.muted { color: var(--muted); }
.acc { color: var(--acc); }
.serif-acc { font-family: var(--font-serif); font-style: italic; color: var(--acc); font-weight: 400; }

/* Glow ring for hero accents */
.glow {
  background: radial-gradient(60% 80% at 30% 0%, color-mix(in oklab, var(--acc) 18%, transparent) 0%, transparent 60%),
              radial-gradient(40% 60% at 90% 100%, color-mix(in oklab, var(--plum) 20%, transparent) 0%, transparent 70%);
}

/* Density toggle — compact label everywhere */
[data-density] .panel-body { padding: calc(8px + var(--d)*4px) calc(10px + var(--d)*4px); }
