/* =====================================================================
   APP STYLES (app.html) — driver, owner, guard and admin screens
   ===================================================================== */
html, body { height: 100%; }
body { overflow-x: hidden; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 60; background: var(--surface); }

.app { min-height: 100%; display: grid; grid-template-columns: 240px 1fr; grid-template-rows: auto 1fr; }
.topbar { grid-column: 1 / -1; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .75rem; min-height: 60px; padding-left: var(--gutter-l); padding-right: var(--gutter-r); }
.topbar .logo-text { font-size: 1.25rem; }
.topbar .spacer { flex: 1; }
.mode-badge { font: 700 10px/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; padding: .35rem .5rem; border-radius: 4px; background: var(--marking); color: var(--marking-ink); }
.mode-badge.live { background: var(--ok-soft); color: var(--ok); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--sign-soft); color: var(--sign); display: grid; place-items: center; font: 700 .9rem/1 var(--f-body); border: 0; cursor: pointer; flex: none; }

.sidenav { border-right: 1px solid var(--line); background: var(--surface); padding: 1rem .75rem; display: flex; flex-direction: column; gap: .15rem; position: sticky; top: calc(60px + env(safe-area-inset-top, 0px)); height: calc(100vh - 60px - env(safe-area-inset-top, 0px)); overflow-y: auto; }
.sidenav .grp { font: 600 10px/1 var(--f-mono); text-transform: uppercase; letter-spacing: .14em; color: var(--muted); padding: 1rem .75rem .5rem; }
.sidenav a { display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem; border-radius: var(--r-sm); text-decoration: none; color: var(--ink); font-weight: 500; font-size: var(--t-sm); }
.sidenav a:hover { background: var(--surface-2); }
.sidenav a.on { background: var(--sign-soft); color: var(--sign); font-weight: 600; }
.sidenav a svg { width: 18px; height: 18px; flex: none; }
.sidenav .foot { margin-top: auto; padding: .75rem; font-size: var(--t-xs); color: var(--muted); display: grid; gap: .5rem; }

.main { min-width: 0; padding-block: 1.25rem 6rem; padding-left: var(--gutter-l); padding-right: var(--gutter-r); }
.view { max-width: 1040px; margin-inline: auto; display: grid; gap: 1.25rem; }
.view.narrow { max-width: 560px; }

.tabbar { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidenav { display: none; }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: .55rem .25rem .5rem; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--sign); }
  .tabbar a.on svg { stroke-width: 2.4; }
}

/* ---------- Common blocks ---------- */
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-title h1 { font-size: clamp(2rem, 5vw, 2.8rem); text-transform: uppercase; }
.page-title p { color: var(--muted); margin-top: .35rem; }
.back { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); text-decoration: none; font-size: var(--t-sm); font-weight: 500; }
.back:hover { color: var(--ink); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.1rem; display: grid; gap: .85rem; min-width: 0; align-content: start; }
.card h2 { font-size: 1.5rem; text-transform: uppercase; }
.card h3 { font-size: 1.2rem; font-family: var(--f-body); font-weight: 700; letter-spacing: 0; }
.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: .75rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.two > *, .three > * { min-width: 0; }
@media (max-width: 720px) { .two, .three { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .45rem 1rem; font-size: var(--t-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 0; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); display: grid; gap: .75rem; justify-items: center; border: 1.5px dashed var(--line); border-radius: var(--r-lg); }
.empty h3 { color: var(--ink); font-family: var(--f-display); font-size: 1.6rem; text-transform: uppercase; }
.banner { padding: .8rem 1rem; border-radius: var(--r-md); font-size: var(--t-sm); display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.banner.demo { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--sign-soft); color: var(--sign); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--r-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); font: 600 var(--t-xs)/1 var(--f-body); padding: .55rem .8rem; border-radius: 5px; cursor: pointer; min-height: 34px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .1); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--sign); border-radius: 50%; animation: spin .8s linear infinite; margin: 3rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Metric tiles (owner/admin) */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.tile { background: var(--surface); padding: 1rem; display: grid; gap: .3rem; min-width: 0; }
.tile .v { font: 800 2rem/1 var(--f-display); font-variant-numeric: tabular-nums; }
.tile .l { font-size: var(--t-xs); color: var(--muted); }
.tile.alert .v { color: var(--bad); }
@media (max-width: 720px) { .tiles { grid-template-columns: 1fr 1fr; } }

