/*
 * ROLLIN Admin v2 — Design Tokens + Component CSS
 *
 * Ported verbatim from design_handoff_saas_dashboard/styles.css (the prototype).
 * Loaded ONLY by /admin/v2/*.html pages. No co-loading with existing /admin/*.html
 * styles, so class-name collisions (.sidebar, .nav, .topbar, etc.) are safe.
 *
 * Existing legacy admin CSS at /css/admin-v2.css is misnamed — that's the v1
 * admin's stylesheet. This (admin/v2/_styles.css) is the canonical v2 source.
 */

/* ============ ROLLIN Admin — Design Tokens ============ */
:root {
  /* Surfaces (dark) */
  --bg: #0A0C0F;
  --bg-elev: #0F1216;
  --surface: #14181E;
  --surface-2: #1A1F27;
  --surface-3: #232934;
  --border: #232934;
  --border-strong: #2E3540;
  --hairline: rgba(255,255,255,0.06);

  /* Text */
  --fg: #ECEFF3;
  --fg-2: #B6BCC7;
  --fg-3: #7C8392;
  --fg-4: #545B68;

  /* Brand & accents */
  --brand: oklch(0.80 0.14 155);
  --brand-2: oklch(0.70 0.16 155);
  --brand-soft: color-mix(in oklab, var(--brand) 18%, transparent);
  --brand-line: color-mix(in oklab, var(--brand) 36%, transparent);

  --info: #7C9CFF;
  --info-soft: color-mix(in oklab, var(--info) 18%, transparent);
  --warn: #F5B544;
  --warn-soft: color-mix(in oklab, var(--warn) 18%, transparent);
  --danger: #F87171;
  --danger-soft: color-mix(in oklab, var(--danger) 18%, transparent);
  --violet: #B79CF6;
  --violet-soft: color-mix(in oklab, var(--violet) 18%, transparent);

  /* Density */
  --row-h: 44px;
  --score-good: #5DE1A3;
  --score-mid:  #F5B544;
  --score-bad:  #F87171;
  --pad-card: 18px;
  --pad-page: 28px;
  --gap: 14px;

  /* Typography */
  --font-ui: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 12px;
  --r-xl: 16px;

  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 1px 2px rgba(0,0,0,0.5);
  --shadow-2: 0 12px 32px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.04) inset;
  --shadow-pop: 0 24px 60px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.06) inset;
}

[data-theme="light"] {
  --bg: #F7F7F5;
  --bg-elev: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #FAFAF8;
  --surface-3: #F0F0EC;
  --border: #E6E6E1;
  --border-strong: #D5D5CF;
  --hairline: rgba(0,0,0,0.06);
  --fg: #14181E;
  --fg-2: #3D434E;
  --fg-3: #6B7280;
  --fg-4: #9CA3AF;
  --brand: oklch(0.62 0.15 155);
  --brand-2: oklch(0.55 0.16 155);
  --brand-soft: color-mix(in oklab, var(--brand) 14%, transparent);
  --brand-line: color-mix(in oklab, var(--brand) 30%, transparent);
  --shadow-1: 0 1px 2px rgba(15,30,40,0.06);
  --shadow-2: 0 12px 32px rgba(15,30,40,0.10);
  --shadow-pop: 0 24px 60px rgba(15,30,40,0.18);
}

[data-density="compact"] {
  --row-h: 36px;
  --pad-card: 14px;
  --pad-page: 22px;
  --gap: 10px;
}
[data-density="comfy"] {
  --row-h: 52px;
  --pad-card: 22px;
  --pad-page: 36px;
  --gap: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

button { font-family: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--brand-soft); color: var(--fg); }

