/* ==========================================================================
   Hush — control center UI (web + Cordova)
   ========================================================================== */
:root {
  --bg: #0E0A12;
  --bg-2: #140F19;
  --panel: #19121F;
  --panel-2: #1E1625;
  --line: rgba(251, 239, 247, .08);
  --line-2: rgba(251, 239, 247, .14);
  --cream: #FBEFF7;
  --ink: rgba(251, 239, 247, .86);
  --muted: rgba(251, 239, 247, .54);
  --faint: rgba(251, 239, 247, .32);
  --accent: #FF2D9B;
  --accent-2: #F7A8E0;
  --ok: #36D6B0;
  --mid: #E9B44C;
  --full: #FF2D9B;
  --info: #B98CF0;
  --display: 'Oswald', 'Barlow Condensed', Impact, system-ui, sans-serif;
  --cond: 'Barlow Condensed', 'Oswald', system-ui, sans-serif;
  --body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 14px;
  --top-h: 64px;
  --panel-w: 420px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.4 var(--body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell {
  position: fixed; inset: 0;
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  grid-template-rows: calc(var(--top-h) + var(--safe-t)) 1fr;
  grid-template-areas: "top top" "panel map";
}

/* ---------- top bar ---------- */
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 22px;
  padding: var(--safe-t) 18px 0;
  background: linear-gradient(180deg, #130E17, #0E0A12);
  border-bottom: 1px solid var(--line);
  z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--cream); text-decoration: none; flex: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--accent), 0 0 16px rgba(255,45,155,.45); }
.brand-name { font: 700 19px/1 var(--display); letter-spacing: .04em; text-transform: uppercase; }
.brand-name em { font-style: normal; color: var(--accent); margin-left: 4px; }

