:root {
  --bg: #0f1419; --panel: #171e26; --panel2: #1d2631; --line: #2a3441;
  --text: #e6ebf1; --muted: #8b98a8; --accent: #3b9eff;
  --up: #26a69a; --down: #ef5350; --warn: #e0a93a;
  --radius: 8px;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f6f9; --panel: #fff; --panel2: #eef1f5; --line: #d8dee6; --text: #18202a; --muted: #637083; --up: #0f8f82; --down: #d33a37; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--panel2); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 28px 0 10px; }

.topbar { display: flex; align-items: center; gap: 20px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
.brand { color: var(--text); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand small { color: var(--muted); font-weight: 400; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--up); display: inline-block; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: var(--muted); padding: 6px 12px; border-radius: 6px; }
.topbar nav a:hover { background: var(--panel2); text-decoration: none; }
.topbar nav a.active { color: var(--text); background: var(--panel2); }
.topbar .search { margin-left: auto; }
.topbar .search input { width: 220px; }
.logout { color: var(--muted); }

main { max-width: 1180px; margin: 0 auto; padding: 20px; }
footer { max-width: 1180px; margin: 20px auto; padding: 0 20px 30px; color: var(--muted); font-size: 12px; }

input, select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; font: inherit; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: wait; }
.small-btn { padding: 4px 10px; font-size: 12px; }
.btn-icon { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 8px; }
.btn-icon:hover { color: var(--down); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid var(--line); background: var(--panel); }
.flash.ok { border-color: var(--up); } .flash.err { border-color: var(--down); } .flash.warn { border-color: var(--warn); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: var(--panel2); }
table.grid.compact td { padding: 6px 12px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ticker { font-weight: 700; font-size: 15px; }
.tag { font-size: 11px; background: var(--panel2); color: var(--muted); padding: 2px 7px; border-radius: 10px; margin-left: 6px; }
.tag.on { background: rgba(38,166,154,.18); color: var(--up); }
.tag.fired { background: rgba(224,169,58,.18); color: var(--warn); margin-left: 0; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; }
.spark.up { stroke: var(--up); } .spark.down { stroke: var(--down); }
.actions-cell { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.actions-cell form { margin: 0; }

.empty { padding: 30px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

.quote { text-align: right; margin-left: auto; }
.quote .big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }

.chart-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.chart-tools label { cursor: pointer; display: flex; align-items: center; gap: 4px; }
.chart-tools .spacer { flex: 1; }
.chip { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 3px 11px; cursor: pointer; font: inherit; font-size: 12px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chart { height: 420px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); position: relative; overflow: hidden; }
.chart.small-chart { height: 130px; }
.chart-label { font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.chart .legend { position: absolute; left: 10px; top: 8px; z-index: 3; font-size: 12px; font-variant-numeric: tabular-nums; pointer-events: none; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.stat .big2 { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.big2 small { font-size: 12px; font-weight: 400; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-items: end; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form-grid label.wide { grid-column: span 2; }

body.login { display: grid; place-items: center; min-height: 100vh; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 320px; display: flex; flex-direction: column; gap: 14px; }
.login-box label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.login-box h1 { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.login-box h1 small { color: var(--muted); font-weight: 400; }

@media (max-width: 700px) {
  .topbar .search { margin-left: 0; width: 100%; } .topbar .search input { width: 100%; }
  .quote { text-align: left; margin-left: 0; }
  .chart { height: 320px; }
}