/* ============ App Shell ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w, 240px) 1fr;
  min-height: 100vh;
  background: var(--bg);
}
.app[data-sidebar="icons"] { --sidebar-w: 64px; }
.app[data-sidebar="labels"] { --sidebar-w: 240px; }

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--hairline);
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  overflow: hidden;
  display: grid; place-items: center;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset;
}
.brand-mark img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.brand-name {
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 14px;
}
.brand-sub {
  color: var(--fg-3);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.app[data-sidebar="icons"] .brand-name,
.app[data-sidebar="icons"] .brand-sub,
.app[data-sidebar="icons"] .nav-label,
.app[data-sidebar="icons"] .nav-section-label,
.app[data-sidebar="icons"] .sidebar-footer-text { display: none; }
.app[data-sidebar="icons"] .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }

.nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-section { margin-top: 16px; }
.nav-section:first-child { margin-top: 4px; }
.nav-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-4);
  padding: 6px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px 10px;
  margin: 1px 4px;
  border-radius: var(--r-sm);
  color: var(--fg-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  user-select: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--fg); }
.nav-item[aria-current="true"] {
  background: var(--surface-2);
  color: var(--fg);
}
.nav-item[aria-current="true"]::before {
  content: '';
  position: absolute;
  left: -4px; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--brand);
  border-radius: 2px;
}
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-item[aria-current="true"] .nav-icon { color: var(--brand); opacity: 1; }
.nav-badge {
  margin-left: auto;
  font-size: 10.5px;
  font-family: var(--font-mono);
  background: var(--surface-3);
  color: var(--fg-2);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 500;
}
.nav-badge[data-tone="danger"] { background: var(--danger-soft); color: var(--danger); }
.nav-badge[data-tone="brand"] { background: var(--brand-soft); color: var(--brand); }

.sidebar-footer {
  border-top: 1px solid var(--hairline);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  flex: 1;
  cursor: pointer;
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd6a5, #ffadad);
  display: grid; place-items: center;
  color: #1A1F27;
  font-weight: 600;
  font-size: 11px;
  flex-shrink: 0;
}
.avatar { position: relative; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.user-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { font-size: 11px; color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signout-icon {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-3);
  display: grid; place-items: center;
  cursor: pointer;
}
.signout-icon:hover { background: var(--surface-2); color: var(--fg); border-color: var(--border); }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(8px);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-3); }
.crumb-sep { opacity: 0.5; }
.crumb-current { color: var(--fg); font-weight: 500; }

.searchbox {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 6px 10px;
  width: 320px;
  color: var(--fg-3);
  font-size: 13px;
  cursor: pointer;
}
.searchbox:hover { border-color: var(--border-strong); }
.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--fg-2);
  margin-left: auto;
}

.icon-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid; place-items: center;
  color: var(--fg-2);
  position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }
.icon-btn .dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--bg-elev);
}

/* Page */
.page {
  padding: var(--pad-page);
  max-width: 100%;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.page-sub { color: var(--fg-3); font-size: 13.5px; margin: 0; }

/* ============ Buttons & form controls ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn[data-variant="primary"] {
  background: var(--brand);
  border-color: var(--brand);
  color: #0A0C0F;
}
.btn[data-variant="primary"]:hover { background: var(--brand-2); }
.btn[data-variant="ghost"] { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn[data-variant="ghost"]:hover { background: var(--surface-2); color: var(--fg); }
.btn[data-variant="danger"] {
  background: var(--danger-soft);
  border-color: var(--danger-soft);
  color: var(--danger);
}
.btn[data-size="sm"] { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn[data-size="lg"] { height: 38px; padding: 0 16px; font-size: 13.5px; }

.input, .select {
  height: 32px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 0 10px;
  font-size: 13px;
  color: var(--fg);
  outline: none;
  width: 100%;
}
.input:focus, .select:focus {
  border-color: var(--brand-line);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input::placeholder { color: var(--fg-4); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--fg-2); font-weight: 500; }
.hint { font-size: 11.5px; color: var(--fg-3); }

.toggle {
  position: relative;
  display: inline-flex;
  width: 32px; height: 18px;
  border-radius: 999px;
  background: var(--surface-3);
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--fg);
  transition: transform 0.15s;
}
.toggle[data-on="true"] { background: var(--brand); }
.toggle[data-on="true"]::after { transform: translateX(14px); background: #0A0C0F; }

.checkbox {
  width: 15px; height: 15px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  display: grid; place-items: center;
  flex-shrink: 0;
  cursor: pointer;
}
.checkbox[data-on="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: #0A0C0F;
}

/* ============ Cards & layout ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--pad-card);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.card-title { font-size: 13.5px; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.card-sub { font-size: 12px; color: var(--fg-3); margin: 2px 0 0; }

.grid { display: grid; gap: var(--gap); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.row { display: flex; align-items: center; gap: var(--gap); flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: var(--gap); }
.spacer { flex: 1; }

/* ============ KPI Tiles ============ */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.kpi-label { font-size: 12px; color: var(--fg-3); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; font-feature-settings: "tnum"; }
.kpi-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-family: var(--font-mono); font-size: 11.5px; padding: 1px 6px; border-radius: 4px; }
.delta[data-tone="up"] { color: var(--brand); background: var(--brand-soft); }
.delta[data-tone="down"] { color: var(--danger); background: var(--danger-soft); }
.delta[data-tone="flat"] { color: var(--fg-3); background: var(--surface-3); }
.kpi-spark { position: absolute; right: 12px; bottom: 12px; opacity: 0.85; }

