/* US ETF Flow Terminal — dark is :root, light overrides the same custom props.
   US convention: GREEN = inflow/up, RED = outflow/down (opposite of the A-share app).

   --pos / --neg are TEXT colors and may darken in light mode for legibility.
   The chart series colors are fixed constants in js/theme.js (CHART_POS/CHART_NEG)
   because histogram bar colors are baked per-data-point — letting them follow the
   theme would force a setData() on every toggle. */

:root {
  --bg:#0b0f17; --panel:#121925; --panel2:#192233; --border:#263247;
  --grid:rgba(120,134,156,0.14);
  --text:#d7deea; --muted:#8e9bad; --accent:#60a5fa;
  --pos:#22c55e; --neg:#ef4444;
  --blue:#60a5fa; --orange:#f59e0b; --purple:#a78bfa;
  --shadow:none;
}
:root[data-theme="light"] {
  --bg:#f6f8fb; --panel:#ffffff; --panel2:#eef2f8; --border:#d8e0ea;
  --grid:rgba(100,116,139,0.15);
  --text:#16202e; --muted:#5d6b7f; --accent:#2563eb;
  --pos:#15803d; --neg:#dc2626;
  --blue:#2563eb; --orange:#b45309; --purple:#7c3aed;
  --shadow:0 1px 2px rgba(16,32,54,0.06);
}

* { margin:0; padding:0; box-sizing:border-box; }
body { background:var(--bg); color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; font-size:13px; }
a { color:var(--accent); text-decoration:none; }
code { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:12px;
  background:var(--panel2); padding:1px 5px; border-radius:4px; }
.hidden { display:none !important; }

/* ---- nav ---- */
.nav { display:flex; gap:5px; align-items:center; padding:10px 16px; background:var(--panel);
  border-bottom:1px solid var(--border); position:sticky; top:0; z-index:100; flex-wrap:wrap; }
.nav .brand { font-weight:750; font-size:15px; color:var(--text); margin-right:14px; }
.nav .brand b { color:var(--accent); }
.nav a.item { padding:6px 12px; border-radius:7px; color:var(--muted); }
.nav a.item.active, .nav a.item:hover { background:var(--panel2); color:var(--text); }
.navspace { flex:1 1 20px; }
.iconbtn { padding:5px 10px; font-size:14px; line-height:1.1; }

/* ---- layout ---- */
.wrap { padding:16px; max-width:1500px; margin:0 auto; }
.foot { max-width:1500px; margin:0 auto; padding:6px 16px 26px; color:var(--muted);
  font-size:11.5px; line-height:1.6; }
.tabs { display:flex; gap:6px; flex-wrap:wrap; margin:10px 0; align-items:center; }
.tab { padding:5px 12px; border-radius:7px; background:var(--panel); color:var(--muted);
  border:1px solid var(--border); cursor:pointer; user-select:none; }
.tab.active { background:var(--accent); color:#fff; font-weight:700; border-color:var(--accent); }
:root[data-theme="dark"] .tab.active { color:#07111f; }
.card { background:var(--panel); border:1px solid var(--border); border-radius:10px;
  padding:13px; box-shadow:var(--shadow); }
.card p { margin:6px 0; line-height:1.55; }
.cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; margin:12px 0; }
.metric { font-size:22px; font-weight:700; margin-top:4px; }
.pos { color:var(--pos); } .neg { color:var(--neg); } .muted { color:var(--muted); }
h1.page { font-size:19px; margin:2px 0 3px; } h2 { font-size:15px; margin:0 0 8px; }
.sub { color:var(--muted); margin-bottom:8px; }
.pill { padding:3px 8px; border-radius:10px; background:var(--panel2); color:var(--muted); font-size:11px; }
.notice { border-left:3px solid var(--accent); padding:10px 12px; background:var(--panel);
  color:var(--muted); margin:12px 0; line-height:1.6; }

/* ---- table ---- */
table { width:100%; border-collapse:collapse; background:var(--panel); border:1px solid var(--border);
  border-radius:9px; overflow:hidden; }
th,td { padding:9px 10px; border-bottom:1px solid var(--border); text-align:right; white-space:nowrap; }
th { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.4px;
  position:sticky; top:0; background:var(--panel); z-index:2; }
th:first-child,td:first-child,th:nth-child(2),td:nth-child(2) { text-align:left; }
tr:hover td { background:var(--panel2); }
.tablewrap { overflow:auto; max-height:680px; border-radius:9px; }
th[data-k] { cursor:pointer; } th[data-k]:hover { color:var(--text); }
th.sorted { color:var(--accent); } th .arrow { font-size:9px; margin-left:2px; }
td .cell2 { display:block; font-size:10.5px; opacity:.7; line-height:1.15; }

/* ---- controls ---- */
input,select,button { background:var(--panel2); color:var(--text); border:1px solid var(--border);
  border-radius:7px; padding:7px 10px; font-size:13px; font-family:inherit; }
button { cursor:pointer; }
button:hover { border-color:var(--accent); }

/* ---- search ---- */
.searchbox { position:relative; }
.searchbox input { width:250px; }
.sresults { position:absolute; top:38px; right:0; width:380px; max-height:340px; overflow:auto;
  background:var(--panel2); border:1px solid var(--border); border-radius:8px; z-index:200;
  display:none; box-shadow:0 8px 24px rgba(0,0,0,.28); }
.sresults div { padding:6px 12px; cursor:pointer; }
.sresults div:hover { background:color-mix(in srgb, var(--accent) 14%, transparent); }

/* ---- chart panes ---- */
.pane { background:var(--panel); border:1px solid var(--border); border-radius:10px;
  margin-bottom:8px; box-shadow:var(--shadow); }
.legend { display:flex; gap:16px; padding:6px 12px; font-size:12px; color:var(--muted); flex-wrap:wrap; }
.dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:5px; }
#pane-price { height:520px; } #pane-vol { height:170px; } #mf-chart { height:520px; }

/* ---- rotation bars ---- */
.rotrow { display:grid; grid-template-columns:180px 1fr 1fr 110px; gap:8px;
  align-items:center; margin:7px 0; }
.rotbar { height:14px; }

/* ---- skeleton ---- */
.skel { background:linear-gradient(90deg,var(--panel2),var(--border),var(--panel2));
  background-size:200% 100%; animation:sh 1.2s linear infinite; border-radius:6px;
  height:14px; width:120px; display:inline-block; }
@keyframes sh { to { background-position:-200% 0; } }

::-webkit-scrollbar { width:9px; height:9px; }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:5px; }

@media (max-width:760px) {
  .searchbox input { width:150px; }
  .sresults { width:min(88vw,380px); }
  .rotrow { grid-template-columns:120px 1fr 1fr 92px; }
}
