/* Base reset + app chrome */
*, *::before, *::after { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  letter-spacing: -0.005em;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--font-mono); font-feature-settings: "ss01"; letter-spacing: -0.01em; }
.serif { font-family: var(--font-display); letter-spacing: -0.01em; }

/* App shell */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  background: var(--bg);
}
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-brand {
  padding: 18px 18px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 30%, oklch(0.85 0.18 62), oklch(0.55 0.18 38) 70%);
  display: grid; place-items: center;
  color: oklch(0.15 0.02 60);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.3);
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.02em; }
.brand-suffix { color: var(--text-dim); font-weight: 400; }

.mode-switcher {
  margin: 4px 14px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 3px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  position: relative;
}
.mode-switcher button {
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 5px;
  transition: all .2s var(--ease);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.mode-switcher button.active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: var(--shadow-1);
}
.mode-switcher .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim);
}
.mode-switcher button.active .dot { background: var(--accent); }
.mode-switcher [data-admin].active .dot { background: var(--neg); }

.nav { padding: 6px 10px; flex: 1; overflow: auto; }
.nav-section-label {
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s var(--ease), color .12s var(--ease);
  position: relative;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 2px;
  background: var(--accent); border-radius: 2px;
}
.nav-item .ic { width: 16px; height: 16px; flex: 0 0 16px; color: var(--text-dim); }
.nav-item.active .ic, .nav-item:hover .ic { color: var(--text); }
.nav-item .badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--text-muted);
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, oklch(0.70 0.10 200), oklch(0.70 0.14 320));
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: white;
}
.sidebar-foot .name { font-size: 12.5px; font-weight: 500; }
.sidebar-foot .sub { font-size: 11px; color: var(--text-dim); }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; flex: 0 0 56px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.crumb {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted);
}
.crumb .sep { color: var(--text-dim); }
.crumb .curr { color: var(--text); font-weight: 500; }
.topbar-spacer { flex: 1; }

.wallet-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px 6px 12px;
  font-size: 12.5px;
}
.wallet-pill .wp-amt { font-family: var(--font-mono); font-weight: 600; font-size: 13px; }
.wallet-pill .add { 
  background: var(--accent); color: var(--accent-fg);
  border-radius: 999px; padding: 4px 10px; font-size: 11.5px; font-weight: 600;
}

.live-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--pos);
  box-shadow: 0 0 0 0 var(--pos);
  animation: livepulse 1.6s ease-out infinite;
}
@keyframes livepulse {
  0% { box-shadow: 0 0 0 0 oklch(0.70 0.14 155 / 0.5); }
  100% { box-shadow: 0 0 0 6px oklch(0.70 0.14 155 / 0); }
}

.icon-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: background .12s var(--ease);
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn .ic { width: 16px; height: 16px; }

/* Content */
.content {
  flex: 1; overflow: auto;
  padding: 28px 32px 80px;
}
.content-narrow { max-width: 1180px; margin: 0 auto; }

/* Cards / panels */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--pad-card);
}
.card.flat { background: var(--bg-elev); }
.card-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.card-title { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }
.card-sub { font-size: 12px; color: var(--text-muted); }

