:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dbe1e8;
  --line-strong: #9aa6b5;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --free: #1fa855;
  --free-soft: #dcf5e5;
  --taken: #e0434b;
  --taken-soft: #fde4e5;
  --mine: #2563eb;
  --mine-soft: #dde8fd;
  --slot-other: #e6eaf0;
  --slot-other-text: #8a96a6;
  --wall: #4b5563;
  --road: #f3f5f8;
  --floor: #eceff3;
  --pavement: #e9ebe6;
  --grass: #cfe6c4;
  --grass-dot: #a9d39a;
  --curb: #b7bdb3;
  --asphalt-1: #545d6c;
  --asphalt-2: #434b58;
  --bay: #b3bcc8;
  --block-bg: #dde2e9;
  --block-line: #bcc4cf;
  --free-ink: #13753a;
  --taken-ink: #a8232a;
  --mine-ink: #1d4ed8;
  --hero-1: #0f172a;
  --hero-2: #1e3a8a;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1120;
    --surface: #131b2c;
    --surface-2: #182236;
    --text: #e6eaf2;
    --muted: #8d9ab0;
    --line: #253049;
    --line-strong: #46536e;
    --accent: #4f8bff;
    --free: #22b45e;
    --free-soft: #133524;
    --taken: #e5525a;
    --taken-soft: #3b1a1d;
    --mine: #4f8bff;
    --mine-soft: #18284a;
    --slot-other: #1b2539;
    --slot-other-text: #56637c;
    --wall: #6b7891;
    --road: #10182a;
    --floor: #151e30;
    --pavement: #182133;
    --grass: #183324;
    --grass-dot: #23503a;
    --curb: #2d3a52;
    --asphalt-1: #2a3345;
    --asphalt-2: #222a3a;
    --bay: #3c4a64;
    --block-bg: #1c2638;
    --block-line: #2c3a54;
    --free-ink: #6ee7a0;
    --taken-ink: #ffa3a8;
    --mine-ink: #a5c4ff;
    --hero-1: #070b16;
    --hero-2: #172a63;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }

.boot { padding: 40vh 16px 0; text-align: center; color: var(--muted); }

