/* The webfont is loaded via <link rel="stylesheet"> in app/views/layouts/_boot.html.erb
   (preconnect + early discovery), not a CSS @import here — an @import is only fetched
   after this file is parsed, which delayed the font and caused a first-paint flash. */

/* ============================================================
   DARKROUTER — Design system (ported from Claude Design handoff)
   Light + dark themes, emerald accent, served as plain CSS via
   Propshaft alongside the compiled Tailwind utilities.
   ============================================================ */

/* ---- Color scales (theme-independent) ---- */
:root {
  --green-50:  oklch(0.972 0.020 158);
  --green-100: oklch(0.940 0.040 158);
  --green-200: oklch(0.885 0.062 158);
  --green-300: oklch(0.805 0.090 157);
  --green-400: oklch(0.720 0.118 156);
  --green-500: oklch(0.620 0.140 155); /* primary */
  --green-600: oklch(0.548 0.132 155);
  --green-700: oklch(0.470 0.110 156);
  --green-800: oklch(0.392 0.088 157);
  --green-900: oklch(0.310 0.062 158);

  --slate-50:  oklch(0.985 0.003 250);
  --slate-100: oklch(0.967 0.004 250);
  --slate-150: oklch(0.948 0.005 250);
  --slate-200: oklch(0.922 0.006 250);
  --slate-300: oklch(0.868 0.008 252);
  --slate-400: oklch(0.715 0.013 254);
  --slate-500: oklch(0.585 0.016 256);
  --slate-600: oklch(0.480 0.018 258);
  --slate-700: oklch(0.380 0.020 260);
  --slate-800: oklch(0.285 0.020 262);
  --slate-900: oklch(0.215 0.020 263);
  --slate-950: oklch(0.155 0.018 264);

  --danger:      oklch(0.585 0.180 25);
  --danger-soft: oklch(0.955 0.025 25);
  --warn:        oklch(0.760 0.130 75);

  --font-sans: 'Hanken Grotesk', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --space-page-y: 56px;
  --space-banner-y: 22px;
  --card-pad: 28px;
  --row-h: 60px;
  --field-h: 44px;

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgba(15,30,45,.04), 0 4px 16px -8px rgba(15,30,45,.10);
  --shadow-pop:  0 12px 40px -12px rgba(15,30,45,.22);
  --border-w: 1px;

  --maxw: 1180px;
}

/* ---- Light theme (default) ---- */
:root, [data-theme="light"] {
  --bg:            oklch(0.984 0.005 155);
  --surface:       #ffffff;
  --surface-2:     oklch(0.966 0.006 155);
  --surface-inset: oklch(0.945 0.007 155);
  --text:          oklch(0.235 0.012 165);
  --text-2:        oklch(0.440 0.012 165);
  --text-muted:    oklch(0.540 0.012 160);
  --text-faint:    oklch(0.665 0.012 160);
  --border:        oklch(0.908 0.008 160);
  --border-strong: oklch(0.860 0.010 160);

  --accent-base:   oklch(0.585 0.150 158);
  --accent:        var(--accent-base);
  --accent-hover:  color-mix(in oklch, var(--accent), black 14%);
  --accent-press:  color-mix(in oklch, var(--accent), black 26%);
  --accent-fg:     #ffffff;
  --accent-soft:   color-mix(in oklch, var(--accent) 13%, var(--surface));
  --accent-soft-2: color-mix(in oklch, var(--accent) 22%, var(--surface));
  --accent-soft-fg:color-mix(in oklch, var(--accent), black 24%);
  --accent-line:   color-mix(in oklch, var(--accent) 34%, var(--surface));

  --positive:      var(--accent-hover);
  --positive-soft: var(--accent-soft);

  --chart-grid:    oklch(0.948 0.006 160);
  --chart-axis:    oklch(0.665 0.012 160);
  --chart-bar:     var(--accent);
  --chart-bar-2:   color-mix(in oklch, var(--accent) 42%, var(--surface));

  --toggle-off:    oklch(0.860 0.010 160);
  --danger-fg:     var(--danger);
  --code-bg:       oklch(0.966 0.006 155);
  color-scheme: light;
}

/* ---- Dark theme ----
   Palette ported from the Claude Design handoff: greenish neutrals (hue ~165)
   and a bright mint accent, replacing the earlier slate (hue ~263) tones. */
[data-theme="dark"] {
  --bg:            oklch(0.158 0.006 165);
  --surface:       oklch(0.195 0.008 165);
  --surface-2:     oklch(0.228 0.010 165);
  --surface-inset: oklch(0.250 0.011 165);
  --text:          oklch(0.965 0.004 160);
  --text-2:        oklch(0.780 0.009 160);
  --text-muted:    oklch(0.650 0.011 160);
  --text-faint:    oklch(0.530 0.012 160);
  --border:        oklch(0.300 0.010 165);
  --border-strong: oklch(0.365 0.012 165);

  --accent:        oklch(0.845 0.155 159);
  --accent-hover:  color-mix(in oklch, var(--accent), white 12%);
  --accent-press:  color-mix(in oklch, var(--accent), white 24%);
  --accent-fg:     oklch(0.180 0.050 159);
  --accent-soft:   color-mix(in oklch, var(--accent) 16%, var(--surface));
  --accent-soft-2: color-mix(in oklch, var(--accent) 30%, var(--surface));
  --accent-soft-fg:color-mix(in oklch, var(--accent), white 22%);
  --accent-line:   color-mix(in oklch, var(--accent) 42%, var(--surface));

  --positive:      var(--accent);
  --positive-soft: var(--accent-soft);

  --chart-grid:    oklch(0.285 0.010 165);
  --chart-axis:    oklch(0.500 0.011 165);
  --chart-bar:     var(--accent);
  --chart-bar-2:   color-mix(in oklch, var(--accent) 45%, var(--surface));

  --toggle-off:    oklch(0.360 0.010 165);
  --warn:          oklch(0.830 0.135 74);
  --danger:        oklch(0.690 0.185 22);
  --danger-soft:   oklch(0.320 0.090 22);
  --danger-fg:     oklch(0.700 0.180 22);
  --code-bg:       oklch(0.218 0.010 165);

  --shadow-card: 0 1px 2px rgba(0,0,0,.30), 0 6px 20px -10px rgba(0,0,0,.50);
  --shadow-pop:  0 16px 48px -12px rgba(0,0,0,.65);
  color-scheme: dark;
}