.kpis { display: flex; gap: 6px; flex: 1; justify-content: center; min-width: 0; }
.kpi {
  display: flex; align-items: baseline; gap: 7px;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255,255,255,.02); white-space: nowrap;
}
.kpi-v { font: 600 17px/1 var(--display); color: var(--cream); font-variant-numeric: tabular-nums; }
.kpi-l { font: 600 11px/1 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

.top-right { display: flex; align-items: center; gap: 10px; flex: none; }
.clock { font: 500 15px/1 var(--display); letter-spacing: .06em; color: var(--cream); font-variant-numeric: tabular-nums; }
.status { display: inline-flex; align-items: center; gap: 7px; font: 600 11px/1 var(--cond); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--mid); box-shadow: 0 0 0 0 rgba(233,180,76,.6); }
.status.is-live i { background: var(--ok); animation: pulse 2.4s ease-out infinite; }
.status.is-error i { background: var(--full); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(54,214,176,.55); } 80%,100% { box-shadow: 0 0 0 9px rgba(54,214,176,0); } }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--ink);
  transition: background .2s, border-color .2s, transform .2s;
}
.icon-btn:hover { background: rgba(255,255,255,.05); border-color: var(--line-2); }
.icon-btn i { font-size: 18px; }
.icon-btn.is-spinning i { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- map ---------- */
.map-wrap { grid-area: map; position: relative; min-height: 0; z-index: 0; isolation: isolate; }
#map { position: absolute; inset: 0; background: #110C15; }
.leaflet-container { font-family: var(--body); background: #110C15; }
/* OpenStreetMap tiles, recoloured into a night palette */
.tiles-night { filter: invert(1) hue-rotate(185deg) brightness(.9) contrast(.9) saturate(.15) sepia(.45) hue-rotate(255deg) saturate(1.3); }
.leaflet-control-attribution { background: rgba(10,11,12,.72) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--ink) !important; }
.leaflet-bar a { background: var(--panel) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.leaflet-bar { border: 1px solid var(--line) !important; box-shadow: none !important; }

.legend {
  position: absolute; left: 14px; bottom: 14px; z-index: 500;
  display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 9px 13px;
  background: rgba(14,16,18,.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 12px;
  font: 600 11px/1 var(--cond); letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .ph-bus { color: var(--accent); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.mid { background: var(--mid); } .dot.full { background: var(--full); }

.locate-btn {
  position: absolute; right: 12px; bottom: 26px; z-index: 500;
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(14,16,18,.86); color: var(--cream); display: grid; place-items: center;
}
.locate-btn i { font-size: 20px; }

/* lot pins */
.lot-pin { --c: var(--ok); --p: 0; position: relative; width: 40px; height: 40px; }
.lot-pin .ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), rgba(251,239,247,.16) 0);
  box-shadow: 0 6px 18px rgba(0,0,0,.55);
  transition: transform .25s cubic-bezier(.2,.9,.3,1);
}
.lot-pin .core {
  position: absolute; inset: 5px; border-radius: 50%;
  background: #19121F; display: grid; place-items: center;
  font: 700 15px/1 var(--display); color: var(--cream);
}
.lot-pin .tag {
  position: absolute; left: 50%; top: 44px; transform: translateX(-50%);
  white-space: nowrap; padding: 3px 7px; border-radius: 6px;
  background: rgba(10,11,12,.8); border: 1px solid var(--line);
  font: 600 11px/1 var(--cond); letter-spacing: .1em; text-transform: uppercase; color: var(--ink);
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
}
.map-zoomed .lot-pin .tag, .lot-pin:hover .tag, .lot-pin.is-selected .tag { opacity: 1; }
.lot-pin:hover .ring, .lot-pin.is-selected .ring { transform: scale(1.12); }
.lot-pin.is-selected .core { box-shadow: inset 0 0 0 2px var(--cream); }
.lot-pin.s-mid { --c: var(--mid); }
.lot-pin.s-full { --c: var(--full); }
.lot-pin.s-full .core { color: var(--accent-2); }

.bus-pin {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  box-shadow: 0 0 0 4px rgba(255,45,155,.25), 0 6px 16px rgba(0,0,0,.5);
  font-size: 16px; transition: transform .2s;
}
.bus-pin.is-selected { transform: scale(1.25); box-shadow: 0 0 0 6px rgba(255,45,155,.35), 0 6px 16px rgba(0,0,0,.5); }

.geo-pin { width: 22px; height: 22px; border-radius: 50%; background: var(--info); border: 3px solid #fff; box-shadow: 0 0 0 0 rgba(185,140,240,.6); animation: geo 2s ease-out infinite; }
@keyframes geo { 0% { box-shadow: 0 0 0 0 rgba(185,140,240,.6); } 100% { box-shadow: 0 0 0 22px rgba(185,140,240,0); } }

.leaflet-tooltip.tip {
  background: rgba(14,16,18,.94); color: var(--ink); border: 1px solid var(--line-2);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.5); padding: 8px 10px;
  font: 500 12px/1.35 var(--body);
}
.leaflet-tooltip.tip::before { display: none; }
.tip b { font: 600 13px/1.2 var(--display); letter-spacing: .03em; color: var(--cream); text-transform: uppercase; }

/* ---------- panel ---------- */
.panel {
  grid-area: panel; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
  z-index: 900;
}
.sheet-handle { display: none; }
.tabs {
  display: grid; grid-template-columns: repeat(5, 1fr);
  border-bottom: 1px solid var(--line); flex: none;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 4px 10px; background: none; border: 0; color: var(--muted);
  font: 600 11px/1 var(--cond); letter-spacing: .12em; text-transform: uppercase;
  position: relative; transition: color .2s;
}
.tab i { font-size: 20px; }
.tab::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: -1px; height: 2px; background: var(--accent); transform: scaleX(0); transition: transform .3s cubic-bezier(.2,.9,.3,1); }
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--cream); }
.tab.is-active::after { transform: scaleX(1); }