/* ============ Tables ============ */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.table-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.table-toolbar .input { max-width: 260px; }
table.t {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
table.t th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
table.t td {
  padding: 0 14px;
  height: var(--row-h);
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}
table.t tr:hover td { background: var(--surface-2); cursor: pointer; }
table.t tr:last-child td { border-bottom: 0; }
.tnum { font-family: var(--font-mono); font-size: 12.5px; font-feature-settings: "tnum"; }
.muted { color: var(--fg-3); }

/* Pill / Badge */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-3);
  color: var(--fg-2);
  white-space: nowrap;
}
.pill[data-tone="brand"] { background: var(--brand-soft); color: var(--brand); }
.pill[data-tone="info"] { background: var(--info-soft); color: var(--info); }
.pill[data-tone="warn"] { background: var(--warn-soft); color: var(--warn); }
.pill[data-tone="danger"] { background: var(--danger-soft); color: var(--danger); }
.pill[data-tone="violet"] { background: var(--violet-soft); color: var(--violet); }
.pill .dot {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

/* ============ Tabs ============ */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tab {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--fg-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-weight: 500;
}
.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] {
  color: var(--fg);
  border-bottom-color: var(--brand);
}
.tab .count {
  font-family: var(--font-mono);
  font-size: 11px;
  margin-left: 6px;
  color: var(--fg-4);
}

/* ============ Drawer / Modal / Toast ============ */
.scrim {
  position: fixed; inset: 0;
  background: rgba(5,7,10,0.6);
  backdrop-filter: blur(2px);
  z-index: 80;
  animation: fade-in 0.15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in-right { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slide-up { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 480px;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  z-index: 90;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-pop);
  animation: slide-in-right 0.2s ease-out;
}
.drawer-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.drawer-body {
  flex: 1; overflow-y: auto;
  padding: 20px;
}
.drawer-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px;
  justify-content: flex-end;
}

.modal-card {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 440px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  z-index: 90;
  box-shadow: var(--shadow-pop);
  animation: slide-up 0.18s ease-out;
}
.modal-head { padding: 18px 20px 6px; }
.modal-body { padding: 6px 20px 14px; color: var(--fg-2); font-size: 13.5px; }
.modal-foot { padding: 12px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--border); }

.toast-stack {
  position: fixed;
  bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 300px; max-width: 380px;
  box-shadow: var(--shadow-pop);
  animation: slide-up 0.2s ease-out;
}
.toast[data-tone="success"] { border-left: 3px solid var(--brand); }
.toast[data-tone="error"] { border-left: 3px solid var(--danger); }
.toast-title { font-size: 13.5px; font-weight: 600; margin: 0 0 1px; }
.toast-body { font-size: 12.5px; color: var(--fg-3); margin: 0; }

/* Empty / Error states */
.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--fg-3);
  font-size: 13.5px;
}
.empty-mark {
  width: 44px; height: 44px;
  margin: 0 auto 14px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  display: grid; place-items: center;
  color: var(--fg-3);
}
.empty h3 { color: var(--fg); font-size: 15px; margin: 0 0 4px; font-weight: 600; }

/* Misc */
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.dot-status {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.dot-status[data-tone="warn"] { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot-status[data-tone="danger"] { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* Focus mode (sign-in) */
.focus-stage {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
@media (max-width: 880px) {
  .focus-stage { grid-template-columns: 1fr; }
  .focus-poster { display: none; }
}
.focus-form {
  display: flex; flex-direction: column;
  justify-content: center;
  padding: 60px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}
.focus-poster {
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  padding: 60px;
}

/* Charts */
.chart-svg { display: block; width: 100%; height: 100%; }
.chart-grid line { stroke: var(--border); stroke-dasharray: 2 4; }
.chart-axis text { fill: var(--fg-4); font-size: 10.5px; font-family: var(--font-mono); }
.chart-tip {
  position: absolute;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 12px;
  pointer-events: none;
  box-shadow: var(--shadow-2);
  z-index: 5;
  white-space: nowrap;
}

/* Map placeholder */
.map-bg {
  background:
    radial-gradient(ellipse at 30% 40%, var(--brand-soft) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 60%, var(--info-soft) 0%, transparent 50%),
    repeating-linear-gradient(0deg, transparent 0 19px, var(--hairline) 19px 20px),
    repeating-linear-gradient(90deg, transparent 0 19px, var(--hairline) 19px 20px),
    var(--surface);
}

/* Legend */
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-2); }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; }

/* Segmented control */
.segmented {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 0;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--fg-3);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
}
.segmented button[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--fg);
}