/* ============================================================
   BASE
   ============================================================ */
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1, "cv01" 1; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.row { display: flex; align-items: center; }
.spacer { flex: 1; }
::selection { background: var(--accent-soft-2); color: var(--accent-soft-fg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================
   COMPONENTS
   ============================================================ */
.card {
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: var(--card-pad); }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--card-pad) - 4px) var(--card-pad);
  border-bottom: var(--border-w) solid var(--border);
}
.card-head h3 { font-size: 16px; white-space: nowrap; margin: 0; font-weight: 700; letter-spacing: -0.02em; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--field-h); padding: 0 18px;
  border-radius: var(--radius-sm);
  border: var(--border-w) solid transparent;
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
  font-family: inherit; cursor: pointer; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .08s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(0.5px); }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-faint); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-sm { height: 38px; padding: 0 14px; font-size: 13.5px; }
.btn-danger { background: transparent; color: var(--danger-fg); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-google { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-google:hover { background: var(--surface-2); border-color: var(--text-faint); }
.btn-google .g-icon { width: 18px; height: 18px; flex: none; }

/* "or" divider between the Google button and the email/password form */
.auth-or {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
  margin: 16px 0;
}
.auth-or::before, .auth-or::after {
  content: ""; flex: 1; height: 1px; background: var(--border-strong);
}

/* Collapsible danger zone (Settings → Delete account) */
.danger-zone { overflow: hidden; }
.danger-zone > summary { outline: none; }
.danger-zone > summary::-webkit-details-marker { display: none; }
.danger-zone > summary:hover { background: var(--danger-soft); }
.danger-zone-chevron { display: inline-flex; color: var(--text-muted); transition: transform 0.15s ease; }
.danger-zone[open] > summary .danger-zone-chevron { transform: rotate(180deg); }

/* Quick-amount chips */
.chip {
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  border: var(--border-w) solid var(--border);
  font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent-soft-fg); background: var(--accent-soft); }

/* Inputs */
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.input {
  height: var(--field-h); width: 100%;
  padding: 0 14px; border-radius: var(--radius-sm);
  border: var(--border-w) solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-size: 15px; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--text-faint); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Native <select>: Tailwind's reset leaves background transparent and color: inherit,
   so in dark mode the option dropdown list (rendered with the OS default light
   background) showed light text on a light popup — unreadable. Pin both the closed
   box and the options to theme tokens. Unlayered, so it beats the @layer base reset. */
select { background-color: var(--surface); color: var(--text); }
select option { background-color: var(--surface); color: var(--text); }

/* Sign-up honeypot. Off-screen instead of display:none/visibility:hidden, both
   of which scrapers commonly skip — a bot that auto-fills every visible-in-DOM
   text field still trips this one. */
.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Code / readonly URL */
.code-field {
  display: flex; align-items: center;
  min-height: var(--field-h); padding: 0 14px;
  border-radius: var(--radius-sm);
  border: var(--border-w) solid var(--border);
  background: var(--code-bg); color: var(--text-2);
  font-family: var(--font-mono); font-size: 13.5px;
}

/* Model catalogue price tile */
.price-box {
  display: grid; gap: 3px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: var(--border-w) solid var(--border);
}

/* Badges & pills */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600;
}
.badge-positive { background: var(--positive-soft); color: var(--positive); }
.badge-neutral  { background: var(--surface-2); color: var(--text-2); }
.balance-pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 14px; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent-soft-fg);
  font-weight: 700; font-size: 14px; cursor: pointer;
  border: var(--border-w) solid transparent;
  transition: background .15s ease, border-color .15s ease;
}
.balance-pill:hover { border-color: var(--accent-line); }

/* Provider monogram badge */
.tk-prov {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  border-radius: 7px; font-weight: 700; font-family: var(--font-sans);
  background: color-mix(in oklch, var(--ptint) 16%, transparent); color: var(--ptint);
}
.prov-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 13px 7px 8px;
  background: var(--surface-2); border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600;
}
.prov-chip.outline { background: transparent; border: 1px solid var(--border); color: var(--text-2); font-size: 12.5px; padding: 6px 12px 6px 7px; }

/* Segmented control */
.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-2); border-radius: var(--radius-pill);
  border: var(--border-w) solid var(--border);
}
.seg button, .seg a {
  border: none; background: transparent; color: var(--text-2);
  height: 30px; padding: 0 16px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; transition: all .18s ease;
}
.seg button.active, .seg a.active { background: var(--text); color: var(--surface); }
[data-theme="dark"] .seg button.active, [data-theme="dark"] .seg a.active { background: var(--accent); color: var(--accent-fg); }
.seg.seg-accent button.active, .seg.seg-accent a.active { background: var(--accent); color: var(--accent-fg); }

/* Language dropdown */
.lang-dd { position: relative; display: inline-flex; }
.lang-dd-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 9px 0 12px;
  background: var(--surface-2); color: var(--text-2);
  border: var(--border-w) solid var(--border); border-radius: var(--radius-pill);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color .18s ease, color .18s ease, background .18s ease;
}
.lang-dd-btn:hover { border-color: var(--text-faint); color: var(--text); }
.lang-dd-btn:focus-visible { outline: none; border-color: var(--accent); }
.lang-dd-caret { color: var(--text-muted); transition: transform .2s ease; }
.lang-dd-btn[aria-expanded="true"] .lang-dd-caret { transform: rotate(180deg); }

.lang-dd-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  min-width: 168px; padding: 6px;
  background: var(--surface); border: var(--border-w) solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-pop);
  animation: lang-dd-in .14s ease;
}
@keyframes lang-dd-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.lang-dd-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  text-decoration: none; white-space: nowrap;
}
.lang-dd-item:hover { background: var(--surface-2); color: var(--text); }
.lang-dd-item.active { color: var(--text); font-weight: 600; }
.lang-dd-check { display: inline-flex; color: var(--accent); }

/* Dark trigger variant for the admin header */
.lang-dd--dark .lang-dd-btn {
  background: transparent; color: var(--slate-300); border-color: var(--slate-700);
}
.lang-dd--dark .lang-dd-btn:hover { color: #fff; border-color: var(--slate-500); }

/* Settings dropdown (icon trigger → theme toggle + link to settings page) */
.settings-dd { position: relative; display: inline-flex; }
.settings-dd .icon-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.settings-dd-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  min-width: 188px; padding: 6px;
  background: var(--surface); border: var(--border-w) solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-pop);
  animation: lang-dd-in .14s ease;
}
.settings-dd-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: var(--radius-sm);
  background: none; border: none; cursor: pointer;
  color: var(--text-2); font: inherit; font-size: 13.5px; font-weight: 600;
  text-decoration: none; text-align: left; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.settings-dd-item:hover { background: var(--surface-2); color: var(--text); }
.settings-dd-item > span:last-child { flex: 1; }

/* Statistics dropdown in the main nav: opens on hover / keyboard focus.
   The padding-bottom (cancelled by the negative margin) keeps the hover zone
   unbroken across the gap to the menu, so moving the cursor down doesn't close it. */
