/* ══ Fundy — base design system ══ */
:root,
html[data-theme="dark"] {
  --bg: #0f1013;
  --bg-elev: #111215;
  --surface: #121317;
  --surface-2: #16171b;
  --surface-3: #1b1c21;
  --surface-4: #24262c;
  --border: #1d1f24;
  --border-2: #26282e;
  --border-3: #353840;
  --row-hover: #131418;
  --text: #ececef;
  --text-2: #a4a7b0;
  --text-3: #6d7079;
  --text-4: #474a52;
  --accent: #7c87f7;
  --accent-rgb: 124, 135, 247;
  --accent-text: #8f99ff;
  --accent-ink: #ffffff;
  --green: #3ddc97;
  --green-rgb: 61, 220, 151;
  --red: #f2466f;
  --red-rgb: 242, 70, 111;
  --pink: #ec4d84;
  --pink-rgb: 236, 77, 132;
  --yellow: #f5b83d;
  --overlay: rgba(3, 4, 6, .74);
  --shadow: 0 24px 70px rgba(0, 0, 0, .6);
  --skel: #17181c;

  /* legacy aliases (live page, wizard, legacy modals) */
  --bg-2: #131418;
  --card: var(--surface);
  --card-2: var(--surface-2);
  --panel: var(--surface);
  --hover: rgba(255, 255, 255, .03);
  --hover-2: rgba(255, 255, 255, .055);
  --text-sub: var(--text-2);
  --text-muted: var(--text-3);
  --border-dim: #18191d;
  --accent-h: color-mix(in srgb, var(--accent) 86%, #fff);
  --accent-dim: rgba(var(--accent-rgb), .15);
  --accent-low: rgba(var(--accent-rgb), .07);
  --green-dim: rgba(var(--green-rgb), .12);
  --red-dim: rgba(var(--red-rgb), .12);
  --yellow-dim: rgba(245, 184, 61, .12);

  --r-xs: 4px;
  --r-sm: 6px;
  --r: 8px;
  --r-lg: 10px;
  --radius: var(--r);
  --radius-lg: var(--r-lg);

  --font: 'Geist', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Departure Mono', 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --pixel: 'Departure Mono', 'Geist Mono', ui-monospace, monospace;
  --sidebar-w: 240px;
  --statusbar-h: 26px;
  --row-h: 46px;
  color-scheme: dark;
}

html[data-theme="midnight"] {
  --bg: #000000;
  --bg-elev: #09090b;
  --surface: #09090b;
  --surface-2: #0e0f11;
  --surface-3: #141518;
  --surface-4: #1c1d21;
  --border: #16171a;
  --border-2: #1f2024;
  --border-3: #2e3036;
  --row-hover: #0b0c0e;
  --bg-2: #09090b;
  --border-dim: #111214;
  --skel: #101114;
}

html[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --surface-3: #eceef1;
  --surface-4: #e2e4e9;
  --border: #e3e5e9;
  --border-2: #d8dbe1;
  --border-3: #c3c7cf;
  --row-hover: #f7f8fa;
  --text: #14161b;
  --text-2: #4b505a;
  --text-3: #80858f;
  --text-4: #a9adb5;
  --accent-text: color-mix(in srgb, var(--accent) 78%, #000);
  --overlay: rgba(18, 20, 26, .38);
  --shadow: 0 24px 70px rgba(18, 20, 26, .18);
  --skel: #eceef1;
  --bg-2: #ffffff;
  --hover: rgba(0, 0, 0, .03);
  --hover-2: rgba(0, 0, 0, .05);
  --border-dim: #eef0f3;
  color-scheme: light;
}

html[data-radius="sharp"] { --r-xs: 2px; --r-sm: 3px; --r: 4px; --r-lg: 5px; }
html[data-radius="round"] { --r-xs: 6px; --r-sm: 9px; --r: 12px; --r-lg: 14px; }
html[data-density="compact"] { --row-h: 36px; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
input, select, textarea { font: inherit; color: inherit; background: none; border: 0; outline: none; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
::selection { background: rgba(var(--accent-rgb), .35); }
:focus-visible { outline: 1.5px solid rgba(var(--accent-rgb), .7); outline-offset: 1px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-3); }
::-webkit-scrollbar-corner { background: transparent; }

/* helpers */
.mono { font-family: var(--mono); }
.muted { color: var(--text-3); }
.dim { color: var(--text-4); }
.sub { color: var(--text-2); }
.green { color: var(--green); }
.red { color: var(--red); }
.accent { color: var(--accent-text); }
.bold { font-weight: 600; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; }
.grow { flex: 1; min-width: 0; }
.ic { display: inline-block; vertical-align: middle; }
.chain-ic, .src-ic { display: inline-block; vertical-align: middle; }

/* ══ App shell ══ */
.app { display: flex; height: calc(100vh - var(--statusbar-h)); }
.app-main { flex: 1; min-width: 0; overflow: auto; position: relative; background: var(--bg); }
.app-main.fixed { overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg);
  min-height: 0;
  transition: width .18s ease;
}
.sb-head {
  height: 54px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 16px;
  border-bottom: 1px solid var(--border);
}
.sb-logo { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; min-width: 0; }
.sb-logo-mark { color: var(--text); display: flex; }
.sb-logo-name { font-size: 13px; font-weight: 600; letter-spacing: -.01em; }
.sb-logo-ver { font-size: 11px; font-weight: 500; color: var(--accent-text); margin-left: -4px; }
.icon-btn {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.active { color: var(--accent-text); background: rgba(var(--accent-rgb), .14); }
.icon-btn.sm { width: 20px; height: 20px; }

.sb-search-row { display: flex; align-items: center; gap: 6px; padding: 14px 12px 8px 14px; flex-shrink: 0; }
.sb-search {
  flex: 1; min-width: 0;
  height: 26px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 4px 0 8px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  transition: border-color .12s;
}
.sb-search:focus-within { border-color: rgba(var(--accent-rgb), .5); }
.sb-search input { flex: 1; min-width: 0; font-size: 12px; color: var(--text); }
.sb-search input::placeholder { color: var(--text-3); }
.kbd-accent {
  font-size: 9.5px; font-weight: 600; letter-spacing: .02em;
  color: var(--accent-text);
  background: rgba(var(--accent-rgb), .2);
  border-radius: 4px;
  padding: 2px 4px;
  cursor: pointer;
  line-height: 1.2;
}
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  font-size: 10px; font-weight: 600; font-family: var(--font);
  color: var(--text-2);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-bottom-width: 2px;
  border-radius: 4px;
}

.sb-launches { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 8px 8px; }
.sb-list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px 6px;
  font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-4);
}
.sb-list-head button { font-size: 10.5px; color: var(--text-3); letter-spacing: 0; text-transform: none; }
.sb-list-head button:hover { color: var(--accent-text); }
.sb-launch {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px;
  border-radius: var(--r);
  cursor: pointer;
  transition: background .1s;
}
.sb-launch:hover { background: var(--surface-2); }
.sb-launch.active { background: var(--surface-3); }
.sb-av {
  position: relative;
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.sb-av .chain-badge {
  position: absolute; right: -3px; bottom: -3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
}
.sb-av .live-dot {
  position: absolute; top: -1px; right: -1px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); border: 1.5px solid var(--bg);
}
.sb-launch-main { flex: 1; min-width: 0; }
.sb-launch-top, .sb-launch-bot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.sb-launch-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-launch-bot { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }
.sb-launch-val { font-size: 11px; font-weight: 600; font-family: var(--mono); white-space: nowrap; }
.sb-empty { padding: 26px 8px; text-align: center; color: var(--text-4); font-size: 11px; }

