html, body { height: 100%; }
body { overflow-x: hidden; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.center { text-align: center; }
.small { font-size: 13px; }
.mono-num { font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 900; display: flex; align-items: center; gap: 14px; height: 60px; padding: 0 16px;
  padding-top: env(safe-area-inset-top); height: calc(60px + env(safe-area-inset-top));
  background: var(--brand); color: var(--brand-ink); }
.topbar .org { font-size: 13px; opacity: .8; border-left: 1px solid rgba(255,255,255,.25); padding-left: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .live { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; opacity: .9; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); display: inline-block; }
.dot.on { background: #2EE59D; box-shadow: 0 0 0 0 rgba(46,229,157,.6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(46,229,157,0); } 100% { box-shadow: 0 0 0 0 rgba(46,229,157,0); } }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 12px; border: 0; background: rgba(255,255,255,.1); color: inherit; display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }
.badge { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: #10214A; font: 700 10px/16px var(--font-body); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 1fr; min-height: calc(100vh - 60px); }
.side { display: none; }
.main { padding: 18px 16px 96px; min-width: 0; }
.main.flush { padding: 0; }
.tabs-bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 800; display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); overflow-x: auto; }
.tabs-bottom a { flex: 1 0 64px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; font-size: 11px; color: var(--muted); text-decoration: none; }
.tabs-bottom a svg { width: 22px; height: 22px; }
.tabs-bottom a.active { color: var(--primary); font-weight: 600; }
@media (min-width: 960px) {
  .shell { grid-template-columns: 236px 1fr; }
  .side { display: block; background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; }
  .side a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
  .side a svg { width: 20px; height: 20px; opacity: .8; }
  .side a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
  .side .count { margin-left: auto; background: var(--accent); color: #10214A; font-size: 11px; font-weight: 700; border-radius: 9px; padding: 1px 7px; }
  .tabs-bottom { display: none; }
  .main { padding: 26px 30px 40px; }
}

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card h3 { font-size: 16px; margin-bottom: 10px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.grid { display: grid; gap: 14px; }
@media (min-width: 700px) { .grid.c2 { grid-template-columns: 1fr 1fr; } .grid.c3 { grid-template-columns: repeat(3, 1fr); } .grid.c4 { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 699px) { .grid.c4 { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font: 700 26px var(--font-display); }
.stat span { color: var(--muted); font-size: 13px; }

.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 12px; background: var(--warn-soft); color: var(--ink); margin-bottom: 16px; flex-wrap: wrap; }
.banner.bad { background: var(--bad-soft); }
.banner.ok { background: var(--ok-soft); }

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
table.t td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.blue { background: var(--primary-soft); color: var(--primary); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--ink-2); padding: 8px 14px; border-radius: 9px; font: 600 13.5px var(--font-body); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty h3 { color: var(--ink); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--bg); }
.auth-side { display: none; }
.auth-main { display: flex; flex-direction: column; justify-content: center; padding: 28px 20px calc(28px + env(safe-area-inset-bottom)); padding-top: calc(28px + env(safe-area-inset-top)); max-width: 460px; width: 100%; margin: 0 auto; }
.auth-main h1 { font-size: 28px; margin: 22px 0 6px; }
.sso { display: grid; gap: 10px; margin: 18px 0 4px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 18px 0 2px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (min-width: 960px) {
  .auth { grid-template-columns: 1.1fr 1fr; }
  .auth-side { display: flex; flex-direction: column; justify-content: space-between; background: var(--brand); color: #fff; padding: 40px; position: relative; overflow: hidden; }
  .auth-side h2 { font-size: 36px; max-width: 13ch; color: #fff; }
  .auth-side p { color: rgba(255,255,255,.75); max-width: 40ch; }
}

/* ---------- live tracking ---------- */
.track { position: relative; height: calc(100vh - 60px - env(safe-area-inset-top)); display: grid; grid-template-rows: 1fr auto; }
.track .map { position: absolute; inset: 0; }
.track .sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 500; max-height: 58%; overflow-y: auto; background: var(--surface);
  border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(16,33,74,.18); padding: 8px 16px calc(84px + env(safe-area-inset-bottom)); }
.sheet .grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.float-card { position: absolute; z-index: 500; top: 12px; left: 12px; right: 12px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 14px; display: flex; gap: 12px; align-items: center; }
.float-card .ic { width: 42px; height: 42px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.float-card .ic svg { width: 22px; height: 22px; }
@media (min-width: 960px) {
  .track .sheet { top: 16px; bottom: 16px; left: 16px; right: auto; width: 400px; max-height: none; border-radius: 20px; padding: 16px 18px 20px; }
  .sheet .grab { display: none; }
  .float-card { left: auto; right: 16px; top: 16px; width: 330px; }
}
.map-ctrls { position: absolute; right: 12px; z-index: 500; display: grid; gap: 8px; bottom: calc(58% + 12px); }
@media (min-width: 960px) { .map-ctrls { bottom: 24px; right: 16px; } }
.map-ctrls button { width: 46px; height: 46px; border-radius: 14px; border: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; }
.map-ctrls button svg { width: 20px; height: 20px; }

.trip-head { display: flex; gap: 12px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.bus-ic { width: 52px; height: 52px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.bus-ic svg { width: 30px; height: 30px; }
.trip-head h3 { margin: 0; font-size: 17px; }
.call { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink); background: var(--surface); flex: none; }
.call svg { width: 18px; height: 18px; }

.stops { list-style: none; margin: 0; padding: 0; }
.stop { display: grid; grid-template-columns: 30px 44px 1fr auto; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.stop:last-child { border-bottom: 0; }
.stop .n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 700 13px var(--font-display); background: var(--surface-2); color: var(--muted); }
.stop .n.ok { background: var(--ok); color: #fff; } .stop .n.blue { background: var(--primary); color: #fff; } .stop .n.bad { background: var(--bad); color: #fff; } .stop .n.done { background: var(--brand); color: #fff; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font: 700 15px var(--font-display); color: #fff; flex: none; }
.stop .who b { display: block; font-size: 15px; }
.stop .who small { display: block; color: var(--muted); font-size: 13px; }
.stop .who small.ok { color: var(--ok); }
.stop.me { background: var(--primary-soft); margin: 0 -10px; padding: 12px 10px; border-radius: 12px; border-bottom: 0; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ok); border-radius: 4px; transition: width .4s; }

.timeline { display: flex; align-items: center; gap: 0; overflow-x: auto; padding: 8px 2px; }
.timeline .tl { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); min-width: 58px; }
.timeline .tl i { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 700 12px var(--font-display); font-style: normal; background: var(--surface-2); color: var(--muted); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.timeline .tl.ok i { background: var(--ok); color: #fff; } .timeline .tl.now i { background: var(--primary); color: #fff; }
.timeline .bar { flex: 1; min-width: 14px; height: 3px; background: var(--line); margin-bottom: 18px; }
.timeline .bar.ok { background: var(--ok); }

/* Leaflet markers */
.bus-marker { width: 46px; height: 46px; display: grid; place-items: center; }
.bus-marker .halo { position: absolute; width: 46px; height: 46px; border-radius: 50%; background: rgba(30,107,255,.18); animation: halo 2.2s infinite; }
@keyframes halo { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
.bus-marker .body { position: relative; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); display: grid; place-items: center; color: var(--accent); }
.bus-marker .body svg { width: 18px; height: 18px; }
.bus-marker .arrow { position: absolute; top: -6px; left: 50%; margin-left: -6px; width: 0; height: 0; border: 6px solid transparent; border-bottom: 8px solid var(--brand); }
.bus-marker.stale .body { background: var(--idle); }
.bus-marker .tag { position: absolute; top: 44px; left: 50%; transform: translateX(-50%); background: var(--brand); color: #fff; font: 700 11px var(--font-body); padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.pin { position: relative; width: 34px; height: 44px; }
.pin .head { position: absolute; top: 0; left: 0; width: 34px; height: 34px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--idle); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.pin b { position: absolute; top: 6px; left: 0; width: 34px; text-align: center; color: #fff; font: 700 14px var(--font-display); }
.pin.ok .head { background: var(--ok); } .pin.blue .head { background: var(--primary); } .pin.bad .head { background: var(--bad); } .pin.done .head { background: var(--brand); }
.pin.school .head { background: var(--accent); } .pin.school b { color: #10214A; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #1E6BFF; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(30,107,255,.2); }
.leaflet-container { font-family: var(--font-body); background: var(--surface-2); }
[data-theme="dark"] .leaflet-control-attribution { background: rgba(15,28,51,.8) !important; color: #8C9BBA; }
.leaflet-popup-content { font-size: 13.5px; }

/* ---------- driver ---------- */
.drv { max-width: 760px; margin: 0 auto; }
.drv-top { background: var(--brand); color: #fff; border-radius: 20px; padding: 18px; display: grid; gap: 12px; }
.drv-top .meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.drv-top .meta div { background: rgba(255,255,255,.08); border-radius: 12px; padding: 10px; }
.drv-top .meta b { display: block; font: 700 19px var(--font-display); }
.drv-top .meta span { font-size: 12px; opacity: .75; }
.drv-map { height: 240px; border-radius: 18px; overflow: hidden; margin: 14px 0; border: 1px solid var(--line); }
.drv-rider { display: grid; grid-template-columns: 30px 1fr; gap: 10px 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; }
.drv-rider .acts { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.drv-rider.done { opacity: .7; }
.gps-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 3000; background: rgba(8,17,31,.55); display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); color: var(--ink); border-radius: 20px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h2 { font-size: 20px; }
.modal .foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.gate { text-align: center; max-width: 420px; }
.gate .big-ic { width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 26px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.gate .big-ic svg { width: 42px; height: 42px; }
#toasts { position: fixed; z-index: 4000; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow); font-size: 14px; animation: rise .25s ease-out; }
.toast.bad { background: var(--bad); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }
.toast b { display: block; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.drawer { position: fixed; z-index: 2500; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); background: var(--surface); box-shadow: -10px 0 40px rgba(0,0,0,.2); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer .list { overflow-y: auto; flex: 1; }
.notif { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.notif.unread { background: var(--primary-soft); }
.notif b { display: block; } .notif p { margin: 2px 0; font-size: 14px; color: var(--ink-2); } .notif small { color: var(--muted); }

.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-chip { border: 2px solid var(--line); border-radius: 14px; padding: 10px; cursor: pointer; background: var(--surface); color: var(--ink); text-align: left; font: 600 13px var(--font-body); }
.theme-chip.on { border-color: var(--primary); }
.theme-chip i { display: flex; height: 26px; border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.theme-chip i span { flex: 1; }

.msg { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); max-width: 88%; }
.msg.staff { background: var(--primary-soft); margin-left: auto; }
.msg small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.chk { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.chk input { width: 22px; height: 22px; min-height: 0; flex: none; margin-top: 1px; accent-color: var(--primary); }
.chk b { display: block; font-size: 14.5px; } .chk span { font-size: 13px; color: var(--muted); }
.sso .btn span svg { width: 20px; height: 20px; }
.drv-rider .n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font: 700 13px var(--font-display); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.big svg { width: 22px; height: 22px; }
.demo-grid .btn { justify-content: flex-start; }
.drv-main { padding-top: 14px; }

@media (max-width: 600px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar .wordmark span { display: none; }
  .topbar .org { padding-left: 10px; font-size: 12px; }
}
.track .leaflet-bottom.leaflet-right { margin-bottom: 0; }
@media (max-width: 959px) { .track .leaflet-control-attribution { display: none; } }

.map-dark .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9) saturate(.6); }

/* Individual apps: chooser, bus code, licence */
.ind-choose { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.ind-opt { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); text-decoration: none; transition: border-color .15s, transform .15s; }
.ind-opt:hover { border-color: var(--primary); transform: translateY(-1px); }
.ind-opt .ic { width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.ind-opt .ic svg { width: 22px; height: 22px; }
.ind-opt b { display: block; font-size: 15.5px; }
.ind-opt small { color: var(--muted); font-size: 13px; }
.code-card { background: var(--brand); color: #fff; border-radius: var(--radius-l); padding: 18px; text-align: center; box-shadow: var(--shadow); }
.code-card .code { font: 800 34px/1.1 var(--font-display); letter-spacing: .08em; margin: 6px 0; color: var(--accent); user-select: all; }
.lic { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.lic.ended { border-color: var(--bad); background: var(--bad-soft); }
.plan-pick { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 16px 10px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; }
.plan-pick b { font: 800 22px var(--font-display); }
.plan-pick span { font-size: 12.5px; color: var(--muted); }
.plan-pick.best { border-color: var(--primary); }
.plan-pick:hover { border-color: var(--primary); }
.plan-pick:disabled { opacity: .6; cursor: wait; }

/* Licences */
.quote { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; margin-top: 12px; }
.key-box { font: 700 24px monospace; letter-spacing: 2px; text-align: center; padding: 16px; border-radius: 14px; background: var(--brand); color: var(--accent); user-select: all; margin: 10px 0; word-break: break-all; }
.pay-opts { display: grid; gap: 8px; margin: 12px 0 6px; }

/* Map / Satellite switch */
.map-style-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 10px; border: 0; background: var(--surface); color: var(--ink);
  font: 600 13px var(--font-body); box-shadow: 0 2px 10px rgba(0,0,0,.25); cursor: pointer; }
.map-style-btn svg { width: 18px; height: 18px; }
.map-style-btn:hover { background: var(--surface-2); }

.side-h { font: 700 11px var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 14px 14px 4px; }
.side-h:first-child { padding-top: 4px; }
/* keep the Map/Satellite switch clear of the floating status card */
.track .leaflet-top.leaflet-right { top: 96px; }