.views { flex: 1; min-height: 0; position: relative; }
.view { position: absolute; inset: 0; overflow-y: auto; padding: 16px 16px calc(24px + var(--safe-b)); display: none; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.view.is-active { display: block; animation: viewIn .35s cubic-bezier(.2,.9,.3,1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 14px; }
.view-head h2, .sec-title {
  margin: 0; font: 600 20px/1.05 var(--display); text-transform: uppercase; letter-spacing: .02em; color: var(--cream);
}
.hint { margin: 2px 0 0; width: 100%; color: var(--muted); font-size: 13px; }
.sec-title { font-size: 13px; letter-spacing: .14em; color: var(--muted); margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.sec-title .count { color: var(--cream); }

/* search */
.search {
  display: flex; align-items: center; gap: 8px; padding: 0 6px 0 12px;
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--bg-2);
  transition: border-color .2s;
}
.search:focus-within { border-color: rgba(255,45,155,.7); }
.search > i { color: var(--muted); font-size: 17px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 12px 0; font-size: 14px; }
.search input::placeholder { color: var(--faint); }
.search-go { width: 32px; height: 32px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; }

#geo-results:not(:empty) { margin-top: 10px; }
.geo-item {
  width: 100%; text-align: left; display: flex; gap: 10px; align-items: flex-start;
  padding: 10px; border: 0; border-radius: 10px; background: none; color: var(--ink);
}
.geo-item:hover { background: rgba(255,255,255,.04); }
.geo-item i { color: var(--info); font-size: 17px; margin-top: 1px; }
.geo-item small { display: block; color: var(--muted); font-size: 12px; }
.geo-card { border: 1px solid rgba(185,140,240,.28); background: rgba(185,140,240,.06); border-radius: var(--r); padding: 12px; }
.geo-card h4 { margin: 0 0 4px; font: 600 14px/1.2 var(--display); text-transform: uppercase; color: var(--cream); letter-spacing: .03em; }
.geo-card p { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }
.badge-in, .badge-out { display: inline-flex; align-items: center; gap: 5px; font: 600 11px/1 var(--cond); letter-spacing: .1em; text-transform: uppercase; padding: 5px 8px; border-radius: 999px; }
.badge-in { color: var(--ok); background: rgba(54,214,176,.1); }
.badge-out { color: var(--accent-2); background: rgba(255,45,155,.12); }

/* lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2);
  width: 100%; text-align: left; color: var(--ink);
  transition: border-color .2s, background .2s, transform .2s;
}
button.row:hover { border-color: var(--line-2); background: #241A2B; }
.row.is-selected { border-color: rgba(255,45,155,.6); }
.code {
  width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center;
  font: 700 13px/1 var(--display); letter-spacing: .06em; color: var(--cream);
  background: rgba(255,255,255,.05); border: 1px solid var(--line);
}
.code.s-ok { box-shadow: inset 0 -3px 0 var(--ok); }
.code.s-mid { box-shadow: inset 0 -3px 0 var(--mid); }
.code.s-full { box-shadow: inset 0 -3px 0 var(--full); }
.row-main { min-width: 0; }
.row-title, .row-sub { display: block; }
.row-title { font: 600 15px/1.15 var(--display); letter-spacing: .02em; text-transform: uppercase; color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side { text-align: right; }
.big { font: 700 22px/1 var(--display); color: var(--cream); font-variant-numeric: tabular-nums; }
.big small { font: 600 12px/1 var(--cond); color: var(--muted); letter-spacing: .08em; margin-left: 2px; }
.tiny { display: block; font: 600 10.5px/1 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

.bays { display: flex; gap: 3px; margin-top: 7px; flex-wrap: wrap; }
.bays i { width: 14px; height: 6px; border-radius: 2px; background: rgba(251,239,247,.14); }
.bays i.on { background: var(--c, var(--ok)); }
.bays.lg i { width: 26px; height: 34px; border-radius: 6px; display: grid; place-items: center; font-size: 15px; color: rgba(255,255,255,.9); }
.bays.lg i.on { background: var(--c, var(--ok)); }

.state { display: inline-flex; align-items: center; gap: 5px; font: 600 10.5px/1 var(--cond); letter-spacing: .12em; text-transform: uppercase; padding: 4px 7px; border-radius: 6px; }
.state.PARKED { color: var(--ok); background: rgba(54,214,176,.1); }
.state.IN_TRANSIT { color: var(--accent-2); background: rgba(255,45,155,.13); }
.state.IDLE { color: var(--muted); background: rgba(255,255,255,.06); }
.state.ON_DUTY { color: var(--ok); background: rgba(54,214,176,.1); }
.state.UPCOMING { color: var(--info); background: rgba(185,140,240,.1); }
.state.FINISHED { color: var(--muted); background: rgba(255,255,255,.06); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: none; border-radius: 999px; padding: 6px 11px; font: 600 11px/1 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.chip.is-active { background: var(--cream); color: #111; border-color: var(--cream); }

.meter { height: 4px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; background: var(--c, var(--ok)); border-radius: inherit; }

/* lot detail */
.back { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--muted); padding: 4px 0; font: 600 12px/1 var(--cond); letter-spacing: .12em; text-transform: uppercase; margin-bottom: 10px; }
.back:hover { color: var(--cream); }
.lot-hero { border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: radial-gradient(120% 140% at 100% 0%, rgba(255,45,155,.12), transparent 55%), var(--panel-2); }
.lot-hero h3 { margin: 0; font: 700 28px/1 var(--display); text-transform: uppercase; color: var(--cream); letter-spacing: .01em; }
.lot-hero .coords { color: var(--muted); font-size: 12px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.lot-hero .avail { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 16px; }
.lot-hero .avail .big { font-size: 46px; }
.lot-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }

.card { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); padding: 12px; }
.card + .card { margin-top: 8px; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.plate {
  display: inline-block; padding: 4px 7px 3px; border-radius: 5px; background: #F2C230; color: #111;
  font: 700 13px/1 var(--display); letter-spacing: .08em; border: 1px solid rgba(0,0,0,.4);
}
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.kv div { min-width: 0; }
.kv dt, .kv .k { font: 600 10.5px/1 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.kv dd, .kv .v { margin: 5px 0 0; font: 600 15px/1.1 var(--display); color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dwell { margin-top: 12px; }
.dwell-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.dwell-top b { color: var(--ink); font-weight: 600; }
.over { --c: var(--accent); }

.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: var(--line-2); }
.tl-item { position: relative; padding: 8px 0; display: flex; justify-content: space-between; gap: 10px; }
.tl-item::before { content: ""; position: absolute; left: -17px; top: 14px; width: 9px; height: 9px; border-radius: 50%; background: var(--panel); border: 2px solid var(--accent); }
.tl-time { font: 600 16px/1 var(--display); color: var(--cream); font-variant-numeric: tabular-nums; }
.tl-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.empty { color: var(--faint); font-size: 13px; padding: 10px 0; }

/* forms */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); margin-bottom: 16px; }
.seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: none; border-radius: 9px; padding: 9px 6px; color: var(--muted); font: 600 12px/1 var(--cond); letter-spacing: .12em; text-transform: uppercase; }
.seg button.is-active { background: var(--panel-2); color: var(--cream); box-shadow: 0 1px 0 rgba(255,255,255,.05) inset, 0 4px 14px rgba(0,0,0,.35); }
.seg i { font-size: 16px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label, .inline-select { display: flex; flex-direction: column; gap: 6px; font: 600 11px/1 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.inline-select { flex-direction: row; align-items: center; gap: 8px; }
.form select, .form input, .inline-select select {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--cream); font: 500 14px/1.2 var(--body); letter-spacing: 0; text-transform: none;
  outline: none; transition: border-color .2s; color-scheme: dark;
}
.inline-select select { width: auto; max-width: 240px; padding: 8px 10px; }
.form select:focus, .form input:focus { border-color: rgba(255,45,155,.75); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-note:empty { display: none; }
.form-note { font-size: 12.5px; color: var(--ink); padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.04); border: 1px dashed var(--line-2); }
.form-note b { color: var(--cream); }
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px; border-radius: 11px; border: 1px solid transparent;
  font: 600 13px/1 var(--cond); letter-spacing: .14em; text-transform: uppercase;
  transition: transform .15s, background .2s, opacity .2s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #FF4DAE; }
.btn-primary:active, .btn-ghost:active { transform: scale(.98); }
.btn-primary[disabled] { opacity: .5; cursor: progress; }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--cream); }
.btn-ghost:hover { background: rgba(255,255,255,.05); }
.btn-primary i, .btn-ghost i { font-size: 16px; }