.sb-features { border-top: 1px solid var(--border); padding: 10px 0 10px; flex-shrink: 0; }
.sb-features-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 14px 6px 16px;
  font-size: 10.5px; color: var(--text-3);
  cursor: pointer; user-select: none;
}
.sb-features-head .ic { transition: transform .15s; }
.sb-features.closed .sb-features-head .ic { transform: rotate(-90deg); }
.sb-features.closed .sb-nav { display: none; }
.sb-item {
  display: flex; align-items: center; gap: 9px;
  height: 28px; padding: 0 16px;
  font-size: 12.5px; color: var(--text-2);
  cursor: pointer; user-select: none;
  transition: color .12s;
  white-space: nowrap;
}
.sb-item .ic { color: var(--text-3); transition: color .12s; }
.sb-item:hover { color: var(--text); }
.sb-item:hover .ic { color: var(--text-2); }
.sb-item.active { color: var(--text); font-weight: 600; }
.sb-item.active .ic { color: var(--text); }
.badge-new {
  font-size: 8.5px; font-weight: 700; letter-spacing: .05em;
  color: var(--accent-text);
  background: rgba(var(--accent-rgb), .18);
  padding: 1px 5px 1px;
  border-radius: 4px;
  line-height: 1.4;
}

.sb-funder { border-top: 1px solid var(--border); padding: 14px 15px; flex-shrink: 0; }
.sb-funder-btn {
  width: 100%; height: 28px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px 0 12px;
  border-radius: 14px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  font-size: 12px; font-weight: 600;
  transition: background .12s;
}
.sb-funder-btn:hover { background: var(--surface-4); }
.sb-funder-btn .grow { text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-funder-bal { font-family: var(--mono); font-size: 10.5px; font-weight: 500; color: var(--text-2); }
.sb-actions { border-top: 1px solid var(--border); padding: 14px 15px 15px; display: flex; gap: 8px; flex-shrink: 0; }
.sb-actions .btn { height: 27px; }
.sb-actions .btn-primary { flex: 1; justify-content: center; }

/* collapsed sidebar */
.app.sb-collapsed { --sidebar-w: 60px; }
.app.sb-collapsed .sb-logo-name, .app.sb-collapsed .sb-logo-ver,
.app.sb-collapsed .sb-search, .app.sb-collapsed .sb-list-head,
.app.sb-collapsed .sb-launch-main, .app.sb-collapsed .sb-features-head,
.app.sb-collapsed .sb-item span, .app.sb-collapsed .sb-funder-btn .grow,
.app.sb-collapsed .sb-funder-bal, .app.sb-collapsed .sb-funder-btn .chev,
.app.sb-collapsed .sb-actions .lbl, .app.sb-collapsed .sb-filter { display: none; }
.app.sb-collapsed .sb-head { padding: 0; justify-content: center; flex-direction: column; gap: 6px; height: 72px; }
.app.sb-collapsed .sb-search-row { justify-content: center; padding: 10px 0 6px; }
.app.sb-collapsed .sb-search-row .sb-search-ic { display: inline-flex; }
.app.sb-collapsed .sb-launch { justify-content: center; padding: 6px 0; }
.app.sb-collapsed .sb-item { justify-content: center; padding: 0; height: 32px; }
.app.sb-collapsed .sb-funder { padding: 12px 10px; }
.app.sb-collapsed .sb-funder-btn { justify-content: center; padding: 0; }
.app.sb-collapsed .sb-actions { flex-direction: column; padding: 12px 10px; }
.app.sb-collapsed .sb-actions .btn { justify-content: center; padding: 0; }
.app.sb-collapsed .sb-features.closed .sb-nav { display: block; }
.sb-search-ic { display: none; }

/* ── Status bar ── */
.statusbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--statusbar-h);
  display: flex; align-items: center;
  padding: 0 10px 0 8px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  font-size: 10.5px;
  color: var(--text-2);
  z-index: 40;
  user-select: none;
}
body.no-statusbar { --statusbar-h: 0px; }
body.no-statusbar .statusbar { display: none; }
.st-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.st-live {
  display: flex; align-items: center; gap: 6px;
  color: var(--green); font-weight: 500;
  padding: 2px 6px; border-radius: 4px; cursor: pointer;
}
.st-live:hover { background: var(--surface-2); }
.st-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px rgba(var(--green-rgb), .18); }
.st-ticker {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px;
}
body.no-ticker .st-ticker { display: none; }
.st-tick { display: flex; align-items: center; gap: 5px; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.st-tick .up { color: var(--green); }
.st-tick .down { color: var(--red); }
.st-right { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.st-link {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 7px;
  border-radius: 4px;
  color: var(--text-2);
  transition: background .12s, color .12s;
}
.st-link:hover { background: var(--surface-2); color: var(--text); }
.st-link .ic { color: var(--text-3); }
.st-sep { width: 1px; height: 12px; background: var(--border-2); margin: 0 5px; }

/* ══ Buttons ══ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px;
  border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, color .12s, opacity .12s;
  user-select: none;
}
.btn .ic { flex-shrink: 0; }
.btn:disabled, .btn.disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-h); }
.btn-cta { background: var(--accent); color: #11132a; }
.btn-cta:hover { background: var(--accent-h); }
.btn-dark, .btn-secondary {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text);
}
.btn-dark:hover, .btn-secondary:hover { background: var(--surface-3); }
.btn-outline { background: transparent; border-color: var(--border-2); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; border-color: var(--border-2); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-plain { background: transparent; color: var(--text-2); }
.btn-plain:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: rgba(var(--red-rgb), .14); border-color: rgba(var(--red-rgb), .28); color: var(--red); }
.btn-danger:hover { background: rgba(var(--red-rgb), .22); }
.btn-pink { background: rgba(var(--pink-rgb), .12); border-color: rgba(var(--pink-rgb), .3); color: var(--pink); }
.btn-pink:hover { background: rgba(var(--pink-rgb), .2); }
.btn-buy { background: rgba(var(--green-rgb), .13); border-color: rgba(var(--green-rgb), .26); color: var(--green); }
.btn-buy:hover { background: rgba(var(--green-rgb), .2); }
.btn-sell { background: rgba(var(--red-rgb), .13); border-color: rgba(var(--red-rgb), .26); color: var(--red); }
.btn-sell:hover { background: rgba(var(--red-rgb), .2); }
.btn-xs { height: 22px; padding: 0 8px; font-size: 11px; border-radius: 5px; gap: 4px; }
.btn-sm { height: 25px; padding: 0 9px; font-size: 11.5px; }
.btn-lg { height: 36px; padding: 0 16px; font-size: 12.5px; border-radius: var(--r); }
.btn-block { width: 100%; justify-content: center; }

/* ══ Inputs ══ */
.inp, .form-input, .search-input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  font-size: 12.5px;
  color: var(--text);
  transition: border-color .12s, background .12s;
}
.inp:focus, .form-input:focus, .search-input:focus { border-color: rgba(var(--accent-rgb), .6); }
.inp::placeholder, .form-input::placeholder, .search-input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea.inp, textarea.form-input, .form-textarea { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
select.inp, select.form-input, .select {
  appearance: none; -webkit-appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236d7079' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}
select option { background: var(--bg-elev); color: var(--text); }
.inp-sm { height: 26px; font-size: 11.5px; padding: 0 8px; border-radius: var(--r-sm); }
.inp-wrap {
  display: flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: border-color .12s;
}
.inp-wrap:focus-within { border-color: rgba(var(--accent-rgb), .55); }
.inp-wrap input { flex: 1; min-width: 0; font-size: 11.5px; color: var(--text); }
.inp-wrap input::placeholder { color: var(--text-3); }
.inp-suffix { font-size: 11px; color: var(--text-3); }

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 11.5px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 11px; color: var(--text-3); margin-top: 5px; line-height: 1.45; }

/* ══ Toggle ══ */
.tgl, .toggle-switch {
  position: relative;
  width: 32px; height: 18px;
  flex-shrink: 0;
  border-radius: 999px;
  background: rgba(var(--pink-rgb), .16);
  border: 1px solid rgba(var(--pink-rgb), .32);
  cursor: pointer;
  transition: background .18s, border-color .18s;
}
.tgl::after, .toggle-switch::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--pink);
  transition: transform .18s ease, background .18s;
}
.tgl.on, .toggle-switch.on { background: rgba(var(--accent-rgb), .26); border-color: rgba(var(--accent-rgb), .5); }
.tgl.on::after, .toggle-switch.on::after { transform: translateX(14px); background: var(--accent-text); }

