/* Stonks design system v2.
   Light + dark theme via `data-theme` on <html>.
   Emerald accent. Red reserved for negative data only. */

:root {
  --bg: #f5f6f9;
  --bg-elev: #ffffff;
  --bg-sunken: #eef1f5;
  --border: #e3e7ed;
  --border-strong: #cbd1da;
  --text: #0f172a;
  --text-muted: #5b6472;
  --text-dim: #8c95a3;
  --accent: #059669;        /* emerald-600 */
  --accent-hover: #047857;
  --accent-soft: #d7f3e3;
  --accent-fg: #ffffff;
  --pos: #059669;
  --pos-soft: #d7f3e3;
  --neg: #dc2626;
  --neg-soft: #fde0e0;
  --neu: #6b7280;
  --neu-soft: #e5e7eb;
  --sidebar-bg: #0b1524;
  --sidebar-fg: #c3cad8;
  --sidebar-fg-muted: #6e7a90;
  --sidebar-active-bg: rgba(16, 185, 129, .14);
  --sidebar-active-fg: #ffffff;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 2px 4px -1px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 10px 24px -12px rgba(15, 23, 42, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --sidebar-w: 236px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 58px;
}

html[data-theme="dark"] {
  --bg: #060a14;
  --bg-elev: #0f1826;
  --bg-sunken: #0a1220;
  --border: #1c2740;
  --border-strong: #2a3757;
  --text: #e7eef9;
  --text-muted: #94a0b8;
  --text-dim: #66728a;
  --accent: #10b981;
  --accent-hover: #34d399;
  --accent-soft: rgba(16, 185, 129, .16);
  --accent-fg: #061911;
  --pos: #34d399;
  --pos-soft: rgba(52, 211, 153, .14);
  --neg: #f87171;
  --neg-soft: rgba(248, 113, 113, .14);
  --neu: #94a3b8;
  --neu-soft: rgba(148, 163, 184, .14);
  --sidebar-bg: #040812;
  --sidebar-fg: #b8c2d4;
  --sidebar-fg-muted: #596584;
  --sidebar-active-bg: rgba(16, 185, 129, .18);
  --sidebar-active-fg: #ffffff;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, .35);
  --shadow-md: 0 14px 34px -12px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { color-scheme: light dark; }
[x-cloak] { display: none !important; }
body {
  margin: 0;
  font-family: 'Inter', ui-sans-serif, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv02','cv03','cv04','cv11';
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
code, pre, .tabular { font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace; }
.tabular-num { font-variant-numeric: tabular-nums; }

/* ========== LAYOUT SHELL ========== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
/* Grid columns default to `auto` min-size, letting wide children (tables,
   charts) push the whole layout wider than the viewport. Force min-width:0
   on the content column so overflow stays inside .scrollx wrappers. */
.app > div { min-width: 0; }

/* Off-canvas drawer backdrop (only visible on narrow screens) */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 55;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(2px);
}

/* Sidebar */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,.04);
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 18px;
  font-weight: 800; letter-spacing: .09em;
  font-size: 15px; color: #fff;
}
.sidebar .brand .logo-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .25);
  flex-shrink: 0;
}
.sidebar a.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 11px; margin: 1px 0;
  border-radius: var(--radius-xs);
  color: var(--sidebar-fg);
  font-weight: 500; font-size: 13.5px;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.sidebar a.nav-item:hover {
  background: rgba(255,255,255,.05); color: #fff;
  transform: translateX(1px);
}
.sidebar a.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-fg);
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar a.nav-item.active:hover { transform: none; }
.sidebar a.nav-item svg {
  width: 18px !important; height: 18px !important;
  flex-shrink: 0;
  color: var(--sidebar-fg-muted);
}
.sidebar a.nav-item.active svg,
.sidebar a.nav-item:hover svg { color: var(--accent); }
.app.collapsed .sidebar a.nav-item span,
.app.collapsed .sidebar .brand span,
.app.collapsed .sidebar .section-label { display: none; }
.app.collapsed .sidebar .brand { justify-content: center; padding: 10px 0 18px; }
.app.collapsed .sidebar a.nav-item { justify-content: center; padding: 10px; }
.sidebar .spacer { flex: 1; min-height: 10px; }
.sidebar .section-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--sidebar-fg-muted);
  letter-spacing: .14em;
  padding: 18px 11px 8px;
  font-weight: 700;
  opacity: .8;
}
.sidebar .section-label:not(:first-of-type) { margin-top: 4px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: saturate(180%) blur(6px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px;
  height: var(--topbar-h);
}
.topbar .icon-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted);
  width: 34px; height: 34px; border-radius: var(--radius-xs);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  flex-shrink: 0;
}
.topbar .icon-btn svg { width: 17px; height: 17px; }
.topbar .icon-btn:hover {
  color: var(--text); border-color: var(--border-strong);
  background: var(--bg-sunken);
}
.topbar .search {
  flex: 1; max-width: 420px;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-sunken);
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  padding: 0 12px;
  height: 34px;
  transition: border-color .12s, background .12s;
}
.topbar .search:focus-within { border-color: var(--accent); background: var(--bg-elev); }
.topbar .search svg { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }
.topbar .search input {
  flex: 1; background: transparent; border: 0; outline: 0;
  color: var(--text); font-size: 13px; padding: 0;
  font-family: inherit;
}
.topbar .search input::placeholder { color: var(--text-dim); }
.topbar .spacer { flex: 1; }
.topbar .user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 3px 12px 3px 3px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.topbar .user-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-fg);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px;
  flex-shrink: 0;
}
.topbar .user-chip .role {
  font-size: 10.5px; color: var(--text-muted);
  background: var(--bg-elev); border: 1px solid var(--border);
  padding: 1px 7px; border-radius: 999px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: .04em;
}

