:root {
  --bg: #1a1330; --surface: #241a44; --surface-2: #2e2256; --line: #43357a;
  --text: #fff4c2; --muted: #c8bde6; --accent: #ffb23f; --focus: #17b3a3;
  --up: #3fd8a8; --down: #ff7a7a; --bar: #ffb23f; --bar-dim: #8a6a3a;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.1rem; color: var(--accent); margin-top: 1.5rem; }
h3 { font-size: 1rem; margin-top: 1.1rem; }
.brand { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--focus); color: #0d0a1a; padding: 6px 10px; border-radius: 6px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button, input { font: inherit; color: inherit; }
button { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .85rem; cursor: pointer; min-height: 40px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #1a1330; border-color: var(--accent); font-weight: 700; }
button[aria-pressed="true"] { background: var(--focus); color: #0d0a1a; border-color: var(--focus); font-weight: 700; }
button:disabled { opacity: .6; cursor: wait; }
.error { color: var(--down); font-weight: 600; margin: .4rem 0; }
.error:empty { display: none; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; }
.login-card label { margin-top: .75rem; font-weight: 600; }
.login-card input { margin-top: .3rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; min-height: 44px; }
.login-card button { margin-top: 1rem; }

#app { max-width: 1100px; margin: 0 auto; padding: 12px 16px 48px; }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.top h1 { margin: 0; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.share-banner { background: var(--focus); color: #0d0a1a; border-radius: 8px; padding: .5rem .75rem; margin: .75rem 0 0; font-weight: 600; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 1rem 0 .75rem; }
.tabs [role="tab"] { border-radius: 8px 8px 0 0; border-bottom: none; background: transparent; padding: .55rem 1rem; }
.tabs [role="tab"][aria-selected="true"] { background: var(--surface); color: var(--accent); font-weight: 700; border-color: var(--line); }
main:focus { outline: none; }
[role="tabpanel"]:focus-visible { outline-offset: 4px; }

.range { border: 1px solid var(--line); border-radius: 8px; padding: .4rem .75rem .6rem; margin: 0 0 .5rem; display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; }
.range legend { padding: 0 .3rem; color: var(--muted); font-size: .85rem; }
.range label { display: inline-flex; align-items: center; gap: .35rem; min-height: 32px; cursor: pointer; }
.range input { accent-color: var(--accent); width: 18px; height: 18px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; }
.tile .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.tile .value { font-size: 1.35rem; font-weight: 700; margin-top: .15rem; overflow-wrap: anywhere; }
.tile .value.muted { color: var(--muted); font-weight: 600; }
.tile .meta { color: var(--muted); font-size: .78rem; margin-top: .2rem; }
.up { color: var(--up); }
.down { color: var(--down); }

.section { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .9rem; margin-top: 1rem; }
.section > h2:first-child { margin-top: 0; }
.source { display: inline-block; font-size: .8rem; color: #0d0a1a; background: var(--muted); border-radius: 999px; padding: .1rem .6rem; font-weight: 700; margin-bottom: .4rem; }
.empty { border: 1px dashed var(--line); border-radius: 8px; padding: .8rem; color: var(--muted); margin: .5rem 0; }
.note { color: var(--muted); font-size: .85rem; margin: .4rem 0; }

.table-wrap { overflow-x: auto; margin: .4rem 0; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
caption { text-align: left; color: var(--muted); font-size: .85rem; padding-bottom: .3rem; }
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.err { color: var(--down); overflow-wrap: anywhere; }

.chart { width: 100%; margin: .4rem 0; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .bar { fill: var(--bar); }
.chart .band { fill: none; stroke: var(--bar); stroke-width: 1.5; stroke-dasharray: 3 3; }
.legend { display: flex; align-items: center; gap: .4em; }
.band-key { display: inline-block; width: 1.2em; height: .9em; border: 1.5px dashed var(--bar); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart text { fill: var(--muted); font: 11px var(--font); }
details { margin: .2rem 0 .6rem; }
summary { cursor: pointer; color: var(--muted); font-size: .85rem; min-height: 32px; display: list-item; padding: .3rem 0; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 1.2rem; }
@media (min-width: 820px) { .grid2 { grid-template-columns: 1fr 1fr; } h1 { font-size: 1.4rem; } }
@media (max-width: 499px) { #me { flex-basis: 100%; font-size: .85rem; } }
@media print { .tabs, .top-actions, .range, .skip { display: none !important; } }