.tk-nav-dd { padding-bottom: 8px; margin-bottom: -8px; }
.tk-nav-dd-btn { display: inline-flex; align-items: center; gap: 5px; cursor: default; }
.tk-nav-dd-btn .lang-dd-caret { transition: transform .2s ease; }
.tk-nav-dd .settings-dd-menu { top: 100%; left: 0; right: auto; display: none; }
.tk-nav-dd:hover .settings-dd-menu,
.tk-nav-dd:focus-within .settings-dd-menu { display: block; }
.tk-nav-dd:hover .tk-nav-dd-btn .lang-dd-caret,
.tk-nav-dd:focus-within .tk-nav-dd-btn .lang-dd-caret { transform: rotate(180deg); }

/* Account dropdown (email trigger in the dashboard header) */
.user-dd-email {
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Toggle switch */
.switch {
  position: relative; width: 42px; height: 24px; border-radius: var(--radius-pill);
  background: var(--toggle-off); border: none; padding: 0; cursor: pointer;
  transition: background .2s ease; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s ease;
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600;
  color: var(--text-muted); padding: 0 0 14px; letter-spacing: 0.01em;
}
.table td { padding: 16px 0; border-top: var(--border-w) solid var(--border); font-size: 14px; }
.table tr:first-child td { border-top: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Breakdown row label linking to the filtered request log. */
.breakdown-link { color: inherit; text-decoration: none; }
.breakdown-link:hover { color: var(--accent); text-decoration: underline; }

/* Stat tiles */
.stat-tile {
  background: var(--surface); border: var(--border-w) solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color .2s ease, transform .2s ease;
}
.stat-tile .stat-label { display: flex; align-items: center; justify-content: space-between; color: var(--text-muted); font-size: 13.5px; font-weight: 500; }
.stat-tile .stat-value { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; }
.stat-icon { color: var(--text-faint); display: grid; place-items: center; }

/* Section title */
.page-title { font-size: 34px; line-height: 1.1; letter-spacing: -0.035em; margin: 0; font-weight: 700; }

/* Empty state */
.empty-state { text-align: center; padding: 46px 20px; display: grid; place-items: center; gap: 6px; }
.empty-state .empty-icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-faint); margin-bottom: 8px;
}
.empty-state .empty-title { font-weight: 700; font-size: 15px; }
.empty-state .empty-desc { color: var(--text-muted); font-size: 13.5px; max-width: 320px; }

/* Skeleton loading */
@keyframes shimmer { 0% { background-position: -340px 0; } 100% { background-position: 340px 0; } }
.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-inset) 50%, var(--surface-2) 75%);
  background-size: 680px 100%; animation: shimmer 1.3s infinite linear;
  border-radius: 6px;
}

/* ============================================================
   APP CHROME
   ============================================================ */
.tk-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in oklch, var(--bg) 84%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.tk-header-inner {
  max-width: var(--maxw); margin: 0 auto; height: 68px;
  padding: 0 28px; display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 12px;
}
.tk-header-inner > .tk-logo { justify-self: start; }
.tk-header-actions { justify-self: end; display: flex; align-items: center; gap: 12px; }
.tk-logo { display: inline-flex; align-items: center; gap: 9px; background: none; border: none; padding: 0; cursor: pointer; }
.tk-logo .tk-mark { width: 26px; height: 26px; color: var(--accent); display: inline-flex; }
.tk-logo .tk-word { font-weight: 800; font-size: 20px; letter-spacing: -0.04em; color: var(--text); }
.tk-logo .tk-word .dim { color: var(--text-2); }

.tk-nav { display: flex; align-items: center; gap: 4px; justify-self: center; }
/* When the dashboard nav is rendered inside a public shell (landing/catalog),
   that shell's own `.btn` rules would override the sign-out button — re-assert
   the design-system button sizing with header-scoped specificity. */
.tk-header .btn { height: var(--field-h); padding: 0 18px; border-radius: var(--radius-sm); font-size: 14px; }
.tk-header .btn-sm { height: 38px; padding: 0 14px; font-size: 13.5px; }
.tk-link {
  background: none; border: none; padding: 8px 13px; border-radius: var(--radius-sm);
  font-size: 14.5px; font-weight: 600; color: var(--text-2); position: relative; white-space: nowrap;
  cursor: pointer; transition: color .15s ease, background .15s ease;
}
.tk-link:hover { color: var(--text); background: var(--surface-2); }
.tk-link.active { color: var(--accent-soft-fg); }
.tk-link.active::after {
  content: ""; position: absolute; left: 13px; right: 13px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--radius-sm); display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  cursor: pointer; transition: all .15s ease; flex: none;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent-line); }
