:root {
    color-scheme: light;
    --page: #f9f9f7;
    --surface: #fcfcfb;
    --text: #0b0b0b;
    --text-secondary: #52514e;
    --muted: #6b6a66;
    --line: #e1e0d9;
    --baseline: #c3c2b7;
    --accent: #2a78d6;
    --accent-strong: #1c5cab;
    --accent-text: #ffffff;
    --bar-fill: #2a78d6;
    --bar-track: #cde2fb;
    --ok: #006300;
    --warn-bg: #fff4dc;
    --warn-line: #fab219;
    --bad: #d03b3b;
    --radius: 8px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --page: #0d0d0d;
        --surface: #1a1a19;
        --text: #f0efec;
        --text-secondary: #c3c2b7;
        --muted: #a3a29b;
        --line: #2c2c2a;
        --baseline: #383835;
        --accent: #6da7ec;
        --accent-strong: #9ec5f4;
        --accent-text: #0b0b0b;
        --bar-fill: #3987e5;
        --bar-track: #104281;
        --ok: #0ca30c;
        --warn-bg: #2f2610;
        --warn-line: #fab219;
        --bad: #e66767;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text: #f0efec;
    --text-secondary: #c3c2b7;
    --muted: #a3a29b;
    --line: #2c2c2a;
    --baseline: #383835;
    --accent: #6da7ec;
    --accent-strong: #9ec5f4;
    --accent-text: #0b0b0b;
    --bar-fill: #3987e5;
    --bar-track: #104281;
    --ok: #0ca30c;
    --warn-bg: #2f2610;
    --warn-line: #fab219;
    --bad: #e66767;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--page);
    color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.top {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.top nav { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.top nav a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom: 2px solid var(--accent); }
.top nav a.quiet { color: var(--muted); }
.brand { font-weight: 700; color: var(--text); }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }
.foot { max-width: 1180px; margin: 0 auto; padding: 8px 16px 32px; color: var(--muted); font-size: .85rem; }

h1 { font-size: 1.6rem; margin: 8px 0 12px; }
h2 { font-size: 1.15rem; margin: 4px 0 10px; }

.muted, small { color: var(--muted); }
.empty { color: var(--muted); font-style: italic; padding: 8px 0; }
.error { color: var(--bad); }
.nowrap { white-space: nowrap; }

.freshness { margin: 0 0 8px; font-size: .85rem; color: var(--muted); }
.freshness.stale { color: var(--text); background: var(--warn-bg); border-left: 4px solid var(--warn-line); padding: 6px 10px; border-radius: 4px; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.card.narrow { max-width: 380px; margin: 32px auto; }
.card.highlight { border-color: var(--accent); }

.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; font-size: .85rem; color: var(--text-secondary); gap: 4px; }
.filter-actions { display: flex; gap: 8px; align-items: center; }
.scope { margin: -8px 0 16px; color: var(--text-secondary); font-size: .9rem; }

input, select, button, .button {
    font: inherit;
    padding: 6px 10px;
    border: 1px solid var(--baseline);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
}

input.small { width: 7em; }
input.price { width: 10em; text-align: right; }
input[type="checkbox"] { width: 18px; height: 18px; padding: 0; accent-color: var(--accent); }

button, .button {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
    cursor: pointer;
    display: inline-block;
}

button:hover, .button:hover { background: var(--accent-strong); text-decoration: none; }
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.danger { background: var(--bad); border-color: var(--bad); color: #ffffff; }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
form.inline { display: inline; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; display: flex; flex-direction: column; }
.tile-label { color: var(--text-secondary); font-size: .85rem; }
.tile-value { font-size: 1.6rem; font-weight: 600; }

.notice { padding: 8px 12px; border-radius: 6px; border-left: 4px solid var(--accent); background: var(--surface); }
.notice.warn { background: var(--warn-bg); border-left-color: var(--warn-line); }
.notice.ok { border-left-color: var(--ok); }

.table-wrap { overflow-x: auto; margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
thead th { color: var(--text-secondary); font-weight: 600; font-size: .82rem; white-space: nowrap; border-bottom-color: var(--baseline); }
tbody th { font-weight: 500; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--page); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.share { display: inline-flex; align-items: center; gap: 8px; min-width: 150px; font-variant-numeric: tabular-nums; }
.share .pct { min-width: 3.6em; text-align: right; color: var(--text); }
progress {
    appearance: none;
    -webkit-appearance: none;
    width: 90px;
    height: 8px;
    border: none;
    border-radius: 4px;
    background: var(--bar-track);
    overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--bar-track); border-radius: 4px; }
progress::-webkit-progress-value { background: var(--bar-fill); border-radius: 4px; }
progress::-moz-progress-bar { background: var(--bar-fill); border-radius: 4px; }

.no-price { color: var(--muted); font-style: italic; }
.partial { color: var(--muted); }
.gift { display: block; font-size: .82rem; color: var(--muted); }
.chip { display: inline-block; padding: 1px 8px; margin: 2px 4px 2px 0; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; color: var(--text-secondary); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 0 0 8px; }
.stats div { display: flex; flex-direction: column; }
.stats dt { color: var(--text-secondary); font-size: .85rem; }
.stats dd { margin: 0; font-size: 1.2rem; font-weight: 600; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.stats dd .share { font-size: .95rem; font-weight: 400; }

.ranked { margin: 0 0 8px; padding-left: 1.4em; }
.ranked li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.ranked li > span:first-child { display: inline-block; min-width: 45%; }

.pager { display: flex; gap: 16px; align-items: center; justify-content: center; margin: 12px 0; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.row label.grow { display: flex; flex-direction: column; gap: 4px; }
.grow { flex: 1 1 200px; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
label.check { flex-direction: row; align-items: center; gap: 8px; }

.sticky-actions { position: sticky; bottom: 0; padding: 10px 0; background: var(--page); }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 600px) {
    main { padding: 12px 16px; }
    .filters label { flex: 1 1 140px; }
    .share { min-width: 120px; }
    progress { width: 60px; }
}

@media (forced-colors: active) {
    progress { border: 1px solid CanvasText; }
}