/* Page header */
.page-head {
  display: flex; align-items: flex-end; gap: 16px;
  margin-bottom: 24px;
}
.page-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0;
}
.page-sub {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 4px 0 0;
  max-width: 56ch;
}
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  transition: all .12s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--surface); color: var(--text); }
.btn.danger { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.lg { padding: 11px 18px; font-size: 14px; }
.btn .ic { width: 14px; height: 14px; }

/* Inputs */
.input, .select, .textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input.mono, .textarea.mono { font-family: var(--font-mono); font-size: 12.5px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label {
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.hint { font-size: 11.5px; color: var(--text-dim); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 7px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0;
}
.badge.pos { background: var(--pos-soft); color: var(--pos); }
.badge.neg { background: var(--neg-soft); color: var(--neg); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge .b-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* Table */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr { transition: background .12s var(--ease); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: 0; }

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-size: 11.5px; font-weight: 500;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 10px;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  display: flex; align-items: baseline; gap: 6px;
}
.kpi-value .unit { font-family: var(--font-ui); font-size: 12px; color: var(--text-muted); font-weight: 500; }
.kpi-foot {
  margin-top: 10px;
  font-size: 11.5px;
  display: flex; align-items: center; gap: 6px;
  color: var(--text-muted);
}
.kpi-foot .delta.pos { color: var(--pos); }
.kpi-foot .delta.neg { color: var(--neg); }
.kpi-spark {
  position: absolute; right: 12px; bottom: 10px;
  width: 70px; height: 30px; opacity: 0.7;
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-23 { display: grid; grid-template-columns: 2fr 3fr; gap: 16px; }
.grid-32 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
@media (max-width: 1100px) {
  .grid-2, .grid-3, .grid-23, .grid-32 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* Modal */
.modal-back {
  position: fixed; inset: 0;
  background: oklch(0 0 0 / 0.5);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: grid; place-items: center;
  animation: fadeIn .15s var(--ease);
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: min(560px, 92vw);
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-2);
  animation: pop .2s var(--ease);
}
.modal.wide { width: min(820px, 94vw); }
.modal.xl { width: min(1080px, 96vw); }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-head .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.modal-body { padding: 20px; }
.modal-foot {
  display: flex; align-items: center; gap: 8px; justify-content: flex-end;
  padding: 14px 20px; border-top: 1px solid var(--border);
  background: var(--surface);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* Tabs */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* Toast */
.toast-stack { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 11px 14px; font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; max-width: 380px;
  box-shadow: var(--shadow-2);
  animation: slideUp .25s var(--ease);
}
.toast.pos { border-color: var(--pos-soft); }
.toast.neg { border-color: var(--neg-soft); }
.toast .ic { width: 16px; height: 16px; }
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Misc */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.gap-3 { gap: 12px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.spacer { flex: 1; }
.tag-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.empty {
  padding: 60px 24px; text-align: center;
  color: var(--text-muted);
}
.empty .big { font-family: var(--font-display); font-size: 32px; color: var(--text); letter-spacing: -0.02em; margin-bottom: 6px; }

/* Switch */
.switch {
  width: 32px; height: 18px;
  background: var(--surface-3); border-radius: 999px;
  position: relative; cursor: pointer;
  transition: background .15s var(--ease);
}
.switch::after {
  content: ""; position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text);
  transition: transform .15s var(--ease);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(14px); background: var(--accent-fg); }

/* Code blocks */
.code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  overflow: auto;
  white-space: pre;
  line-height: 1.55;
}
.code .k { color: var(--accent); }
.code .s { color: var(--pos); }
.code .c { color: var(--text-dim); }

/* Scrollbar - subtle */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; border: 2px solid transparent; }

/* Progress */
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s var(--ease); }
.progress.pos > span { background: var(--pos); }
.progress.neg > span { background: var(--neg); }

/* Provider mini-chip */
.prov-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-muted);
}
.prov-chip .pd { width: 6px; height: 6px; border-radius: 1px; }

/* Tweaks panel */
.tweaks-panel {
  position: fixed; right: 20px; bottom: 20px;
  width: 280px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  z-index: 150;
  font-size: 12px;
}
.tweaks-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.tweaks-head h4 { margin: 0; font-size: 13px; font-weight: 600; }
.tweaks-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 14px; }
.tweak-row { display: flex; align-items: center; gap: 10px; }
.tweak-label { font-size: 11.5px; color: var(--text-muted); flex: 1; }
.swatch-grid { display: flex; gap: 6px; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .12s var(--ease);
}
.swatch.active { border-color: var(--text); }
.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px;
}
.seg button {
  padding: 4px 8px; font-size: 11px;
  color: var(--text-muted); border-radius: 4px;
}
.seg button.active { background: var(--surface-3); color: var(--text); }

/* ═══════════════════════════════════════════════════════════════
   PREMIUM REFINEMENTS — additive layer to fix table, polish, etc.
   ═══════════════════════════════════════════════════════════════ */

/* ─── Table (was completely unstyled) ─── */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  white-space: nowrap;
}
.table thead th:first-child { border-top-left-radius: var(--r-lg); padding-left: 18px; }
.table thead th:last-child { border-top-right-radius: var(--r-lg); padding-right: 18px; }
.table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.table tbody td:first-child { padding-left: 18px; }
.table tbody td:last-child  { padding-right: 18px; }
.table tbody tr { transition: background 120ms var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--r-lg); }
.table tbody tr:last-child td:last-child  { border-bottom-right-radius: var(--r-lg); }
.table .mono { font-size: 12.5px; }