/* ══ Checkbox ══ */
.cbx, .checkbox {
  width: 14px; height: 14px; flex-shrink: 0;
  border-radius: 4px;
  border: 1.5px solid var(--border-3);
  background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  color: transparent;
}
.cbx:hover, .checkbox:hover { border-color: var(--text-3); }
.cbx.on, .checkbox.checked { background: var(--accent); border-color: var(--accent); color: #fff; }
.cbx.part { background: var(--accent); border-color: var(--accent); color: #fff; }
.cbx svg, .checkbox svg { width: 10px; height: 10px; }
.checkbox.checked::after { content: ''; width: 7px; height: 4px; border-left: 1.8px solid #fff; border-bottom: 1.8px solid #fff; transform: translateY(-1px) rotate(-45deg); }

/* ══ Segmented ══ */
.seg {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
}
.seg-btn {
  height: 22px; padding: 0 9px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border-radius: var(--r-sm);
  font-size: 11px; font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface-4); color: var(--text); font-weight: 600; }
.seg-lg .seg-btn { height: 28px; padding: 0 12px; font-size: 12px; }
.seg-fill { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }

/* ══ Badges / tags ══ */
.badge-rec {
  font-size: 10px; font-weight: 500;
  color: var(--accent-text);
  background: rgba(var(--accent-rgb), .16);
  padding: 1px 6px;
  border-radius: 4px;
}
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px;
  border-radius: 5px;
  background: var(--surface-4);
  font-size: 11px; font-weight: 500; color: var(--text);
  white-space: nowrap;
}
.pill.accent { background: rgba(var(--accent-rgb), .18); color: var(--accent-text); }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px; font-weight: 600;
  white-space: nowrap;
}
.tag-green { background: rgba(var(--green-rgb), .13); color: var(--green); }
.tag-red { background: rgba(var(--red-rgb), .13); color: var(--red); }
.tag-accent { background: rgba(var(--accent-rgb), .16); color: var(--accent-text); }
.tag-muted { background: var(--surface-3); color: var(--text-3); }
.tag-yellow { background: rgba(245, 184, 61, .13); color: var(--yellow); }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ══ Cards ══ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title { font-size: 12.5px; font-weight: 600; }
.card-sub { font-size: 11.5px; color: var(--text-3); }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* section divider label (e.g. REFERRAL PROGRAM) */
.sect-div {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--mono);
  font-size: 9px; font-weight: 500;
  letter-spacing: .14em;
  color: var(--text-4);
  text-transform: uppercase;
  user-select: none;
}
.sect-div::before, .sect-div::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ══ Page scaffolding ══ */
.page { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.page-bar {
  height: 54px; flex-shrink: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}
.page-bar-title { font-size: 13px; font-weight: 600; white-space: nowrap; letter-spacing: -.005em; }
.page-bar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.page-bar .vsep { width: 1px; height: 18px; background: var(--border-2); margin: 0 4px; }
.page-body { flex: 1; min-height: 0; overflow: auto; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  height: 54px; padding: 0 18px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
}
.page-title { font-size: 13px; font-weight: 600; }
.page-subtitle { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.page-actions { display: flex; align-items: center; gap: 8px; }

/* ══ Tables ══ */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th {
  position: sticky; top: 0; z-index: 2;
  height: 32px; padding: 0 13px;
  text-align: left;
  font-size: 11px; font-weight: 500;
  color: var(--text-3);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.tbl th.r, .tbl td.r { text-align: right; }
.tbl td {
  height: var(--row-h); padding: 0 13px;
  border-bottom: 1px solid var(--border-dim);
  font-size: 12px;
  white-space: nowrap;
  vertical-align: middle;
}
.tbl tbody tr { transition: background .08s; }
.tbl tbody tr:hover td { background: var(--row-hover); }
.tbl tbody tr.sel td { background: rgba(var(--accent-rgb), .06); }
.th-in { display: inline-flex; align-items: center; gap: 4px; }
.th-sort { cursor: pointer; display: inline-flex; align-items: center; gap: 3px; }
.th-sort:hover { color: var(--text-2); }
.th-sort .ic, .th-flt .ic { color: var(--text-4); }
.th-sort.on, .th-sort.on .ic { color: var(--accent-text); }
.th-flt { cursor: pointer; display: inline-flex; padding: 2px; border-radius: 3px; }
.th-flt:hover .ic { color: var(--text-2); }
.th-flt.on .ic { color: var(--accent-text); }
.cell2 { display: flex; flex-direction: column; gap: 1px; line-height: 1.3; }
.cell2 .s { font-size: 10.5px; color: var(--text-3); }

/* data-table (legacy) */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.data-table th { height: 32px; padding: 0 12px; text-align: left; font-size: 11px; font-weight: 500; color: var(--text-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { height: 40px; padding: 0 12px; border-bottom: 1px solid var(--border-dim); font-size: 12px; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: var(--row-hover); }
.data-table .mono { font-family: var(--mono); font-size: 11.5px; }
.data-table .green { color: var(--green); }
.data-table .red { color: var(--red); }
.data-table .muted { color: var(--text-3); }

/* ══ Modals ══ */
.modal-layer {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity .16s ease;
}
.modal-layer.open { opacity: 1; }
.modal-layer.top { align-items: flex-start; padding-top: 12vh; }
.modal-backdrop { position: absolute; inset: 0; background: var(--overlay); backdrop-filter: blur(3px); }
.modal {
  position: relative;
  width: 460px; max-width: 100%;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  transform: translateY(6px) scale(.985);
  transition: transform .16s ease;
  overflow: hidden;
}
.modal-layer.open .modal { transform: none; }
.modal-sm { width: 380px; }
.modal-md { width: 560px; }
.modal-lg { width: 920px; }
.modal-xl { width: 1180px; height: min(880px, calc(100vh - 48px)); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-shrink: 0;
  margin: 0 22px;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border-2);
}
.modal-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; letter-spacing: -.005em; }
.modal-close {
  width: 24px; height: 24px; margin-right: -4px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: background .12s, color .12s;
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-body { padding: 18px 22px; overflow-y: auto; min-height: 0; }
.modal-footer {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px 22px 18px;
}
.modal-footer .left { margin-right: auto; }
.modal-note { font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
.kv { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; font-size: 12px; }
.kv + .kv { border-top: 1px solid var(--border-dim); }
.kv .k { color: var(--text-3); }
.kv .v { font-weight: 600; }
.box { background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--r); padding: 12px; }
.warn-box { background: rgba(var(--red-rgb), .08); border: 1px solid rgba(var(--red-rgb), .24); border-radius: var(--r); padding: 11px 12px; color: var(--red); font-size: 12px; line-height: 1.5; }
.info-box { background: rgba(var(--accent-rgb), .08); border: 1px solid rgba(var(--accent-rgb), .22); border-radius: var(--r); padding: 11px 12px; color: var(--text-2); font-size: 12px; line-height: 1.5; }

/* ══ Popover / menus ══ */
.popover {
  position: fixed;
  z-index: 150;
  min-width: 180px;
  background: var(--bg-elev);
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
  padding: 5px;
  animation: popIn .12s ease;
}
@keyframes popIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.menu-item {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  height: 30px; padding: 0 9px;
  border-radius: var(--r-sm);
  font-size: 12px; color: var(--text);
  text-align: left;
  white-space: nowrap;
}
.menu-item .ic { color: var(--text-3); }
.menu-item:hover { background: var(--surface-3); }
.menu-item.danger, .menu-item.danger .ic { color: var(--red); }
.menu-item .r { margin-left: auto; color: var(--text-3); font-size: 11px; font-family: var(--mono); }
.menu-item.on .check { color: var(--accent-text); }
.menu-sep { height: 1px; background: var(--border-2); margin: 5px 2px; }
.menu-label { padding: 6px 9px 4px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-4); }
.pop-pad { padding: 8px; }

/* ══ Tooltip ══ */
.tooltip {
  position: fixed; z-index: 300;
  max-width: 260px;
  padding: 6px 9px;
  border-radius: 6px;
  background: #22242a;
  border: 1px solid #2f3139;
  color: #e8e9ec;
  font-size: 11px; line-height: 1.45;
  pointer-events: none;
  opacity: 0;
  transition: opacity .1s;
}
.tooltip.show { opacity: 1; }
.info-i { color: var(--text-4); display: inline-flex; cursor: help; vertical-align: middle; }
.info-i:hover { color: var(--text-2); }

/* ══ Toasts ══ */
.toast-container {
  position: fixed;
  right: 16px; bottom: calc(var(--statusbar-h) + 14px);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 400;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 9px;
  min-width: 220px; max-width: 340px;
  padding: 10px 13px;
  background: var(--bg-elev);
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
  font-size: 12px; color: var(--text);
  animation: toastIn .18s ease;
}
.toast .t-ic { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast.success .t-ic { background: rgba(var(--green-rgb), .16); color: var(--green); }
.toast.error .t-ic { background: rgba(var(--red-rgb), .16); color: var(--red); }
.toast.info .t-ic { background: rgba(var(--accent-rgb), .16); color: var(--accent-text); }
.toast.out { animation: toastOut .2s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ══ Empty / skeleton ══ */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 40px 20px;
}
.empty-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
.empty-desc { font-size: 11px; color: var(--text-3); margin-top: 5px; max-width: 360px; }
.empty-actions { display: flex; gap: 8px; margin-top: 18px; }
.empty-ic {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text-2);
  margin-bottom: 12px;
}
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 48px 20px; text-align: center; color: var(--text-3); }
.empty-state .empty-icon { font-size: 30px; }
.empty-state .empty-title { font-size: 13.5px; color: var(--text-2); }
.empty-state .empty-desc { font-size: 12px; }
.center-note { padding: 40px 0; text-align: center; font-size: 11px; color: var(--text-3); }
.skel-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.skel-row { display: flex; gap: 12%; height: 46px; align-items: center; padding: 0 14px; border-bottom: 1px solid var(--border-dim); opacity: .55; }
.skel { height: 8px; border-radius: 4px; background: var(--skel); }

.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; flex-shrink: 0; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.8); } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .8s linear infinite; }