/* ---------- hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(120% 90% at 85% 110%, rgba(96, 165, 250, 0.35), transparent 60%),
    linear-gradient(160deg, var(--hero-1) 30%, var(--hero-2));
  padding: calc(14px + env(safe-area-inset-top)) 16px 56px;
}
.hero .scene {
  position: absolute;
  right: max(0px, calc(50% - 400px));
  bottom: 30px;
  width: 190px;
  height: auto;
  pointer-events: none;
}
@media (max-width: 480px) { .hero .scene { width: 136px; right: 4px; bottom: 32px; } }
.hero-inner { max-width: 760px; margin: 0 auto; position: relative; z-index: 1; }
.hero-top { display: flex; align-items: center; gap: 10px; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: #2563eb; display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.hero h1 { font-size: 20px; margin: 0; letter-spacing: 0.2px; }
.hero .who { margin-left: auto; font-size: 13px; opacity: 0.85; display: flex; gap: 8px; align-items: center; }
.hero .who button { background: rgba(255, 255, 255, 0.12); border: 0; border-radius: 8px; padding: 4px 9px; color: #fff; cursor: pointer; font-size: 12px; }
.hero .status { margin-top: 14px; font-size: 15px; max-width: 70%; }
.hero .status b { font-weight: 650; }

/* ---------- layout ---------- */
main { max-width: 760px; margin: -34px auto 0; padding: 0 16px calc(40px + env(safe-area-inset-bottom)); position: relative; z-index: 2; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.card h2 { font-size: 15px; margin: 0 0 10px; }
.card h3 { font-size: 13px; margin: 14px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.tabs { display: flex; gap: 6px; background: var(--surface); border-radius: 12px; padding: 4px; box-shadow: var(--shadow); margin-bottom: 14px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); position: relative; }
.tabs button.on { background: var(--accent); color: var(--accent-text); }
.dot { display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--taken); color: #fff; font-size: 11px; line-height: 18px; margin-left: 6px; }

.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button small { display: block; font-weight: 500; font-size: 12px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.summary { display: flex; align-items: baseline; justify-content: space-between; margin: 12px 2px 8px; gap: 10px; }
.summary .big { font-size: 22px; font-weight: 750; }
.summary .big span { color: var(--free); }

/* ---------- map ---------- */
.map-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; -webkit-overflow-scrolling: touch; }
.map { display: block; width: 100%; min-width: 660px; height: auto; font-family: inherit; }
.map .floor { fill: var(--floor); stroke: var(--line); }
.map .outdoor { fill: var(--pavement); stroke: var(--line); }
.map .grass-bg { fill: var(--grass); }
.map .grass-dot { fill: var(--grass-dot); }
.map .curb { stroke: var(--curb); stroke-width: 3; }
.map .asphalt-1 { stop-color: var(--asphalt-1); }
.map .asphalt-2 { stop-color: var(--asphalt-2); }
.map .road-edge { stroke: rgba(255, 255, 255, 0.55); stroke-width: 2; }
.map .lane { stroke: rgba(255, 255, 255, 0.8); stroke-width: 3; stroke-dasharray: 22 16; }
.map .road-arrow { stroke: rgba(255, 255, 255, 0.75); stroke-width: 4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.map .zone-pill rect { fill: var(--surface); stroke: var(--line); }
.map .zone-pill text { fill: var(--text); font-size: 14px; font-weight: 700; letter-spacing: 0.3px; }
.map .block { fill: url(#hatch); stroke: var(--block-line); stroke-width: 1.5; }
.map .wall { fill: var(--wall); }
.map .wall-line { stroke: var(--wall); stroke-width: 5; fill: none; stroke-linecap: round; }
.map .stair { stroke: var(--block-line); stroke-width: 2; }
.map .block-label { font-size: 12px; fill: var(--muted); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.map .pillar { fill: var(--wall); }
.map .hatch-bg { fill: var(--block-bg); }
.map .hatch-line { stroke: var(--block-line); stroke-width: 2; }
.map .ramp { fill: url(#ramp); stroke: var(--block-line); stroke-width: 1.5; }
.map .ramp-arrow { stroke: #fff; stroke-width: 4; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.map .ramp-label { font-size: 11px; font-weight: 700; fill: #fff; letter-spacing: 1px; text-anchor: middle; }
.map .barrier-bar { fill: #fff; stroke: #dc2626; stroke-width: 2; stroke-dasharray: 9 9; }
.map .barrier-post { fill: #dc2626; stroke: #fff; stroke-width: 2; }
.map .ramp-1 { stop-color: var(--asphalt-1); }
.map .ramp-2 { stop-color: var(--asphalt-2); }

.spot .bay { fill: none; stroke: var(--bay); stroke-width: 3; stroke-linecap: square; }
.spot .bay-num { fill: var(--slot-other-text); font-size: 14px; font-weight: 700; text-anchor: middle; }
.spot .dis-sign rect { fill: #2563eb; }
.spot .dis-sign circle { fill: #fff; }
.spot .dis-sign path { stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.map .street-lane { stroke: rgba(255, 255, 255, 0.7); stroke-width: 2; stroke-dasharray: 14 10; }
.map .street-name { font-size: 10px; font-weight: 700; fill: rgba(255, 255, 255, 0.75); letter-spacing: 1px; text-transform: uppercase; }
.map .map-note { font-size: 12px; font-weight: 600; fill: var(--muted); }
.map .bike-pad { fill: var(--floor); stroke: var(--line); }
.map .rack { stroke: var(--line-strong); stroke-width: 3; stroke-linecap: round; }
.map .bike .tire { fill: var(--text); opacity: 0.6; }
.map .bike .crank { stroke: var(--muted); stroke-width: 1.5; }
.map .bike .pedal, .map .bike .grip, .map .bike .saddle { fill: var(--text); opacity: 0.65; }
.map .bike .bar { fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; opacity: 0.8; }

.spot.ours { cursor: pointer; outline: none; }
.spot .tile { stroke-width: 2; filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.18)); transition: transform 0.15s; }
.spot.free .tile { fill: var(--free-soft); stroke: var(--free); }
.spot.booked .tile, .spot.owner .tile { fill: var(--taken-soft); stroke: var(--taken); }
.spot.mine .tile { fill: var(--mine-soft); stroke: var(--mine); }
.spot.inactive .tile { fill: url(#hatch); stroke: var(--line-strong); }
.spot.ours:hover .tile, .spot.ours:focus-visible .tile { stroke-width: 3.5; }

.spot .num-pill rect { fill: var(--surface); }
.spot .num-pill text { font-size: 13px; font-weight: 800; text-anchor: middle; fill: var(--text); }
.spot .who { font-size: 12.5px; font-weight: 700; text-anchor: middle; }
.spot.free .who, .spot.free .free-t { fill: var(--free-ink); }
.spot.booked .who, .spot.owner .who { fill: var(--taken-ink); }
.spot.mine .who { fill: var(--mine-ink); }
.spot .muted-t { fill: var(--slot-other-text); font-size: 11px; }
.spot .free-mark circle { fill: var(--free); }
.spot .free-mark .p { fill: #fff; font-size: 18px; font-weight: 800; text-anchor: middle; }
.spot .free-t { font-size: 11px; font-weight: 800; letter-spacing: 1px; text-anchor: middle; }

.car { --car: var(--taken); }
.spot.mine .car { --car: var(--mine); }
.car .car-body, .car .car-mirror { fill: var(--car); }
.car .car-roof { fill: color-mix(in srgb, var(--car) 78%, #000); }
.car .car-glass { fill: #1e293b; opacity: 0.82; }
.car .car-light { fill: #fde68a; }
.car .car-shadow { fill: rgba(15, 23, 42, 0.22); transform: translate(1.5px, 2.5px); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }

/* ---------- spot list ---------- */
.spots { display: grid; gap: 8px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.badge { flex: none; width: 48px; height: 48px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 16px; line-height: 1; text-align: center; }
.badge small { display: block; font-size: 9px; font-weight: 600; opacity: 0.85; margin-top: 2px; }
.badge.free { background: var(--free); }
.badge.booked, .badge.owner { background: var(--taken); }
.badge.mine { background: var(--mine); }
.badge.inactive { background: var(--slot-other); color: var(--slot-other-text); }
.row .info { flex: 1 1 160px; min-width: 0; }
.row .title { font-weight: 650; }
.row .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.row .acts:empty { display: none; }

/* ---------- controls ---------- */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 13px; border-radius: 10px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.go { background: var(--free); border-color: var(--free); color: #fff; }
.btn.danger { color: var(--taken); }
.btn.danger.solid { background: var(--taken); border-color: var(--taken); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; padding: 12px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: default; }

input[type='text'], input[type='date'], input[type='password'], select {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 10px; min-width: 0;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); flex: 1 1 130px; }
.form label.check { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; color: var(--text); font-size: 14px; padding-bottom: 9px; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }

.list { display: grid; gap: 6px; }
.item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; flex-wrap: wrap; }
.item .grow { flex: 1; min-width: 140px; }
.chip { display: inline-block; font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); margin-left: 4px; vertical-align: 1px; }
.chip.warn { background: var(--taken-soft); color: var(--taken); border-color: transparent; }
.chip.ok { background: var(--free-soft); color: var(--free); border-color: transparent; }
.chip.blue { background: var(--mine-soft); color: var(--mine); border-color: transparent; }
.notice { background: var(--taken-soft); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 2px; }

/* ---------- pin ---------- */
.pin-screen { max-width: 360px; margin: 0 auto; padding: 0 16px; }
.pin-screen .card { padding: 22px 18px; text-align: center; }
.pin-input { width: 100%; text-align: center; font-size: 30px; letter-spacing: 14px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); margin: 14px 0; }
.pin-field { display: block; font-size: 13px; color: var(--muted); margin-top: 8px; }
.pin-field .pin-input { margin: 4px 0 0; font-size: 22px; letter-spacing: 10px; padding: 8px; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 8px; font-size: 14px; }
.error { color: var(--taken); font-size: 14px; min-height: 20px; }

/* ---------- dialog / toast ---------- */
dialog {
  border: 0; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  width: 100%; max-width: 520px; margin: auto auto 0; background: var(--surface); color: var(--text);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.25);
}
@media (min-width: 600px) { dialog { border-radius: 18px; margin: auto; } }
dialog::backdrop { background: rgba(2, 6, 23, 0.5); }
dialog h2 { margin: 0 0 4px; font-size: 18px; }
dialog .acts { display: grid; gap: 8px; margin-top: 16px; }
dialog textarea { width: 100%; min-height: 120px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--surface-2); font: 14px/1.4 ui-monospace, Consolas, monospace; color: var(--text); resize: vertical; }
#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: 0.2s; max-width: calc(100% - 32px); z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--taken); color: #fff; }

/* ---------- notifications / push / admin day ---------- */
.notes { border-left: 4px solid var(--accent); }
.note-item { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.push-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.push-card > div:first-child { flex: 1 1 200px; }
.push-card .acts { display: flex; gap: 6px; }
.other-day { display: flex; align-items: center; gap: 8px; margin-top: 8px; justify-content: flex-end; }
.other-day input { padding: 5px 8px; }