/* seats */
.seat-wrap { display: grid; grid-template-columns: 1fr; gap: 14px; }
.trip-card { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: var(--panel-2); }
.trip-route { display: flex; align-items: center; gap: 10px; font: 700 20px/1 var(--display); text-transform: uppercase; color: var(--cream); }
.trip-route i { color: var(--accent); font-size: 18px; }
.seat-stats { display: flex; gap: 18px; margin-top: 12px; }
.bus-shell {
  margin: 0 auto; width: 100%; max-width: 290px;
  border: 2px solid var(--line-2); border-radius: 34px 34px 18px 18px;
  padding: 18px 16px 16px; background: linear-gradient(180deg, rgba(255,255,255,.03), transparent);
}
.bus-front { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--line-2); color: var(--muted); font: 600 10.5px/1 var(--cond); letter-spacing: .14em; text-transform: uppercase; }
.bus-front i { font-size: 22px; color: var(--ink); }
.seat-grid { display: grid; grid-template-columns: 1fr 1fr 18px 1fr 1fr; gap: 7px; }
.seat {
  aspect-ratio: 1 / 1.05; border-radius: 8px 8px 5px 5px; border: 1.5px solid rgba(54,214,176,.55);
  background: rgba(54,214,176,.07); color: var(--ok);
  font: 600 12px/1 var(--display); display: grid; place-items: center; padding: 0;
  transition: transform .15s, background .2s;
}
.seat:hover:not(.sold) { transform: translateY(-2px); background: rgba(54,214,176,.18); }
.seat.sold { border-color: transparent; background: rgba(255,255,255,.07); color: var(--faint); cursor: not-allowed; }
.seat.picked { background: var(--accent); border-color: var(--accent); color: #fff; }
.aisle { }
.sell-bar { display: flex; gap: 8px; align-items: stretch; }
.sell-bar input { flex: 1; min-width: 0; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--cream); outline: none; }

