:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #16202c;
  --muted: #5d6b7a;
  --border: #dde3ea;
  --primary: #1760d4;
  --primary-text: #ffffff;
  --ok: #17803d;
  --ok-bg: #e3f6ea;
  --warn: #9a5b00;
  --warn-bg: #fff3dc;
  --bad: #b3261e;
  --bad-bg: #fde7e5;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161d;
    --card: #1a212b;
    --text: #e8edf3;
    --muted: #9aa8b7;
    --border: #2c3643;
    --primary: #4b8df8;
    --ok: #5fd08a;
    --ok-bg: #173323;
    --warn: #f0b457;
    --warn-bg: #3a2c12;
    --bad: #ff8a80;
    --bad-bg: #3d1a18;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* ----- Customer (mobile-first) ----- */
.narrow { max-width: 480px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; margin: 8px 0 16px; font-weight: 700; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 8px; background: var(--primary); color: var(--primary-text);
  display: grid; place-items: center; font-size: 22px; font-weight: 800;
}
label { display: block; font-weight: 600; margin: 0 0 6px; }
input, select {
  font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.plate-input {
  font-size: 1.8rem; font-weight: 700; letter-spacing: .08em; text-align: center; text-transform: uppercase;
  padding: 14px;
}
.plate-input::placeholder { text-transform: none; letter-spacing: normal; font-size: 1.2rem; font-weight: 500; }
.stepper { display: grid; grid-template-columns: 64px 1fr 64px; gap: 10px; align-items: center; }
.stepper button { font-size: 1.8rem; height: 64px; }
.stepper .value { text-align: center; font-size: 1.6rem; font-weight: 700; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row .v { font-weight: 600; text-align: right; }
.total { font-size: 1.4rem; font-weight: 800; }

button, .btn {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); padding: 10px 14px; text-decoration: none; display: inline-block;
}
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 700; }
button.big, .btn.big { width: 100%; padding: 16px; font-size: 1.15rem; text-align: center; }
button:disabled { opacity: .55; cursor: default; }

.alert { padding: 12px 14px; border-radius: 8px; margin: 12px 0; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.muted { background: var(--bg); color: var(--muted); }

.ticket-plate { font-size: 2.2rem; font-weight: 800; letter-spacing: .08em; text-align: center; margin: 8px 0; }
.countdown { font-size: 2.4rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }

.extend-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-top: 8px; }
.extend-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px;
  border: 1px solid var(--primary); border-radius: 10px;
}
.extend-btn .plus { font-size: 1.2rem; font-weight: 800; color: var(--primary); }
.extend-btn:active { background: var(--bg); }

.zone-list a {
  display: flex; justify-content: space-between; align-items: center; text-decoration: none; color: inherit;
}

/* ----- Admin ----- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--border);
}
.topbar .brand { margin: 0; }
.wide { max-width: 1280px; margin: 0 auto; padding: 20px 16px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button.active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; }
.stat.selected { outline: 2px solid var(--primary); }
.stat .n { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.filters > div { min-width: 150px; }
.filters input, .filters select { width: auto; min-width: 150px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.plate { font-weight: 800; letter-spacing: .05em; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.checkbox input { width: auto; }
.actions { display: flex; gap: 6px; }
.hours-grid { display: grid; gap: 6px; max-width: 560px; }
.hours-row { display: grid; grid-template-columns: 140px 110px auto 110px 1fr; gap: 8px; align-items: center; }
.hours-row .checkbox { margin: 0; font-weight: 500; }
.hours-row input[type=time] { padding: 6px 8px; }
.hours-row input:disabled { opacity: .4; }
.hours-row button { padding: 6px 10px; justify-self: start; }
@media (max-width: 640px) {
  .hours-row { grid-template-columns: 1fr 1fr auto 1fr; }
  .hours-row > :last-child { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .filters > div, .filters input, .filters select { width: 100%; }
}

.reminder-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.reminder-row button { flex: none; }

.card.compact { padding: 14px 16px; margin-bottom: 12px; }
.reminder-check { margin: 4px 2px 14px; font-weight: 500; }
.reminder-check input { width: 20px; height: 20px; }

.receipt-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; margin-bottom: 12px; }
.receipt-actions button { padding: 14px 10px; font-size: 1.05rem; }

/* ----- Kontrola (warden) ----- */
.zone-select { margin-bottom: 12px; font-weight: 700; }
.check-result { border-radius: var(--radius); padding: 18px; margin-bottom: 12px; text-align: center; color: #fff; }
.check-result.paid { background: #17803d; }
.check-result.expired, .check-result.unpaid { background: #b3261e; }
.check-result.free { background: #5d6b7a; }
.check-result .r-plate { font-size: 1.6rem; font-weight: 800; letter-spacing: .08em; }
.check-result .r-title { font-size: 2.2rem; font-weight: 900; line-height: 1.1; margin: 4px 0; }
.check-result .r-detail { font-size: 1.05rem; }
.check-result .other-zone { margin-top: 10px; padding: 8px; border-radius: 8px; background: #ffb300; color: #1a1a1a; font-weight: 700; }
.camera { position: relative; margin-bottom: 10px; border-radius: 10px; overflow: hidden; background: #000; }
.camera video { width: 100%; display: block; }
.camera .frame {
  position: absolute; left: 10%; width: 80%; top: 50%; aspect-ratio: 4 / 1; transform: translateY(-50%);
  border: 3px solid #4bd37b; border-radius: 8px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35);
}
.camera-status { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px; text-align: center; color: #fff; background: rgba(0, 0, 0, .55); font-weight: 600; }
.scan-buttons { display: flex; gap: 8px; }
.scan-buttons .big { flex: 1; }
.suggest { margin-top: 10px; padding: 10px; border-radius: 8px; background: var(--warn-bg); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.manual { display: flex; gap: 8px; margin-top: 10px; }
.manual .plate-input { font-size: 1.3rem; padding: 10px; }
.active-list { display: grid; gap: 6px; margin-top: 10px; }
.active-item { display: flex; justify-content: space-between; text-align: left; }
.history-row { display: grid; grid-template-columns: 50px 1fr auto; gap: 8px; align-items: center; padding: 4px 0; }

.sms-field { margin: 0 2px 14px; }
.sms-field input { margin: 4px 0; }