/* ---------- Explore ---------- */
.filters { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.2fr; gap: .6rem; align-items: end; }
.filters .field label { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.filters > * { min-width: 0; }
@media (max-width: 760px) { .filters { grid-template-columns: 1fr 1fr; } .filters .field:first-child, .filters .field:last-child { grid-column: 1 / -1; } }
.explore { display: grid; grid-template-columns: 1fr 380px; gap: 1rem; align-items: start; }
.explore > * { min-width: 0; }
.mapbox { height: min(64vh, 560px); border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); position: sticky; top: calc(76px + env(safe-area-inset-top, 0px)); }
.spot-list { display: grid; gap: .6rem; max-height: min(64vh, 560px); overflow-y: auto; padding-right: 2px; }
@media (max-width: 960px) { .explore { grid-template-columns: 1fr; } .mapbox { position: relative; top: 0; height: 46vh; } .spot-list { max-height: none; } }
.mobile-switch { display: none; }
@media (max-width: 960px) { .mobile-switch { display: inline-flex; } .explore[data-show="list"] .mapbox, .explore[data-show="map"] .spot-list { display: none; } }

.spot-item { display: grid; grid-template-columns: 76px 1fr auto; gap: .8rem; align-items: center; padding: .7rem; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md); cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; }
.spot-item:hover, .spot-item.sel { border-color: var(--sign); }
.spot-item .thumb { width: 76px; height: 64px; border-radius: 8px; overflow: hidden; background: var(--asphalt); }
.spot-item .thumb img, .spot-item .thumb svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.spot-item h4 { font-size: var(--t-sm); line-height: 1.3; }
.spot-item .meta { font-size: var(--t-xs); color: var(--muted); display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .2rem; }
.spot-item .price { text-align: right; font: 700 var(--t-md)/1.1 var(--f-mono); }
.spot-item .price small { display: block; font: 500 var(--t-xs)/1.3 var(--f-body); color: var(--muted); }

