/* ==========================================================================
   OrcaRouter Lite — design system
   Light, premium SaaS aesthetic matching orcarouter.ai brand identity.
   ========================================================================== */

:root {
  /* Brand */
  --brand:        #2D7FF9;
  --brand-deep:   #1B5FCC;
  --brand-soft:   #EAF2FF;
  --brand-glow:   rgba(45, 127, 249, 0.18);

  /* Ink scale */
  --ink:    #0A0F1C;
  --ink-2:  #5B6B82;
  --ink-3:  #94A2B8;
  --ink-4:  #C5CDDB;

  /* Surfaces */
  --surface:    #FFFFFF;
  --surface-2:  #F7F9FC;
  --surface-3:  #EFF3F8;
  --border:     #E4E9F0;
  --border-strong: #D2DAE5;

  /* Status */
  --ok:    #10B981;
  --ok-soft: #DDF6EB;
  --warn:  #F59E0B;
  --warn-soft: #FFF1D6;
  --err:   #EF4444;
  --err-soft: #FFE0E0;

  /* Shadow */
  --shadow-sm:   0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:      0 4px 12px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg:   0 24px 48px -12px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-glow: 0 0 0 4px var(--brand-glow);

  /* Radius */
  --r-xs: 6px;
  --r-sm: 8px;
  --r:    10px;
  --r-md: 14px;
  --r-lg: 20px;

  /* Spacing scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

  /* Type */
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Monaco, "Cascadia Mono", Consolas, monospace;

  /* Motion */
  --ease:       cubic-bezier(0.16, 1, 0.3, 1);
  --ease-back:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --d-fast:     140ms;
  --d:          220ms;
  --d-slow:     320ms;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h:  64px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* The HTML `hidden` attribute must always win over component display rules
   (e.g. `.palette { display: grid }`), otherwise toggling `el.hidden = true`
   from JS becomes a no-op and overlays can't be closed. */
[hidden] { display: none !important; }

/* -------------------------- reset / base ---------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
h1 { font-size: 22px; letter-spacing: -0.02em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p  { margin: 0; color: var(--ink-2); }
a  { color: var(--brand); text-decoration: none; transition: color var(--d-fast) var(--ease); }
a:hover { color: var(--brand-deep); }
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--ink);
}
.muted { color: var(--ink-3); }

/* Focus */
:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-glow);
  border-color: var(--brand) !important;
}

/* -------------------------- Brand wordmark -------------------------------- */
.brand-logo-img {
  display: block;
  height: 44px;
  width: auto;
  max-width: 100%;
  filter: drop-shadow(0 4px 14px var(--brand-glow));
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.brand-logo-img-sm { height: 32px; }

/* Legacy SVG-based wordmark — kept for any future use */
.brand-logo {
  display: inline-flex;
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 4px 14px var(--brand-glow));
  flex-shrink: 0;
}
.brand-logo svg { width: 100%; height: 100%; }
.brand-logo-sm { width: 28px; height: 28px; }
.brand-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.brand-wordmark-sm { font-size: 16px; gap: 6px; }
.brand-orca   { color: var(--ink); }
.brand-router { color: var(--brand); }
.brand-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: white;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  padding: 3px 8px;
  border-radius: 5px;
  box-shadow: 0 2px 6px var(--brand-glow);
}
.brand-wordmark-sm .brand-pill { font-size: 9px; padding: 2px 6px; }

/* ==========================================================================
   AUTH GATE
   ========================================================================== */
