/* Everstra Insights -- one stylesheet, no inline styles (CSP style-src 'self'),
 * no framework. Light and dark follow the system; print = the PDF export. */
:root {
    color-scheme: light dark;
    --fg: #1b2330; --bg: #f3f5f8; --card: #fff; --muted: #64707d; --line: #dfe4ea;
    --accent: #2b6fd4; --accent-2: #43c382; --accent-soft: rgba(43, 111, 212, .1);
    --warn: #e8590c; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
    --radius: 12px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --fg: #e6eaf0; --bg: #0f1318; --card: #171c23; --muted: #9aa5b1; --line: #2a323c;
        --accent: #58a6ff; --accent-soft: rgba(88, 166, 255, .14);
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; min-height: 100vh; display: flex; flex-direction: column;
    font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--fg); background: var(--bg);
}
a { color: var(--accent); }
.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 1.5rem; padding-bottom: 2rem; }

/* header */
header.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
header.top .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; padding-top: .7rem; padding-bottom: .7rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--fg); text-decoration: none; font-weight: 650; font-size: 1.05rem; }
.brand img { display: block; }
.brand span { color: var(--muted); font-weight: 600; padding-left: .6rem; border-left: 1px solid var(--line); }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
nav a { color: var(--muted); text-decoration: none; padding: .35rem .75rem; border-radius: 8px; font-weight: 500; }
nav a:hover { color: var(--fg); background: var(--accent-soft); }
nav a.on { color: var(--accent); background: var(--accent-soft); }
form.logout { display: inline; margin: 0 0 0 .5rem; }

h1.title { font-size: 1.5rem; margin: 0 0 1rem; letter-spacing: -.01em; }
footer { color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); background: var(--card); }
footer .wrap { padding-top: .8rem; padding-bottom: .8rem; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin: 0 0 1.25rem; }
.stats { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1.5rem; }
.big { font-size: 2.2rem; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.since { color: var(--muted); margin: 0; }

/* controls */
input, select, button { font: inherit; color: var(--fg); }
input, select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .6rem; min-height: 2.3rem; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 8px; padding: .45rem 1rem; font-weight: 600; min-height: 2.3rem; }
button:hover { filter: brightness(1.08); }
button.ghost, .ghost-link { background: transparent; color: var(--accent); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .8rem; font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; min-height: 2.3rem; }
button.ghost:hover, .ghost-link:hover { background: var(--accent-soft); filter: none; }

.quick { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip { text-decoration: none; color: var(--fg); border: 1px solid var(--line); border-radius: 999px; padding: .25rem .8rem; font-size: .88rem; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
form.filters { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; margin: 0; }
form.filters label, form.login label { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; color: var(--muted); font-weight: 500; }
form.filters .actions { display: flex; gap: .5rem; align-items: center; }

.note, .err { padding: .6rem .9rem; border-left: 4px solid var(--warn); background: var(--card); border-radius: 6px; }

/* chart + table */
.chart-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; margin-bottom: .5rem; }
.chart { position: relative; height: 340px; max-width: 720px; margin: 0 auto; }
.chart.wide { max-width: 100%; height: 440px; }
.table-card { overflow-x: auto; padding: .5rem; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: .5rem .8rem; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, tr:hover td { background: var(--accent-soft); }
th:first-child, td:first-child { text-align: left; }

/* login */
body.login-page main.wrap { display: flex; align-items: center; justify-content: center; padding-top: 2rem; }
.login-card { width: 100%; max-width: 24rem; text-align: center; padding: 2rem 1.75rem; border-top: 4px solid var(--accent); }
.login-card .logo { display: block; margin: 0 auto .75rem; width: 168px; height: auto; }
.login-card h1 { font-size: 1.2rem; font-weight: 600; color: var(--muted); margin: 0 0 1.25rem; }
form.login { display: flex; flex-direction: column; gap: .9rem; text-align: left; }
form.login input { width: 100%; }
form.login button { margin-top: .25rem; width: 100%; }

@media (max-width: 600px) {
    .chart { height: 280px; }
    .chart.wide { height: 380px; }
    form.filters label { flex: 1 1 calc(50% - 1rem); }
    form.filters label input, form.filters label select { width: 100%; }
}

/* PDF / print: chart and table, no controls */
@media print {
    :root { --fg: #000; --bg: #fff; --card: #fff; --muted: #444; --line: #bbb; color-scheme: light; }
    header.top nav, .filters-card, .chart-tools, form.logout { display: none !important; }
    header.top { position: static; border: 0; }
    body { background: #fff; }
    .card { box-shadow: none; border: 1px solid var(--line); break-inside: avoid; }
    .chart, .chart.wide { max-width: 100%; height: 360px; }
    tr:hover td { background: none; }
    a { color: #000; text-decoration: none; }
}
button:disabled { opacity: .45; cursor: default; filter: none; }