/* ─── Sidebar refinements ─── */
.sidebar { padding: 16px 12px 12px; min-width: 0; }
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 18px;
  min-width: 0;
}
.sidebar-brand > div:last-child { min-width: 0; overflow: hidden; }
.brand-name {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 400;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-suffix { color: var(--accent); margin-left: 2px; }
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), oklch(0.65 0.16 50));
  color: var(--accent-fg);
  font-family: var(--font-display);
  font-size: 18px;
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(217, 119, 87, 0.25);
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section-label {
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 120ms var(--ease);
  user-select: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.nav-item .ic { flex-shrink: 0; }
.nav-item .badge { margin-left: auto; font-size: 10.5px; }

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-foot .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.sidebar-foot .name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Topbar refinements ─── */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.crumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-muted);
}
.crumb .curr { color: var(--text); font-weight: 500; }
.crumb .sep { color: var(--text-dim); }
.topbar-spacer { flex: 1; }

.wallet-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 6px 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
}
.wallet-pill .wp-amt { font-family: var(--font-mono); font-weight: 500; }
.wallet-pill .add {
  margin-left: 4px;
  padding: 4px 10px;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 120ms var(--ease);
}
.wallet-pill .add:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(217,119,87,0.3); }

.live-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--pos-soft);
  border: 1px solid color-mix(in oklch, var(--pos) 30%, transparent);
  border-radius: 999px;
  font-size: 12px;
  color: var(--pos);
  font-weight: 500;
}
.live-dot {
  width: 6px; height: 6px;
  background: var(--pos); border-radius: 50%;
  animation: livepulse 2s cubic-bezier(.4,0,.6,1) infinite;
}
@keyframes livepulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--pos); }
  50% { opacity: .6; box-shadow: 0 0 0 4px transparent; }
}

.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 120ms var(--ease);
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(217,119,87,0.2);
}
.btn.primary:hover { box-shadow: 0 4px 12px rgba(217,119,87,0.35); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; }

/* ─── Cards ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  position: relative;
}
.card.flat { background: var(--surface-2); }
.card-head {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 14.5px; font-weight: 600; color: var(--text);
}
.card-sub {
  font-size: 12px; color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Page head ─── */
.page-head {
  display: flex; align-items: flex-start; gap: 16px;
  margin-bottom: 28px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  color: var(--text);
  line-height: 1.2;
}
.page-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}
.page-head .actions {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}

/* ─── Content area ─── */
.content { flex: 1; overflow-y: auto; }
.content-narrow { max-width: 1200px; margin: 0 auto; padding: 32px 32px 64px; }

/* ─── Form elements (consistent dark/light) ─── */
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: all 120ms var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }
.input.mono, .textarea.mono { font-family: var(--font-mono); font-size: 12.5px; }
.textarea { resize: vertical; min-height: 80px; font-family: inherit; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field .label {
  font-size: 12px; font-weight: 500;
  color: var(--text-muted);
}
.field .label .dim { color: var(--text-dim); font-weight: 400; }

/* ─── Badges ─── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.pos    { background: var(--pos-soft);    color: var(--pos); }
.badge.neg    { background: var(--neg-soft);    color: var(--neg); }
.badge.warn   { background: var(--warn-soft);   color: var(--warn); }
.badge.info   { background: var(--info-soft);   color: var(--info); }

/* ─── Utility ─── */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; }
.gap-3 { gap: 12px; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.mono { font-family: var(--font-mono); }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

.tag-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

/* ─── Code blocks ─── */
.code {
  margin: 0;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
}
.code .c { color: var(--text-dim); }
.code .s { color: var(--accent); }
.code .k { color: var(--info); font-weight: 600; }

/* ─── Grids ─── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.grid-23 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.grid-32 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3  { display: grid; grid-template-columns: repeat(3, 1fr); }

@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-23, .grid-32 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .content-narrow { padding: 24px 20px 48px; }
}

/* ─── App layout ─── */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: 100vh;
  overflow: hidden;
}
.sidebar {
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.main { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

/* ─── KPI cards ─── */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  transition: all 120ms var(--ease);
}
.kpi:hover { border-color: var(--border-strong); }
.kpi-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 8px;
}
.kpi-value {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 300;
  letter-spacing: -0.01em;
  line-height: 1;
  margin-bottom: 6px;
}
.kpi-value .unit { font-size: 16px; color: var(--text-muted); margin-left: 2px; }

