/* site.css: shared look for every page (dark + light themes). Served by server.js; loaded after each page's own <style>,
   so the common pieces (header, panels, tables, inputs, buttons) look the same everywhere. Colors are tokens on :root. */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d11; --panel: #111419; --panel-2: #161a21; --head: #13171d; --th: #151920; --hover: #1a2030;
  --border: #262c36; --line: #1e232c; --line-soft: #181c23;
  --text: #d6dae1; --muted: #8b94a4; --faint: #5d6676; --strong: #f4f6f9;
  --accent: #3d7eff; --accent-soft: rgba(61,126,255,.14); --on-accent: #fff; --link: #75aaff;
  --up: #2ebd6b; --down: #ef5350; --warn: #f0a43a; --brand: #f0a43a;
  --up-soft: rgba(46,189,107,.14); --down-soft: rgba(239,83,80,.14); --warn-soft: rgba(240,164,58,.12);
  --zone-a: #121a28; --zone-b: #1b170e; --map-gap: #0b0d11;
  --shadow: 0 8px 28px rgba(0,0,0,.45);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f6; --panel: #ffffff; --panel-2: #f7f8fa; --head: #f8f9fb; --th: #f3f5f8; --hover: #edf3ff;
  --border: #dadfe6; --line: #e7eaef; --line-soft: #eff1f4;
  --text: #1c2129; --muted: #5b6472; --faint: #8b93a0; --strong: #0b0d11;
  --accent: #2563eb; --accent-soft: rgba(37,99,235,.10); --on-accent: #fff; --link: #1d5bd8;
  --up: #11884a; --down: #d32f2f; --warn: #b26a00; --brand: #d98a12;
  --up-soft: rgba(17,136,74,.10); --down-soft: rgba(211,47,47,.09); --warn-soft: rgba(178,106,0,.09);
  --zone-a: #eef3fb; --zone-b: #fbf5ea; --map-gap: #ffffff;
  --shadow: 0 8px 24px rgba(15,23,42,.12);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.45 "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
::selection { background: var(--accent-soft); }
.mono, code, kbd { font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; }
:focus-visible { outline: 2px solid var(--accent) !important; outline-offset: 1px; }

