/* KYE Admin Console™ — Operator dashboard.
   Owners-only at admin.kyeprotocol.com. Dark theme harmonised to the
   kyeprotocol.com landing-page tokens (see public/site/styles.css).
   Admin uses the purple accent (`#6366f1`) from the landing-page's
   focus-ring family — same palette, distinct surface. This file is
   the token-definition file for admin.kyeprotocol.com; every OTHER
   css file under public/admin/** uses var(--…) per the
   design-tokens-coherent gate. */

:root {
  --bg: #0b0f1c;
  --paper: #131a2c;
  --paper-2: #1a2238;
  --paper-3: #232c46;
  --surface: var(--paper);
  --surface-2: var(--paper-2);
  --surface-3: var(--paper-3);
  --surface-solid: #ffffff;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --line-soft: rgba(255, 255, 255, 0.04);
  --text: #eef1f9;
  --text-muted: #aab2cc;
  --text-dim: #7d869f;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --accent-ink: #4338ca;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.12);
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  --font-mono: var(--mono);
  --font-ui:   var(--sans);
  --radius: 10px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--line);
  --scrim: rgba(0, 0, 0, 0.55);

  /* Type scale + icon sizes — locked by /design-system/tokens/type.json
     (constitution §24). Remediation Wave 5 mapped every Npx font-size
     to these tokens; this :root MUST define them. */
  --type-9: 9px; --type-10: 10px; --type-11: 11px; --type-12: 12px;
  --type-13: 13px; --type-14: 14px; --type-16: 16px; --type-18: 18px;
  --type-22: 22px; --type-28: 28px; --type-36: 36px; --type-48: 48px;
  --icon-12: 12px; --icon-14: 14px; --icon-16: 16px; --icon-18: 18px;
  --icon-20: 20px; --icon-24: 24px;
  --font-ui: "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: var(--type-14);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre { font-family: var(--mono); font-size: var(--type-12); }
pre {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0;
}

/* ---------- Top nav ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  height: 56px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: var(--type-14);
  letter-spacing: 0.02em;
  color: var(--text);
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  /* F3 — token-driven; was hardcoded #6366f1/#818cf8 */
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  display: grid; place-items: center;
  color: var(--color-paper); font-weight: 800; font-size: var(--type-13);
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: var(--type-13);
  font-weight: 500;
}
.nav a:hover { background: var(--paper-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-2); }
.topbar-right { display: flex; align-items: center; gap: 12px; color: var(--text-dim); font-size: var(--type-12); }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--paper-2);
  border-radius: 999px;
  border: 1px solid var(--line);
}
.avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  /* F4 — token-driven; was hardcoded #6366f1/#ec4899 magenta leak */
  background: linear-gradient(135deg, var(--accent), var(--accent-ink));
  display: grid; place-items: center;
  font-size: var(--type-11); font-weight: 700; color: var(--color-paper);
}