.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s-6);
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, var(--brand-soft), transparent 70%),
    radial-gradient(ellipse 60% 50% at 80% 100%, var(--brand-soft), transparent 70%),
    var(--surface-2);
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-8);
  box-shadow: var(--shadow-lg);
  animation: card-in 480ms var(--ease) both;
}
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-tagline {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}
.auth-title { margin-top: var(--s-6); font-size: 22px; }
.auth-sub   { margin-top: var(--s-2); }
.auth-form  { margin-top: var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); }
.auth-status {
  min-height: 1.2em;
  font-size: 13px;
  color: var(--err);
  margin: 0;
  transition: color var(--d-fast) var(--ease);
}
.auth-status.ok { color: var(--ok); }
.auth-help {
  margin-top: var(--s-6);
  border-top: 1px solid var(--border);
  padding-top: var(--s-4);
  font-size: 13px;
  color: var(--ink-2);
}
.auth-help summary {
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  color: var(--ink);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.auth-help summary::before {
  content: "›";
  color: var(--ink-3);
  font-size: 16px;
  transition: transform var(--d) var(--ease);
}
.auth-help[open] summary::before { transform: rotate(90deg); }
.auth-help ol { padding-left: 20px; margin: var(--s-3) 0 0; line-height: 1.7; }
.code-block {
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 6px 10px;
  margin-top: 6px;
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ==========================================================================
   APP SHELL — sidebar + content
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  animation: fade-in 320ms var(--ease) both;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--s-5) var(--s-3);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--s-2) var(--s-5);
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  --pad-x: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px var(--pad-x);
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  transition:
    background var(--d-fast) var(--ease),
    color var(--d-fast) var(--ease),
    transform var(--d-fast) var(--ease);
  position: relative;
}
.nav-item svg { color: var(--ink-3); transition: color var(--d-fast) var(--ease); }
.nav-item kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.nav-item:hover svg { color: var(--ink-2); }
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-deep);
}
.nav-item.active svg { color: var(--brand); }
.nav-item.active kbd { background: white; border-color: var(--brand-soft); color: var(--brand-deep); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -13px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--brand);
  border-radius: 0 3px 3px 0;
  animation: nav-pulse 320ms var(--ease) both;
}
.nav-item.ghost { color: var(--ink-3); font-weight: 400; }
.nav-item:active:not(.active) { transform: scale(0.985); }

.sidebar-foot {
  margin-top: auto;
  padding-top: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-meta {
  margin-top: var(--s-3);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
  border-top: 1px solid var(--border);
  padding-top: var(--s-3);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-4);
  box-shadow: 0 0 0 2px transparent;
  transition: background var(--d) var(--ease), box-shadow var(--d) var(--ease);
}
.status-dot.ok   { background: var(--ok);  box-shadow: 0 0 0 3px var(--ok-soft); animation: dot-pulse 2s ease-in-out infinite; }
.status-dot.err  { background: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.version-tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

/* -------------------------- content / topbar ----------------------------- */
.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  height: var(--topbar-h);
  padding: 0 var(--s-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-left { min-width: 0; }
.page-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.page-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 2px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* ==========================================================================
   PANELS
   ========================================================================== */
.panels { padding: var(--s-8); display: grid; gap: var(--s-6); }
.panel { display: none; flex-direction: column; gap: var(--s-6); }
.panel.active { display: flex; animation: panel-in var(--d-slow) var(--ease) both; }

.row-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--s-6); }
@media (max-width: 980px) {
  .row-2 { grid-template-columns: 1fr; }
}

/* ----------------------------- Card -------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-6);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
}
.card-title { font-size: 15px; font-weight: 600; }
.card-sub {
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 2px;
}
.help-banner {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--brand-soft) 0%, white 100%);
  border-color: var(--brand-soft);
}
.help-banner h3 { font-size: 14px; }
.help-banner.dismissed { display: none; }

/* ----------------------------- Pills ------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-deep);
  background: var(--brand-soft);
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.pill.ok  { color: #066943; background: var(--ok-soft); }
.pill.err { color: #8a1c1c; background: var(--err-soft); }
.pill.warn { color: #8a5a07; background: var(--warn-soft); }
.pill.muted { color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border); }

/* ==========================================================================
   KPI CARDS
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-4);
}
@media (max-width: 980px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-5);
  position: relative;
  overflow: hidden;
  transition: transform var(--d) var(--ease), box-shadow var(--d) var(--ease), border-color var(--d) var(--ease);
  animation: kpi-in 480ms var(--ease) both;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}
.kpi-card:nth-child(1) { animation-delay: 0ms; }
.kpi-card:nth-child(2) { animation-delay: 60ms; }
.kpi-card:nth-child(3) { animation-delay: 120ms; }
.kpi-card:nth-child(4) { animation-delay: 180ms; }
.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-3);
}
.kpi-label { font-size: 12px; font-weight: 500; letter-spacing: 0.01em; text-transform: uppercase; }
.kpi-icon { color: var(--ink-3); }
.kpi-value {
  margin-top: var(--s-3);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.kpi-sub { margin-top: 4px; font-size: 12.5px; color: var(--ink-3); }
.kpi-extra {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-3);
}
.kpi-extra-label { letter-spacing: 0.02em; }
.kpi-extra-value {
  font-weight: 600;
  color: var(--brand-deep);
  font-variant-numeric: tabular-nums;
}
.kpi-card-accent {
  background: linear-gradient(135deg, var(--brand-soft) 0%, white 60%);
  border-color: var(--brand-soft);
}
.kpi-card-accent .kpi-value { color: var(--brand-deep); }
.kpi-card-accent .kpi-icon  { color: var(--brand); }

/* ==========================================================================
   HOSTED FALLBACK CARD
   ========================================================================== */