/* ---------- site header (filled by site.js) ---------- */
header#site { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px; height: 46px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--border); }
#site .brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--strong); font: 600 17px/1 "IBM Plex Sans", sans-serif; letter-spacing: -.015em; white-space: nowrap; }
#site .brand b { font-weight: 700; }
#site .brand .logo { width: 28px; height: 28px; flex: none; }
#site nav { display: flex; height: 100%; overflow-x: auto; scrollbar-width: none; min-width: 0; flex: 0 1 auto; }
#site nav::-webkit-scrollbar { display: none; }
#site nav a { display: flex; align-items: center; padding: 0 11px; height: 100%; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
#site nav a:hover { color: var(--strong); }
#site nav a.on { color: var(--strong); border-bottom-color: var(--brand); }
#site .tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#site .search { position: relative; }
#site .search input { width: 230px; height: 30px; padding: 0 30px 0 10px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; color: var(--text); font: inherit; }
#site .search input::placeholder { color: var(--faint); }
#site .search > kbd { position: absolute; right: 7px; top: 7px; font-size: 10px; color: var(--faint); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; line-height: 14px; pointer-events: none; }
#site .sugg { position: absolute; right: 0; top: 34px; width: 340px; background: var(--panel); border: 1px solid var(--border); border-radius: 4px; box-shadow: var(--shadow); display: none; overflow: hidden; }
#site .sugg a { display: flex; gap: 10px; align-items: baseline; padding: 7px 10px; text-decoration: none; color: var(--text); border-top: 1px solid var(--line-soft); }
#site .sugg a:first-child { border-top: 0; }
#site .sugg a.on, #site .sugg a:hover { background: var(--hover); }
#site .sugg b { font: 600 12px "IBM Plex Mono", monospace; color: var(--strong); min-width: 64px; }
#site .sugg span { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#site .sugg .tag { font: 600 10px "IBM Plex Sans", sans-serif; font-style: normal; color: var(--link); border: 1px solid var(--border); border-radius: 3px; padding: 0 5px; margin-left: auto; flex: none; }
#site .theme { width: 30px; height: 30px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; color: var(--muted); cursor: pointer; padding: 0; }
#site .theme:hover { color: var(--strong); border-color: var(--faint); }
#site .theme svg { width: 15px; height: 15px; }
.pagebar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); font-size: 12px; }
.pagebar:empty { display: none; }
.pagebar a { color: var(--link); text-decoration: none; }
.pagebar a:hover { text-decoration: underline; }
.pagebar #st { margin-left: auto; color: var(--muted); }
@media (max-width: 1500px) { #site nav a { padding: 0 8px; } #site .search input { width: 190px; } }
@media (max-width: 1440px) and (min-width: 761px) { #site nav a { padding: 0 6.5px; } #site .search input { width: 165px; } header#site { gap: 14px; } }
@media (min-width: 761px) { #site .tools { flex: none; } }
@media (max-width: 900px) { #site .search input { width: 150px; } #site .search > kbd { display: none; } header#site { gap: 10px; } }
/* phones: logo + search + account on the first row, the page links as a swipeable strip below; the header scrolls away */
@media (max-width: 760px) {
  :root { --scr-top: 0px; }
  header#site { position: static; flex-wrap: wrap; height: auto; padding: 8px 12px 0; gap: 8px 10px; }
  #site .tools { flex: 1; min-width: 0; justify-content: flex-end; }
  #site .search { flex: 1; min-width: 0; max-width: 260px; }
  #site .search input { width: 100%; }
  #site .sugg { width: min(340px, calc(100vw - 24px)); right: auto; left: 0; }
  #site nav { order: 3; flex-basis: 100%; height: 38px; margin: 0 -12px; padding: 0 4px; border-top: 1px solid var(--line-soft); }
  #site nav a { padding: 0 10px; }
}
@media (max-width: 480px) { #site .login { display: none; } #site .brand { font-size: 16px; } #site .brand .logo { width: 26px; height: 26px; } }

/* ---------- panels ---------- */
.box { margin: 14px 16px 0; background: var(--panel); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.box > h2 { margin: 0; padding: 10px 14px; background: transparent; color: var(--strong); border-bottom: 1px solid var(--line);
  font: 600 11px/1.4 "IBM Plex Sans", sans-serif; letter-spacing: .09em; text-transform: uppercase; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.box > h2 span { color: var(--muted); font-weight: 400; font-size: 12px; letter-spacing: 0; text-transform: none; }
.msg { padding: 14px; color: var(--warn); }
.note { padding: 12px 16px 28px; color: var(--faint); font-size: 11px; line-height: 1.6; }
.site-f { display: flex; gap: 10px 20px; flex-wrap: wrap; justify-content: space-between; align-items: center; margin-top: 24px; padding: 14px 16px 22px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11.5px; }
.site-f nav { display: flex; gap: 16px; }
.site-f a { color: var(--muted); text-decoration: none; }
.site-f a:hover { color: var(--link); }
.modal .fine a { color: var(--link); }

/* ---------- controls ---------- */
input, select, textarea { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 4px; font: inherit; }
input, select { height: 30px; padding: 0 8px; }
input[type=checkbox] { height: auto; accent-color: var(--accent); }
input[type=date] { color-scheme: inherit; }
select { padding-right: 4px; }
textarea { padding: 8px 10px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; background: var(--panel-2); }
.seg button { background: transparent; color: var(--muted); border: 0; border-right: 1px solid var(--border); padding: 0 11px; height: 28px; font: 500 12px "IBM Plex Sans", sans-serif; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--strong); }
.seg button.on { background: var(--accent); color: var(--on-accent); }
.btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 4px; height: 30px; padding: 0 12px; font: 500 12px "IBM Plex Sans", sans-serif; cursor: pointer; }
.btn:hover { border-color: var(--faint); color: var(--strong); }
.btn.go, .ai-go { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- tables ---------- */
table { border-collapse: collapse; }
th { background: var(--th); color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .03em; }
td { border-bottom-color: var(--line-soft); }
td, th { font-variant-numeric: tabular-nums; }
tr:hover > td { background: var(--hover); }

/* ---------- stat tiles ---------- */
.tiles { background: var(--line); }
.tile { background: var(--panel); }
.tile span { color: var(--muted); font-size: 10.5px; letter-spacing: .07em; }
.tile b { font-family: "IBM Plex Sans", sans-serif; font-weight: 600; letter-spacing: -.01em; color: var(--strong); }
.tile small { color: var(--faint); }

.up { color: var(--up); } .dn { color: var(--down); }

/* ---------- loading placeholders (Site.skel) ---------- */
:root, :root[data-theme="dark"] { --skel-a: #181c23; --skel-b: #222832; }
:root[data-theme="light"] { --skel-a: #eef0f3; --skel-b: #f8f9fb; }
.skel { display: block; height: 11px; border-radius: 3px; background: linear-gradient(90deg, var(--skel-a) 0%, var(--skel-b) 45%, var(--skel-a) 90%); background-size: 300% 100%; animation: skel 1.4s ease-in-out infinite; }
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: -50% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }
.skel-rows { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.skel-table > div { display: flex; gap: 14px; align-items: center; padding: 9px 14px; border-top: 1px solid var(--line-soft); }
.skel-table > div:first-child { border-top: 0; }
.skel-table .skel { height: 10px; }
.skel-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1px; background: var(--line); }
.skel-tiles > div { background: var(--panel); padding: 12px; display: flex; flex-direction: column; gap: 8px; }

/* ---------- account: sign in, avatar menu, notifications ---------- */
#site .acct-slot { display: flex; align-items: center; gap: 8px; }
#site .signin { height: 30px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); font: 600 12px "IBM Plex Sans", sans-serif; cursor: pointer; white-space: nowrap; }
#site .login { height: 30px; padding: 0 10px; border-radius: 4px; border: 1px solid var(--border); background: none; color: var(--text); font: 500 12px "IBM Plex Sans", sans-serif; cursor: pointer; white-space: nowrap; }
#site .login:hover { border-color: var(--faint); color: var(--strong); }
#site .bell-w, #site .acct-w { position: relative; }
#site .bell, #site .avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 4px; border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); cursor: pointer; padding: 0; position: relative; }
#site .bell:hover, #site .avatar:hover { color: var(--strong); border-color: var(--faint); }
#site .bell svg { width: 15px; height: 15px; }
#site .bell b { position: absolute; top: -5px; right: -6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--down); color: #fff; font: 600 10px/16px "IBM Plex Sans", sans-serif; }
#site .avatar { border-radius: 50%; overflow: hidden; font: 600 11px "IBM Plex Sans", sans-serif; color: var(--strong); }
#site .avatar img { width: 100%; height: 100%; object-fit: cover; }
#site .menu { position: absolute; right: 0; top: 36px; width: 250px; background: var(--panel); border: 1px solid var(--border); border-radius: 4px; box-shadow: var(--shadow); z-index: 30; padding: 4px 0; }
#site .menu.notes { width: 340px; max-height: 70vh; overflow-y: auto; }
#site .menu .who { display: flex; flex-direction: column; padding: 8px 12px 9px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
#site .menu .notes .who, #site .menu.notes .who { flex-direction: row; justify-content: space-between; align-items: center; }
#site .menu .who b { color: var(--strong); font-weight: 600; }
#site .menu .who span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
#site .menu a, #site .menu button.out { display: flex; justify-content: space-between; width: 100%; padding: 7px 12px; color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; text-align: left; cursor: pointer; }
#site .menu a:hover, #site .menu button.out:hover { background: var(--hover); }
#site .menu a small { color: var(--faint); }
#site .menu button.out { border-top: 1px solid var(--line); margin-top: 4px; color: var(--muted); }
#site .menu .mark { background: none; border: 0; color: var(--link); font: inherit; font-size: 12px; cursor: pointer; padding: 0; }
#site .menu a.note { flex-direction: column; gap: 2px; border-top: 1px solid var(--line-soft); }
#site .menu a.note b { color: var(--strong); font-weight: 600; font-size: 12.5px; }
#site .menu a.note span { color: var(--muted); font-size: 12px; }
#site .menu a.note small { color: var(--faint); font-size: 11px; }
#site .menu a.note.new { box-shadow: inset 3px 0 0 var(--accent); }
#site .menu a.all { justify-content: center; color: var(--link); border-top: 1px solid var(--line); font-size: 12px; }
#site .menu .empty { padding: 12px; color: var(--muted); font-size: 12px; }
#site .menu .empty a { display: inline; padding: 0; color: var(--link); }
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(5, 8, 12, .55); display: grid; place-items: center; padding: 16px; }
.modal { position: relative; width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); padding: 26px 26px 20px; }
.modal h2 { margin: 0 0 6px; font: 600 18px "IBM Plex Sans", sans-serif; color: var(--strong); }
.modal p { margin: 0 0 16px; color: var(--muted); }
.modal .x { position: absolute; top: 10px; right: 12px; background: none; border: 0; color: var(--faint); font-size: 22px; cursor: pointer; }
.modal .gbtn { min-height: 44px; display: flex; justify-content: center; }
.modal .gbtn .skel { width: 300px; }
.modal .dev { margin-top: 10px; display: flex; justify-content: center; }
.modal .setup { color: var(--warn); font-size: 12.5px; background: var(--warn-soft); border-radius: 4px; padding: 10px 12px; }
.modal .err { color: var(--down); margin: 10px 0 0; min-height: 1em; font-size: 12.5px; }
.modal .fine { font-size: 11px; color: var(--faint); margin: 12px 0 0; }
.modal .fine b { color: var(--muted); font-weight: 600; }
.modal .perks { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 6px; color: var(--text); font-size: 13px; }
.modal .perks li { padding-left: 20px; position: relative; }
.modal .perks li::before { content: ""; position: absolute; left: 3px; top: 4px; width: 8px; height: 4px; border-left: 2px solid var(--up); border-bottom: 2px solid var(--up); transform: rotate(-45deg); }
.modal .swap { margin: 14px 0 0; text-align: center; font-size: 12.5px; color: var(--muted); }
.modal .swap button { background: none; border: 0; padding: 0; color: var(--link); font: inherit; font-weight: 600; cursor: pointer; }
.modal .swap button:hover { text-decoration: underline; }
/* watchlist star (Site.star) */
.star { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 4px; border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); font: 500 12px "IBM Plex Sans", sans-serif; cursor: pointer; }
.star svg { width: 15px; height: 15px; }
.star:hover { color: var(--strong); border-color: var(--faint); }
.star.on { color: var(--brand); border-color: var(--brand); }
/* hover star next to any ticker link + toast */
.qstar { position: absolute; z-index: 40; width: 20px; height: 20px; padding: 0; display: grid; place-items: center; border-radius: 4px; border: 1px solid var(--border); background: var(--panel); color: var(--faint); cursor: pointer; box-shadow: var(--shadow); }
.qstar[hidden] { display: none; }
.qstar svg { width: 13px; height: 13px; }
.qstar:hover { color: var(--brand); border-color: var(--brand); }
.qstar.on { color: var(--brand); }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 70; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
  display: flex; gap: 14px; align-items: center; padding: 9px 14px; border-radius: 6px; background: var(--strong); color: var(--bg); font-size: 13px; box-shadow: var(--shadow); }
.toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button, .toast a { background: none; border: 0; padding: 0; color: inherit; font: 600 12.5px "IBM Plex Sans", sans-serif; cursor: pointer; text-decoration: underline; opacity: .85; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
#site .sugg .hint { padding: 6px 10px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11px; }
#site .sugg kbd { font: 500 10px "IBM Plex Mono", monospace; border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; color: var(--muted); }
/* affiliate links (TradingView, Ledger): small, clearly labeled, never in the way */
.aff{display:flex;align-items:center;flex-wrap:wrap;gap:6px 14px;margin:0 14px 14px;font-size:12px;color:var(--muted)}
.aff a{color:var(--link);text-decoration:none;font-weight:500}
.aff a:hover{text-decoration:underline}
.aff .aff-note{color:var(--faint);font-size:11px}
.aff-bar{margin:12px 14px 0;padding:8px 12px;border:1px solid var(--line);background:var(--panel)}
