/* Insider Flow — design tokens, layout and components. Dark by default, light via [data-theme="light"]. */
:root {
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 14px; --radius-sm: 8px; --rail: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
:root[data-theme="dark"] {
  --bg: #0a0b09; --bg-2: #0f100d; --surface: #141612; --surface-2: #1a1c17; --surface-3: #21241d;
  --border: #23261f; --border-2: #32362c; --text: #eceee6; --muted: #8e9286; --faint: #5f6358;
  --accent: #c6f432; --accent-ink: #11160a; --accent-soft: rgba(198, 244, 50, .12); --accent-text: #c6f432;
  --buy: #4ade80; --buy-soft: rgba(74, 222, 128, .13); --sell: #fb7185; --sell-soft: rgba(251, 113, 133, .13);
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .13); --info: #7dd3fc; --info-soft: rgba(125, 211, 252, .12);
  --shadow: 0 24px 60px rgba(0, 0, 0, .55); --overlay: rgba(4, 5, 3, .62); --grid: rgba(255, 255, 255, .05);
}
:root[data-theme="light"] {
  --bg: #f4f5f0; --bg-2: #eceee6; --surface: #ffffff; --surface-2: #f6f7f2; --surface-3: #eceee5;
  --border: #e4e6dc; --border-2: #d3d6c8; --text: #13160d; --muted: #6a6e60; --faint: #9a9e90;
  --accent: #bef264; --accent-ink: #11160a; --accent-soft: rgba(132, 204, 22, .16); --accent-text: #4d7c0f;
  --buy: #15803d; --buy-soft: rgba(21, 128, 61, .11); --sell: #be123c; --sell-soft: rgba(190, 18, 60, .09);
  --warn: #a16207; --warn-soft: rgba(202, 138, 4, .13); --info: #0369a1; --info-soft: rgba(3, 105, 161, .1);
  --shadow: 0 24px 60px rgba(20, 24, 10, .22); --overlay: rgba(20, 24, 10, .38); --grid: rgba(0, 0, 0, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); text-decoration: none; }
.num, .tbl td.num, .kpi .v, .mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
::selection { background: var(--accent); color: var(--accent-ink); }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- shell */
.rail { position: fixed; inset: 0 auto 0 0; width: var(--rail); background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 6px; z-index: 40; }
.rail .logo { width: 36px; height: 36px; border-radius: 10px; margin-bottom: 14px; display: block; }
.rail .spacer { flex: 1; }
.nav-btn { position: relative; width: 40px; height: 40px; border-radius: 11px; border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; transition: background .15s, color .15s; }
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-btn.active::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-btn[data-tip]:hover::after { content: attr(data-tip); position: absolute; left: 50px; top: 50%; transform: translateY(-50%); background: var(--surface-3);
  color: var(--text); padding: 4px 9px; border-radius: 7px; font-size: 12px; white-space: nowrap; border: 1px solid var(--border-2); pointer-events: none; z-index: 5; }
