/* Whale Tracker — one stylesheet for every page.
   A night-watch console: deep navy, amber for anything that asks for
   attention, numbers in mono. Light scheme follows the OS. */

:root {
  color-scheme: dark light;
  --bg: #0e1320;
  --panel: #151b2b;
  --panel-2: #1b2335;
  --rule: #273150;
  --ink: #e6eaf2;
  --muted: #9aa5bd;
  --faint: #5f6b85;
  --accent: #f0b44a;
  --accent-ink: #1a1405;
  --up: #46c98a;
  --down: #f26d6d;
  --focus: #8fb4ff;
  --radius: 10px;
  --radius-s: 6px;
  --sans: "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f4f8;
    --panel: #ffffff;
    --panel-2: #f6f7fa;
    --rule: #dde2ec;
    --ink: #141b2b;
    --muted: #5b667d;
    --faint: #8a94a8;
    --accent: #b9791a;
    --accent-ink: #ffffff;
    --up: #1d8a55;
    --down: #c8403b;
    --focus: #2f6fe4;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  font-feature-settings: "ss01";
}
.num, .addr { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 0.95em; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--accent); color: var(--accent-ink); }
[hidden] { display: none !important; }

/* ---- navbar ------------------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.nav-in {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 22px; height: 54px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { width: 22px; height: 22px; flex: none; }
.tabs { display: flex; gap: 2px; height: 100%; }
.tabs a {
  display: flex; align-items: center; padding: 0 12px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 120ms;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.live {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted);
  padding: 4px 10px 4px 8px; border: 1px solid var(--rule); border-radius: 999px; background: var(--panel);
}
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); position: relative; flex: none; }
.live .dot.live-on { background: var(--up); }
.live .dot.live-on::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid var(--up);
  animation: ping 2.4s ease-out infinite;
}
.live .dot.stale { background: var(--down); }
@keyframes ping { 0% { transform: scale(0.5); opacity: 0.9; } 100% { transform: scale(1.8); opacity: 0; } }
.menu { position: relative; }
.menu > button { display: inline-flex; align-items: center; gap: 6px; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px;
  background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-s);
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.5); padding: 4px; display: none; flex-direction: column;
}
.menu[open] .menu-list { display: flex; }
.menu-list button, .menu-list form button {
  width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 4px; font: inherit; color: var(--ink); cursor: pointer;
}
.menu-list button:hover { background: var(--panel-2); }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }

/* ---- page --------------------------------------------------------------- */
main { max-width: 1180px; margin: 0 auto; padding: 26px 20px 48px; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h2 small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 8px; }
.lede { color: var(--muted); max-width: 70ch; margin: 6px 0 0; }
.hint { color: var(--muted); font-size: 13px; max-width: 76ch; margin: 4px 0 0; }
section { margin-top: 36px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; padding-bottom: 10px; border-bottom: 1px solid var(--rule); margin-bottom: 12px; }
.sec-head .hint { flex-basis: 100%; margin: 0; }
.sec-head .ctrl { margin-left: auto; }

