:root {
  --ground: #e9eeec;      /* beton */
  --surface: #ffffff;
  --ink: #18221f;
  --ink-soft: #4f5d58;
  --line: #c9d3cf;
  --accent: #0f6b4c;      /* zielony "do przodu" */
  --accent-ink: #ffffff;
  --display-bg: #13201b;  /* panel wyświetlacza dystrybutora */
  --display-digit: #7ff0b0;
  --display-dim: #3b5a4d;
  --warn-bg: #fff3c4;
  --warn-ink: #5c4500;
  --danger: #b3261e;
  --focus: #1b5cff;
  --radius-s: 6px;
  --radius-m: 12px;
  --gutter: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--ground);
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #101614;
    --surface: #1a2320;
    --ink: #e7eeeb;
    --ink-soft: #a3b2ac;
    --line: #2f3d38;
    --accent: #3fbf8a;
    --accent-ink: #0c1512;
    --display-bg: #050a08;
    --warn-bg: #3d3100;
    --warn-ink: #ffe28a;
    --danger: #ff8a80;
    --focus: #8ab4ff;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--ground); }
body { font-size: 17px; line-height: 1.45; padding-bottom: env(safe-area-inset-bottom); }
[hidden] { display: none !important; }

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

h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.875rem; }

/* ---------- Pasek górny ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  background: #1d2a26; color: #e8efec;
}
.brand { font-weight: 700; }
.who { margin-left: auto; font-size: 0.9rem; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .link { color: #e8efec; }

.offline, .demo-banner {
  padding: 10px var(--gutter); font-size: 0.95rem;
  background: var(--warn-bg); color: var(--warn-ink); border-bottom: 1px solid var(--line);
}

main { max-width: 560px; margin: 0 auto; padding: 20px var(--gutter) 40px; outline: none; }
main.wide { max-width: 1180px; }

/* ---------- Formularze ---------- */
label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=date], input[type=month], input[type=number], select, textarea {
  width: 100%; font: inherit; font-size: 1.05rem; color: var(--ink);
  padding: 12px 14px; min-height: 50px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-s);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.field { margin-bottom: 18px; }
.hint { font-size: 0.875rem; color: var(--ink-soft); margin-top: 6px; }
.error-text { color: var(--danger); font-weight: 600; margin: 8px 0 0; }

button { font: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 12px 20px; width: 100%;
  font-weight: 700; font-size: 1.05rem;
  border: 0; border-radius: var(--radius-m);
  background: var(--accent); color: var(--accent-ink);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.small { min-height: 40px; padding: 8px 14px; width: auto; font-size: 0.95rem; border-radius: var(--radius-s); }
.btn.danger { background: var(--danger); color: #fff; }
.link { background: none; border: 0; padding: 6px 4px; color: var(--accent); text-decoration: underline; font-size: 0.95rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px; }

/* ---------- Logowanie ---------- */
.login { padding-top: 8vh; }
.login h1 { font-size: 2rem; }
.login .lede { color: var(--ink-soft); margin-bottom: 28px; }

/* ---------- Kroki kierowcy ---------- */
.steps { list-style: none; margin: 18px 0 0; padding: 0; }
.step { position: relative; padding: 0 0 26px 46px; }
.step::before {
  content: attr(data-n);
  position: absolute; left: 0; top: -2px;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 0.95rem;
  background: var(--surface); border: 2px solid var(--line); color: var(--ink-soft);
}
.step::after { content: ""; position: absolute; left: 15px; top: 34px; bottom: 4px; width: 2px; background: var(--line); }
.step:last-child::after { display: none; }
.step.done::before { content: "✓"; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step.active::before { border-color: var(--accent); color: var(--accent); }
.step.locked { opacity: 0.45; pointer-events: none; }
.step h2 { font-size: 1.1rem; margin: 2px 0 10px; }

.photo-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 150px; padding: 18px; text-align: center;
  border: 2px dashed var(--line); border-radius: var(--radius-m); background: var(--surface);
  font-weight: 700; font-size: 1.1rem; color: var(--ink);
}
.photo-drop svg { width: 40px; height: 40px; }
.photo-drop small { font-weight: 400; color: var(--ink-soft); font-size: 0.875rem; }
.photo-preview { display: flex; gap: 12px; align-items: center; }
.photo-preview img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius-s); border: 1px solid var(--line); }