/* ---------- Layout ---------- */
.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 28px 60px;
}
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}
.page-title {
  font-size: var(--type-22);
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.page-sub {
  color: var(--text-muted);
  font-size: var(--type-13);
  margin: 0;
}

/* ---------- Cards / grid ---------- */
.grid {
  display: grid;
  gap: 16px;
}
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) {
  .grid-3, .grid-4, .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card-title {
  font-size: var(--type-11);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 0 0 10px;
  font-weight: 600;
}
.metric {
  font-size: var(--type-28);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.metric-sub {
  font-size: var(--type-12);
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--type-11);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.pill-ok    { background: var(--success-soft); color: #4ade80; }
.pill-warn  { background: var(--warning-soft); color: #fbbf24; }
.pill-info  { background: var(--info-soft);    color: #7dd3fc; }
.pill-bad   { background: var(--danger-soft);  color: #f87171; }
.pill-muted { background: var(--paper-3); color: var(--text-muted); }
.pill-accent{ background: var(--accent-soft);  color: var(--accent-2); }

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
table.kye {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--type-13);
}
table.kye th, table.kye td {
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.kye thead th {
  background: var(--paper-2);
  color: var(--text-dim);
  font-size: var(--type-11);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  border-bottom: 1px solid var(--line-strong);
}
table.kye tbody tr:hover { background: var(--paper-2); cursor: pointer; }
table.kye tbody tr:last-child td { border-bottom: 0; }
table.kye td.mono { font-family: var(--mono); font-size: var(--type-12); color: var(--text-muted); }

/* ---------- Toolbar / chips ---------- */
.toolbar {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.chip {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--text-muted);
  border: 1px solid var(--line);
  font-size: var(--type-12);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}
.chip:hover, .chip.active {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-color: var(--accent);
}
input.kye, select.kye, textarea.kye {
  background: var(--paper);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: var(--type-13);
  font-family: inherit;
}
input.kye:focus, select.kye:focus, textarea.kye:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
button.kye {
  background: var(--accent);
  color: var(--color-paper);
  border: 0;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: var(--type-13);
  font-weight: 600;
  cursor: pointer;
}
button.kye:hover { background: #6d28d9; }
button.kye-ghost {
  background: var(--paper-2);
  color: var(--text);
  border: 1px solid var(--line);
}
button.kye-ghost:hover { background: var(--paper-3); }

/* ---------- Detail / drawer ---------- */
.detail {
  background: var(--paper-2);
  border-top: 1px solid var(--line);
  padding: 14px 18px;
  font-family: var(--mono);
  font-size: var(--type-12);
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
}
.row-detail {
  display: none;
}
.row-detail.open { display: table-row; }

/* ---------- Section ---------- */
.section { margin-bottom: 28px; }
.section-title {
  font-size: var(--type-13);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 0 0 12px;
  font-weight: 600;
}

.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.demo-note {
  font-size: var(--type-11);
  padding: 8px 14px;
  background: var(--info-soft);
  color: #7dd3fc;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.2);
  display: inline-block;
}

footer.kye-footer {
  margin-top: 60px;
  padding: 24px 28px;
  border-top: 1px solid var(--line);
  font-size: var(--type-12);
  color: var(--text-dim);
  text-align: center;
}
footer.kye-footer .tm-notice {
  margin: 8px auto 0;
  font-size: var(--type-11);
  line-height: 1.5;
  color: var(--text-dim);
  opacity: .72;
  max-width: 980px;
}

/* Chain-link visualisation (transparency log row) */
.chain-cell { font-family: var(--mono); font-size: var(--type-11); }
.hash-trunc { color: var(--text-muted); }

/* === Mobile safety net (added to fix sev0 horizontal scroll) === */
html, body { overflow-x: hidden; max-width: 100vw; }
* { box-sizing: border-box; }
img, video, iframe, svg, canvas { max-width: 100%; height: auto; }
pre, code { max-width: 100%; overflow-x: auto; word-break: normal; }
table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 760px) {
  .topbar, .top, header.top, header.topbar, .header { flex-wrap: wrap !important; row-gap: 8px; padding: 10px 12px !important; }
  .topbar-right, .topbar .right, .top-right { width: 100%; justify-content: flex-start; font-size: var(--type-11); flex-wrap: wrap; }
  .nav { flex-wrap: wrap !important; row-gap: 4px; gap: 2px !important; flex: 1 1 100% !important; margin-left: 0 !important; }
  .nav a { font-size: var(--type-12); padding: 6px 10px !important; }
  .layout, .grid-2, .grid-3, .grid-4, .grid-2-asym, .split { grid-template-columns: 1fr !important; }
  .container, .wrap, main, section { max-width: 100% !important; }
  .hero, h1 { font-size: clamp(22px, 6vw, 30px) !important; line-height: 1.15; }
  h2 { font-size: clamp(18px, 5vw, 24px) !important; }
  .stat, .badge, .chip, .pill { font-size: var(--type-11) !important; }
  .card, .row, .panel { padding: 12px !important; }
  .term-prompt, .topbar-right .meta, .top-meta { display: none; }
}
@media (max-width: 420px) {
  .nav a { font-size: var(--type-12); padding: 5px 8px !important; }
  body { font-size: var(--type-14); }
}

/* === §FINAL — surface-chrome standardisation (locked NAMING.md surface=admin) === */
:root {
  /* Canonical brand colour — Google green, NAMING.md §1 */
  --kye-color-brand: #1A8754;
  --kye-color-brand-2: #166644;
  /* Surface accent — keeps the per-surface visual identity */
  --kye-surface: "admin";
}
.topbar, .top, header.top, header.topbar, .header { height: 56px !important; }
.brand-mark, .brand-logo { width: 28px !important; height: 28px !important; }
.nav a, .topbar a { font-size: var(--type-13) !important; }
.brand { color: var(--kye-color-brand) !important; }
