:root {
    --ground: #eef2ef;
    --surface: #ffffff;
    --surface-2: #f6f9f7;
    --line: #dfe7e2;
    --line-soft: #ebf0ec;
    --ink: #10201a;
    --ink-2: #33473e;
    --muted: #61756b;
    --faint: #8a9b93;
    --brand: #067f43;
    --brand-2: #03a84e;
    --brand-wash: #e7f5ed;
    --warn: #a56a0d;
    --warn-wash: #fbf2e2;
    --bad: #b3291d;
    --bad-wash: #fbeae8;
    --shadow: 0 1px 2px rgba(12, 40, 28, .06), 0 8px 24px -18px rgba(12, 40, 28, .35);
    --ui: 'Figtree', 'Segoe UI', Helvetica, Arial, sans-serif;
    --serif: 'Newsreader', Georgia, serif;
    --mono: 'IBM Plex Mono', 'SF Mono', Consolas, monospace;
    --r: 10px;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ground: #0c1411; --surface: #121c18; --surface-2: #16211c;
        --line: #22302a; --line-soft: #1b2622;
        --ink: #e6efe9; --ink-2: #c0d1c7; --muted: #91a59b; --faint: #6d8177;
        --brand: #3ecb80; --brand-2: #35d182; --brand-wash: #12271b;
        --warn: #d9a34f; --warn-wash: #28200f; --bad: #e8776a; --bad-wash: #2a1614;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -18px rgba(0, 0, 0, .8);
    }
}
:root[data-theme="dark"] {
    --ground: #0c1411; --surface: #121c18; --surface-2: #16211c;
    --line: #22302a; --line-soft: #1b2622;
    --ink: #e6efe9; --ink-2: #c0d1c7; --muted: #91a59b; --faint: #6d8177;
    --brand: #3ecb80; --brand-2: #35d182; --brand-wash: #12271b;
    --warn: #d9a34f; --warn-wash: #28200f; --bad: #e8776a; --bad-wash: #2a1614;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -18px rgba(0, 0, 0, .8);
}

*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0; background: var(--ground); color: var(--ink);
    font-family: var(--ui); font-size: 15px; line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
    background: var(--surface); border-right: 1px solid var(--line);
    padding: 22px 16px; display: flex; flex-direction: column; gap: 26px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(140deg, var(--brand), var(--brand-2));
    display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px;
}
.brand-name { font-weight: 700; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: var(--faint); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
    font-family: var(--mono); font-size: 10px; font-weight: 600;
    letter-spacing: .14em; text-transform: uppercase; color: var(--faint); padding: 0 8px 8px;
}
.nav button {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
    background: none; border: 0; cursor: pointer; padding: 9px 10px; border-radius: 8px;
    font-size: 14.5px; font-weight: 500; color: var(--ink-2);
}
.nav button:hover { background: var(--surface-2); }
.nav button.on { background: var(--brand-wash); color: var(--brand); font-weight: 600; }
.nav .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .55; flex: none; }
.nav .badge {
    margin-left: auto; font-family: var(--mono); font-size: 11px; font-weight: 600;
    background: var(--warn-wash); color: var(--warn); padding: 1px 7px; border-radius: 20px;
}
.side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--muted); }
.side-foot b { display: block; color: var(--ink); font-weight: 600; }