.hosted-card {
  background: linear-gradient(135deg, var(--brand-soft) 0%, white 70%);
  border-color: var(--brand-soft);
}
.hosted-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s-4);
}
.hosted-card-compact .hosted-card-head { align-items: center; }
.hosted-cta {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  margin-top: var(--s-4);
}
.hosted-cta-actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}
.hosted-step {
  font-size: 12.5px;
  color: var(--ink-3);
}
.hosted-step code {
  font-size: 11.5px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}
.hosted-paste { margin: 0; }
.hosted-active {
  margin-top: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.hosted-meta { font-size: 13px; color: var(--ink-2); margin: 0; }
.hosted-savings {
  font-size: 13px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
}

/* ==========================================================================
   UNREACHABLE MODELS GRID
   ========================================================================== */
.unreachable-list { margin-top: var(--s-3); }
.unreachable-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-3);
  margin-top: var(--s-2);
}
.unreachable-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color var(--d-fast) var(--ease), transform var(--d-fast) var(--ease);
}
.unreachable-item:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}
.unreachable-id { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink); }
.unreachable-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.unreachable-provider { text-transform: capitalize; }
.unreachable-caps { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.cap-pill {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

/* ==========================================================================
   FORMS
   ========================================================================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.flex-grow { flex: 1 1 auto; min-width: 0; }
.flex-grow-0 { flex: 0 0 auto; min-width: 180px; }
.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}
.field-control { position: relative; display: flex; align-items: center; }
.field-control input { padding-right: 38px; }
.field-control .icon-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
}

input, select, textarea {
  font: inherit;
  font-size: 14px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 9px 12px;
  border-radius: var(--r-sm);
  transition: border-color var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease), background var(--d-fast) var(--ease);
}
input::placeholder { color: var(--ink-3); }
input:hover, select:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
  outline: none;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235B6B82' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.inline-form {
  display: flex;
  align-items: flex-end;
  gap: var(--s-3);
}
@media (max-width: 720px) {
  .inline-form { flex-wrap: wrap; }
  .inline-form > * { flex: 1 1 100%; }
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition:
    transform var(--d-fast) var(--ease),
    background var(--d-fast) var(--ease),
    border-color var(--d-fast) var(--ease),
    color var(--d-fast) var(--ease),
    box-shadow var(--d-fast) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--brand);
  color: white;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06), 0 4px 12px var(--brand-glow);
}
/* Color is repeated on :hover so the rule beats the base `a:hover`
   selector (specificity 0,1,1) when the button is rendered as an
   `<a>` (e.g. the "Get free credit" CTA links to orcarouter.ai/register).
   Without this, hover flips text to var(--brand-deep) on a blue
   background and becomes unreadable. */
.btn-primary:hover { background: var(--brand-deep); color: white; box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06), 0 6px 18px var(--brand-glow); }
.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); border-color: var(--border-strong); }
.btn-ghost code { background: transparent; border: none; padding: 0; color: var(--ink-2); font-size: 12px; }
.btn-danger {
  background: white;
  color: var(--err);
  border-color: var(--err-soft);
}
/* Same `a:hover` override defense as .btn-primary above. */
.btn-danger:hover { background: var(--err-soft); color: var(--err); border-color: var(--err); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-full { width: 100%; padding: 11px 14px; font-size: 14px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  color: var(--ink-3);
  cursor: pointer;
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-wrap { position: relative; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky;
  top: 0;
}
thead th:first-child { border-top-left-radius: var(--r-xs); }
thead th:last-child  { border-top-right-radius: var(--r-xs); }
.th-actions { width: 1px; }
tbody td {
  padding: 12px;
  font-size: 13.5px;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr { transition: background var(--d-fast) var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr.row-in { animation: row-in 320ms var(--ease) both; }

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-10) var(--s-4);
  text-align: center;
  color: var(--ink-3);
  border: 1px dashed var(--border);
  border-radius: var(--r);
  margin-top: var(--s-2);
}
.empty-state.shown { display: flex; animation: fade-up var(--d-slow) var(--ease) both; }
.empty-state h3 { color: var(--ink); margin-top: var(--s-3); }
.empty-state p { margin-top: var(--s-2); max-width: 360px; }
.empty-illustration {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  border-radius: 50%;
  color: var(--brand);
  animation: float 4s ease-in-out infinite;
}
.empty-mini { padding: var(--s-6) 0; text-align: center; color: var(--ink-3); }

/* ==========================================================================
   PROVIDER QUICK-ADD CHIPS
   ========================================================================== */
.provider-quickadd {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--d-fast) var(--ease);
}
.chip:hover {
  background: var(--brand-soft);
  border-color: var(--brand-soft);
  color: var(--brand-deep);
  transform: translateY(-1px);
}
.chip.configured {
  background: var(--ok-soft);
  border-color: var(--ok-soft);
  color: #066943;
  cursor: default;
}
.chip.configured::before {
  content: "✓";
  font-weight: 700;
}

/* ==========================================================================
   STRATEGY CARDS
   ========================================================================== */
.strategy-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-3);
}
@media (max-width: 980px) { .strategy-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .strategy-grid { grid-template-columns: 1fr; } }