/* ─── Segmented control ─── */
.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2px;
}
.seg button {
  padding: 5px 12px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--r-xs);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms var(--ease);
}
.seg button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* ─── Mode switcher ─── */
.mode-switcher {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2px;
  margin: 0 6px 16px;
}
.mode-switcher button {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 8px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--r-xs);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms var(--ease);
}
.mode-switcher button.active { background: var(--surface); color: var(--text); }
.mode-switcher button .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.mode-switcher button[data-admin].active .dot { background: var(--accent); }


/* ─── Code tabs (UserKeys / UserDocs) ─── */
.code-tab {
  padding: 11px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms var(--ease);
  margin-bottom: -1px;
}
.code-tab:hover { color: var(--text); }
.code-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.code-block {
  margin: 0;
  padding: 20px 24px;
  background: oklch(0.13 0.006 70);
  color: oklch(0.92 0.005 80);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  min-height: 200px;
}
[data-theme="light"] .code-block {
  background: oklch(0.97 0.004 80);
  color: oklch(0.20 0.006 70);
  border-top: 1px solid var(--border);
}

/* ─── Legal document modal content ─── */
.legal-content h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 20px 0 8px;
  letter-spacing: -0.005em;
}
.legal-content h4:first-child { margin-top: 0; }
.legal-content p {
  color: var(--text-muted);
  margin: 0 0 10px;
}
.legal-content ul {
  margin: 0 0 10px;
  padding-left: 22px;
  color: var(--text-muted);
}
.legal-content li {
  margin-bottom: 4px;
}
.legal-content strong {
  color: var(--text);
  font-weight: 600;
}
.legal-content code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
}


/* ════════════════════════════════════════════════
   Auth screen BASE (desktop) — must come BEFORE mobile rules
   ════════════════════════════════════════════════ */
.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
  color: var(--text);
}
.auth-marketing {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
}
.auth-form-pane {
  display: grid;
  place-items: center;
  padding: 48px;
}

/* Tablet (721-1000px) — keep 2 cols, less padding */
@media (max-width: 1000px) and (min-width: 721px) {
  .auth-marketing, .auth-form-pane { padding: 28px; }
  .auth-marketing h1 { font-size: 28px !important; }
}


/* ════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — surgical, doesn't break desktop or cards
   ════════════════════════════════════════════════════════════════ */

/* Sidebar backdrop overlay (mobile drawer) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.5);
  backdrop-filter: blur(4px);
  z-index: 150;
  animation: fadeIn 0.2s var(--ease);
}

/* Mobile hamburger button — appears in topbar on mobile */
.mobile-menu-btn {
  display: none;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--surface-2); }
.mobile-menu-btn svg { width: 18px; height: 18px; }

/* ─────────────── ≤900px (tablet/mobile) ─────────────── */
@media (max-width: 900px) {
  /* Collapse to single-column shell */
  .app {
    grid-template-columns: 1fr;
  }

  /* Hamburger button visible */
  .mobile-menu-btn {
    display: inline-flex;
  }

  /* Sidebar → drawer (slide from left) */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 270px;
    max-width: 80vw;
    z-index: 180;
    transform: translateX(-105%);
    transition: transform 0.25s var(--ease);
    box-shadow: var(--shadow-2);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; }

  /* Topbar tightened */
  .topbar {
    padding: 12px 14px;
    gap: 10px;
  }
  .crumb { font-size: 13px; min-width: 0; overflow: hidden; }
  .crumb span { white-space: nowrap; }

  /* Content padding */
  .content {
    padding: 18px 16px 80px;
  }

  /* Page head stacks */
  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-head .actions {
    margin-left: 0;
    width: 100%;
    display: flex;
    gap: 8px;
  }
  .page-head .actions .btn {
    flex: 1;
    justify-content: center;
  }

  /* Auth screen — single column */
  .auth-screen {
    grid-template-columns: 1fr;
  }
  .auth-marketing {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 24px 20px;
    gap: 14px;
  }
  .auth-marketing h1 {
    font-size: 26px !important;
    line-height: 1.2 !important;
    margin-bottom: 12px !important;
  }
  .auth-marketing p {
    font-size: 13.5px !important;
    line-height: 1.55 !important;
  }
  .auth-marketing .model-tiles,
  .auth-marketing .trust-strip { display: none; }
  .auth-marketing .legal-links {
    flex-wrap: wrap;
    gap: 8px 14px !important;
    font-size: 11px !important;
  }
  .auth-form-pane {
    padding: 28px 20px 40px;
  }
}

