:root {
    --bg: #0f1318;
    --panel: #171c24;
    --panel-2: #1d2430;
    --line: #2a3340;
    --text: #cdd5df;
    --muted: #76808f;
    --ok: #3fb98a;
    --na: #d8a23a;
    --bad: #e5546a;
    --accent: #5b8def;
    --drawer-w: 214px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

body { transition: padding-left .2s ease; }

.topbar {
    display: flex; align-items: center; gap: 18px;
    padding: 14px 28px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

/* belka STAGING (instancja testowa; COMPARYZE_ENV=staging) */
.staging-bar {
    background: repeating-linear-gradient(-45deg, #7a5b12, #7a5b12 14px, #634a0e 14px, #634a0e 28px);
    color: #ffe9b0;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 5px 10px;
}
.brand { font-weight: 700; letter-spacing: 2px; color: #fff; }
.topbar nav { display: flex; gap: 20px; }
.topbar nav a { color: var(--muted); text-decoration: none; padding: 4px 2px; }
.topbar nav a:hover { color: var(--text); }
.topbar nav a.active { color: #fff; border-bottom: 2px solid var(--accent); }
.topbar nav a.muted { opacity: .5; cursor: default; }

/* ── hamburger + wysuwany boczny panel nawigacji ─────────────────────── */
.nav-toggle { background: transparent; border: 1px solid var(--line); color: var(--text);
    border-radius: 8px; padding: 6px 10px; font-size: 15px; line-height: 1; cursor: pointer; }
.nav-toggle:hover { border-color: var(--accent); }
.nav-pinned .nav-toggle { display: none; }         /* zadokowany panel — hamburger zbędny */

.drawer { position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh; width: var(--drawer-w);
    background: var(--panel); border-right: 1px solid var(--line); z-index: 60;
    display: flex; flex-direction: column;
    transform: translateX(-100%); transition: transform .2s ease; }
.drawer.open { transform: translateX(0); box-shadow: 2px 0 22px rgba(0,0,0,.4); }
.nav-pinned .drawer { transform: translateX(0); box-shadow: none; }  /* no-FOUC: dok bez animacji */

.drawer-head { display: flex; align-items: center; justify-content: space-between;
    padding: 15px 16px; border-bottom: 1px solid var(--line); }
.drawer-title { font-weight: 700; letter-spacing: 2px; color: #fff; font-size: 12px; }
.pin-btn { background: transparent; border: 1px solid transparent; border-radius: 6px;
    cursor: pointer; font-size: 14px; padding: 4px 7px; line-height: 1;
    filter: grayscale(1); opacity: .55; transition: .15s; }
.pin-btn:hover { opacity: 1; filter: grayscale(0); border-color: var(--line); }
.pin-btn[aria-pressed="true"] { opacity: 1; filter: grayscale(0);
    background: var(--panel-2); border-color: var(--accent); }

.drawer-nav { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; }
.drawer-nav a { color: var(--muted); text-decoration: none; font-size: 14px;
    padding: 10px 12px; border-radius: 8px; border-left: 3px solid transparent; }
.drawer-nav a:hover { color: var(--text); background: var(--panel-2); }
.drawer-nav a.active { color: #fff; background: var(--panel-2); border-left-color: var(--accent); }

.drawer-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.45); }
.drawer-scrim[hidden] { display: none; }

.nav-pinned body { padding-left: var(--drawer-w); }

main { max-width: 1080px; margin: 0 auto; padding: 28px; }

/* ── Prices: widok "All periods" (sekcje jedna pod drugą) ───────────── */
html { scroll-behavior: smooth; }
.period-chips { margin: 0 0 18px; }
.period-chips .chip { text-decoration: none; color: var(--muted); cursor: pointer; }
.period-chips .chip:hover { color: #fff; border-color: var(--accent); }
.stack-sec { scroll-margin-top: 14px; margin-bottom: 26px; }
.stack-sec h2.pdate { font-size: 13px; color: var(--text); text-transform: none;
    letter-spacing: .3px; margin: 0 0 8px; font-weight: 700; }
.stack-sec h2.pdate::before { content: ""; display: inline-block; width: 8px; height: 8px;
    border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: baseline; }

/* ── Trends: kafelki zakresu osi X (7D/30D/90D/YTD/All) ─────────────── */
.range-chips { display: flex; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.range-chips .chip { background: var(--panel-2); border: 1px solid var(--line);
    border-radius: 999px; padding: 5px 14px; font-size: 12px; color: var(--muted);
    cursor: pointer; font-weight: 600; letter-spacing: .02em; }
.range-chips .chip:hover { color: #fff; border-color: var(--accent); }
.range-chips .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Today / Overview ────────────────────────────────────────────────── */
.ov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start;
    margin-top: 4px; }
.ov-grid .panel { margin: 0; }
@media (max-width: 900px) { .ov-grid { grid-template-columns: 1fr; } }
.ov-list { list-style: none; margin: 0; padding: 0; }
.ov-list li { display: flex; align-items: baseline; gap: 10px; padding: 9px 0;
    border-bottom: 1px solid var(--panel-2); font-size: 13px; flex-wrap: wrap; }
.ov-list li:last-child { border-bottom: none; }
.ov-list .who { font-weight: 600; color: var(--text); white-space: nowrap; }
.ov-list .what { color: var(--muted); flex: 1; min-width: 140px; }
.ov-list .dlen { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px;
    padding: 1px 6px; font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.mv-down.bad { color: var(--bad); font-weight: 700; white-space: nowrap; }
.mv-up.good { color: var(--ok); font-weight: 700; white-space: nowrap; }
.pill { border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 600;
    white-space: nowrap; }
.pill.warn { background: rgba(229,84,106,.14); color: var(--bad); }
.pill.win  { background: rgba(63,185,138,.14); color: var(--ok); }
.card .sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.card .num small { font-size: 13px; color: var(--muted); font-weight: 400; }
.ov-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.ov-actions .btn { text-decoration: none; }
.section-note { font-size: 11.5px; color: var(--muted); margin: 6px 0 0; }
.ov-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* ── stopka ──────────────────────────────────────────────────────────── */
.footer { display: flex; gap: 18px; align-items: center; margin: 40px 0 6px;
    padding-top: 14px; border-top: 1px solid var(--panel-2);
    color: var(--muted); font-size: 12px; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); }

/* ── FAQ — akordeon ──────────────────────────────────────────────────── */
.panel.faq { max-width: 760px; line-height: 1.6; padding: 10px 26px 22px; }
.panel.faq h2 { margin: 30px 0 6px; }                 /* globalny h2 = muted/uppercase */
.panel.faq h2:first-child { margin-top: 14px; }
.faq-item { border-bottom: 1px solid var(--panel-2); }
.faq-item:last-of-type { border-bottom: none; }
.faq-item summary { list-style: none; cursor: pointer; padding: 13px 30px 13px 0;
    position: relative; font-weight: 600; font-size: 14px; color: var(--text);
    transition: color .12s; user-select: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "❯"; position: absolute; right: 6px; top: 13px;
    color: var(--muted); font-size: 12px; transition: transform .18s ease, color .12s; }
.faq-item summary:hover { color: #fff; }
.faq-item summary:hover::after { color: var(--accent); }
.faq-item[open] summary { color: #fff; }
.faq-item[open] summary::after { transform: rotate(90deg); color: var(--accent); }
.faq-a { padding: 0 26px 16px 0; color: var(--muted); }
.faq-a p { margin: 0 0 10px; }
.faq-a p:last-child { margin-bottom: 0; }
.faq-a strong { color: var(--text); }
.faq-a ul { margin: 4px 0 10px; padding-left: 20px; }
.faq-a li { margin: 3px 0; }
.faq-a code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px;
    padding: 1px 5px; font-size: 12px; color: var(--text); }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 14px; margin: 0 0 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

.run-picker select {
    background: var(--panel-2); color: var(--text);
    border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px;
}
.run-picker label { color: var(--muted); margin-right: 8px; }

/* karuzela okresów: ‹ [select] › + pozycja */
.period-nav { display: inline-flex; align-items: center; gap: 6px; }
.pnav { background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 6px; width: 32px; height: 34px; font-size: 18px; line-height: 1;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.pnav:hover:not([disabled]) { border-color: var(--accent); color: #fff; }
.pnav[disabled] { opacity: .35; cursor: default; }
a.pnav { text-decoration: none; }
.pnav.off { opacity: .35; pointer-events: none; }
.period-select { min-width: 118px; }
.ppos { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.run-nav { display: inline-flex; align-items: center; gap: 6px; }

/* przewodnik: jak czytać komórkę */
.guide .small, .guide strong { display: block; }
.cell-guide { display: flex; gap: 36px; flex-wrap: wrap; margin-top: 14px; }
.guide-ex { display: flex; gap: 16px; align-items: center; }
.cell-demo { width: 96px; min-height: 54px; border: 1px solid var(--line); border-radius: 8px;
    display: flex; flex-direction: column; align-items: flex-end; justify-content: center;
    padding: 8px 12px; }
.cell-demo.cheaper { background: rgba(229,84,106,.10); }
.cell-demo.pricier { background: rgba(63,185,138,.08); }
.cell-demo .p { font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 600; }
.cell-demo .d { display: block; font-size: 11px; line-height: 1.3; }
.guide-notes { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--muted); }
.guide-notes li { margin: 3px 0; }
.guide-notes b { color: var(--text); }
.guide-notes b.va-up { color: #3fb98a; }
.guide-notes b.va-down { color: #e5546a; }
.guide-notes b.d-up { color: var(--na); }
.guide-notes b.d-down { color: var(--ok); }
.htmx-request .price-grid, .price-grid.htmx-request { opacity: .55; transition: opacity .1s; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.card {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 10px; padding: 16px 18px;
}
.card .num { font-size: 26px; font-weight: 700; }
.card .lbl { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card.ok .num { color: var(--ok); }
.card.na .num { color: var(--na); }
.card.bad .num { color: var(--bad); }

.grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 10px; padding: 18px 20px; margin-bottom: 18px;
}

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
    padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--panel-2); }
.tbl tr:last-child td { border-bottom: none; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.err { color: var(--na); font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

.badge { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: rgba(63,185,138,.14); color: var(--ok); }
.badge.bad { background: rgba(229,84,106,.14); color: var(--bad); }

.all-good { color: var(--ok); }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: 10px;
    padding: 40px; text-align: center; }
.muted { color: var(--muted); }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* ── strona cen: legenda + siatka ─────────────────────────────────── */
.run-picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.run-picker label:not(:first-child) { margin-left: 10px; }

.legend { display: flex; flex-wrap: wrap; gap: 18px; margin: 4px 0 16px; color: var(--muted); font-size: 12px; }
.lg-item { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 13px; height: 13px; border-radius: 3px; display: inline-block; border: 1px solid var(--line); }
.sw.self { background: rgba(91,141,239,.30); }
.sw.cheaper { background: rgba(229,84,106,.30); }
.sw.pricier { background: rgba(63,185,138,.28); }
.sw.na { background: var(--panel-2); }
.sw.heat-bar { width: 48px; background: linear-gradient(90deg,
    rgba(63,185,138,.6), rgba(216,162,58,.6), rgba(229,84,106,.6)); }

.panel.nopad { padding: 0; overflow-x: auto; }
table.price-grid { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
table.price-grid th, table.price-grid td {
    height: 44px; box-sizing: border-box; vertical-align: middle;
}
/* równe kolumny: kategoria stała, 7 firm dzieli resztę po równo */
table.price-grid th.cat-h, table.price-grid td.cat { width: 150px; }
table.price-grid thead th {
    background: var(--panel-2); color: var(--muted); font-weight: 600;
    padding: 6px 12px; text-align: right; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; line-height: 1.2;
}
table.price-grid thead th.cat-h { text-align: left; }
table.price-grid thead th.self { color: #cdd5df; }
table.price-grid td { padding: 4px 12px; border-bottom: 1px solid var(--panel-2); text-align: right; }
table.price-grid td.cat { text-align: left; font-weight: 600; color: var(--text); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
table.price-grid tr:last-child td { border-bottom: none; }

.cell .p { font-variant-numeric: tabular-nums; }
.cell .d { display: block; font-size: 10.5px; margin-top: 1px; line-height: 1.1; }
.va { font-style: normal; font-weight: 700; margin-right: 4px; font-size: 11px; }
.va-up   { color: #3fb98a; }   /* more expensive than Go → Go is cheaper */
.va-down { color: #e5546a; }   /* cheaper than Go → competitor undercuts Go */
.cell.self    { background: rgba(91,141,239,.14); font-weight: 700; }
.cell.cheaper { background: rgba(229,84,106,.10); }
.cell.pricier { background: rgba(63,185,138,.08); }
.cell.na      { color: var(--muted); }
.cell.nomatch { color: #41505f; }
.cell.nomatch::before { content: "—"; }
.cell.chg { box-shadow: inset 2px 0 0 0 var(--accent); }
.d-up   { color: var(--na); }
.d-down { color: var(--ok); }

.small { font-size: 12px; }

/* ── eksport ─────────────────────────────────────────────────────── */
.export-form { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin: 18px 0; }
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld label { color: var(--muted); font-size: 12px; }
input[type="date"] {
    background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 6px; padding: 8px 10px; color-scheme: dark;
}
.btn {
    background: var(--accent); color: #fff; border: none; border-radius: 6px;
    padding: 10px 18px; font-weight: 600; cursor: pointer; font-size: 13px;
}
.btn:hover { filter: brightness(1.1); }

/* ── admin ───────────────────────────────────────────────────────── */
.subnav { display: flex; gap: 4px; margin: -4px 0 20px; border-bottom: 1px solid var(--line); }
.subnav a { padding: 9px 16px; color: var(--muted); text-decoration: none;
    border-bottom: 2px solid transparent; }
.subnav a:hover { color: var(--text); }
.subnav a.on { color: #fff; border-bottom-color: var(--accent); }

input[type="text"], input[type="number"] {
    background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 6px; padding: 8px 10px; font-size: 13px;
}
input:focus { outline: none; border-color: var(--accent); }
.inline-form { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin: 14px 0 6px; }
.inline-form .fld { flex: 0 1 auto; }
.inline-form input[type="text"] { min-width: 220px; }

.btn-link { background: none; border: none; cursor: pointer; font-size: 13px; color: var(--accent); padding: 0; }
.btn-link.danger { color: var(--bad); }
.btn-link:hover { text-decoration: underline; }
td.right, .right { text-align: right; }
form { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
    padding: 5px 12px; font-size: 12px; font-variant-numeric: tabular-nums;
    display: inline-flex; gap: 8px; align-items: center; }
.chip i { font-style: normal; font-size: 10px; color: var(--muted); }
.chip.manual { border-color: rgba(91, 141, 239, .5); }
.chip.manual i { color: var(--accent); }

.map-grid td { padding: 2px 6px; }
.map-grid th.cat-h, .map-grid td.cat { width: 130px; }
.map-grid input[type="text"] { width: 100%; box-sizing: border-box; background: transparent;
    border: 1px solid transparent; border-radius: 4px; padding: 6px; font-size: 12px; text-align: left; }
.map-grid input[type="text"]:hover { border-color: var(--line); }
.map-grid input[type="text"]:focus { background: var(--panel-2); border-color: var(--accent); }
.save-bar { display: flex; align-items: center; gap: 14px; margin-top: 16px; }

/* custom autocomplete popup dla mappingu — pełne nazwy pojazdów mimo wąskich kolumn */
.ac-pop { position: fixed; z-index: 1000; background: var(--panel-2); border: 1px solid var(--accent);
    border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.5); max-height: 280px; overflow-y: auto;
    min-width: 200px; max-width: 460px; padding: 4px; }
.ac-opt { padding: 6px 10px; font-size: 12px; white-space: nowrap; border-radius: 4px; cursor: pointer;
    color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.ac-opt:hover, .ac-opt.on { background: var(--accent); color: #fff; }
.ac-opt b { color: #fff; font-weight: 700; }
.ac-empty { padding: 6px 10px; font-size: 12px; color: var(--muted); }

.import-actions { display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
    margin-top: 12px; }
.upload-form { display: flex; align-items: center; gap: 8px; margin: 0; flex-wrap: wrap; }
.upload-form input[type="file"] { color: var(--muted); font-size: 12px; max-width: 210px; }
.upload-form select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 6px; padding: 6px 8px; font-size: 12px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text);
    text-decoration: none; display: inline-flex; align-items: center; }
.btn.ghost:hover { border-color: var(--accent); filter: none; }
.row-actions { display: flex; gap: 14px; justify-content: flex-end; align-items: center; }
.row-actions form { margin: 0; }

.ref-tag { font-size: 9px; background: var(--accent); color: #fff; padding: 1px 5px;
    border-radius: 4px; vertical-align: middle; margin-left: 5px; font-weight: 600; letter-spacing: .03em; }
.map-grid th.self, .map-grid td.self { background: rgba(91,141,239,.10); }
.self-form { margin: 0; }
.self-form select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 6px; padding: 5px 8px; font-size: 12px; max-width: 160px; }
.access-form { display: flex; align-items: center; gap: 14px; margin: 0; flex-wrap: wrap; }
.access-form select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 6px; padding: 5px 8px; font-size: 12px; }
.acc-chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }

.col-list { list-style: none; margin: 12px 0 0; padding: 0; max-width: 460px; }
.col-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; background: var(--panel-2);
    border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.col-row .grip { color: var(--muted); user-select: none; letter-spacing: -2px; }
.col-name { flex: 1; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.col-move { display: flex; gap: 6px; }
.col-move .pnav { width: 28px; height: 28px; font-size: 14px; }

.pw-form { display: flex; align-items: center; gap: 10px; }
.pw-form input { background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 6px; padding: 6px 9px; font-size: 12px; min-width: 170px; }
.pw-form input:focus { outline: none; border-color: var(--accent); }

/* ── logowanie ─────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    padding: 32px 28px; width: 100%; max-width: 340px; display: flex; flex-direction: column; }
.login-card .brand { font-size: 18px; margin-bottom: 2px; }
.login-card label { color: var(--muted); font-size: 12px; margin: 14px 0 6px; }
.login-card input { background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 6px; padding: 10px 12px; font-size: 14px; }
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card .btn { margin-top: 20px; padding: 11px; }
.login-err { background: rgba(229,84,106,.14); color: var(--bad); border-radius: 6px;
    padding: 8px 12px; font-size: 13px; margin-top: 14px; }

/* ── obszar użytkownika w topbarze ── */
.user-area { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.uname { color: var(--muted); font-size: 13px; }
.logout { color: var(--muted); text-decoration: none; font-size: 13px; }
.logout:hover { color: var(--text); }
.client-switch select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 6px; padding: 6px 8px; font-size: 13px; }

.market-switch { display: inline-flex; gap: 2px; background: var(--panel-2);
    border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.market-switch a { padding: 5px 12px; border-radius: 6px; color: var(--muted);
    text-decoration: none; font-size: 13px; }
.market-switch a.on { background: var(--accent); color: #fff; }
.market-switch a:hover:not(.on) { color: var(--text); }

.flash { background: rgba(63,185,138,.12); color: var(--ok); border: 1px solid rgba(63,185,138,.3);
    border-radius: 8px; padding: 12px 16px; margin-bottom: 18px; font-size: 14px;
    font-variant-numeric: tabular-nums; }

.log { background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
    padding: 12px 14px; margin: 0; max-height: 300px; overflow: auto; white-space: pre;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px;
    line-height: 1.5; color: var(--text); }

@media (max-width: 760px) {
    .gear-btn { padding: 7px 9px; }
    .gear-btn .gear-label { display: none; }

    main { padding: 16px 12px; }

    /* górny pasek: hamburger + marka w rzędzie, reszta zawija się pod spód */
    .topbar { flex-wrap: wrap; gap: 10px 12px; padding: 12px 14px; }
    .nav-pinned body { padding-left: 0; }   /* na mobile panel zawsze nakładką, bez przesuwania */

    /* nagłówek strony: tytuł nad filtrami, filtry pełną szerokością */
    .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
    .run-picker { gap: 8px 10px; }
    .run-picker label { margin-left: 0; }
    .run-picker label:not(:first-child) { margin-left: 0; }
    .run-picker select { flex: 1 1 130px; min-width: 0; }

    .legend { gap: 10px 14px; }

    /* siatka cen: przewijaj poziomo zamiast ściskać kolumny */
    table.price-grid { min-width: 720px; }
    table.price-grid th.cat-h, table.price-grid td.cat {
        width: 112px; position: sticky; left: 0; z-index: 2; background: var(--panel);
        border-right: 1px solid var(--line);
    }
    table.price-grid thead th.cat-h { background: var(--panel-2); z-index: 3; }
    /* przyklejona kolumna referencyjna zaraz za kategorią — widoczna przy scrollu w bok.
       Celuje w pozycyjną klasę .selfcol (KAŻDA komórka kolumny ref, też N/A/no-match),
       nie w .self (tylko gdy jest cena) — inaczej N/A pływały i nakładały się na konkurencję. */
    table.price-grid th.self, table.price-grid td.cell.selfcol {
        position: sticky; left: 112px; z-index: 1; border-right: 1px solid var(--line);
    }
    table.price-grid td.cell.selfcol { background: #1b2230; }
    table.price-grid thead th.self { background: #222c3c; z-index: 2; }

    /* nagłówki tabeli zawsze widoczne przy scrollu w DÓŁ: siatka przewija się WEWNĄTRZ
       panelu (ograniczona wysokość), dzięki czemu sticky thead trzyma górę. */
    .panel.nopad { max-height: 78vh; max-height: 78dvh; overflow: auto; }

    .cards { grid-template-columns: repeat(2, 1fr); }
    .grid { grid-template-columns: 1fr; }
    /* tabele skuteczności: przewijaj poziomo, gdy nie mieszczą się na wąskim ekranie */
    .panel { overflow-x: auto; }
    .panel .tbl { min-width: 460px; }
    .export-form { gap: 12px; }
    .export-form .fld { flex: 1 1 140px; }
    .export-form .btn { flex: 1 0 100%; }
}

@media (max-width: 420px) {
    .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
    .card .num { font-size: 22px; }
    h1 { font-size: 18px; }
}

/* admin: run controls (on-demand + delete run) */
.admin-actions .action-row { display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap; margin-top: 12px; }
.admin-actions .action-row label { font-size: 13px; color: var(--muted); }
.admin-actions select { padding: 6px 10px; background: var(--panel-2);
    color: var(--text); border: 1px solid var(--line); border-radius: 6px; }
.btn.danger { background: var(--bad); }
.badge.warn { background: rgba(216,162,58,.16); color: var(--na); }

/* przycisk koła zębatego -> Grid Settings (obok siatki cen / trendów) */
.gear-btn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
    color: var(--muted); text-decoration: none; font-size: 13px; white-space: nowrap; }
.gear-btn:hover { border-color: var(--accent); color: #fff; }
.gear-btn svg { display: block; transition: transform .3s ease; }
.gear-btn:hover svg { transform: rotate(45deg); }


/* świeżość danych + soft-lock subskrypcji + health strip + UX (audyt 2026-07) */
.data-asof { display: inline-flex; align-items: center; gap: 7px; margin: 0 0 10px;
    padding: 6px 12px; background: var(--panel); border: 1px solid var(--line);
    border-radius: 999px; font-size: 12.5px; color: var(--muted); }
.data-asof b { color: var(--text); font-weight: 600; }
.asof-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.data-asof.stale-warn { border-color: rgba(216,162,58,.5); color: var(--na); }
.data-asof.stale-warn .asof-dot { background: var(--na); }
.data-asof.stale-warn b { color: var(--na); }

.lock-banner { background: rgba(229,84,106,.12); border: 1px solid rgba(229,84,106,.35);
    color: var(--text); border-radius: 10px; padding: 14px 18px; margin-bottom: 16px; }
.panel.locked { position: relative; }
.panel.locked > * { filter: blur(5px); pointer-events: none; user-select: none; }
.panel.locked::after { content: "Subscription expired — renew to unlock"; position: absolute;
    inset: 0; display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 15px; z-index: 5; }

.health-strip { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.health-card { flex: 1 1 240px; background: var(--panel); border: 1px solid var(--line);
    border-left: 4px solid var(--ok); border-radius: 10px; padding: 12px 16px; }
.health-card.warn { border-left-color: var(--na); }
.health-card.bad  { border-left-color: var(--bad); }
.health-card .hs-market { font-weight: 700; margin-bottom: 3px; }
.health-card .hs-line { font-size: 12.5px; color: var(--muted); }
.health-card .hs-alert { font-size: 12.5px; color: var(--bad); font-weight: 600; margin-top: 3px; }

tr.rowlink { cursor: pointer; }
tr.rowlink:hover td.cat { color: var(--accent); }

.map-grid input.miss { border-color: var(--bad); background: rgba(229,84,106,.08); }
.miss-demo { color: var(--bad); font-weight: 600; }

.account-form label { display: block; font-size: 12.5px; color: var(--muted); margin: 8px 0 4px; }
.account-form input { width: 100%; padding: 8px 10px; background: var(--panel-2);
    color: var(--text); border: 1px solid var(--line); border-radius: 6px; }
.subtle-link { color: var(--muted); }
.subtle-link:hover { color: var(--text); }
a.uname { color: var(--muted); text-decoration: none; }
a.uname:hover { color: var(--text); text-decoration: underline; }
.access-form input[type=date] { background: var(--panel-2); color: var(--text);
    border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.pw-form input[type=email] { background: var(--panel-2); color: var(--text);
    border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; width: 190px; }

/* scorecard: Price Index + headroom */
.score-grid td.cell { text-align: right; font-variant-numeric: tabular-nums; }
.score-grid th.cat-h, .score-grid td.cat { width: 170px; }
.score-grid td.pi-low  { background: rgba(63,185,138,.14); color: var(--ok); font-weight: 700; }
.score-grid td.pi-mid  { color: var(--text); font-weight: 600; }
.score-grid td.pi-high { background: rgba(229,84,106,.14); color: var(--bad); font-weight: 700; }
.score-grid .hd { color: var(--bad); margin-right: 8px; }
.score-grid .hu { color: var(--ok); }

/* merge history (zszywanie historii po zmianie nazwy) */
.merge-form { display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; }
.merge-form select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 6px; padding: 4px 8px; font-size: 12px; max-width: 220px; }