.strategy-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition:
    transform var(--d-fast) var(--ease),
    border-color var(--d-fast) var(--ease),
    background var(--d-fast) var(--ease),
    box-shadow var(--d-fast) var(--ease);
}
.strategy-card input { position: absolute; opacity: 0; pointer-events: none; }
.strategy-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.strategy-card.selected {
  border-color: var(--brand);
  background: linear-gradient(135deg, var(--brand-soft) 0%, white 80%);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.strategy-card.selected .strategy-icon { background: var(--brand); color: white; }
.strategy-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}
.strategy-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.strategy-desc  { font-size: 12.5px; color: var(--ink-3); line-height: 1.5; margin: 0; }
.strategy-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: white;
  background: var(--brand);
  padding: 2px 6px;
  border-radius: 4px;
}

/* "How auto works" list */
.how-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.6;
}
.how-list li::marker { color: var(--brand); font-weight: 700; }
.how-list strong { color: var(--ink); font-weight: 600; }

/* ==========================================================================
   CHARTS — vanilla SVG bar chart
   ========================================================================== */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bar-row {
  display: grid;
  grid-template-columns: 200px 1fr 110px;
  gap: var(--s-3);
  align-items: center;
  font-size: 13px;
  animation: bar-grow 480ms var(--ease) both;
}
.bar-label {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  position: relative;
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  position: absolute;
  inset: 0 100% 0 0;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-deep) 100%);
  border-radius: 999px;
  transition: right 600ms var(--ease);
}
.bar-value {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--ink-2);
  text-align: right;
}
.bar-value .reqs { color: var(--ink-3); margin-left: 6px; }
@media (max-width: 720px) {
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .bar-value { text-align: left; }
}

/* ==========================================================================
   CODE BLOCKS / CALLOUT / RECENT MINI
   ========================================================================== */
.code-pre {
  position: relative;
  background: #0E1320;
  color: #E6EDF3;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  padding: var(--s-4) var(--s-5);
  padding-right: 48px;
  border-radius: var(--r-sm);
  overflow-x: auto;
  margin: 0;
  border: 1px solid #1B2233;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.code-pre code { background: none; border: none; padding: 0; color: inherit; font-size: inherit; }
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-xs);
  color: #94A2B8;
  cursor: pointer;
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease), transform var(--d-fast) var(--ease);
}
.copy-btn:hover { background: rgba(255,255,255,0.12); color: white; }
.copy-btn:active { transform: scale(0.92); }
.copy-btn.copied {
  background: var(--ok);
  border-color: var(--ok);
  color: white;
}

.callout {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4);
  background: linear-gradient(135deg, var(--brand-soft) 0%, white 100%);
  border: 1px solid var(--brand-soft);
  border-radius: var(--r);
  animation: fade-up var(--d-slow) var(--ease) both;
}
.callout-head { display: flex; align-items: center; gap: 8px; color: var(--brand-deep); font-size: 13.5px; }

.recent-mini {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}
.recent-row {
  display: grid;
  grid-template-columns: 90px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: background var(--d-fast) var(--ease), border-color var(--d-fast) var(--ease);
}
.recent-row:hover { background: var(--surface-2); border-color: var(--border-strong); }
.recent-when { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.recent-model { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-latency { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ink-2); }

/* ==========================================================================
   SEGMENTED CONTROL
   ========================================================================== */
.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 0;
}
.seg-btn {
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--ink-3);
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

/* ==========================================================================
   HINTS / CHECKLIST
   ========================================================================== */
.hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-3);
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.hint svg { flex-shrink: 0; margin-top: 2px; color: var(--brand); }
.hint code { font-size: 11.5px; }