/* ─────────────── ≤600px (phone) ─────────────── */
@media (max-width: 600px) {
  body { font-size: 14px; }

  /* Typography */
  .page-title { font-size: 22px !important; }
  .page-sub { font-size: 12.5px; }

  /* Cards: smaller radius + tighter padding */
  .card {
    padding: 16px !important;
    border-radius: 12px !important;
  }

  /* Modals: slide up from bottom, full width */
  .modal-back {
    align-items: flex-end;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh !important;
    border-radius: 18px 18px 0 0 !important;
    animation: slideUp 0.25s var(--ease);
  }
  .modal-head, .modal-foot {
    padding: 14px 16px !important;
  }
  .modal-body, .modal > div:not(.modal-head):not(.modal-foot) {
    padding: 14px 16px !important;
  }

  /* Forms — bigger inputs (avoids iOS auto-zoom) */
  .input, .textarea, .select {
    font-size: 16px !important;
    padding: 11px 13px !important;
    border-radius: 10px !important;
  }

  /* Buttons — tap-friendly */
  .btn {
    min-height: 42px;
    padding: 10px 16px !important;
    font-size: 14px !important;
    border-radius: 10px !important;
  }
  .btn.sm { min-height: 34px; }

  /* Wallet pill compact */
  .wallet-pill {
    font-size: 12px !important;
    padding: 5px 10px !important;
  }

  /* Stack only specific marked rows */
  .row.stack-mobile {
    flex-direction: column;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .row.stack-mobile > * { width: 100%; }

  /* Seg control: keep horizontal, allow scroll */
  .seg {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .seg::-webkit-scrollbar { display: none; }
  .seg button {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Tables — make them scroll horizontally instead of breaking layout */
  .table-wrap, .scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table {
    min-width: max-content;
  }

  /* OPT-IN card layout for specific tables that have data-label */
  table.mobile-cards {
    display: block;
    width: 100%;
    min-width: 0;
  }
  table.mobile-cards thead { display: none; }
  table.mobile-cards tbody { display: block; }
  table.mobile-cards tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 12px 14px;
  }
  table.mobile-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0 !important;
    border: none !important;
    gap: 12px;
    text-align: right;
  }
  table.mobile-cards td::before {
    content: attr(data-label);
    font-weight: 500;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    flex-shrink: 0;
  }

  /* Code blocks scroll */
  pre, .code-block { overflow-x: auto; font-size: 12px; }

  /* Side-item slightly bigger */
  .side-item { padding: 11px 14px !important; }
}

/* ─────────────── Drawer close button only on mobile ─────────────── */
@media (max-width: 900px) {
  .show-mobile-close { display: grid !important; }
}

/* Animation */
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ════════════════════════════════════════════════
   Mobile auth: brand + form only, minimal layout
   ════════════════════════════════════════════════ */
@media (max-width: 720px) {
  .auth-marketing {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding: 18px 20px;
    gap: 12px;
    border-bottom: 1px solid var(--border);
  }
  .auth-marketing > div:first-child {
    /* brand row */
  }
  /* Hide everything except the brand row */
  .auth-marketing-content,
  .auth-marketing .model-tiles,
  .auth-marketing .trust-strip,
  .auth-marketing .legal-links {
    display: none !important;
  }
  /* Brand name larger on mobile since it's the only header */
  .auth-marketing .brand-name {
    font-size: 18px !important;
    font-weight: 500;
  }
  /* Form pane gets all the space */
  .auth-form-pane {
    padding: 28px 22px 60px;
    min-height: calc(100vh - 70px);
  }
}
