/* 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. */

/* ============================================================
   TOKENLY — 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;
  --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.985 0.006 160);
  --surface:       #ffffff;
  --surface-2:     var(--slate-50);
  --surface-inset: var(--slate-100);
  --text:          var(--slate-900);
  --text-2:        var(--slate-600);
  --text-muted:    var(--slate-500);
  --text-faint:    var(--slate-400);
  --border:        var(--slate-200);
  --border-strong: var(--slate-300);

  --accent-base:   var(--green-500);
  --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:    var(--slate-150);
  --chart-axis:    var(--slate-400);
  --chart-bar:     var(--accent);
  --chart-bar-2:   color-mix(in oklch, var(--accent) 42%, var(--surface));

  --toggle-off:    var(--slate-300);
  --danger-fg:     var(--danger);
  --code-bg:       var(--slate-50);
  color-scheme: light;
}

/* ---- Dark theme ---- */
[data-theme="dark"] {
  --bg:            oklch(0.165 0.018 264);
  --surface:       oklch(0.205 0.020 263);
  --surface-2:     oklch(0.235 0.020 263);
  --surface-inset: oklch(0.255 0.020 263);
  --text:          oklch(0.965 0.005 255);
  --text-2:        oklch(0.780 0.012 255);
  --text-muted:    oklch(0.650 0.015 256);
  --text-faint:    oklch(0.530 0.016 258);
  --border:        oklch(0.305 0.016 263);
  --border-strong: oklch(0.370 0.018 263);

  --accent:        color-mix(in oklch, var(--accent-base), white 13%);
  --accent-hover:  color-mix(in oklch, var(--accent), white 12%);
  --accent-press:  color-mix(in oklch, var(--accent), white 24%);
  --accent-fg:     oklch(0.190 0.030 160);
  --accent-soft:   color-mix(in oklch, var(--accent) 20%, var(--surface));
  --accent-soft-2: color-mix(in oklch, var(--accent) 32%, 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.016 263);
  --chart-axis:    oklch(0.500 0.016 258);
  --chart-bar:     var(--accent);
  --chart-bar-2:   color-mix(in oklch, var(--accent) 45%, var(--surface));

  --toggle-off:    oklch(0.360 0.016 263);
  --danger:        oklch(0.660 0.170 25);
  --danger-soft:   oklch(0.320 0.080 25);
  --danger-fg:     oklch(0.700 0.170 25);
  --code-bg:       oklch(0.235 0.020 263);

  --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;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  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);
  /* As a grid/flex item, default min-width:auto lets a wide child (rigid input
     row, table) stretch the single-column page grid past the viewport. */
  min-width: 0;
}
.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); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.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; }
/* The Google button's `button_to` form must span the full form width, overriding
   the global `form.button_to { display: inline-flex }` rule. */
.btn-google-form { display: block; width: 100%; }

.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); }