/* Main content */
.main { padding: 24px 28px 40px; max-width: 1600px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-head .grow { flex: 1; }
.page-title { font-size: 22px; font-weight: 700; margin: 0 0 2px; letter-spacing: -0.01em; }
.page-sub   { color: var(--text-muted); margin: 0; font-size: 13.5px; }

/* ========== COMPONENTS ========== */

/* Card */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.card-pad { padding: 18px; }
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  font-weight: 600;
  font-size: 13.5px;
}
.card-header .grow { flex: 1; }
.card-header .subtitle { color: var(--text-muted); font-weight: 400; font-size: 12.5px; }

/* Grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  /* Sidebar becomes off-canvas drawer (with full labels visible when open). */
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 60;
    box-shadow: var(--shadow-md);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .app.sidebar-open .sidebar-backdrop { display: block; }
  /* In drawer mode always show labels, even if "collapsed" was persisted. */
  .app.collapsed .sidebar a.nav-item span,
  .app.collapsed .sidebar .brand span,
  .app.collapsed .sidebar .section-label { display: inline; }
  .app.collapsed .sidebar a.nav-item { justify-content: flex-start; padding: 8px 11px; }
  .app.collapsed .sidebar .brand { justify-content: flex-start; padding: 10px 10px 18px; }
}
@media (max-width: 700px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .main { padding: 14px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .search { max-width: none; }
  .topbar .search span:not(.grow), .topbar .search kbd { display: none; }
  .topbar .user-chip { padding: 3px; gap: 0; }
  .topbar .user-chip .nowrap, .topbar .user-chip .role { display: none; }
  .page-head { margin-bottom: 14px; }
  .page-title { font-size: 19px; }
  .stat .value { font-size: 22px; }
  table.data th, table.data td { padding: 8px 10px; font-size: 12.5px; }
  .card-pad { padding: 14px; }
}

/* Stat tile */
.stat {
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 2px;
  min-height: 98px;
}
.stat .label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: .08em;
  font-weight: 600;
}
.stat .value {
  font-size: 26px; font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat .sub { color: var(--text-muted); font-size: 12px; margin-top: auto; padding-top: 4px; }
.stat .delta { font-weight: 600; font-size: 12px; }
.stat .delta.pos { color: var(--pos); }
.stat .delta.neg { color: var(--neg); }
.stat .delta.neu { color: var(--neu); }

/* ---------- Buttons ----------
   Hierarchy:
     .btn            primary action (one per surface). Filled accent.
     .btn.secondary  alternate action. Outlined.
     .btn.ghost      tertiary / inline action. No chrome until hover.
     .btn.danger     destructive (delete, revoke, reset).
   Sizes: default | .btn.sm. Icons (svg) auto-size + auto-color.
   States: :hover, :focus-visible, :disabled. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-fg);
  border: 1px solid transparent; border-radius: var(--radius-xs);
  padding: 8px 14px; font-weight: 600; font-size: 13px;
  cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, color .12s, transform .08s, box-shadow .12s;
  font-family: inherit;
  line-height: 1.3;
  user-select: none;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); color: var(--accent-fg); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn:disabled, .btn[disabled] {
  opacity: .55; cursor: not-allowed;
  background: var(--accent); color: var(--accent-fg);
}
.btn:disabled:hover, .btn[disabled]:hover { background: var(--accent); transform: none; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn.secondary {
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { border-color: var(--accent); background: var(--bg-sunken); color: var(--text); }
.btn.secondary:disabled, .btn.secondary[disabled] {
  background: var(--bg-elev); border-color: var(--border); color: var(--text-muted);
}

.btn.ghost {
  background: transparent; color: var(--text-muted); border: 1px solid transparent;
}
.btn.ghost:hover { color: var(--text); background: var(--bg-sunken); }
.btn.ghost:disabled, .btn.ghost[disabled] {
  background: transparent; color: var(--text-dim);
}
.btn.ghost:disabled:hover, .btn.ghost[disabled]:hover { background: transparent; }

.btn.danger { background: var(--neg, #ef4444); color: #fff; }
.btn.danger:hover { background: #b91c1c; color: #fff; }
.btn.danger:focus-visible { box-shadow: 0 0 0 3px rgba(239,68,68,.25); }

/* ---------- Inputs ----------
   `.input` covers <input>, <select>, <textarea>. Heights line up with .btn
   (default ~36px / .sm ~28px) so a label + input + button sits on one row
   without visual jitter. `.label` is the small caption that sits above. */
.input, select.input, textarea.input {
  width: 100%;
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 8px 11px; font-size: 13px; outline: none;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.input::placeholder { color: var(--text-dim); }
.input:hover:not(:focus):not(:disabled) { border-color: var(--border-strong); }
.input:focus, select.input:focus, textarea.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input:disabled, .input[disabled] {
  background: var(--bg-sunken); color: var(--text-dim); cursor: not-allowed;
}
.input.sm, select.input.sm {
  padding: 5px 9px; font-size: 12px;
}
textarea.input { resize: vertical; min-height: 76px; }
.input.error, .input[aria-invalid="true"] {
  border-color: rgba(239,68,68,.6);
}
.input.error:focus, .input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(239,68,68,.18);
}

.label {
  display: block; font-size: 12px; color: var(--text-muted);
  margin-bottom: 4px; font-weight: 500;
}
.label .req { color: var(--neg, #ef4444); margin-left: 2px; }
.label.muted { color: var(--text-dim); font-weight: 400; }

/* Search input with icon */
.search-input {
  position: relative;
}
.search-input input {
  padding-left: 34px !important;
}
.search-input .icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-input .icon svg { width: 15px; height: 15px; display: block; }

/* Badge / chip */
.badge, a.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
  background: var(--bg-sunken); color: var(--text-muted);
  border: 1px solid var(--border);
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
}
a.badge:hover { background: var(--bg-elev); color: var(--text); border-color: var(--border-strong); }
.badge.accent, a.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.badge.pos { background: var(--pos-soft); color: var(--pos); border-color: transparent; font-weight: 600; }
.badge.neg { background: var(--neg-soft); color: var(--neg); border-color: transparent; font-weight: 600; }
.badge.neu { background: var(--neu-soft); color: var(--neu); border-color: transparent; font-weight: 600; }
.badge.lg { font-size: 12.5px; padding: 4px 12px; }

/* Alerts */
.alert {
  padding: 11px 14px; border-radius: var(--radius-xs);
  border: 1px solid transparent; font-size: 13px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert.error { background: var(--neg-soft); color: var(--neg); border-color: rgba(239,68,68,.25); }
.alert.info  { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- Data table ----------
   table.data            standard density
   table.data.compact    tighter padding for dense lists
   <th>                  uppercase tracked label, sunken bg
   td.num                right-aligned (uses tabular-nums automatically)
   tr:hover              subtle row highlight
   .data .dim            muted text inside a cell
   .data .pos / .neg     semantic colors for delta cells (font-weight 600). */
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th, table.data td {
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
table.data th {
  font-weight: 600; color: var(--text-muted); background: var(--bg-sunken);
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
table.data thead th { border-bottom: 1px solid var(--border-strong); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover td { background: color-mix(in srgb, var(--bg-sunken) 70%, transparent); }
table.data td.num, table.data th.num { text-align: right; }
table.data td.center, table.data th.center { text-align: center; }
table.data td.dim { color: var(--text-muted); }
table.data td.mono { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; }
table.data td.pos { color: var(--pos); font-weight: 600; }
table.data td.neg { color: var(--neg); font-weight: 600; }
table.data.compact th, table.data.compact td { padding: 6px 10px; font-size: 12.5px; }
table.data.no-hover tbody tr:hover td { background: transparent; }
table.data.borderless td, table.data.borderless th { border-bottom: 0; }

/* Value cells */
.cell.pos { color: var(--pos); font-weight: 600; }
.cell.neg { color: var(--neg); font-weight: 600; }
.cell.neu { color: var(--text-muted); }

/* Mini delta pill */
.delta-pill {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.delta-pill.pos { background: var(--pos-soft); color: var(--pos); }
.delta-pill.neg { background: var(--neg-soft); color: var(--neg); }
.delta-pill.neu { background: var(--neu-soft); color: var(--neu); }

/* Heatmap-style cell (for movers) */
.heat {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  text-align: right;
  display: inline-block;
  min-width: 62px;
}

/* Auth shell */
.auth-shell {
  display: grid; grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}
.auth-brand {
  background:
    radial-gradient(1000px 500px at 12% -15%, rgba(16,185,129,.42), transparent 60%),
    radial-gradient(900px 500px at 90% 110%, rgba(16,185,129,.28), transparent 60%),
    #04120c;
  color: #d1fae5;
  padding: 56px 64px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-brand::before {
  content: ''; position: absolute; inset: 0;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.02) 0, rgba(255,255,255,.02) 1px, transparent 1px, transparent 40px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.02) 0, rgba(255,255,255,.02) 1px, transparent 1px, transparent 40px);
  pointer-events: none;
}
.auth-brand > * { position: relative; }
.auth-brand .big {
  font-size: 38px; font-weight: 800; letter-spacing: -0.01em;
  color: #fff; line-height: 1.1;
  max-width: 480px;
}
.auth-brand .tagline {
  color: #9be7c2; margin-top: 14px; font-size: 15px;
  max-width: 420px; line-height: 1.55;
}
.auth-brand .logo {
  display: inline-flex; align-items: center; gap: 10px;
  color: #fff; font-weight: 800; letter-spacing: .14em;
  font-size: 14px;
}
.auth-brand .bullets {
  margin-top: 28px; display: flex; flex-direction: column; gap: 10px;
}
.auth-brand .bullets li {
  display: flex; align-items: center; gap: 10px;
  color: #b4eed0; font-size: 13.5px; list-style: none;
}
.auth-brand .bullets .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,.22);
}

.auth-panel {
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.auth-card { width: 100%; max-width: 360px; }
.auth-card h1 {
  font-size: 26px; margin: 0 0 4px; font-weight: 700;
  letter-spacing: -0.01em;
}
.auth-card p.sub { color: var(--text-muted); margin: 0 0 22px; }
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}

/* Sparkline */
.spark { display: inline-block; vertical-align: middle; }

/* Util */
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.mono { font-family: ui-monospace, monospace; }
.nowrap { white-space: nowrap; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.scrollx { overflow-x: auto; }

/* ApexCharts theming */
.apexcharts-tooltip {
  background: var(--bg-elev) !important; color: var(--text) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-md) !important;
  border-radius: var(--radius-xs) !important;
}
.apexcharts-tooltip-title {
  background: var(--bg-sunken) !important;
  border-color: var(--border) !important;
  font-weight: 600 !important;
}
.apexcharts-xaxistooltip, .apexcharts-yaxistooltip {
  background: var(--bg-elev) !important; color: var(--text) !important;
  border-color: var(--border) !important;
}
.apexcharts-menu { background: var(--bg-elev) !important; border-color: var(--border) !important; }
.apexcharts-menu-item:hover { background: var(--bg-sunken) !important; }

/* Tabulator theming */
.tabulator {
  background: var(--bg-elev) !important;
  border: 1px solid var(--border) !important;
  border-radius: 0 !important;
  color: var(--text) !important;
  font-size: 13px;
}
.tabulator .tabulator-header {
  background: var(--bg-sunken) !important;
  border-bottom: 1px solid var(--border) !important;
}
.tabulator .tabulator-col {
  background: var(--bg-sunken) !important;
  border-right: 1px solid var(--border) !important;
}
.tabulator .tabulator-col-title {
  color: var(--text-muted) !important;
  font-size: 11px !important;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}
.tabulator .tabulator-row {
  background: var(--bg-elev) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--border) !important;
}
.tabulator .tabulator-row.tabulator-row-even {
  background: var(--bg-elev) !important;
}
.tabulator .tabulator-row:hover { background: var(--bg-sunken) !important; }
.tabulator .tabulator-cell { border-right: 0 !important; }
.tabulator .tabulator-header-filter input {
  background: var(--bg-elev) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--radius-xs);
  padding: 4px 8px;
  font-family: inherit;
}

/* scrollbar in dark */
html[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg); }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ---------- Skeleton loaders ---------- */
@keyframes stonks-skel-pulse {
  0%, 100% { opacity: .55; }
  50%      { opacity: .85; }
}
.skel {
  display: inline-block;
  background: linear-gradient(90deg, var(--bg-sunken) 0%, var(--border) 50%, var(--bg-sunken) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-xs);
  animation: stonks-skel-shimmer 1.4s ease-in-out infinite;
}
@keyframes stonks-skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel-line   { height: 12px; width: 100%; margin: 6px 0; display: block; }
.skel-line.sm{ height: 10px; }
.skel-line.lg{ height: 18px; }
.skel-block  { display: block; width: 100%; }
.hero-quote.skeleton { animation: stonks-skel-pulse 1.4s ease-in-out infinite; }

/* ---------- Empty state ----------
   Usage:
     <div class="empty-state">
       <div class="ico">…inline svg…</div>
       <h3>No alerts yet</h3>
       <p>Set a threshold below — you'll see fires here when they trigger.</p>
       <a class="btn sm" href="…">Create your first alert</a>
     </div>
   Compact variant inside a card-pad: add `.empty-state.compact`. */
.empty-state {
  text-align: center; padding: 44px 18px 36px; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.empty-state.compact { padding: 28px 14px; }
.empty-state .ico {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--bg-sunken); color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 8px; transition: background .2s, color .2s;
}
.empty-state .ico svg { width: 22px; height: 22px; }
.empty-state:hover .ico { color: var(--accent); }
.empty-state h3 { margin: 0; color: var(--text); font-size: 15px; font-weight: 600; }
.empty-state p  { margin: 0 auto; max-width: 380px; font-size: 13px; line-height: 1.55; }
.empty-state .btn, .empty-state a.btn {
  margin-top: 14px;
}
.empty-state code {
  font-size: 11.5px; padding: 1px 6px; border-radius: 4px;
  background: var(--bg-sunken); border: 1px solid var(--border); color: var(--text-muted);
}

/* ---------- Skeleton row / card helpers ---------- */
.skel-row { display: flex; gap: 10px; padding: 10px 0; align-items: center; }
.skel-row .skel-line { flex: 1; margin: 0; }
.skel-row .skel-line.fixed { flex: 0 0 auto; }
.skel-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elev);
}
.skel-table .skel-row { border-top: 1px solid var(--border); }
.skel-table .skel-row:first-child { border-top: 0; }

/* ---------- Keyboard help overlay ---------- */
.kbd-help-bd {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.kbd-help-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-md); padding: 22px 24px; min-width: 320px; max-width: 460px;
}
.kbd-help-card h3 { margin: 0 0 12px; font-size: 15px; }
.kbd-help-row { display: flex; align-items: center; padding: 7px 0; gap: 10px;
                border-top: 1px solid var(--border); font-size: 13px; }
.kbd-help-row:first-of-type { border-top: 0; }
.kbd-help-row .lbl { flex: 1; color: var(--text); }
.kbd-help-row kbd  {
  background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 7px; font-size: 11.5px; color: var(--text-muted); font-family: inherit;
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .icon-btn, .user-chip, #cmdk { display: none !important; }
  .app { display: block !important; }
  .main { padding: 0 !important; }
  body  { background: #fff !important; color: #000 !important; }
  .card { break-inside: avoid; box-shadow: none !important; border: 1px solid #ccc !important; }
  a { color: #000 !important; text-decoration: none !important; }
  .btn, .scrollx button, button { display: none !important; }
}