.icon-btn.active { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
/* Inline styles from the icon helper set display:inline-flex, so the toggle
   rules use !important to win over them. */
.theme-toggle .ico-sun { display: none !important; }
[data-theme="dark"] .theme-toggle .ico-moon { display: none !important; }
[data-theme="dark"] .theme-toggle .ico-sun { display: inline-flex !important; }
.icon-act {
  width: 32px; height: 32px; border-radius: var(--radius-sm); display: inline-grid; place-items: center;
  border: none; background: transparent; color: var(--text-muted); cursor: pointer; transition: all .15s ease;
}
.icon-act:hover { background: var(--surface-2); color: var(--accent); }
.icon-act.danger { color: var(--danger-fg); }
.icon-act.danger:hover { background: var(--danger-soft); }

/* Settings page */
.settings-options { display: grid; gap: 8px; max-width: 440px; }
.settings-option {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: var(--border-w) solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 14.5px; font-weight: 600; text-decoration: none;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.settings-option:hover { border-color: var(--text-faint); color: var(--text); background: var(--surface-2); }
.settings-option.active { border-color: var(--accent-line); color: var(--text); background: var(--accent-soft); }
.settings-option-check { display: inline-flex; color: var(--accent); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setting-label { font-size: 13px; color: var(--text-muted); margin-bottom: 3px; }
.setting-value { font-size: 14.5px; color: var(--text); word-break: break-all; }

/* Stacked selectable options (theme, language). */
.settings-options { display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.settings-option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: var(--border-w) solid var(--border);
  color: var(--text-2); font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; text-align: left;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.settings-option:hover { background: var(--surface-2); color: var(--text); }
.settings-option.active { border-color: var(--accent); color: var(--text); }
.settings-option-check { display: inline-flex; color: var(--accent); visibility: hidden; }
.settings-option.active .settings-option-check { visibility: visible; }

.tk-main { max-width: var(--maxw); margin: 0 auto; padding: var(--space-banner-y) 28px 120px; }
/* When the referral banner is present, mirror its top margin below it so the
   heading sits symmetrically; without the banner the heading takes its place. */
.rbn-wrap + .tk-main { padding-top: var(--space-banner-y); }
.tk-page { animation: tkpage .35s ease both; }

/* Flash banners */
.flash {
  display: flex; align-items: center; gap: 9px; margin-bottom: 22px;
  padding: 12px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
}
.flash-notice { background: var(--accent-soft); color: var(--accent-soft-fg); border-color: var(--accent-line); }
.flash-alert { background: var(--danger-soft); color: var(--danger-fg); border-color: color-mix(in oklch, var(--danger) 30%, transparent); }

/* Mobile nav */
.show-mobile { display: none !important; }
.tk-mobile-menu { display: none; }
@media (max-width: 720px) {
  .show-mobile { display: inline-grid !important; }
  .hide-mobile { display: none !important; }
  .tk-header-inner { padding: 0 16px; gap: 8px; }
  .tk-main { padding: var(--space-banner-y) 16px 90px; }
  .page-title { font-size: 26px; }
  .stat-tile .stat-value { font-size: 26px; }
  .tk-mobile-menu {
    display: grid; gap: 2px; padding: 10px 16px 16px;
    border-top: 1px solid var(--border); background: var(--surface);
  }
  .tk-mobile-menu[hidden] { display: none; }
  .tk-mobile-link {
    text-align: left; background: none; border: none; padding: 13px 12px; border-radius: var(--radius-sm);
    font-size: 16px; font-weight: 600; color: var(--text-2); cursor: pointer;
  }
  .tk-mobile-link.active { color: var(--accent-soft-fg); background: var(--accent-soft); }
  .keys-table, .logs-table { min-width: 560px; }
  /* The balance link left the nav — the pill is the only way to the balance
     page, so it stays visible on mobile (compacted). */
  .balance-pill { height: 28px; padding: 0 10px; font-size: 13px; }
}
.logs-table { min-width: 640px; }

/* ============================================================
   CHART
   ============================================================ */
.chart-wrap { display: flex; gap: 14px; height: 300px; }
.chart-yaxis {
  display: flex; flex-direction: column; justify-content: space-between;
  text-align: right; padding-bottom: 26px; flex: none; width: 58px;
}
.chart-yaxis span { font-size: 11px; color: var(--text-faint); line-height: 1; font-family: var(--font-mono); }
.chart-plot { flex: 1; position: relative; min-width: 0; }
.chart-grid-lines { position: absolute; inset: 0 0 26px 0; }
.chart-grid-lines div { position: absolute; left: 0; right: 0; border-top: 1px solid var(--chart-grid); }
.chart-bars { position: absolute; inset: 0 0 26px 0; display: flex; align-items: flex-end; gap: 4px; }
.chart-col { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.chart-bar {
  width: 100%; background: var(--chart-bar);
  border-radius: var(--radius-sm) var(--radius-sm) 2px 2px;
  transition: height .5s cubic-bezier(.22,1,.36,1), background .15s ease;
}
.chart-col:hover .chart-bar { background: var(--accent-hover); }
.chart-xaxis { position: absolute; left: 0; right: 0; bottom: 0; height: 26px; display: flex; gap: 4px; }
.chart-xaxis span {
  flex: 1; text-align: center; font-size: 10.5px; color: var(--text-faint);
  overflow: hidden; white-space: nowrap; padding-top: 8px; font-family: var(--font-mono);
}
.chart-tooltip {
  position: absolute; transform: translate(-50%, -8px);
  background: var(--text); color: var(--surface); padding: 7px 11px; border-radius: 8px;
  white-space: nowrap; font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-pop);
  z-index: 5; pointer-events: none;
}
.chart-tooltip .tt-label { opacity: .65; font-weight: 500; font-size: 11px; }

/* ============================================================
   LOG DETAIL (inline reveal row)
   ============================================================ */
.detail-row td { background: var(--surface-2); padding: 18px var(--card-pad); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px 24px; }
.detail-grid dt { color: var(--text-muted); font-size: 12px; margin-bottom: 3px; }
.detail-grid dd { margin: 0; font-weight: 600; font-size: 13.5px; font-variant-numeric: tabular-nums; }

/* ============================================================
   KEYFRAMES — visibility-safe (never start from opacity:0)
   ============================================================ */
@keyframes tkspin { to { transform: rotate(360deg); } }
@keyframes tkrow { from { transform: translateY(-6px); } to { transform: none; } }
@keyframes tkslide { from { transform: translateX(26px); } to { transform: none; } }
@keyframes tkpage { from { transform: translateY(7px); } to { transform: none; } }
.tk-fresh { animation: tkrow .4s ease; }

/* ============================================================
   Admin back-office — dark theme.
   The admin UI is built with raw Tailwind neutral utilities
   (slate / white), not the design-system component classes.
   Rather than annotate every view with `dark:` variants, we
   remap the handful of neutral utilities it uses to the dark
   design tokens, scoped to `.admin-ui` under [data-theme=dark].
   Accent chips (emerald / rose / amber / indigo) read fine on
   the dark surfaces and are intentionally left untouched.
   ============================================================ */

/* Icon buttons in the (always dark) admin header: theme toggle, hamburger. */
.admin-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border-radius: var(--radius-sm);
  color: var(--slate-300); background: transparent; border: 0; cursor: pointer;
  transition: color .15s ease, background-color .15s ease;
}
.admin-icon-btn:hover { color: #fff; background: rgba(255,255,255,.08); }

/* Light content top-bar (sidebar layout): adapts to the active theme. Its icon
   buttons sit on a light surface, so they need dark-on-light contrast — unlike
   the always-dark sidebar where the default slate-300 button color is correct. */
.admin-topbar { background: var(--surface); border-bottom: var(--border-w) solid var(--border); }
.admin-topbar .admin-icon-btn { color: var(--text-muted); }
.admin-topbar .admin-icon-btn:hover { color: var(--text); background: var(--surface-inset); }

/* Hamburger: hidden on desktop, shown once the link row collapses (< lg, 1024px).
   Declared here (and after .admin-icon-btn) so source order — not a same-specificity
   tie with Tailwind's `lg:hidden` across files — decides, making it deterministic. */
.admin-burger { display: none; }
@media (max-width: 1023px) { .admin-burger { display: inline-flex; } }

[data-theme="dark"] .admin-ui { background: var(--bg); color: var(--text); }

/* Surfaces */
[data-theme="dark"] .admin-ui .bg-white { background: var(--surface); }
[data-theme="dark"] .admin-ui .bg-slate-50 { background: var(--bg); }
[data-theme="dark"] .admin-ui .bg-slate-100 { background: var(--surface-2); }
[data-theme="dark"] .admin-ui .hover\:bg-slate-50:hover { background: var(--surface-2); }
[data-theme="dark"] .admin-ui .hover\:bg-slate-100:hover { background: var(--surface-2); }

/* Borders */
[data-theme="dark"] .admin-ui .border-slate-50,
[data-theme="dark"] .admin-ui .border-slate-100,
[data-theme="dark"] .admin-ui .border-slate-200,
[data-theme="dark"] .admin-ui .border-slate-300,
[data-theme="dark"] .admin-ui .border-slate-800 { border-color: var(--border); }

/* Text */
[data-theme="dark"] .admin-ui .text-slate-900,
[data-theme="dark"] .admin-ui .text-slate-800,
[data-theme="dark"] .admin-ui .text-slate-700 { color: var(--text); }
[data-theme="dark"] .admin-ui .text-slate-600,
[data-theme="dark"] .admin-ui .text-slate-500 { color: var(--text-2); }
[data-theme="dark"] .admin-ui .text-slate-400 { color: var(--text-muted); }
[data-theme="dark"] .admin-ui .hover\:text-slate-700:hover,
[data-theme="dark"] .admin-ui .hover\:text-slate-800:hover { color: var(--text); }

/* Semantic accent tints. Tailwind's colored utilities are light-baked
   (near-white -50/-100 fills, dark -600…-900 text) and read wrong on the dark
   surface, so re-map the SOFT shades used for cards/badges/alerts onto the
   theme's tokens. Solid accents (-500/-600 fills, buttons, bars) and *hover*
   variants are left alone — they carry white text or only appear on hover, and
   stay legible as-is. `--ink-indigo`/`--ink-violet` fill the gap for hues the
   green theme has no token for. */
[data-theme="dark"] .admin-ui {
  --ink-indigo: oklch(0.66 0.19 274);
  --ink-violet: oklch(0.66 0.19 292);
}
/* Soft fills */
[data-theme="dark"] .admin-ui .bg-indigo-50,
[data-theme="dark"] .admin-ui .bg-indigo-100 { background: color-mix(in oklch, var(--ink-indigo) 20%, var(--surface)); }
[data-theme="dark"] .admin-ui .bg-violet-50 { background: color-mix(in oklch, var(--ink-violet) 20%, var(--surface)); }
[data-theme="dark"] .admin-ui .bg-emerald-50,
[data-theme="dark"] .admin-ui .bg-emerald-100 { background: color-mix(in oklch, var(--accent) 15%, var(--surface)); }
[data-theme="dark"] .admin-ui .bg-rose-50,
[data-theme="dark"] .admin-ui .bg-rose-100 { background: var(--danger-soft); }
[data-theme="dark"] .admin-ui .bg-amber-50,
[data-theme="dark"] .admin-ui .bg-amber-100 { background: color-mix(in oklch, var(--warn) 15%, var(--surface)); }
/* Soft borders (100…400; the brighter -500/-600 are kept as accents) */
[data-theme="dark"] .admin-ui .border-indigo-100,
[data-theme="dark"] .admin-ui .border-indigo-200,
[data-theme="dark"] .admin-ui .border-indigo-300,
[data-theme="dark"] .admin-ui .border-indigo-400 { border-color: color-mix(in oklch, var(--ink-indigo) 42%, var(--surface)); }
[data-theme="dark"] .admin-ui .border-emerald-200,
[data-theme="dark"] .admin-ui .border-emerald-300,
[data-theme="dark"] .admin-ui .border-emerald-400 { border-color: color-mix(in oklch, var(--accent) 42%, var(--surface)); }
[data-theme="dark"] .admin-ui .border-rose-100,
[data-theme="dark"] .admin-ui .border-rose-200,
[data-theme="dark"] .admin-ui .border-rose-300,
[data-theme="dark"] .admin-ui .border-rose-400 { border-color: color-mix(in oklch, var(--danger) 42%, transparent); }
[data-theme="dark"] .admin-ui .border-amber-200 { border-color: color-mix(in oklch, var(--warn) 42%, transparent); }
/* Dark text accents -> lightened so they read on the dark surface */
[data-theme="dark"] .admin-ui .text-indigo-600,
[data-theme="dark"] .admin-ui .text-indigo-700,
[data-theme="dark"] .admin-ui .text-indigo-800,
[data-theme="dark"] .admin-ui .text-indigo-900 { color: color-mix(in oklch, var(--ink-indigo), white 22%); }
[data-theme="dark"] .admin-ui .text-violet-700 { color: color-mix(in oklch, var(--ink-violet), white 22%); }
[data-theme="dark"] .admin-ui .text-emerald-600,
[data-theme="dark"] .admin-ui .text-emerald-700,
[data-theme="dark"] .admin-ui .text-emerald-800 { color: var(--positive); }
[data-theme="dark"] .admin-ui .text-rose-500,
[data-theme="dark"] .admin-ui .text-rose-600,
[data-theme="dark"] .admin-ui .text-rose-700,
[data-theme="dark"] .admin-ui .text-rose-800 { color: var(--danger-fg); }
[data-theme="dark"] .admin-ui .text-amber-600,
[data-theme="dark"] .admin-ui .text-amber-700,
[data-theme="dark"] .admin-ui .text-amber-800 { color: var(--warn); }

/* The admin header keeps its dark slate look; only re-tint it so it
   sits a touch above the page background in dark mode. */
[data-theme="dark"] .admin-ui header.bg-slate-900 { background: var(--surface); border-color: var(--border); }

/* Lazy dashboard board: dim the current content and float a spinner while the
   turbo-frame is loading (initial lazy fetch and every period/metric switch). */
.admin-ui .tm-frame[aria-busy="true"] { position: relative; display: block; min-height: 9rem; }
.admin-ui .tm-frame[aria-busy="true"] > * { opacity: 0.4; transition: opacity 0.15s ease; }
.admin-ui .tm-frame[aria-busy="true"]::after {
  content: ""; position: absolute; top: 2rem; left: 50%; width: 1.75rem; height: 1.75rem;
  margin-left: -0.875rem; border-radius: 9999px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: tm-spin 0.7s linear infinite;
}
@keyframes tm-spin { to { transform: rotate(360deg); } }

/* ============================================================
   ROUTING-FILTERS  (per-key settings modal — api_keys#settings)
   Three filter cards — required capabilities, blocked access groups,
   and per-model price limits with an expandable route list and a live
   "routes available" count. Mirrors RoutingPreference#allows? client-side
   via routing_preview_controller.js.
   ============================================================ */
.rp-page { display: grid; gap: 24px; }
.rp-stack { display: grid; gap: 16px; }
.rp-card { padding: clamp(20px, 2.4vw, 30px); }
.rp-card-head { margin-bottom: 22px; }
.rp-section-title { font-size: clamp(19px, 2vw, 23px); font-weight: 700; letter-spacing: -0.02em; }
.rp-section-desc { color: var(--text-2); font-size: 13.5px; line-height: 1.55; margin-top: 7px; }
.rp-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 8px; }

/* --- per-key settings modal --- */
.key-settings-dialog {
  width: min(1100px, 94vw);
  max-height: 90vh;
  /* center in the top layer — some resets zero out the UA dialog margin,
     which pins the modal to the top-left, so set it back explicitly. */
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}
/* No backdrop-filter: a blur here forced Chrome to recompute the top-layer
   backdrop on every style recalc inside the dialog (e.g. a :has() toggle when a
   block chip is checked), and the GPU compositor intermittently failed to
   repaint the dialog's own content — sections below the toggled chip went blank
   ("content disappears"). The plain dim reads as a modal without that bug. */
.key-settings-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.key-settings { display: flex; flex-direction: column; max-height: 90vh; }
.key-settings-head {
  display: flex; align-items: center; gap: 12px;
  padding: 20px clamp(20px, 2.4vw, 28px);
  border-bottom: 1px solid var(--border);
}
.key-settings-head .rp-section-title { flex: 1; }
/* translateZ(0) gives the scroll area its own compositing layer so its rows
   always repaint after a style recalc (e.g. a :has() block-chip toggle) —
   belt-and-suspenders for the same top-layer repaint glitch the backdrop-filter
   removal above addresses. Without it, rows below a toggled route went blank. */
/* The form is the flex column: a scrolling body (.ks-body) and a fixed footer
   (.rp-actions) that never scrolls. min-height:0 lets the body actually shrink
   and scroll inside the flex column instead of overflowing. */
.key-settings form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.key-settings .ks-body { flex: 1; min-height: 0; overflow-y: auto; padding: clamp(18px, 2.4vw, 26px); transform: translateZ(0); }
/* Real footer: outside the scroll area, separated by a top border. */
.key-settings .rp-actions {
  flex: none;
  margin: 0;
  padding: 16px clamp(18px, 2.4vw, 26px);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.key-settings-loading { padding: 40px; text-align: center; }
.ks-flag { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
/* Vertical breathing room so one flag's hint doesn't run into the next title. */
.ks-flag + .ks-flag { margin-top: 18px; }
/* Reuse the custom .cap-box checkbox from "required capabilities" below: hide
   the native input and let the styled box align with the title's first line. */
.ks-flag input[type="checkbox"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ks-flag .cap-box { margin-top: 1px; }
.ks-flag input:disabled + .cap-box { opacity: .5; }
.ks-flag input:disabled ~ .ks-flag-text { opacity: .7; }
.ks-flag-text { display: grid; gap: 3px; min-width: 0; flex: 1; }
.ks-flag-title { font-weight: 600; }
.ks-flag-hint { font-size: 13px; line-height: 1.5; }
/* The cheaper-than-official flag wraps its checkbox + percent sub-field, so the
   adjacent-flag margin rule above can't reach it; restore the gap on the wrap. */
.ks-flag + [data-controller="cheaper-percent"] { margin-top: 18px; }
/* The "below official by, %" field, revealed under the flag when it's checked. */
.ks-flag-sub { margin: 10px 0 0 32px; }
.ks-pct { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.ks-pct-input { display: inline-flex; align-items: center; gap: 4px; }
.ks-pct-input input { width: 5rem; }

/* --- required capabilities: styled checkboxes --- */
.rp-caps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 28px; }
.cap-item { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.cap-item .cap-check { flex: 0 1 auto; min-width: 0; }
.cap-tip {
  position: relative; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: help; border-radius: 50%;
  transition: color .15s ease;
}
.cap-tip:hover, .cap-tip:focus-visible, .cap-tip.is-open { color: var(--accent); outline: none; }
.cap-tip:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
.cap-tip-bubble {
  position: absolute; top: calc(100% + 8px); right: -6px; z-index: 40;
  width: max-content; max-width: 280px;
  padding: 9px 11px; border-radius: 10px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
  font-size: 12.5px; line-height: 1.45; text-align: left; white-space: normal;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .14s ease, transform .14s ease, visibility .14s;
  pointer-events: none;
}
.cap-tip-bubble::after {
  content: ""; position: absolute; bottom: 100%; right: 9px;
  border: 6px solid transparent; border-bottom-color: var(--border-strong);
}
.cap-tip:hover .cap-tip-bubble,
.cap-tip:focus-visible .cap-tip-bubble,
.cap-tip.is-open .cap-tip-bubble {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.cap-check {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 7px 0; cursor: pointer; font-size: 14px; color: var(--text-2);
}
.cap-check input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.cap-box {
  flex: none; width: 19px; height: 19px; border-radius: 6px;
  border: 1.5px solid var(--border-strong); background: transparent;
  display: grid; place-items: center; transition: background .15s ease, border-color .15s ease;
}
.cap-box::after {
  content: ""; width: 9px; height: 5px;
  border-left: 2px solid var(--accent-fg); border-bottom: 2px solid var(--accent-fg);
  margin-top: -2px; transform: rotate(-45deg) scale(0); transition: transform .15s ease;
}
.cap-check input:checked + .cap-box,
.ks-flag input:checked + .cap-box { background: var(--accent); border-color: var(--accent); }
.cap-check input:checked + .cap-box::after,
.ks-flag input:checked + .cap-box::after { transform: rotate(-45deg) scale(1); }
.cap-check input:checked ~ .cap-text { color: var(--text); }
.cap-check input:focus-visible + .cap-box,
.ks-flag input:focus-visible + .cap-box { box-shadow: 0 0 0 3px var(--accent-soft); }
/* Disabled cap (e.g. "Prompt caching" while prompt-cache emulation is on). */
.cap-check input:disabled + .cap-box { opacity: .45; cursor: not-allowed; }
.cap-item.is-disabled { opacity: .6; }
.cap-item.is-disabled .cap-check { cursor: not-allowed; }

/* Reasoning: a three-state gate set apart from the plain capability checkboxes. */
.rp-reasoning {
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
}
.rp-reasoning-label { font-size: 14px; font-weight: 600; color: var(--text); }
.rp-reasoning select {
  padding: 7px 11px; border-radius: 8px; font-size: 14px;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.rp-reasoning select:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.rp-reasoning-hint { flex-basis: 100%; color: var(--text-2); font-size: 13px; line-height: 1.5; margin: 0; }

/* --- blocked access groups: toggleable chips grouped by provider --- */
.rp-blocks { display: grid; gap: 18px; }
.rp-block-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 16px; align-items: start; }
.rp-block-name { font-size: 12.5px; font-weight: 600; color: var(--text); padding-top: 8px; }
.rp-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.block-chip {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font-family: var(--font-mono); font-size: 12.5px; padding: 6px 11px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.block-chip:hover { border-color: var(--text-faint); }
.block-chip input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.block-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--border-strong); }
.block-chip:has(input:checked) {
  border-color: var(--danger); background: var(--danger-soft); color: var(--danger-fg);
  text-decoration: line-through;
}
.block-chip:has(input:checked) .block-dot { background: var(--danger); }
.rp-block-foot { margin-top: 20px; padding-top: 16px; border-top: var(--border-w) solid var(--border); }
.rp-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px;
  border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; border: 1px solid transparent;
}
.rp-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.rp-pill.is-green { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.rp-pill.is-red {
  color: var(--danger-fg); background: var(--danger-soft);
  border-color: color-mix(in oklch, var(--danger) 42%, transparent);
}

/* --- per-model price limits --- */
.rp-head,
.rp-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 116px 116px 92px;
  gap: 12px; align-items: center;
}
.rp-head {
  padding: 0 4px 10px; color: var(--text-muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .08em;
  border-bottom: var(--border-w) solid var(--border);
}
.rp-model { border-bottom: var(--border-w) solid var(--border); }
.rp-row { padding: 12px 4px; }
.rp-name { font-size: 13.5px; line-height: 1.25; word-break: break-word; }
.rp-chevron {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; padding: 2px;
  color: var(--text-muted); transition: transform 0.15s ease;
}
.rp-chevron.open { transform: rotate(90deg); }

/* model on/off switch: the name is a label; checking it blocks the whole model */
.rp-power { display: inline-flex; align-items: center; gap: 8px; min-width: 0; cursor: pointer; }
.rp-power input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.rp-power-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--accent); background: var(--accent);
  transition: background .15s ease, border-color .15s ease;
}
.rp-power:hover .rp-power-dot { border-color: var(--text-faint); }
.rp-power input:checked ~ .rp-power-dot { background: var(--danger); border-color: var(--danger); }
.rp-model-off .rp-name { text-decoration: line-through; color: var(--text-muted); }
.rp-model-off .price-input { opacity: 0.45; pointer-events: none; }
.rp-model-off .rp-chevron { opacity: 0.45; }
.rp-block-row.is-provider-off .rp-chips { opacity: 0.45; pointer-events: none; }
.rp-block-row.is-provider-off .rp-power-label { text-decoration: line-through; color: var(--text-muted); }

/* price input with a $ prefix */
.price-input {
  display: inline-flex; align-items: center; gap: 2px; height: 38px; padding: 0 10px;
  border-radius: var(--radius-sm); border: var(--border-w) solid var(--border-strong);
  background: var(--surface); transition: border-color .15s ease, box-shadow .15s ease;
}
.price-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.price-input .cur { color: var(--text-faint); font-size: 13px; flex: none; }
.price-input input {
  width: 100%; min-width: 0; border: none; background: transparent; color: var(--text);
  font-family: var(--font-mono); font-size: 13.5px; text-align: right; outline: none; padding: 0;
}
.price-input input::-webkit-outer-spin-button,
.price-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.price-input input { -moz-appearance: textfield; appearance: textfield; }

/* live route-count badge */
.rp-count {
  justify-self: end; display: inline-flex; align-items: center; height: 26px; padding: 0 10px;
  border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--border-strong); color: var(--text-2); background: var(--surface);
}
.rp-count.is-green { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.rp-count.is-amber {
  color: var(--warn); background: color-mix(in oklch, var(--warn) 16%, transparent);
  border-color: color-mix(in oklch, var(--warn) 42%, transparent);
}
.rp-count.is-red {
  color: var(--danger-fg); background: var(--danger-soft);
  border-color: color-mix(in oklch, var(--danger) 42%, transparent);
}

/* expanded route list (inset panel) */
.rp-routes { padding: 4px 4px 16px 30px; }
.rp-panel {
  background: var(--surface-inset); border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.rp-subhead,
.rp-route {
  display: grid; grid-template-columns: minmax(0, 1fr) 90px 90px 72px; gap: 14px;
  align-items: center; padding: 10px 14px;
  border-bottom: var(--border-w) solid var(--border);
}
.rp-route:last-child { border-bottom: 0; }
.rp-subhead {
  background: var(--surface-2); color: var(--text-muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .08em;
}
.rp-route { font-size: 12.5px; }
.rp-route-name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-route .tnum { text-align: right; color: var(--text); }
.rp-route .tnum.over { color: var(--danger-fg); }
.rp-route-disabled { opacity: 0.55; }

/* status cell: green check (passing) → red ✕ (excluded) → "too pricey" text */
.rp-route-status { justify-self: end; display: inline-flex; align-items: center; }
.rp-route-status .ok-icon { color: var(--accent); display: inline-flex; }
.rp-route-status .bad-icon { color: var(--text-muted); display: none; }
.rp-route-status .pricey-text { display: none; font-family: var(--font-mono); font-size: 11px; color: var(--danger-fg); }
.rp-route-disabled .rp-route-status .ok-icon { display: none; }
.rp-route-disabled .rp-route-status .bad-icon { display: inline-flex; }
.rp-route-pricey .rp-route-status .bad-icon { display: none; }
.rp-route-pricey .rp-route-status .pricey-text { display: inline; }

@media (max-width: 720px) {
  .rp-block-row { grid-template-columns: 1fr; gap: 8px; }
  .rp-block-name { padding-top: 0; }
  .rp-head,
  .rp-row { grid-template-columns: 24px minmax(0, 1fr) 92px 92px; }
  .rp-head > span:nth-child(5),
  .rp-count { display: none; }
  .rp-subhead,
  .rp-route { grid-template-columns: minmax(0, 1fr) 70px 56px; }
  .rp-subhead > span:nth-child(3),
  .rp-route > .tnum[data-cell="out"] { display: none; }
}

/* ============================================================
   BALANCE PAGE — top-up redesign
   ============================================================ */

/* Step label: numbered circle + title */
.bal-step {
  display: flex; align-items: baseline; gap: 11px; margin-bottom: 16px;
}
.bal-step-num {
  flex: none; width: 22px; height: 22px; border-radius: var(--radius-pill);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
  font-family: var(--font-mono); margin-top: 1px;
  border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent-soft-fg);
}
.bal-step-title { font-weight: 700; font-size: 15px; }
.bal-step-hint { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* Amount field */
.bal-amount-wrap {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); height: 60px; padding: 0 18px; margin-bottom: 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.bal-amount-wrap:focus-within {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.bal-amount-cur { font-size: 26px; color: var(--text-muted); font-weight: 600; flex: none; }
.bal-amount-input {
  flex: 1; min-width: 0; border: none; background: transparent; color: var(--text);
  font-size: 30px; font-weight: 700; outline: none; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.bal-amount-input::placeholder { color: var(--text-faint); }
.bal-amount-input::-webkit-outer-spin-button,
.bal-amount-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bal-amount-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Preset chips */
.bal-presets { display: flex; gap: 8px; margin-bottom: 30px; flex-wrap: wrap; }
.bal-preset {
  flex: 1; min-width: 56px; height: 38px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 700; font-family: var(--font-mono);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.bal-preset:hover { border-color: var(--accent); color: var(--accent-soft-fg); background: var(--accent-soft); }
.bal-preset.is-on { border-color: var(--accent); background: var(--accent); color: var(--accent-fg); }

/* Rail tiles (fiat / crypto) */
.bal-rail-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.bal-rail-tile {
  display: block; width: 100%; text-align: left; cursor: pointer;
  font: inherit; padding: 16px 18px; border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-strong); background: var(--surface);
  transition: all .16s ease; position: relative;
}
.bal-rail-tile:hover { border-color: var(--text-faint); }
.bal-rail-tile.is-on {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: 0 8px 28px -16px var(--accent-line);
}
.bal-rail-tile-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px;
}
.bal-rail-radio {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--border-strong); background: transparent;
  display: grid; place-items: center; transition: all .15s ease;
}
.bal-rail-tile.is-on .bal-rail-radio {
  border-color: var(--accent); background: var(--accent);
}
.bal-rail-check { display: none; color: var(--accent-fg); }
.bal-rail-tile.is-on .bal-rail-check { display: block; }
.bal-rail-title { font-weight: 700; font-size: 16px; white-space: nowrap; }
.bal-rail-note { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); margin-top: 11px; }

/* Fee badge */
.bal-fee {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: var(--radius-pill); white-space: nowrap;
}
.bal-fee.is-free {
  border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent-soft-fg);
}
.bal-fee.is-partial {
  border: 1px solid color-mix(in oklch, var(--warn) 42%, transparent);
  background: color-mix(in oklch, var(--warn) 14%, var(--surface));
  color: var(--warn);
}

/* Payment logos row */
.bal-pay-logos { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bal-pay-logo {
  display: grid; place-items: center; padding: 0 9px;
  height: 36px; border-radius: 9px; background: #fff;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.18);
  flex: none;
}
.bal-pay-logo img { height: 18px; width: auto; object-fit: contain; display: block; }
.bal-pay-logo img.is-sbp { height: 26px; }

/* Crypto coin stack */
.bal-coin-stack { display: flex; align-items: center; }
.bal-coin-stack-more { font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; color: var(--text-muted); margin-left: 10px; }

/* Summary block */
.bal-summary {
  margin-top: 22px; padding: 14px 16px;
  border-radius: var(--radius); background: var(--surface-inset);
  border: 1px solid var(--border); display: grid; gap: 0;
}
.bal-summary-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 4px 0; gap: 12px;
}
.bal-summary-row-label { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.bal-summary-row-val {
  font-family: var(--font-mono); font-size: 13.5px; font-weight: 600;
  white-space: nowrap; color: var(--text);
}
.bal-summary-row-val.is-accent { color: var(--accent); }
.bal-summary-divider { height: 1px; background: var(--border); margin: 8px 0; }

/* Balance inline display (in top-up card header) */
.bal-current {
  text-align: right; padding: 10px 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-soft), transparent 110%);
  border: 1px solid var(--accent-line); flex: none;
}
.bal-current-label {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted);
  letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
}
.bal-current-val {
  font-size: clamp(24px, 3vw, 32px); font-weight: 800; line-height: 1.05;
  margin-top: 3px; font-variant-numeric: tabular-nums; letter-spacing: -0.04em;
}

/* Top-ups history table */
.topup-head { background: var(--surface-2); }
.topup-row {
  display: grid; grid-template-columns: 1fr 1.3fr 90px; gap: 14px;
  align-items: center; padding: 12px 22px; border-bottom: 1px solid var(--border);
}
.topup-row:last-child { border-bottom: 0; }

@media (max-width: 600px) {
  .bal-rail-grid { grid-template-columns: 1fr; }
}

/* ── Referral / channel-subscription banner (design: "DarkRouter Banner" V1 — Минимал) ──
   Dark theme reproduces the design's exact mint palette; light theme adapts the same
   mint family for a pale background while keeping the brand button readable. */
:root, [data-theme="light"] {
  --rbn-bg: #f1faf5;
  --rbn-border: #d6e6dd;
  --rbn-text: #16201c;
  --rbn-amount: #0f9d63;
  --rbn-btn-bg: #2fb574;
  --rbn-btn-fg: #ffffff;
  --rbn-btn-bg-hover: #259a61;
  --rbn-x: #8a948f;
  --rbn-x-hover-bg: rgba(0,0,0,.05);
  --rbn-x-hover: #5f6864;
}
[data-theme="dark"] {
  --rbn-bg: #0e1211;
  --rbn-border: #171d1b;
  --rbn-text: #f2f5f4;
  --rbn-amount: #5fe3a1;
  --rbn-btn-bg: #5fe3a1;
  --rbn-btn-fg: #04130c;
  --rbn-btn-bg-hover: #2fb574;
  --rbn-x: #5f6864;
  --rbn-x-hover-bg: rgba(255,255,255,.05);
  --rbn-x-hover: #8a948f;
}
.rbn-wrap { max-width: var(--maxw); margin: var(--space-banner-y) auto 0; padding: 0 28px; }
.rbn {
  display: flex; align-items: center; gap: 16px;
  background: var(--rbn-bg); border: 1px solid var(--rbn-border);
  border-radius: 14px; padding: 14px 16px;
}
.rbn-gift { color: var(--rbn-amount); flex: none; display: inline-flex; }
.rbn-txt { flex: 1; min-width: 0; font-size: 15px; font-weight: 500; color: var(--rbn-text); }
.rbn-txt strong { color: var(--rbn-amount); font-weight: 600; }
.rbn-cta {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  background: var(--rbn-btn-bg); color: var(--rbn-btn-fg); border: none;
  padding: 9px 16px; border-radius: 9px; font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; transition: background .15s;
}
.rbn-cta:hover { background: var(--rbn-btn-bg-hover); }
.rbn-x {
  margin-left: 6px; width: 30px; height: 30px; flex: none;
  border-radius: 8px; border: none; background: transparent; color: var(--rbn-x);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: .15s;
}
.rbn-x:hover { background: var(--rbn-x-hover-bg); color: var(--rbn-x-hover); }
@media (max-width: 720px) { .rbn-wrap { padding: 0 16px; } }