/* 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; }

/* 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; }

/* 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; 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: 66px;
  padding: 0 28px; 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-nav { display: flex; align-items: center; gap: 4px; margin-left: 18px; }
.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; }

.tk-main { flex: 1 0 auto; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: var(--space-page-y) 28px 80px; }
.tk-page { animation: tkpage .35s ease both; }

/* Footer */
.tk-footer { border-top: 1px solid var(--border); background: var(--surface); }
.tk-footer-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 22px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.tk-footer-brand { display: inline-flex; align-items: center; gap: 10px; }
.tk-footer-mark { color: var(--accent); display: inline-flex; }
.tk-footer-copy { font-size: 13.5px; color: var(--text-muted); }
.tk-footer-contacts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tk-footer-link {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  font-size: 13.5px; font-weight: 600; color: var(--text-2); text-decoration: none;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.tk-footer-link:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.tk-footer-link span { white-space: nowrap; }

/* 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: 28px 16px 56px; }
  .tk-footer-inner { padding: 20px 16px; flex-direction: column; align-items: flex-start; gap: 14px; }
  .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); }
  .logs-table { min-width: 560px; }
  .balance-pill { display: none; }

  /* API keys: restack the table into one card per key instead of h-scrolling.
     DOM cell order is name, key, status, actions. */
  .keys-table { min-width: 0; }
  .keys-table thead { display: none; }
  .keys-table tbody { display: grid; gap: 12px; }
  .keys-table tr {
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px 12px;
    border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  }
  .keys-table td { border: none; padding: 0; }
  .keys-table td.keys-name { grid-column: 1; grid-row: 1; font-size: 15px; }
  .keys-table td.keys-actions { grid-column: 2; grid-row: 1; text-align: right; }
  .keys-table td.keys-key { grid-column: 1 / -1; grid-row: 2; }
  .keys-table td.keys-key > div { flex-wrap: wrap; }
  .keys-table td.keys-status {
    grid-column: 1 / -1; grid-row: 3; display: flex; align-items: center; gap: 10px; text-align: left;
  }
  .keys-table td.keys-status::before {
    content: attr(data-label); color: var(--text-muted); font-size: 13px;
  }

  /* Card headers hold a nowrap title + a seg toggle; let them wrap so the
     toggle drops to its own line instead of overflowing the viewport. */
  .card-head { flex-wrap: wrap; }
  .card-head .seg { margin-left: 0; }

  /* Chart: tighten the y-axis gutter and let the (every-other) x-axis time
     labels spill into their empty neighbours instead of being clipped. */
  .chart-wrap { height: 240px; gap: 8px; }
  .chart-yaxis { width: 44px; }
  .chart-yaxis span { font-size: 10px; }
  .chart-xaxis span { overflow: visible; font-size: 10px; }
}
.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); }

/* 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; } }

/* The top-bar burger doubles as the desktop collapse button: shown everywhere. */
.admin-topbar-btn.admin-burger { display: inline-flex; }

/* Top-bar icon buttons (theme toggle, hamburger, sign-out) on the new light
   shell. Token-based so they read correctly in both light and dark themes,
   unlike the always-dark `.admin-icon-btn` they replace. `button_to` wraps the
   sign-out button in a `form.button_to`; keep that inline so it lines up. */
.admin-topbar-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm);
  color: var(--text-2); background: transparent; border: 0; cursor: pointer;
  transition: color .15s ease, background-color .15s ease;
}
.admin-topbar-btn:hover { color: var(--text); background: var(--surface-2); }
form.button_to { display: inline-flex; }

/* Off-canvas sidebar: slides in below `lg` when the body is marked open.
   Tailwind v4 positions the sidebar with the `translate` property (not
   `transform`), so these overrides must use `translate` too — otherwise they
   set an unrelated property and Tailwind's `-translate-x-full` keeps winning.
   Higher specificity than Tailwind's base utility, so they take effect. */
.admin-sidebar-open .admin-sidebar { translate: 0 0; }
.admin-main { transition: padding-left .2s ease; }
@media (min-width: 1024px) {
  .admin-backdrop { display: none; }
  /* Desktop collapse: slide the docked sidebar away and reclaim its column. */
  .admin-sidebar-collapsed .admin-sidebar { translate: -100% 0; }
  .admin-sidebar-collapsed .admin-main { padding-left: 0; }
}

[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); }

/* 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); }
[data-theme="dark"] .admin-ui .hover\:bg-slate-100:hover { background: var(--surface-2); }

/* The mobile sidebar backdrop reads as a scrim over the dark surface too. */
[data-theme="dark"] .admin-ui .admin-backdrop { background: rgba(0, 0, 0, .55); }

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

/* The page is a single-column grid; let the cards shrink to the column so a
   wide child (table, input row) can't stretch the whole page past the viewport. */
.bal-page, .bal-page > * { min-width: 0; }

/* 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) */
/* auto-fit so tiles reflow to fewer columns on narrow screens instead of
   overflowing the card; min(100%, 200px) keeps a lone column from demanding
   more than the available width. */
.bal-rail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 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; }