.checklist {
  list-style: none;
  padding: 0;
  margin: var(--s-3) 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.checklist li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
  transition: color var(--d) var(--ease);
}
.check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-4);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all var(--d) var(--ease);
}
.checklist li.done { color: var(--ink); }
.checklist li.done .check {
  background: var(--ok);
  border-color: var(--ok);
}
.checklist li.done .check::after {
  content: "";
  width: 8px;
  height: 4px;
  border: 2px solid white;
  border-top: none;
  border-right: none;
  transform: rotate(-45deg) translate(1px, -1px);
  animation: check-in 280ms var(--ease) both;
}

/* ==========================================================================
   TOAST
   ========================================================================== */
.toast-region {
  position: fixed;
  top: var(--s-4);
  right: var(--s-4);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 14px;
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  max-width: 360px;
  font-size: 13.5px;
  color: var(--ink);
  pointer-events: auto;
  animation: toast-in 320ms var(--ease) both;
}
.toast.leaving { animation: toast-out 220ms var(--ease) both; }
.toast .ico {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  flex-shrink: 0;
}
.toast.ok  .ico { background: var(--ok-soft);  color: var(--ok); }
.toast.err .ico { background: var(--err-soft); color: var(--err); }
.toast.info .ico { background: var(--brand-soft); color: var(--brand); }

/* ==========================================================================
   DRAWER (help)
   ========================================================================== */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--d-slow) var(--ease);
}
.drawer:not([hidden]) { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.drawer-body {
  padding: var(--s-5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
}
.drawer-body section h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); margin-bottom: 8px; }
.drawer-body section p, .drawer-body section li { font-size: 13.5px; color: var(--ink-2); line-height: 1.6; }
.drawer-body ol, .drawer-body ul { padding-left: 20px; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.kbd-list { list-style: none; padding: 0 !important; }
.kbd-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.kbd-list span { color: var(--ink-2); font-size: 13px; }
.link-list { list-style: none; padding: 0 !important; }

kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--ink-2);
  line-height: 1.4;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 28, 0.32);
  backdrop-filter: blur(2px);
  z-index: 40;
  animation: fade-in var(--d) var(--ease) both;
}

/* ==========================================================================
   COMMAND PALETTE
   ========================================================================== */
.palette {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: start center;
  padding-top: 14vh;
  background: rgba(10, 15, 28, 0.32);
  backdrop-filter: blur(4px);
  animation: fade-in var(--d-fast) var(--ease) both;
}
.palette-card {
  width: min(560px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: palette-in var(--d) var(--ease) both;
}
.palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.palette-input-wrap svg { color: var(--ink-3); flex-shrink: 0; }
.palette-input-wrap input {
  border: none !important;
  padding: 0;
  font-size: 15px;
  background: transparent;
  flex: 1;
  box-shadow: none !important;
}
.palette-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 50vh;
  overflow-y: auto;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-xs);
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--d-fast) var(--ease);
}
.palette-item .meta { margin-left: auto; font-size: 11.5px; color: var(--ink-3); }
.palette-item:hover, .palette-item.focused { background: var(--brand-soft); color: var(--brand-deep); }
.palette-item:hover .meta, .palette-item.focused .meta { color: var(--brand-deep); }
.palette-empty {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-3);
}

/* ==========================================================================
   TOOLTIP (CSS-only, attribute-driven)
   ========================================================================== */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translate(-50%, 4px);
  background: var(--ink);
  color: white;
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 5px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--d-fast) var(--ease), transform var(--d-fast) var(--ease);
  z-index: 30;
  box-shadow: var(--shadow);
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes kpi-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes row-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes nav-pulse {
  from { transform: scaleY(0); opacity: 0; }
  to   { transform: scaleY(1); opacity: 1; }
}
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--ok-soft); }
  50%      { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.08); }
}
@keyframes bar-grow {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(8px, -8px) scale(0.96); }
  to   { opacity: 1; transform: translate(0, 0) scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translate(0, 0) scale(1); }
  to   { opacity: 0; transform: translate(8px, -4px) scale(0.96); }
}
@keyframes palette-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes check-in {
  from { transform: rotate(-45deg) translate(1px, -1px) scale(0); }
  to   { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 860px) {
  :root { --sidebar-w: 64px; }
  .sidebar { padding: var(--s-3) var(--s-2); }
  .sidebar-brand .brand-wordmark { display: none; }
  .nav-item span:not(.status-dot) { display: none; }
  .nav-item kbd { display: none; }
  .nav-item.active::before { left: -9px; }
  .sidebar-meta { justify-content: center; }
  .sidebar-meta span:not(.status-dot) { display: none; }
  .topbar { padding: 0 var(--s-4); }
  .panels { padding: var(--s-4); }
  .topbar-right .btn-ghost code { display: none; }
}
