:root {
  --bg: #f3f5f4;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e3e7e5;
  --accent: #0b7a4b;
  --accent-text: #ffffff;
  --error: #b91c1c;
  --note: #fef3c7;

  --free: #0b7a4b;
  --free-bg: #e7f5ee;
  --held: #b45309;
  --held-bg: #fdf3e2;
  --occupied: #6b7280;
  --occupied-bg: #eef0f2;
  --yours: #1d5fbf;
  --yours-bg: #e6eefb;
  --asphalt: #d8dcda;
  --lane: #ffffff;

  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412;
    --card: #18201d;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #2b3632;
    --accent: #3fbf86;
    --accent-text: #0e1412;
    --error: #f87171;
    --note: #3a3220;

    --free: #3fbf86;
    --free-bg: #15291f;
    --held: #f0a64a;
    --held-bg: #33261a;
    --occupied: #9ca3af;
    --occupied-bg: #22292b;
    --yours: #6ea8fe;
    --yours-bg: #172338;
    --asphalt: #252d2a;
    --lane: #4a5550;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif; }
.shell { max-width: 860px; margin: 0 auto; padding: 28px 16px 64px; }

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand svg { width: 34px; height: 34px; fill: var(--accent); flex: none; }
.brand h1 { margin: 0; font-size: 1.6rem; }
.who { margin-left: auto; }
h2 { margin: 0 0 14px; font-size: 1.25rem; }
.eyebrow { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; }
.note { background: var(--note); padding: 10px 14px; border-radius: 8px; font-size: .9rem; }
.count { color: var(--muted); font-weight: 500; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; }
.card.narrow { max-width: 440px; }

label { display: block; margin: 16px 0 6px; font-weight: 600; }
label.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; margin: 10px 0; }
label.check input { width: 18px; height: 18px; }
input, select { padding: 8px 10px; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
form input:not([type=checkbox]) { width: 100%; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button, .button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); padding: 8px 16px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { border: none; background: none; color: var(--accent); padding: 8px 4px; }
button.danger { color: var(--error); }
.button.ms { width: 100%; padding: 12px; margin-top: 8px; }
.button.ms svg { width: 20px; height: 20px; }

.actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.actions.end { justify-content: flex-end; }
.error { color: var(--error); margin: 12px 0 0; }
.error.banner { background: var(--card); border: 1px solid var(--error); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; }

/* ---------- My reservation / offer / queue status ---------- */
.mine { border-color: var(--yours); }
.mine h2, .offer h2, .queued h2 { margin: 2px 0 0; }
.mine-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.remaining { text-align: right; font-size: 1.8rem; font-weight: 700; color: var(--yours); line-height: 1.1; font-variant-numeric: tabular-nums; }
.remaining small { display: block; font-size: .8rem; font-weight: 500; color: var(--muted); }
.remaining.soon { color: var(--held); }
.progress { height: 8px; border-radius: 4px; background: var(--yours-bg); margin: 14px 0 8px; overflow: hidden; }
.progress div { height: 100%; background: var(--yours); width: 0; transition: width .4s; }
.adjust { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.adjust-label { color: var(--muted); font-size: .9rem; margin-right: 4px; }
.adjust #mine-release { margin-left: auto; }
.offer { border-color: var(--held); background: var(--held-bg); }
.offer .eyebrow { color: var(--held); }
.queued { border-color: var(--held); }

/* ---------- Parking lot ---------- */
.lot-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 14px; }
.lot-head h2 { margin: 0; }
.lot { display: grid; gap: 14px 0; background: var(--asphalt); border-radius: 10px; padding: 14px; }
.lane { grid-row: 1 / -1; align-self: stretch; justify-self: center; width: 4px; background: repeating-linear-gradient(to bottom, var(--lane) 0 18px, transparent 18px 34px); border-radius: 2px; }

.spot { background: var(--card); border: 2px solid var(--border); border-radius: 10px; padding: 14px 16px; min-height: 150px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.spot-head { display: flex; align-items: center; gap: 8px; }
.spot-head svg { width: 22px; height: 22px; flex: none; }
.spot-name { font-weight: 700; }
.badge { margin-left: auto; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.spot-info { color: var(--muted); font-size: .92rem; flex: 1; }
.spot-info strong { color: var(--text); font-weight: 600; }
.spot button { align-self: flex-start; }

.spot.free { border-color: var(--free); background: var(--free-bg); }
.spot.free svg { fill: var(--free); }
.spot.free .badge { background: var(--free); color: var(--accent-text); }
.spot.held { border-color: var(--held); background: var(--held-bg); }
.spot.held svg { fill: var(--held); }
.spot.held .badge { background: var(--held); color: var(--card); }
.spot.occupied { border-color: var(--border); background: var(--occupied-bg); }
.spot.occupied svg { fill: var(--occupied); }
.spot.occupied .badge { background: var(--occupied); color: var(--card); }
.spot.yours { border-color: var(--yours); background: var(--yours-bg); }
.spot.yours svg { fill: var(--yours); }
.spot.yours .badge { background: var(--yours); color: var(--card); }

.lot-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.legend { color: var(--muted); font-size: .85rem; display: inline-flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.free { background: var(--free); }
.legend i.held { background: var(--held); }
.legend i.occupied { background: var(--occupied); }
.legend i.yours { background: var(--yours); }

/* ---------- Queue & history ---------- */
.queue { margin: 0; padding: 0; list-style: none; }
.queue li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.queue li:last-child { border-bottom: none; }
.queue .pos { width: 28px; height: 28px; border-radius: 50%; background: var(--occupied-bg); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.queue .me .pos { background: var(--yours); color: var(--card); }
.queue .sub { color: var(--muted); font-size: .88rem; margin-left: auto; text-align: right; }
.queue .sub.held { color: var(--held); font-weight: 600; }

details.card > summary { cursor: pointer; font-weight: 600; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--text); padding: 22px; width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .4); }

@media (max-width: 560px) {
  .shell { padding-top: 18px; }
  .card { padding: 16px; }
  .lot { padding: 10px; }
  .spot { padding: 10px; min-height: 140px; font-size: .92rem; }
  .badge { position: absolute; top: -10px; right: 8px; }
  .remaining { font-size: 1.4rem; }
  .adjust #mine-release { margin-left: 0; }
}

/* ---------- Reserving for an external guest ---------- */
.reserve-opts { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.guest-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; margin: -4px 0 14px; padding: 12px 14px; border-radius: 10px; background: var(--yours-bg); }
.guest-fields label { margin: 0 0 4px; font-weight: 600; font-size: .9rem; }
.guest-fields label .muted { font-weight: 400; }
.guest-fields input { display: block; width: 100%; margin-top: 4px; }
.guest-fields .hint { grid-column: 1 / -1; margin: 6px 0 0; }
.mine.guest .eyebrow { color: var(--yours); }
.mine + .mine { margin-top: -4px; }
@media (max-width: 560px) { .guest-fields { grid-template-columns: 1fr; } }

/* ---------- All chargers occupied: join the queue ---------- */
.full { border-color: var(--held); }
.full .eyebrow { color: var(--held); }
.full h2 { margin: 2px 0 8px; }
.full p { margin: 0 0 8px; }