.main { margin-left: var(--rail); min-height: 100%; padding: 22px 28px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* a page that fills the window: the list takes the remaining height and scrolls inside its card */
.main.fill { height: 100vh; display: flex; flex-direction: column; padding-bottom: 22px; }
.main.fill > .page-head { flex: none; }
.main.fill > .stack { flex: 1; min-height: 0; }
.main.fill > .stack > .card:not(.grow) { flex: none; }
.main.fill .card.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.main.fill .card.grow > .tbl-wrap { flex: 1; min-height: 0; }
.main.fill .card.grow > .tbl-foot { flex: none; }
.hz { display: inline-flex; align-items: center; gap: 8px; } .hz span { white-space: nowrap; }
.daterow { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 12px; } .daterow .field { width: 170px; }
@media (max-width: 768px) {
  .main.fill { height: auto; display: block; padding-bottom: 90px; }
  .main.fill .card.grow { display: block; } .main.fill .card.grow > .tbl-wrap { max-height: 70vh; }
  .rail { inset: auto 0 0 0; width: 100%; height: 58px; flex-direction: row; justify-content: space-around; padding: 0 8px; border-right: 0; border-top: 1px solid var(--border); }
  .rail .logo, .rail .spacer { display: none; }
  .nav-btn.active::before { display: none; } .nav-btn[data-tip]:hover::after { display: none; }
  .main { margin-left: 0; padding: 16px 14px 90px; }
}

/* ---------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--border-2);
  background: var(--surface); font-size: 13px; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s; }
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); } .btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.icon { width: 30px; padding: 0; justify-content: center; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.input, .select { height: 30px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; font-size: 13px; min-width: 0; width: 100%; outline: none; transition: border-color .12s, box-shadow .12s; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--faint); }
.select { appearance: none; padding-right: 26px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e9286' stroke-width='2.4' 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; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; } .field > label { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.input-icon { position: relative; } .input-icon svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; } .input-icon .input { padding-left: 30px; }
.seg { display: inline-flex; align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { height: 24px; padding: 0 11px; border-radius: 7px; border: 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 500; transition: all .12s; }
.seg button:hover { color: var(--text); } .seg button.active { background: var(--surface-3); color: var(--text); box-shadow: 0 0 0 1px var(--border-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border-2); background: transparent; color: var(--muted); font-size: 12px; }
.chip:hover { color: var(--text); } .chip.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent-text); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 30px; height: 18px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-2); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked { background: var(--accent-soft); border-color: var(--accent); } .switch input:checked::after { transform: translateX(12px); background: var(--accent); }

/* ---------------------------------------------------------------- cards, pills, kpis */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card.flat { padding: 0; overflow: hidden; }
.card h3 { margin: 0 0 12px; font-size: 13.5px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h3 .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.grid { display: grid; gap: 14px; } .g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.g6 { grid-template-columns: repeat(6, 1fr); } .g-main { grid-template-columns: 2.1fr 1fr; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g6 { grid-template-columns: repeat(3, 1fr); } .g-main { grid-template-columns: 1fr; } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .g2, .g4, .g6 { grid-template-columns: 1fr 1fr; } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; min-width: 0; }
.kpi .k { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 21px; font-weight: 600; letter-spacing: -.02em; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .d { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos { color: var(--buy); } .neg { color: var(--sell); } .dim { color: var(--muted); } .faint { color: var(--faint); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px 0 6px; border-radius: 7px; font-size: 12px; font-weight: 500; border: 1px solid transparent; white-space: nowrap; }
.pill svg { flex: none; }
.pill.buy { background: var(--buy-soft); color: var(--buy); border-color: color-mix(in srgb, var(--buy) 30%, transparent); }
.pill.sell { background: var(--sell-soft); color: var(--sell); border-color: color-mix(in srgb, var(--sell) 30%, transparent); }
.pill.single { background: var(--surface-3); color: var(--muted); border-color: var(--border-2); }
.pill.cluster { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.pill.info { background: var(--info-soft); color: var(--info); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.neutral { background: var(--surface-3); color: var(--muted); }
button.pill { cursor: pointer; } button.pill:hover { filter: brightness(1.15); }
.callout { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 10px; padding: 10px 14px; color: var(--text); font-size: 13px; }
.empty { border: 1px dashed var(--border-2); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; } .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sp { flex: 1; }

/* ---------------------------------------------------------------- tables */
.tbl-wrap { overflow: auto; max-width: 100%; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { position: sticky; top: 0; z-index: 2; background: var(--surface); text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 11px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
.tbl th.sortable { cursor: pointer; } .tbl th.sortable:hover { color: var(--text); } .tbl th .arrow { color: var(--accent-text); margin-left: 3px; }
.tbl td { padding: 0 12px; height: 46px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; transition: background .1s; } .tbl tbody tr.click:hover { background: var(--surface-2); }
.tbl tbody tr.sel { background: var(--accent-soft); }
.tbl td.r, .tbl th.r { text-align: right; } .tbl td.ell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.tk { font-weight: 600; letter-spacing: .01em; border-bottom: 1px dashed var(--faint); cursor: pointer; padding-bottom: 1px; }
.tk:hover { color: var(--accent-text); border-color: var(--accent-text); }
.score { display: inline-flex; align-items: center; gap: 8px; min-width: 112px; }
.score .bar { flex: 1; height: 5px; background: var(--surface-3); border-radius: 5px; overflow: hidden; position: relative; min-width: 56px; }
.score .bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 5px; }
.score .bar::after { content: ""; position: absolute; left: 50%; top: -1px; bottom: -1px; width: 1px; background: var(--faint); opacity: .7; }
.score.lo .bar i { background: var(--sell); } .score.hi .bar i { background: var(--buy); }
.tbl-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- filter bar */
.filters { padding: 14px 16px; }
.filters .top { display: grid; grid-template-columns: minmax(220px, 1.6fr) auto auto minmax(120px, .5fr) auto auto; gap: 10px; align-items: end; }
.filters .adv { display: none; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.filters.open .adv { display: grid; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; } .triple { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.link { cursor: pointer; border-bottom: 1px dashed var(--faint); padding-bottom: 1px; } .link:hover { color: var(--accent-text); border-color: var(--accent-text); }
.badge-count { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; font-weight: 700; min-width: 17px; height: 17px; display: inline-grid; place-items: center; padding: 0 5px; }
@media (max-width: 1100px) { .filters .top { grid-template-columns: 1fr 1fr; } .filters .adv { grid-template-columns: repeat(2, 1fr); } }

/* ---------------------------------------------------------------- drawer, modal, hovercard */
.overlay { position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(3px); z-index: 100; opacity: 0; animation: fade .18s forwards; }
.drawer { position: fixed; top: 0; bottom: 0; right: 0; width: 88vw; max-width: 1760px; background: var(--bg); border-left: 1px solid var(--border-2); z-index: 101;
  box-shadow: var(--shadow); display: flex; flex-direction: column; transform: translateX(100%); animation: slide .26s var(--ease) forwards; }
.drawer.closing { animation: slideOut .2s var(--ease) forwards; } .overlay.closing { animation: fadeOut .2s forwards; }
.drawer.narrow { width: min(88vw, 980px); }
.drawer-head { padding: 16px 24px 0; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--border); background: var(--bg-2); }
.drawer-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.drawer-title .t { font-size: 26px; font-weight: 650; letter-spacing: -.02em; } .drawer-title .co { color: var(--muted); font-size: 15px; }
.drawer-tabs { display: flex; gap: 4px; } .drawer-tabs button { background: none; border: 0; color: var(--muted); height: 38px; padding: 0 12px; font-weight: 500; font-size: 13.5px; border-bottom: 2px solid transparent; }
.drawer-tabs button:hover { color: var(--text); } .drawer-tabs button.active { color: var(--text); border-color: var(--accent); }
.drawer-body { flex: 1; overflow: auto; padding: 22px 24px 40px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 26px; color: var(--muted); font-size: 13px; padding-bottom: 12px; } .facts b { color: var(--text); font-weight: 600; }
@media (max-width: 768px) { .drawer, .drawer.narrow { width: 100vw; max-width: none; border-left: 0; } .drawer-body { padding: 16px 14px 40px; } .drawer-head { padding: 12px 14px 0; } }
.modal { position: fixed; z-index: 120; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.98); width: min(94vw, 1500px); height: min(90vh, 900px);
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; opacity: 0; animation: pop .2s var(--ease) forwards; overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-body { flex: 1; min-height: 0; position: relative; }
.hovercard { position: fixed; z-index: 90; width: 380px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden;
  opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; pointer-events: none; }
.hovercard.show { opacity: 1; transform: none; pointer-events: auto; }
.hovercard .hc-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 4px; } .hovercard .hc-chart { height: 190px; }
.hovercard .hc-foot { padding: 4px 12px 10px; display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
@keyframes fade { to { opacity: 1; } } @keyframes fadeOut { to { opacity: 0; } } @keyframes slide { to { transform: none; } } @keyframes slideOut { to { transform: translateX(100%); } } @keyframes pop { to { opacity: 1; transform: translate(-50%, -50%); } }

/* ---------------------------------------------------------------- detail pieces */
.hbar-row { display: grid; grid-template-columns: minmax(150px, 1.4fr) 2fr 62px; gap: 10px; align-items: center; font-size: 12.5px; padding: 3px 0; }
.hbar-row .lbl { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar { height: 8px; background: var(--surface-3); border-radius: 8px; position: relative; overflow: hidden; } .hbar i { position: absolute; top: 0; bottom: 0; border-radius: 8px; background: var(--accent); }
.hbar.div::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--faint); }
.heat { display: grid; gap: 4px; } .heat .c { padding: 8px 6px; text-align: center; border-radius: 8px; font-size: 12.5px; font-weight: 500; background: var(--surface-2); }
.heat .h { color: var(--muted); font-size: 12px; background: none; }
.gauge { height: 14px; border-radius: 10px; background: var(--sell-soft); position: relative; overflow: hidden; border: 1px solid var(--border); }
.gauge i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, color-mix(in srgb, var(--buy) 70%, transparent), var(--buy)); border-radius: 10px 0 0 10px; }
.gauge::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: .5; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); } .list-item:last-child { border-bottom: 0; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-3); display: grid; place-items: center; font-weight: 650; font-size: 12px; color: var(--muted); flex: none; }
.chart-box { width: 100%; position: relative; } .chart-box.tall { height: 420px; } .chart-box.mid { height: 320px; } .chart-box.sm { height: 220px; }
.progress { position: fixed; left: var(--rail); right: 0; top: 0; height: 3px; z-index: 60; background: transparent; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; box-shadow: 0 0 12px var(--accent); }
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface-3); border: 1px solid var(--border-2); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 420px; font-size: 13px; animation: pop2 .2s var(--ease); }
.toast.err { border-color: var(--sell); } .toast.ok { border-color: var(--accent); }
@keyframes pop2 { from { opacity: 0; transform: translateY(8px); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
details.acc { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); } details.acc > summary { list-style: none; cursor: pointer; padding: 12px 16px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
details.acc > summary::-webkit-details-marker { display: none; } details.acc[open] > summary { border-bottom: 1px solid var(--border); } details.acc .in { padding: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; } @media (max-width: 1200px) { .form-grid { grid-template-columns: repeat(2, 1fr); } } @media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.fs { display: flex; flex-direction: column; gap: 11px; } .fs > h4 { margin: 0 0 2px; font-size: 13px; font-weight: 600; }
