:root {
  --plane: #f6f6f3; --surface: #ffffff; --surface-2: #fafaf8;
  --text: #0b0b0b; --text-2: #52514e; --muted: #898781;
  --line: #e4e3dc; --line-strong: #c9c8bf;
  --accent: #1f63c4; --accent-hover: #184f95; --accent-soft: #e8f1fd; --on-accent: #ffffff;
  --good: #006300; --good-bg: #e6f4e6; --bad: #b3261e; --bad-bg: #fbe9e7; --warn: #8a5a00; --warn-bg: #fdf1d3;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --grid: #e1e0d9; --axis: #c3c2b7;
  --shadow: 0 1px 2px rgba(20, 20, 15, .05), 0 1px 1px rgba(20, 20, 15, .03);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --plane: #0d0d0d; --surface: #1a1a19; --surface-2: #20201f;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #898781;
    --line: #2c2c2a; --line-strong: #3d3d3a;
    --accent: #5598e7; --accent-hover: #86b6ef; --accent-soft: #15273f; --on-accent: #0b0b0b;
    --good: #3fbf3f; --good-bg: #12290f; --bad: #f08a80; --bad-bg: #361815; --warn: #f2c264; --warn-bg: #33270c;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #0ca30c; --series-7: #9085e9; --series-8: #e66767;
    --grid: #2c2c2a; --axis: #383835;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--plane); color: var(--text);
  font: 15px/1.5 "Inter", system-ui, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }

/* ---------- pasek górny ---------- */
header.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
header.top .in { max-width: 1180px; margin: 0 auto; padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; }
nav { display: flex; gap: 4px; flex: 1; align-self: stretch; }
nav a { display: flex; align-items: center; padding: 0 12px; color: var(--text-2); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
nav a:hover { color: var(--text); text-decoration: none; }
nav a.on { color: var(--text); border-bottom-color: var(--accent); }
.who { display: flex; align-items: center; gap: 10px; }
.who a { color: var(--text-2); font-weight: 500; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 72px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--text-2); }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.sub { color: var(--text-2); margin-top: 6px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- karty ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card.flush .card-head { padding: 18px 20px 0; }
.card-head .hint { color: var(--muted); font-size: 13px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.tile .k { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tile .v { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tile .v small { font-size: 15px; font-weight: 600; color: var(--text-2); }
.tile .d { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.tile.hl { border-color: var(--good); background: linear-gradient(0deg, var(--good-bg), var(--good-bg)), var(--surface); }

/* ---------- formularze ---------- */
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .fit { flex: 0 0 auto; }
.stack > * + * { margin-top: 14px; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus, button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
button, .btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 15px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap; }
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
button:disabled { opacity: .5; cursor: default; }
button.ghost, .btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); }
button.danger { background: var(--surface); color: var(--bad); border-color: var(--line-strong); }
button.danger:hover { background: var(--bad-bg); }
button.small, .btn.small { padding: 5px 10px; font-size: 13px; }
form.inline { display: inline; }
.checks { display: grid; gap: 8px; max-height: 340px; overflow: auto; padding: 4px 2px; }
.checks label { display: flex; gap: 9px; align-items: flex-start; color: var(--text); font-size: 14px; font-weight: 400; margin: 0; }
.checks input { margin-top: 4px; }

/* ---------- tabele ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.card.flush th:first-child, .card.flush td:first-child { padding-left: 20px; }
.card.flush th:last-child, .card.flush td:last-child { padding-right: 20px; }
thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600;
  background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.link:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td .name { font-weight: 600; color: var(--text); }
td .meta { font-size: 13px; color: var(--muted); }
.price { font-weight: 650; font-variant-numeric: tabular-nums; }
.best { color: var(--good); font-weight: 650; }
.spark { color: var(--series-1); display: block; }

.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 2px 7px;
  border-radius: 99px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.delta.down { color: var(--good); background: var(--good-bg); }
.delta.up { color: var(--bad); background: var(--bad-bg); }
.delta.flat { color: var(--muted); background: var(--surface-2); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; font-size: 12px;
  font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge.ok { color: var(--good); background: var(--good-bg); border-color: transparent; }
.badge.ok::before { background: var(--good); }
.badge.err { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.badge.err::before { background: var(--bad); }
.badge.run { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.badge.run::before { background: var(--warn); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.flash { padding: 11px 15px; border-radius: 10px; margin-bottom: 16px; background: var(--good-bg); color: var(--good); font-weight: 500; }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.url { word-break: break-all; }
pre.err { white-space: pre-wrap; background: var(--warn-bg); color: var(--warn); padding: 12px 14px;
  border-radius: 10px; font-family: inherit; font-size: 13px; line-height: 1.5; margin: 0 0 16px; }
.empty { text-align: center; padding: 44px 20px; color: var(--text-2); }
.empty h2 { margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }

/* ---------- wykresy ---------- */
.chartbox { position: relative; height: 340px; }
.chartbox.tall { height: 400px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; font-size: 13px; color: var(--text-2); }
.legend button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; padding: 2px 0; }
.legend button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.legend button.off { opacity: .4; text-decoration: line-through; }
.legend i { width: 14px; height: 3px; border-radius: 2px; flex: none; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: baseline; }
details.table-view { margin-top: 14px; }
details.table-view summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 500; }

/* ---------- logowanie ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { margin-bottom: 18px; font-size: 18px; }

@media (max-width: 720px) {
  header.top .in { height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 8px 16px; }
  nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  nav a { padding: 8px 10px; }
  main { padding: 18px 16px 56px; }
  h1 { font-size: 22px; }
  .tile .v { font-size: 24px; }
  .chartbox, .chartbox.tall { height: 280px; }
}

/* ---------- filtr metrażu ---------- */
.filterbar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 12px 16px; }
.filterbar .inline-field { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--text-2); font-size: 14px; }
.filterbar input[type=number] { width: 84px; padding: 6px 8px; }
.filterbar .hint { color: var(--muted); font-size: 13px; flex: 1 1 260px; }

/* ---------- zakładki skanu i powiadomienia ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 9px 14px; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 99px; text-align: center;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.rule { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-top: 12px; background: var(--surface); }
.rule.off { opacity: .65; }
.rule-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.rule-head h3 { font-size: 15px; font-weight: 650; }
.rule ul { margin: 6px 0 0; padding-left: 18px; }
.rule details { margin-top: 10px; }
.rule details > summary, details.newrule > summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; }
.ruleform fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 14px; margin: 14px 0 0; min-width: 0; }
.ruleform legend { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0 6px; }
.ruleform .opt { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; margin: 0; padding: 5px 0;
  color: var(--text); font-size: 14px; font-weight: 400; }
.ruleform .opt input[type=number], .ruleform .opt input[type=time] { width: 96px; padding: 5px 8px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.ruleform .opt select { width: auto; padding: 5px 8px; }
.ruleform .opt.sub { padding-left: 24px; color: var(--text-2); }
.ruleform .hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.ruleform .checks { max-height: 220px; margin: 6px 0 0 24px; }

/* ---------- loty ---------- */
.route { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; }
.route .arrow { color: var(--muted); font-weight: 400; }
.note { background: var(--warn-bg); color: var(--warn); padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.note a { color: inherit; text-decoration: underline; }
input.iata { text-transform: uppercase; }