/* Simple (drawn) map */
.smap { width: 100%; height: 100%; display: block; background: var(--surface-2); cursor: grab; }
.smap .road { stroke: var(--surface); stroke-linecap: round; }
.smap .block { fill: color-mix(in srgb, var(--line) 55%, var(--surface-2)); }
.smap .water { fill: color-mix(in srgb, var(--sign) 18%, var(--surface-2)); }
.smap .zlabel { font: 700 11px var(--f-mono); fill: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.smap .pin { cursor: pointer; }
.smap .pin rect { stroke: var(--surface); stroke-width: 2; }
.smap .pin text { font: 700 11px var(--f-mono); }
.smap .you { fill: var(--sign); stroke: var(--surface); stroke-width: 3; }
.smap .ring { fill: color-mix(in srgb, var(--sign) 10%, transparent); stroke: var(--sign); stroke-dasharray: 4 4; }
.map-note { position: absolute; left: 8px; bottom: 8px; font-size: 10px; background: var(--surface); color: var(--muted); padding: 2px 6px; border-radius: 4px; }

/* Leaflet pin */
.lpin { background: var(--marking); color: var(--marking-ink); border: 2px solid #fff; border-radius: 6px; font: 700 11px/1 var(--f-mono); padding: 5px 6px; box-shadow: 0 2px 6px rgb(0 0 0 / .3); white-space: nowrap; transform: translate(-50%, -100%); position: absolute; }
.lpin.taken { background: #6B7280; color: #fff; }
.lpin.sel { background: var(--sign); color: #fff; }

/* ---------- Spot detail ---------- */
.gallery { display: grid; grid-template-columns: 2fr 1fr; gap: .5rem; border-radius: var(--r-lg); overflow: hidden; }
.gallery > * { min-width: 0; }
.gallery .main-ph { aspect-ratio: 4/3; background: var(--asphalt); }
.gallery .side { display: grid; gap: .5rem; grid-template-rows: 1fr 1fr; }
.gallery img, .gallery svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .side > div { background: var(--asphalt); min-height: 0; }
@media (max-width: 600px) { .gallery { grid-template-columns: 1fr; } .gallery .side { display: none; } }
.detail { display: grid; grid-template-columns: 1fr 360px; gap: 1.25rem; align-items: start; }
.detail > * { min-width: 0; }
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }
.book-box { position: sticky; top: calc(76px + env(safe-area-inset-top, 0px)); }
.features { display: flex; gap: .4rem; flex-wrap: wrap; }
.sensor { display: flex; gap: .6rem; align-items: center; font-size: var(--t-sm); padding: .7rem .8rem; border-radius: var(--r-md); background: var(--surface-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.dot.idle { background: var(--muted); }
.quote { display: grid; gap: .4rem; font-size: var(--t-sm); }
.quote div { display: flex; justify-content: space-between; gap: 1rem; }
.quote div span:last-child { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.quote .total { border-top: 1.5px solid var(--ink); padding-top: .5rem; font-weight: 700; font-size: var(--t-md); }
.review { border-top: 1px solid var(--line); padding-top: .75rem; display: grid; gap: .25rem; font-size: var(--t-sm); }
.stars { color: var(--marking); letter-spacing: 1px; font-size: 1rem; }
.qty { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: var(--r-sm); }
.qty button { width: 40px; height: 40px; border: 0; background: none; color: var(--ink); font-size: 1.2rem; cursor: pointer; }
.qty span { min-width: 3.5rem; text-align: center; font: 600 var(--t-sm)/1 var(--f-mono); }

/* ---------- Pass (ticket) ---------- */
.ticket { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
.ticket-top { background: var(--sign); color: var(--sign-ink); padding: 1.1rem 1.2rem; display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.ticket-top .slot-big { font: 800 3rem/0.9 var(--f-display); }
.ticket-top .eyebrow { color: color-mix(in srgb, var(--sign-ink) 75%, transparent); }
.perf { height: 22px; position: relative; background: var(--surface); }
.perf::before { content: ""; position: absolute; left: 14px; right: 14px; top: 50%; border-top: 2px dashed var(--line); }
.perf::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 0 50%, var(--concrete) 11px, transparent 12px), radial-gradient(circle at 100% 50%, var(--concrete) 11px, transparent 12px); }
.ticket-body { padding: .3rem 1.2rem 1.2rem; display: grid; gap: 1rem; }
.qr-wrap { display: grid; justify-items: center; gap: .5rem; }
.qr { background: #fff; padding: 10px; border-radius: 10px; width: 200px; height: 200px; display: grid; place-items: center; }
.qr svg { width: 180px; height: 180px; display: block; }
.pass-code { font: 700 1.4rem/1 var(--f-mono); letter-spacing: .12em; }

/* ---------- Lists / tables ---------- */
.blist { display: grid; gap: .6rem; }
.bitem { display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; align-items: center; padding: .85rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); text-decoration: none; color: inherit; }
.bitem:hover { border-color: var(--sign); }
.bitem .when { text-align: center; min-width: 52px; border-right: 1px solid var(--line); padding-right: .8rem; }
.bitem .when b { display: block; font: 800 1.6rem/1 var(--f-display); }
.bitem .when span { font: 600 10px/1.2 var(--f-mono); text-transform: uppercase; color: var(--muted); }
.bitem h4 { font-size: var(--t-sm); }
.bitem p { font-size: var(--t-xs); color: var(--muted); }
.bitem > div { min-width: 0; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
table.tbl th, table.tbl td { padding: .7rem .85rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
table.tbl th { font: 600 10px/1.2 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
table.tbl td.n, table.tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.wrap { white-space: normal; min-width: 200px; }
table.tbl tr:last-child td { border-bottom: 0; }

/* Bar chart */
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .5rem; align-items: end; height: 180px; padding-top: 1.2rem; border-bottom: 1px solid var(--line); }
.bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; }
.bar i { display: block; width: 100%; max-width: 44px; background: var(--sign); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar.last i { background: var(--marking); }
.bar em { font: 600 10px/1 var(--f-mono); font-style: normal; color: var(--ink); position: absolute; margin-bottom: 4px; white-space: nowrap; }
.bar-labels { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .5rem; font: 600 10px/1 var(--f-mono); color: var(--muted); text-align: center; text-transform: uppercase; margin-top: .4rem; }

/* Login */
.login { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.login .card { width: min(100%, 420px); padding: 1.6rem; }
.otp { font: 700 1.6rem/1 var(--f-mono); letter-spacing: .5em; text-align: center; }
.demo-users { display: grid; gap: .4rem; }
.demo-users button { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .65rem .8rem; background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-sm); cursor: pointer; color: var(--ink); font: 500 var(--t-sm)/1.2 var(--f-body); text-align: left; }
.demo-users button:hover { border-color: var(--sign); }

/* Photo picker */
.photos { display: flex; gap: .5rem; flex-wrap: wrap; }
.photos .ph { width: 92px; height: 72px; border-radius: 8px; overflow: hidden; position: relative; background: var(--surface-2); }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; }
.photos .ph button { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgb(0 0 0 / .65); color: #fff; cursor: pointer; font-size: 13px; line-height: 1; }
.photos label.add { width: 92px; height: 72px; border-radius: 8px; border: 1.5px dashed var(--muted); display: grid; place-items: center; cursor: pointer; color: var(--muted); font-size: var(--t-xs); text-align: center; }
.photos input { display: none; }
.pin-map { height: 260px; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); position: relative; }
.shot { border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); max-height: 320px; }
.shot img { width: 100%; max-height: 320px; object-fit: cover; }

/* Sheet (custom confirm dialog) */
.sheet-bg { position: fixed; inset: 0; background: rgb(10 12 16 / .55); z-index: 90; display: grid; place-items: end center; padding: 1rem; padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); animation: fade .15s ease; }
@media (min-width: 700px) { .sheet-bg { place-items: center; } }
.sheet { background: var(--surface); border-radius: var(--r-lg); padding: 1.3rem; width: min(100%, 440px); display: grid; gap: 1rem; box-shadow: var(--shadow); }
.sheet h3 { font-size: 1.6rem; text-transform: uppercase; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.scan-video { width: 100%; border-radius: var(--r-md); background: #000; max-height: 300px; object-fit: cover; }
.verify-result { border-radius: var(--r-lg); padding: 1.2rem; display: grid; gap: .6rem; }
.verify-result.ok { background: var(--ok-soft); border: 2px solid var(--ok); }
.verify-result.bad { background: var(--bad-soft); border: 2px solid var(--bad); }
.verify-result .big { font: 800 2.2rem/1 var(--f-display); text-transform: uppercase; }
.verify-result.ok .big { color: var(--ok); } .verify-result.bad .big { color: var(--bad); }

.menu { position: absolute; right: var(--gutter-r); top: 58px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); padding: .4rem; min-width: 220px; display: grid; z-index: 70; }
.menu a, .menu button { text-align: left; padding: .6rem .7rem; border-radius: 6px; text-decoration: none; color: var(--ink); background: none; border: 0; font: 500 var(--t-sm)/1.2 var(--f-body); cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--surface-2); }
.menu .who { padding: .6rem .7rem; font-size: var(--t-xs); color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: .3rem; }

/* Icons inside buttons and links */
.btn svg, .back svg { width: 18px; height: 18px; flex: none; }