/* ---- bento -------------------------------------------------------------- */
.bento {
  display: grid; gap: 12px; margin-top: 22px;
  grid-template-columns: repeat(14, 1fr);
  grid-template-areas:
    "hero hero hero hero hero hero hero hero a a a a a a"
    "hero hero hero hero hero hero hero hero b b b c c c";
}
.tile { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.tile-hero { grid-area: hero; padding: 0; display: flex; flex-direction: column; }
.tile-a { grid-area: a; } .tile-b { grid-area: b; } .tile-c { grid-area: c; }
.tile h2 { font-size: 13px; font-weight: 500; color: var(--muted); }
.tile .big { font-size: 34px; line-height: 1.1; font-weight: 500; margin-top: 10px; letter-spacing: -0.02em; }
.tile .sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
.tile .kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin-top: 10px; font-size: 13px; }
.tile .kv dt { color: var(--muted); } .tile .kv dd { margin: 0; text-align: right; white-space: nowrap; }
.tile-hero .head { display: flex; align-items: baseline; gap: 10px; padding: 14px 18px 10px; border-bottom: 1px solid var(--rule); }
.tile-hero .head h2 { color: var(--ink); font-size: 14px; font-weight: 600; }
.tile-hero .head .hint { margin: 0; margin-left: auto; font-size: 12px; }
.feed { overflow-y: auto; max-height: 384px; flex: 1; }
.feed .line {
  display: grid; grid-template-columns: 92px 1fr auto auto; gap: 8px 12px; align-items: center;
  padding: 9px 18px; border-bottom: 1px solid var(--rule); font-size: 13px;
}
.feed .line:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-size: 12px; }
.feed .what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .what .addr { color: var(--muted); }
.feed .line.fresh { animation: fresh 2.6s ease-out 1; }
@keyframes fresh { 0% { background: color-mix(in srgb, var(--accent) 28%, transparent); } 100% { background: transparent; } }
@media (max-width: 900px) {
  .bento { grid-template-columns: 1fr 1fr; grid-template-areas: "hero hero" "a a" "b c"; }
  .feed { max-height: 300px; }
}
@media (max-width: 560px) {
  .bento { grid-template-columns: 1fr; grid-template-areas: "hero" "a" "b" "c"; }
  .feed .line { grid-template-columns: 1fr auto; }
  .feed .line time { grid-column: 1 / -1; }
}

/* ---- buttons ------------------------------------------------------------ */
button, .btn {
  font: inherit; font-size: 12.5px; line-height: 1; color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--rule); border-radius: var(--radius-s); padding: 6px 10px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; transition: border-color 120ms, background 120ms;
}
button:hover, .btn:hover { border-color: var(--faint); text-decoration: none; }
.btn.buy, button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.buy:hover { filter: brightness(1.06); }
button.done { color: var(--up); border-color: var(--up); }
button.quiet { background: none; border-color: transparent; color: var(--muted); padding: 6px 6px; }
button.quiet:hover { color: var(--ink); border-color: transparent; background: var(--panel-2); }
.actions { display: inline-flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }

/* ---- tags --------------------------------------------------------------- */
.tag { display: inline-block; font-size: 11px; line-height: 1; padding: 3px 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--rule); color: var(--muted); margin-left: 6px; vertical-align: middle; white-space: nowrap; }
.tag.bad { color: var(--down); border-color: color-mix(in srgb, var(--down) 40%, transparent); }
.tag.good { color: var(--up); border-color: color-mix(in srgb, var(--up) 40%, transparent); }
.tag.hot { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ---- tables & lists ----------------------------------------------------- */
.box { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: right; font-weight: 500; font-size: 12px; color: var(--muted); padding: 10px 12px; white-space: nowrap; border-bottom: 1px solid var(--rule); background: var(--panel-2); }
th:first-child, td:first-child { text-align: left; }
td { text-align: right; padding: 9px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
td:first-child { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.up { color: var(--up); } .down { color: var(--down); }
.empty { padding: 26px 18px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-weight: 500; margin-bottom: 2px; }

.grid { display: grid; grid-template-columns: 18px minmax(150px, 1.6fr) repeat(5, minmax(60px, 1fr)) 230px; gap: 10px; align-items: center; }
details.row { border-bottom: 1px solid var(--rule); }
details.row:last-child { border-bottom: 0; }
details.row > summary { padding: 10px 14px; cursor: pointer; list-style: none; font-size: 13px; }
details.row > summary::-webkit-details-marker { display: none; }
details.row > summary::before { content: ""; width: 0; height: 0; border: 4px solid transparent; border-left: 6px solid var(--faint); display: inline-block; margin-left: 4px; transition: transform 140ms; }
details.row[open] > summary::before { transform: rotate(90deg) translateX(-1px); }
details.row > summary:hover { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
.head { padding: 8px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--rule); background: var(--panel-2); }
.r { text-align: right; }
.positions { padding: 6px 14px 16px 42px; }
.positions .full { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12.5px; margin: 0 0 6px; word-break: break-all; }
.positions .hint { margin: 0 0 10px; }
.positions th { background: none; }
.positions th:first-child, .positions td:first-child { padding-left: 0; }

.line { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--rule); font-size: 13px; }
.line:last-child { border-bottom: 0; }
.line .actions { margin-left: auto; }
.add { display: flex; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
input { flex: 1; min-width: 0; font: inherit; font-size: 13px; color: var(--ink); background: var(--bg); border: 1px solid var(--rule); border-radius: var(--radius-s); padding: 7px 10px; }
.msg { font-size: 12.5px; color: var(--down); padding: 8px 14px 0; }
.toggle { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); cursor: pointer; }
.toggle input { flex: none; width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }

@media (max-width: 820px) {
  .grid { grid-template-columns: 18px 1fr 80px 230px; }
  .wide { display: none; }
}

/* ---- dialog ------------------------------------------------------------- */
dialog { width: min(380px, calc(100vw - 32px)); background: var(--panel); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--radius); padding: 22px; }
dialog::backdrop { background: rgba(5, 8, 16, 0.6); backdrop-filter: blur(2px); }
dialog h2 { font-size: 17px; }
dialog label { display: block; font-size: 12.5px; color: var(--muted); margin: 14px 0 5px; }
dialog input { width: 100%; }
dialog .row-end { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
dialog .note { font-size: 12.5px; margin: 10px 0 0; min-height: 18px; }
dialog .note.bad { color: var(--down); } dialog .note.good { color: var(--up); }

/* ---- charts ------------------------------------------------------------- */
.chart { width: 100%; height: 260px; display: block; }
.chart .bar { transition: opacity 120ms; }
.chart:hover .bar { opacity: 0.55; }
.chart .bar:hover { opacity: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.share { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); vertical-align: middle; margin-right: 8px; }

/* ---- footer ------------------------------------------------------------- */
footer { border-top: 1px solid var(--rule); margin-top: 48px; }
.foot-in { max-width: 1180px; margin: 0 auto; padding: 26px 20px 34px; display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 20px 32px; font-size: 13px; color: var(--muted); }
.foot-in h3 { font-size: 13px; font-weight: 600; color: var(--ink); margin: 0 0 8px; }
.foot-in p { margin: 0 0 6px; max-width: 48ch; }
.foot-in ul { list-style: none; margin: 0; padding: 0; }
.foot-in li { margin: 0 0 6px; }
@media (max-width: 720px) { .foot-in { grid-template-columns: 1fr; } }

/* ---- auth pages --------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth form { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: 26px; }
.auth .brand { margin-bottom: 18px; }
.auth label { display: block; font-size: 12.5px; color: var(--muted); margin: 14px 0 5px; }
.auth input { width: 100%; }
.auth button { width: 100%; justify-content: center; margin-top: 20px; padding: 9px; }
.auth .err { color: var(--down); font-size: 13px; margin: 0 0 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- institutions page -------------------------------------------------- */
.chart-wrap { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.bento.inst .tile-hero { min-height: 340px; }

/* ---- market page -------------------------------------------------------- */
.hbar { display: grid; grid-template-columns: 140px 1fr 90px; gap: 12px; align-items: center; padding: 6px 0; font-size: 13px; }
.hbar-track { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.hbar-value { text-align: right; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.panel h3 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 2px; }
.panel .now { font-size: 20px; font-weight: 500; margin: 0 0 8px; letter-spacing: -0.01em; }
.panel .now small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.panel svg { width: 100%; display: block; }
.regime { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin-top: 10px; }
.regime .item { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--panel-2); }
.regime .item i { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--faint); }
.regime .item.up i { background: var(--up); } .regime .item.down i { background: var(--down); } .regime .item.warn i { background: var(--accent); }
.regime .item b { display: block; font-weight: 500; }
.regime .item span { color: var(--muted); }
.gauge { height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--down), var(--accent) 50%, var(--up)); position: relative; margin: 14px 0 6px; }
.gauge i { position: absolute; top: -4px; width: 4px; height: 18px; background: var(--ink); border-radius: 2px; transform: translateX(-2px); }
.spark { width: 120px; height: 28px; display: inline-block; vertical-align: middle; }
@media (max-width: 820px) { .panel-grid { grid-template-columns: 1fr; } .hbar { grid-template-columns: 100px 1fr 80px; } }