/* drivers gantt */
.gantt { position: relative; }
.g-axis { position: relative; height: 22px; margin-left: 118px; border-bottom: 1px solid var(--line); }
.g-axis span { position: absolute; top: 2px; transform: translateX(-50%); font: 600 10.5px/1 var(--cond); color: var(--muted); letter-spacing: .08em; }
.g-row { display: grid; grid-template-columns: 118px 1fr; align-items: center; min-height: 44px; border-bottom: 1px solid var(--line); }
.g-name { padding-right: 8px; min-width: 0; }
.g-name b { display: block; font: 600 13px/1.15 var(--display); text-transform: uppercase; color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .02em; }
.g-name small { color: var(--muted); font-size: 11.5px; }
.g-track { position: relative; height: 44px; }
.g-shift { position: absolute; top: 12px; height: 20px; border-radius: 6px; background: rgba(54,214,176,.16); border: 1px solid rgba(54,214,176,.45); }
.g-shift.UPCOMING { background: rgba(185,140,240,.12); border-color: rgba(185,140,240,.4); }
.g-shift.FINISHED { background: rgba(255,255,255,.05); border-color: var(--line-2); }
.g-trip { position: absolute; top: 15px; height: 14px; border-radius: 4px; background: var(--accent); opacity: .9; }
.g-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--cream); z-index: 2; pointer-events: none; }
.g-axis .now-tag { top: 1px; color: #111; background: var(--cream); padding: 2px 4px; border-radius: 3px; font-weight: 700; letter-spacing: .14em; z-index: 3; }
.g-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }

/* toasts */
.toasts { position: fixed; right: 16px; top: calc(var(--top-h) + var(--safe-t) + 12px); z-index: 3000; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  background: rgba(20,22,25,.96); border: 1px solid var(--line-2); box-shadow: 0 18px 40px rgba(0,0,0,.5);
  animation: toastIn .35s cubic-bezier(.2,.9,.3,1);
}
.toast i { font-size: 19px; flex: none; }
.toast.ok i { color: var(--ok); } .toast.err i { color: var(--accent-2); }
.toast b { display: block; font: 600 13px/1.2 var(--display); text-transform: uppercase; letter-spacing: .04em; color: var(--cream); }
.toast span { font-size: 13px; color: var(--ink); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }

.setup {
  margin: 8px 0; padding: 16px; border-radius: var(--r); border: 1px dashed rgba(255,45,155,.55); background: rgba(255,45,155,.07);
}
.setup h3 { margin: 0 0 6px; font: 600 16px/1.1 var(--display); text-transform: uppercase; color: var(--cream); }
.setup p { margin: 0; color: var(--ink); font-size: 13px; }
.setup code { font-size: 12px; color: var(--accent-2); }

