@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

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

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

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

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

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

.bal-grid { display: grid; grid-template-columns: 1.05fr 1fr; }
@media (max-width: 760px) {
  .bal-grid { grid-template-columns: 1fr; }
  .bal-grid > div:first-child { border-right: none !important; border-bottom: 1px solid var(--border); }
}

/* 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 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; }
  .balance-pill { display: none; }
}
.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; }
