:root {
  --navy: #0E2236; --ink: #0F2338; --muted: #4B5866; --line: #E1E6EB;
  --red: #D13B30; --bub: #C62F25; --bub-sel: #8E1C15; --green: #2FAE57; --green-ink: #17663A;
  --amber: #F2A900; --map: #E3E8ED; --header: 68px; --sheet: 44vh;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Public Sans', system-ui, sans-serif; color: var(--ink); background: #F4F6F8; overflow: hidden; }
button { font: inherit; color: inherit; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #2B6CB0; outline-offset: 2px; }

/* header */
.top { height: var(--header); padding: 0 24px; background: var(--navy); color: #fff; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.city-logo { height: 44px; width: auto; flex: none; display: block; }
.brand-text { padding-left: 14px; border-left: 1px solid rgba(255,255,255,.25); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-size: 18px; font-weight: 800; white-space: nowrap; }
.brand-sub { font-size: 12px; color: #B9C7D6; }
.demo-badge { font-size: 12px; font-weight: 800; letter-spacing: .04em; color: #1A1A1A; background: #FFD66B; padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
.badge-short { display: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #DCE5EE; white-space: nowrap; }
.live strong { color: #fff; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #3DD26E; }
.ghost-btn { height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,.3); background: transparent; color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.ghost-btn:hover { background: rgba(255,255,255,.08); }

/* layout */
.layout { height: calc(100vh - var(--header)); height: calc(100dvh - var(--header)); display: grid; grid-template-columns: 380px 1fr; }
.side { grid-column: 1; grid-row: 1; overflow-y: auto; padding: 20px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 18px; }
.map { grid-column: 2; grid-row: 1; position: relative; overflow: hidden; background: var(--map); touch-action: none; cursor: grab; user-select: none; }
.map.dragging { cursor: grabbing; }
.handle { display: none; }

/* map world */
.anchor { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.layer-img { position: absolute; left: 0; top: 0; pointer-events: none; user-select: none; }
.pc { position: absolute; overflow: hidden; background: var(--red); }
.pc.pre { background: var(--green); }
.pc > i { position: absolute; top: 0; bottom: 0; background: var(--green); }
.edge { position: absolute; left: 0; top: 0; width: 0; height: 0; padding: 0; border: 0; background: none; cursor: pointer; }
.edge.sel .pc { box-shadow: 0 0 0 5px rgba(15,35,56,.55); }
.truck { position: absolute; width: 36px; height: 72px; padding: 0; border: 0; background: none; cursor: pointer; z-index: 2; }
.truck img { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 8px 6px rgba(15,35,56,.4)); pointer-events: none; }
.halo { position: absolute; left: -32px; top: -14px; width: 100px; height: 100px; border-radius: 50%; background: rgba(242,169,0,.22); border: 3px solid rgba(242,169,0,.75); animation: halo 1.8s ease-out infinite; pointer-events: none; }
.truck.sel .halo { background: rgba(242,169,0,.38); }
.truck.done .halo { display: none; }

/* bubbles */
.bubble { position: absolute; width: 0; height: 0; padding: 0; border: 0; background: none; cursor: pointer; z-index: 2; }
.bubble .dot { position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--bub); }
.bubble .pill { position: absolute; left: 0; bottom: 13px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; background: var(--bub); color: #fff; font-weight: 800; font-size: 13px; line-height: 1; padding: 7px 10px; border-radius: 999px; border: 2px solid #fff; box-shadow: 0 6px 16px rgba(15,35,56,.3); }
.bubble .tail { position: absolute; left: -5px; bottom: 9px; width: 10px; height: 10px; background: var(--bub); transform: rotate(45deg); border-right: 2px solid #fff; border-bottom: 2px solid #fff; }
.bubble.sel { z-index: 6; }
.bubble.sel .pill { background: var(--bub-sel); font-size: 14px; padding: 9px 12px; }
.bubble.sel .tail { background: var(--bub-sel); }
.bubble.sel .dot { border-color: var(--bub-sel); }
.bubble .nm { display: none; font-weight: 600; }
.bubble.sel .nm { display: inline; }
.truck-tag { position: absolute; transform: translate(-50%, -100%); background: var(--ink); color: #fff; font-weight: 800; font-size: 12px; line-height: 1; padding: 7px 10px; border-radius: 999px; white-space: nowrap; box-shadow: 0 4px 12px rgba(15,35,56,.3); pointer-events: none; z-index: 7; }

.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.legend { position: absolute; left: 16px; bottom: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; background: rgba(255,255,255,.95); border-radius: 12px; padding: 10px 14px; box-shadow: 0 2px 10px rgba(15,35,56,.14); font-size: 13px; font-weight: 600; color: #2D3A48; cursor: default; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .legend-demo { display: none; font-weight: 800; color: #1A1A1A; background: #FFD66B; padding: 3px 8px; border-radius: 999px; }
.sw { display: inline-block; width: 22px; height: 7px; border-radius: 3px; }
.sw.red { background: var(--red); } .sw.green { background: var(--green); }
.sw.zone { height: 0; border-top: 2px dashed #7C8B99; border-radius: 0; }
.pill-mini { font-style: normal; padding: 3px 7px; border-radius: 999px; background: var(--bub); color: #fff; font-size: 11px; font-weight: 800; }
.osm { position: absolute; right: 72px; bottom: 16px; font-size: 11px; color: #3E4B59; background: rgba(255,255,255,.85); padding: 3px 6px; border-radius: 4px; text-decoration: none; }
.controls { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.controls button { width: 44px; height: 44px; border-radius: 12px; border: 0; background: #fff; box-shadow: 0 4px 14px rgba(15,35,56,.2); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); }
.controls button.dark { background: var(--ink); color: #fff; }

/* detail panel */
.panel { position: absolute; left: 16px; top: 16px; width: 350px; max-width: calc(100% - 32px); max-height: calc(100% - 100px); overflow-y: auto; background: #fff; border-radius: 18px; box-shadow: 0 12px 32px rgba(15,35,56,.22); padding: 18px; z-index: 10; cursor: default; animation: rise .25s ease-out; }
.panel-head { display: flex; align-items: center; gap: 12px; }
.panel-truck { width: 24px; height: 48px; flex: none; }
.panel-titles { flex: 1; min-width: 0; }
.panel h2 { margin: 0; font-size: 22px; font-weight: 800; }
.panel p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.close { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; background: #F1F3F5; display: flex; align-items: center; justify-content: center; cursor: pointer; }

/* sidebar */
.block { display: flex; flex-direction: column; gap: 10px; }
.card { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; gap: 8px; }
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .08em; color: var(--muted); }
.muted { font-size: 13px; color: var(--muted); }
.row-between { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.big { display: flex; align-items: baseline; gap: 8px; }
.big #pct { font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.bar { height: 8px; border-radius: 4px; background: #E7EBEF; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--green); border-radius: 4px; transition: width .4s; }
select { height: 48px; border: 1.5px solid #C3CDD7; border-radius: 12px; padding: 0 12px; background: #fff; font: 700 16px 'Public Sans', sans-serif; color: var(--ink); cursor: pointer; }
.status { border-radius: 14px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.status.red { background: #FBEAE8; color: var(--bub-sel); }
.status.green { background: #E4F4E9; color: var(--green-ink); }
.status .col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.status .k { font-size: 13px; font-weight: 700; }
.status .v { font-size: 30px; line-height: 1.05; font-weight: 800; }
.status.green .v { font-size: 18px; }
.status .s { font-size: 13px; color: #5A2A26; }
.status.green .s { color: #2D4A37; }
.chip-btn { flex: none; height: 40px; padding: 0 12px; border-radius: 999px; background: #fff; font-weight: 700; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.status.red .chip-btn { border: 1.5px solid #E7B8B3; color: var(--bub-sel); }
.status.green .chip-btn { border: 1.5px solid #B7DEC3; color: var(--green-ink); }
.chip-btn.on { background: var(--bub-sel); color: #fff !important; border-color: var(--bub-sel) !important; }
.check { width: 40px; height: 40px; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.truck-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tcard { height: 60px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: #fff; text-align: left; cursor: pointer; border: 1.5px solid var(--line); }
.tcard.sel { border: 2px solid var(--ink); }
.tcard img { width: 18px; height: 36px; flex: none; }
.tcard .t1 { display: block; font-size: 14px; font-weight: 800; }
.tcard .t2 { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcard > span { min-width: 0; }
.srow { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 10px; border: 0; border-bottom: 1px solid #EDF0F3; text-align: left; cursor: pointer; border-radius: 8px; background: transparent; }
.srow:hover { background: #F1F4F7; }
.srow.sel { background: #EAF1F8; }
.srow .swatch { width: 6px; height: 30px; border-radius: 3px; flex: none; background: var(--red); }
.srow.done .swatch { background: var(--green); }
.srow .nm { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.srow .nm b { font-size: 14px; }
.srow .nm small { font-size: 12px; color: var(--muted); }
.chip { flex: none; font-size: 12px; font-weight: 800; padding: 5px 9px; border-radius: 999px; background: var(--bub); color: #fff; white-space: nowrap; }
.chip.ok { background: #E4F4E9; color: var(--green-ink); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid #EDF0F3; font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.stat { background: #F1F3F5; border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.stat .k { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 800; }
.stat .bar { height: 5px; background: #DCE2E8; }
.follow { margin-top: 14px; width: 100%; height: 46px; border-radius: 12px; cursor: pointer; font-weight: 800; font-size: 15px; background: var(--amber); color: #1A1A1A; border: 0; }
.follow.on { background: #fff; border: 2px solid var(--ink); color: var(--ink); }
.sect { margin: 14px 0 0; display: block; }
.fine { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

@keyframes halo { 0% { transform: scale(.5); opacity: .95; } 100% { transform: scale(1.2); opacity: 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .halo, .live-dot, .panel { animation: none; } }

/* phone: full-screen map with a bottom sheet */
@media (max-width: 860px) {
  :root { --header: 56px; }
  .top { padding: 0 12px; gap: 10px; }
  .city-logo { height: 32px; }
  .brand-text { padding-left: 10px; }
  .brand-name { font-size: 15px; }
  .brand { flex: 1; }
  .brand { gap: 10px; }
  .brand-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
  .brand-sub, .ghost-btn span, .live, .badge-long, .city { display: none; }
  .badge-short { display: inline; }
  .demo-badge { font-size: 11px; padding: 5px 8px; flex: none; }
  .top-right { gap: 8px; }
  .ghost-btn { width: 40px; padding: 0; justify-content: center; }
  .layout { display: block; position: relative; }
  .map { position: absolute; inset: 0; }
  .side { position: absolute; left: 0; right: 0; bottom: 0; height: var(--sheet); border-right: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(15,35,56,.18); padding: 8px 16px 20px; z-index: 20; gap: 14px; }
  .handle { display: block; width: 40px; height: 4px; border-radius: 2px; background: #CFD6DD; margin: 0 auto; flex: none; }
  .legend { top: 12px; bottom: auto; left: 12px; right: 12px; gap: 10px; font-size: 11px; padding: 7px 10px; }
  .legend span:nth-child(4), .legend span:nth-child(5), .demo-badge { display: none; }
  .legend .legend-demo { display: inline-flex; }
  .controls { right: 12px; bottom: calc(var(--sheet) + 12px); }
  .osm { left: 12px; right: auto; bottom: calc(var(--sheet) + 8px); font-size: 11px; }
  .panel { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-width: none; max-height: 62%; border-radius: 22px 22px 0 0; z-index: 30; }
  .layout.has-panel .side { visibility: hidden; }
  .truck-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