.skeleton { height: 68px; border-radius: var(--r); background: linear-gradient(90deg, rgba(255,255,255,.03), rgba(255,255,255,.07), rgba(255,255,255,.03)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
.skeleton + .skeleton { margin-top: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ==========================================================================
   Tablet & phone: map on top, panel becomes a bottom sheet (Cordova layout)
   ========================================================================== */
@media (max-width: 1100px) {
  :root { --panel-w: 380px; }
  .kpi:nth-child(4) { display: none; }
}
@media (max-width: 860px) {
  :root { --top-h: 56px; }
  .shell { grid-template-columns: 1fr; grid-template-rows: calc(var(--top-h) + var(--safe-t)) 1fr; grid-template-areas: "top" "map"; }
  .kpis { display: none; }
  .topbar { gap: 10px; padding-left: 14px; padding-right: 12px; }
  .top-right { margin-left: auto; gap: 8px; }
  .status b { display: none; }
  .clock { font-size: 14px; }
  .icon-btn { width: 34px; height: 34px; }
  .brand-name { font-size: 17px; }

  .panel {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: 52%; height: 52dvh;
    border-right: 0; border-top: 1px solid var(--line-2);
    border-radius: 20px 20px 0 0; box-shadow: 0 -18px 40px rgba(0,0,0,.45);
    transition: height .38s cubic-bezier(.2,.9,.3,1);
    display: flex; flex-direction: column;
  }
  .panel.is-expanded { height: calc(100% - var(--top-h) - var(--safe-t) - 8px); }
  .sheet-handle { display: grid; place-items: center; height: 20px; border: 0; background: none; flex: none; }
  .sheet-handle span { width: 42px; height: 4px; border-radius: 4px; background: var(--line-2); }
  .tabs { order: 3; border-bottom: 0; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); background: var(--panel); }
  .tab { padding: 10px 2px 9px; font-size: 10px; letter-spacing: .08em; }
  .tab::after { top: -1px; bottom: auto; }
  .views { order: 2; }
  .view { padding: 4px 14px 18px; }
  #map { bottom: calc(52dvh - 20px); }
  .legend { display: none; }
  .locate-btn { bottom: calc(52dvh + 12px); }
  .toasts { left: 12px; right: 12px; max-width: none; }
  .lot-hero h3 { font-size: 24px; }
}
@media (max-width: 380px) {
  .kv { grid-template-columns: 1fr 1fr; }
  .row2 { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ==========================================================================
   Live tracking — 3D bus on the real road + HUD
   ========================================================================== */
.bus3d-icon { background: none; border: 0; }
.bus3d { position: relative; width: 64px; height: 64px; cursor: pointer; }
.bus3d canvas { position: relative; width: 64px; height: 64px; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .55)); z-index: 1; }
.bus3d.is-flat { display: grid; place-items: center; }
.bus3d.is-flat > i { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 16px; z-index: 1; }
.bus3d-halo {
  position: absolute; left: 50%; top: 55%; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border-radius: 50%; background: radial-gradient(circle, rgba(255, 45, 155, .55), rgba(255, 45, 155, 0) 70%);
}
.bus3d-tag {
  position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); z-index: 2;
  padding: 2px 6px; border-radius: 5px; white-space: nowrap;
  background: rgba(14, 10, 18, .88); border: 1px solid rgba(255, 45, 155, .5);
  font: 700 10px/1.2 var(--cond); letter-spacing: .1em; color: var(--cream);
}
.bus3d.is-arrived .bus3d-tag { border-color: var(--ok); color: var(--ok); }
.bus3d.is-followed .bus3d-tag { background: var(--accent); border-color: var(--accent); color: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .bus3d canvas { animation: busBob 1.6s cubic-bezier(0.77, 0, 0.175, 1) infinite alternate; }
  .bus3d-halo { animation: busHalo 2.2s cubic-bezier(0.23, 1, 0.32, 1) infinite; }
  .bus3d.is-arrived canvas, .bus3d.is-arrived .bus3d-halo { animation: none; }
}
@keyframes busBob { from { transform: translateY(0); } to { transform: translateY(-2px); } }
@keyframes busHalo { from { transform: scale(.7); opacity: .9; } to { transform: scale(1.9); opacity: 0; } }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(255, 45, 155, .6); flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .live-dot { animation: liveDot 1.8s cubic-bezier(0.23, 1, 0.32, 1) infinite; }
}
@keyframes liveDot { to { box-shadow: 0 0 0 9px rgba(255, 45, 155, 0); } }