/* Pole litrów – wygląd wyświetlacza dystrybutora */
.pump {
  background: var(--display-bg); border-radius: var(--radius-m); padding: 14px 16px 12px;
  box-shadow: inset 0 0 0 3px #2a3832;
}
.pump-row { display: flex; align-items: baseline; gap: 10px; }
.pump input {
  flex: 1; min-width: 0; background: transparent; border: 0; padding: 0; min-height: 0;
  color: var(--display-digit); text-align: right;
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  font-size: clamp(2.6rem, 13vw, 3.4rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.04em;
  text-shadow: 0 0 12px color-mix(in srgb, var(--display-digit) 45%, transparent);
}
.pump input::placeholder { color: var(--display-dim); text-shadow: none; }
.pump input:focus { box-shadow: none; outline: none; }
.pump:focus-within { box-shadow: inset 0 0 0 3px var(--display-digit); }
.pump-unit { color: var(--display-digit); font-weight: 700; font-size: 1.4rem; }
.pump-note { color: #9fb8ad; font-size: 0.85rem; margin-top: 4px; }

.fuel-choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fuel-choice input { position: absolute; opacity: 0; pointer-events: none; }
.fuel-choice label {
  display: grid; place-items: center; min-height: 60px; margin: 0;
  border: 2px solid var(--line); border-radius: var(--radius-m); background: var(--surface);
  font-size: 1.1rem; font-weight: 700; cursor: pointer;
}
.fuel-choice input:checked + label { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.fuel-choice input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }

.plate-input { text-transform: uppercase; font-weight: 700; letter-spacing: 0.06em; }

.history { margin-top: 30px; }
.history ul { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.history .l { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.success { text-align: center; padding-top: 6vh; }
.success .big { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; margin: 10px 0; }

/* ---------- Panel administratora ---------- */
.tabs { display: flex; gap: 4px; margin: 0 0 18px; border-bottom: 2px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button {
  background: none; border: 0; padding: 12px 14px; font-weight: 600; color: var(--ink-soft);
  border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap;
}
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { margin: 0; min-width: 150px; }
.toolbar .field input, .toolbar .field select { min-height: 42px; padding: 8px 10px; font-size: 0.95rem; }
.toolbar .spacer { flex: 1; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 600; color: var(--ink-soft); background: color-mix(in srgb, var(--ground) 60%, var(--surface)); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
tr.voided td { text-decoration: line-through; color: var(--ink-soft); }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
td.zero { color: var(--ink-soft); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--warn-bg); color: var(--warn-ink); }
.tag.neutral { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink-soft); }
.empty { padding: 30px; text-align: center; color: var(--ink-soft); }

/* Okno szczegółów */
dialog {
  width: min(920px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); color: var(--ink);
}
dialog::backdrop { background: rgba(10, 16, 14, 0.55); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.dlg-head h2 { margin: 0; }
.dlg-body { padding: 18px; display: grid; gap: 22px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .dlg-body { grid-template-columns: 1.1fr 1fr; } }
.dlg-photo img { width: 100%; border-radius: var(--radius-s); border: 1px solid var(--line); background: #000; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 18px; }
dl.facts dt { color: var(--ink-soft); }
dl.facts dd { margin: 0; font-weight: 600; }
.corrections { list-style: none; margin: 0; padding: 0; font-size: 0.92rem; }
.corrections li { padding: 8px 0; border-bottom: 1px solid var(--line); }
pre.ocr { white-space: pre-wrap; font-size: 0.8rem; background: var(--ground); padding: 8px; border-radius: var(--radius-s); max-height: 140px; overflow: auto; }

.temp-pass { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.3rem; font-weight: 700; padding: 10px; background: var(--ground); border-radius: var(--radius-s); user-select: all; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: var(--radius-m);
  background: #1d2a26; color: #f0f5f3; font-weight: 600; z-index: 50;
}
.toast.error { background: var(--danger); color: #fff; }

.spinner { width: 20px; height: 20px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.pad { padding: 18px; }
.brand { white-space: nowrap; }
.plate-input::placeholder { text-transform: none; letter-spacing: 0; font-weight: 400; }
@media (max-width: 420px) { .brand { font-size: 0.95rem; } }
.pump-label { color: #9fb8ad; font-size: 0.85rem; font-weight: 600; margin-top: 2px; }
.pump-row + .pump-label { margin-top: 10px; padding-top: 8px; border-top: 1px solid #2a3832; }
.pump-price { color: var(--display-digit); font-size: 0.9rem; font-weight: 600; margin: 10px 0 0; min-height: 1.2em; }
.pump-price.bad { color: #ffb4a8; }
.success .big-sub { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: -4px 0 10px; color: var(--ink-soft); }