.main { padding: 26px clamp(18px, 3vw, 34px) 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.crumb { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
h1 { font-size: 25px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 0; }
.shop-pick {
    display: inline-flex; align-items: center; gap: 9px; background: var(--surface);
    border: 1px solid var(--line); border-radius: 20px; padding: 7px 14px;
    font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow);
}
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-2); position: relative; }
.live::after {
    content: ""; position: absolute; inset: -4px; border-radius: 50%;
    border: 2px solid var(--brand-2); opacity: .5; animation: ping 2s ease-out infinite;
}
@keyframes ping { 0% { transform: scale(.6); opacity: .6; } 80%, 100% { transform: scale(1.7); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .live::after, .view.on, .sub.on { animation: none; } }

.view { display: none; }
.view.on { display: block; animation: fade .3s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- verdict */
.verdict {
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
    padding: 26px 28px; box-shadow: var(--shadow); margin-bottom: 16px;
    display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
}
.verdict-ring { flex: none; }
.verdict-text { flex: 1; min-width: 240px; }
.verdict-text h2 {
    font-family: var(--serif); font-weight: 400; font-size: clamp(23px, 3vw, 31px);
    line-height: 1.15; margin: 0 0 6px; letter-spacing: -.01em;
}
.verdict-text p { margin: 0; color: var(--muted); font-size: 14.5px; max-width: 56ch; }
.verdict-meta { font-family: var(--mono); font-size: 11.5px; color: var(--faint); margin-top: 10px; }

/* ---------------------------------------------------------------- kpis */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-l { font-size: 12.5px; color: var(--muted); }
.kpi-l b { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-v {
    font-family: var(--mono); font-size: 27px; font-weight: 600; letter-spacing: -.02em;
    margin-top: 8px; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.kpi-v small { font-size: 15px; font-weight: 500; color: var(--muted); }
.kpi-n { font-size: 12px; color: var(--faint); margin-top: 5px; }
.ok { color: var(--brand); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.grade { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; background: var(--brand); color: #fff; font-family: var(--mono); font-weight: 600; font-size: 20px; }
.bar { height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; margin-top: 12px; }
.bar span { display: block; height: 100%; border-radius: 4px; background: var(--brand-2); }
.bar.is-warn span { background: var(--warn); }

/* ---------------------------------------------------------------- cards */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.card + .card { margin-top: 16px; }
.card-h {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--line-soft); background: var(--surface-2);
}
.card-h h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-h .hint { font-size: 12.5px; color: var(--faint); }
.card-b { padding: 18px; }

/* explainer */
.why {
    background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 9px;
    padding: 13px 15px; font-size: 13.5px; color: var(--ink-2); margin-bottom: 16px;
}
.why b { font-weight: 600; }
.why-t {
    font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .12em;
    text-transform: uppercase; color: var(--faint); display: block; margin-bottom: 5px;
}

/* problems / findings */
.att { display: flex; flex-direction: column; gap: 10px; }
.att-i { border: 1px solid var(--line); border-radius: 9px; padding: 13px 15px; background: var(--surface); }
.att-i.w { background: var(--warn-wash); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.att-i.g { background: var(--brand-wash); border-color: color-mix(in srgb, var(--brand) 26%, transparent); }
.att-top { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.pill {
    font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .08em;
    text-transform: uppercase; padding: 3px 8px; border-radius: 20px; background: var(--warn); color: #fff;
}
.pill.info { background: var(--faint); }
.pill.good { background: var(--brand); }
.att-i strong { font-size: 14.5px; font-weight: 600; }
.att-i p { margin: 2px 0 10px; font-size: 13.5px; color: var(--muted); }
.att-i p.last { margin-bottom: 0; }
.btn {
    display: inline-flex; align-items: center; gap: 7px; background: var(--brand); color: #fff;
    border: 0; border-radius: 7px; padding: 7px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent); }
.btn.ghost:hover { background: var(--brand-wash); }
.btn:focus-visible, .nav button:focus-visible, .col-add:focus-visible, .submenu button:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

/* chart */
.chart svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.chart-legend b { font-family: var(--mono); color: var(--ink); font-weight: 600; }

/* timeline */
.tl { display: flex; flex-direction: column; }
.tl-i { display: grid; grid-template-columns: 13px minmax(0, 1fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.tl-i:last-child { border-bottom: 0; }
.tl-d { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; background: var(--faint); }
.tl-d.ok { background: var(--brand-2); } .tl-d.warn { background: var(--warn); } .tl-d.bad { background: var(--bad); }
.tl-t { font-size: 13.5px; }
.tl-m { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }

/* ------------------------------------------------- monitoring sub-layout */
.mon { display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: 18px; align-items: start; }
.submenu {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
    padding: 10px; box-shadow: var(--shadow); position: sticky; top: 20px;
    display: flex; flex-direction: column; gap: 2px;
}
.submenu button {
    display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
    background: none; border: 0; cursor: pointer; padding: 9px 11px; border-radius: 8px;
    font-size: 14px; font-weight: 500; color: var(--ink-2);
}
.submenu button:hover { background: var(--surface-2); }
.submenu button.on { background: var(--brand-wash); color: var(--brand); font-weight: 600; }
.state { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--brand-2); }
.state.w { background: var(--warn); }
.submenu .cnt { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--warn); font-weight: 600; }
.sub { display: none; }
.sub.on { display: block; animation: fade .25s ease both; }
.sub-head { margin-bottom: 14px; }
.sub-head h2 { margin: 0 0 4px; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.sub-head p { margin: 0; color: var(--muted); font-size: 14px; max-width: 68ch; }

/* ---------------------------------------------------------------- board */
.board-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 14px; align-items: start; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.col-h { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 0 2px; }
.col-h h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.col-n { font-family: var(--mono); font-size: 11.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 0 7px; }
.col-h .mark { width: 6px; height: 20px; border-radius: 3px; background: var(--faint); }
.mark.quote { background: var(--warn); } .mark.work { background: var(--brand-2); } .mark.done { background: var(--brand); }
.cards { display: flex; flex-direction: column; gap: 9px; }
.tcard {
    background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
    padding: 12px 13px; box-shadow: 0 1px 2px rgba(12, 40, 28, .05); cursor: pointer;
}
.tcard:hover { border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.tcard.fresh { animation: pop .4s ease both; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.tcard h4 { margin: 0 0 7px; font-size: 14px; font-weight: 600; line-height: 1.35; }
.tcard-m { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.chip { border-radius: 20px; padding: 2px 8px; font-weight: 600; }
.chip.h { background: var(--brand-wash); color: var(--brand); }
.chip.q { background: var(--warn-wash); color: var(--warn); }
.chip.auto { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.col-add {
    width: 100%; margin-top: 10px; background: none; border: 1px dashed var(--line);
    border-radius: 8px; padding: 9px; color: var(--muted); font-size: 13.5px; cursor: pointer;
}
.col-add:hover { border-color: var(--brand); color: var(--brand); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; font-size: 13.5px; border-bottom: 1px solid var(--line-soft); }
th { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }
.note { font-size: 12.5px; color: var(--muted); margin: 14px 0 0; }

/* toast */
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
    background: var(--ink); color: var(--ground); padding: 11px 20px; border-radius: 24px;
    font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none;
    transition: opacity .25s ease, transform .25s ease; z-index: 30;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.mock {
    position: fixed; right: 14px; bottom: 14px; z-index: 20;
    font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
    background: var(--ink); color: var(--ground); padding: 7px 13px; border-radius: 20px; opacity: .82;
}

@media (max-width: 1080px) { .grid-2 { grid-template-columns: 1fr; } .board { grid-template-columns: repeat(2, minmax(200px, 1fr)); } }
@media (max-width: 860px) {
    .mon { grid-template-columns: 1fr; }
    .submenu { position: static; flex-direction: row; overflow-x: auto; }
    .submenu button { white-space: nowrap; }
}
@media (max-width: 760px) {
    .shell { grid-template-columns: 1fr; }
    .side { flex-direction: row; align-items: center; gap: 14px; overflow-x: auto; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
    .side .nav-label, .side-foot, .brand-sub { display: none; }
    .nav { flex-direction: row; gap: 6px; }
    .nav button { white-space: nowrap; }
    .board { grid-template-columns: 1fr; }
}

/* ------------------------------------------------- ekran logowania */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box {
    width: 100%; max-width: 400px; background: var(--surface);
    border: 1px solid var(--line); border-radius: 14px; padding: 32px;
    box-shadow: var(--shadow);
}
.login-box .brand { justify-content: center; margin-bottom: 22px; padding: 0; }
.login-box h1 { font-size: 20px; text-align: center; margin: 0 0 6px; }
.login-box .lead { text-align: center; color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
    width: 100%; padding: 11px 13px; font: inherit; font-size: 14.5px;
    background: var(--surface-2); color: var(--ink);
    border: 1px solid var(--line); border-radius: 8px;
}
.field input:focus { outline: 2px solid var(--brand-2); outline-offset: 1px; border-color: var(--brand-2); }
.btn.wide { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }
.alert {
    background: var(--bad-wash); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
    color: var(--bad); border-radius: 8px; padding: 11px 14px; font-size: 13.5px; margin-bottom: 16px;
}
.login-foot { text-align: center; font-size: 12.5px; color: var(--faint); margin: 18px 0 0; }

/* ------------------------------------------------- stany i drobiazgi */
.empty { color: var(--muted); font-size: 14px; padding: 22px; text-align: center; }
.shop-switch { display: flex; gap: 6px; flex-wrap: wrap; }
.shop-switch a {
    display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
    background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
    padding: 7px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); box-shadow: var(--shadow);
}
.shop-switch a.on { border-color: var(--brand); color: var(--brand); }
.nav a {
    display: flex; align-items: center; gap: 10px; width: 100%; text-decoration: none;
    padding: 9px 10px; border-radius: 8px; font-size: 14.5px; font-weight: 500; color: var(--ink-2);
}
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--brand-wash); color: var(--brand); font-weight: 600; }
.submenu a {
    display: flex; align-items: center; gap: 9px; text-decoration: none;
    padding: 9px 11px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--ink-2);
}
.submenu a:hover { background: var(--surface-2); }
.submenu a.on { background: var(--brand-wash); color: var(--brand); font-weight: 600; }
.logout { margin-top: 10px; font-size: 12.5px; color: var(--muted); text-decoration: none; }
.logout:hover { color: var(--brand); }
form.inline { display: inline; }
form.inline button { border: 0; cursor: pointer; }
.flash {
    background: var(--brand-wash); border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
    color: var(--brand); border-radius: 9px; padding: 12px 16px; font-size: 14px; margin-bottom: 16px;
}
.score-areas { display: flex; flex-direction: column; gap: 9px; }
.score-area { display: grid; grid-template-columns: 150px 1fr 46px; gap: 12px; align-items: center; font-size: 13.5px; }
.score-area .t { font-weight: 600; }
.score-area .n { font-family: var(--mono); text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }


.field select.select {
    width: 100%; padding: 11px 13px; font: inherit; font-size: 14.5px;
    background: var(--surface-2); color: var(--ink);
    border: 1px solid var(--line); border-radius: 8px;
}
.field select.select:focus { outline: 2px solid var(--brand-2); outline-offset: 1px; }
.shop-switch a .col-n { margin-left: 4px; }

/* ------------------------------------------------- wykresy (SVG z serwera) */
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .ax { font-family: var(--mono); font-size: 10px; fill: var(--faint); }
.donut-v { font-family: var(--mono); font-size: 21px; font-weight: 600; fill: var(--ink); }
.donut-s { font-family: var(--ui); font-size: 10px; fill: var(--muted); }
.upbars { display: flex; align-items: flex-end; gap: 4px; height: 62px; margin-top: 6px; }
.upbar { flex: 1; display: flex; align-items: flex-end; height: 100%; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.upbar i { display: block; width: 100%; background: var(--brand-2); border-radius: 3px; }
.upbar.w i { background: var(--warn); }
.upbar.b i { background: var(--bad); }
.donut-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

.field textarea.area {
    width: 100%; padding: 12px 13px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
    background: var(--surface-2); color: var(--ink);
    border: 1px solid var(--line); border-radius: 8px; resize: vertical;
}
.field textarea.area:focus { outline: 2px solid var(--brand-2); outline-offset: 1px; }
.field .tl-m { display: block; margin-top: 5px; }