.live-chip {
  position: absolute; left: 14px; top: 14px; z-index: 600;
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; border-radius: 999px;
  background: rgba(20, 14, 26, .88); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 45, 155, .45); color: var(--cream);
  font: 600 11.5px/1 var(--cond); letter-spacing: .14em; text-transform: uppercase;
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), background-color 200ms ease;
}
.live-chip b { color: var(--accent); }
.live-chip:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) { .live-chip:hover { background: rgba(40, 20, 44, .92); } }

.live-hud {
  position: absolute; left: 14px; top: 58px; z-index: 650; width: 300px;
  padding: 14px; border-radius: 16px;
  background: rgba(18, 12, 24, .9); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 45, 155, .35);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .05);
  transform-origin: 20px 0;
}
@media (prefers-reduced-motion: no-preference) {
  .live-hud:not([hidden]) { animation: hudIn 260ms cubic-bezier(0.23, 1, 0.32, 1); }
}
@keyframes hudIn { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
.live-hud header { display: flex; align-items: center; gap: 8px; font: 600 11px/1 var(--cond); letter-spacing: .16em; text-transform: uppercase; color: var(--cream); }
.lh-mode { margin-left: auto; padding: 3px 6px; border-radius: 5px; background: rgba(54, 214, 176, .12); color: var(--ok); font-size: 10px; }
.lh-mode.is-sim { background: rgba(255, 45, 155, .16); color: var(--accent-2); }
.lh-x { width: 26px; height: 26px; border: 0; border-radius: 7px; background: none; color: var(--muted); display: grid; place-items: center; }
.lh-bus { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.lh-code { font: 600 12px/1 var(--cond); letter-spacing: .1em; color: var(--muted); }
.lh-nav { margin-left: auto; display: flex; gap: 4px; }
.lh-nav button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line-2); background: none; display: grid; place-items: center; }
.lh-route { display: flex; align-items: center; gap: 8px; margin-top: 10px; font: 700 18px/1.1 var(--display); text-transform: uppercase; color: var(--cream); }
.lh-route i { color: var(--accent); font-size: 15px; }
.lh-bar { position: relative; height: 6px; margin: 16px 6px 6px; border-radius: 6px; background: rgba(255, 255, 255, .08); }
.lh-fill { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transform-origin: left; transform: scaleX(0); }
.lh-runner { position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 12px; box-shadow: 0 0 0 4px rgba(255, 45, 155, .25); }
.lh-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.lh-stats b { display: block; font: 700 17px/1.1 var(--display); color: var(--cream); font-variant-numeric: tabular-nums; }
.lh-stats small { display: block; margin-top: 3px; font: 600 10px/1.2 var(--cond); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.lh-speed { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 4px; margin-top: 14px; padding: 3px; border-radius: 10px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); }
.lh-speed button { border: 0; border-radius: 7px; padding: 7px 4px; background: none; color: var(--muted); font: 600 11px/1 var(--cond); letter-spacing: .1em; text-transform: uppercase; transition: background-color 180ms ease, color 180ms ease; }
.lh-speed button.is-active { background: var(--accent); color: #fff; }
.lh-cam { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--ink); }
.lh-cam input { accent-color: var(--accent); }
.lh-note { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.4; }

@media (max-width: 860px) {
  .live-chip { top: 10px; left: 10px; }
  .live-hud { left: 10px; right: 64px; top: 50px; width: auto; padding: 12px; }
  .lh-stats b { font-size: 15px; }
  .lh-note, .lh-cam { display: none; }
  .lh-bus { margin-top: 8px; }
  .lh-route { margin-top: 6px; font-size: 15px; }
  .lh-bar { margin-top: 10px; }
  .lh-stats, .lh-speed { margin-top: 10px; }
  .lh-nav button { width: 26px; height: 26px; }
  /* while following a bus the bottom sheet steps aside */
  body.is-following .panel:not(.is-expanded) { height: 30%; height: 30dvh; }
  body.is-following #map { bottom: calc(30dvh - 20px); }
  body.is-following .locate-btn { bottom: calc(30dvh + 12px); }
}