/* Progress bar */
.bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

/* Code chip */
.code-chip {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--fg-2);
  border: 1px solid var(--hairline);
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* === Score badges & evidence === */
.score-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-weight: 600;
  padding: 3px 8px; border-radius: 6px; font-size: 12px;
  background: color-mix(in oklab, var(--score-good) 16%, transparent);
  color: var(--score-good);
  border: 1px solid color-mix(in oklab, var(--score-good) 30%, transparent);
}
.score-badge[data-tone="mid"] { background: color-mix(in oklab, var(--score-mid) 16%, transparent); color: var(--score-mid); border-color: color-mix(in oklab, var(--score-mid) 30%, transparent); }
.score-badge[data-tone="bad"] { background: color-mix(in oklab, var(--score-bad) 16%, transparent); color: var(--score-bad); border-color: color-mix(in oklab, var(--score-bad) 30%, transparent); }

.score-ring { position: relative; width: 84px; height: 84px; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
}

/* === Dev notes === */
.devnote {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  background: color-mix(in oklab, #5EEAD4 8%, var(--surface-2));
  border: 1px dashed color-mix(in oklab, #5EEAD4 32%, var(--border));
  border-radius: 6px;
  margin: 10px 0;
  font-size: 12px;
  color: var(--fg-2);
}
.devnote-tag {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.08em; color: #5EEAD4;
  background: color-mix(in oklab, #5EEAD4 18%, transparent);
  padding: 2px 6px; border-radius: 3px; flex-shrink: 0;
  border: 1px solid color-mix(in oklab, #5EEAD4 32%, transparent);
}

/* === Issue category accents === */
.cat-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: color-mix(in oklab, currentColor 14%, transparent);
  border: 1px solid color-mix(in oklab, currentColor 28%, transparent);
}
.cat-pill .cat-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* === Stat strip === */
.statstrip {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden; margin-bottom: var(--gap);
}
.statstrip > div { padding: 16px 18px; border-right: 1px solid var(--hairline); }
.statstrip > div:last-child { border-right: 0; }
.statstrip-label { font-size: 11px; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.statstrip-value { font-family: var(--font-mono); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }

/* === Map placeholder === */
.map-placeholder {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
  background-image:
    linear-gradient(120deg, color-mix(in oklab, var(--brand) 8%, transparent), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 23px, var(--hairline) 23px 24px),
    repeating-linear-gradient(90deg, transparent 0 23px, var(--hairline) 23px 24px);
}


/* =============================================================================
 * ⌘K Command palette (topbar global search)
 * ============================================================================= */
.cmdk-bg {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  backdrop-filter: blur(2px);
}
.cmdk-bg[data-open="true"] { display: flex; }
.cmdk-panel {
  width: min(560px, 92vw);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong, var(--border));
  border-radius: var(--r-lg, 14px);
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  overflow: hidden;
}
.cmdk-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline);
  color: var(--fg-3);
}
#cmdk-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--fg); font: inherit; font-size: 15px;
}
#cmdk-input::placeholder { color: var(--fg-4); }
.cmdk-results { max-height: 52vh; overflow-y: auto; padding: 6px; }
.cmdk-row {
  display: grid;
  grid-template-columns: 22px 1fr auto auto;
  align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-md);
  color: var(--fg); text-decoration: none; cursor: pointer;
}
.cmdk-row.is-active { background: var(--brand-soft); }
.cmdk-row-icon { color: var(--fg-3); display: grid; place-items: center; }
.cmdk-row.is-active .cmdk-row-icon { color: var(--brand); }
.cmdk-row-label { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-row-sub { color: var(--fg-3); font-size: 12px; white-space: nowrap; }
.cmdk-row-kind {
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--fg-4);
  background: var(--surface-3); padding: 1px 6px; border-radius: 4px;
}
.cmdk-empty { padding: 28px; text-align: center; color: var(--fg-4); font-size: 13px; }
