:root {
  --bg: #f4f6f5; --card: #fff; --ink: #14201c; --muted: #5d6b66; --line: #e3e8e6;
  --brand: #0b5d4f; --brand-2: #e7f2ef; --gold: #d99a00; --dp: #9aa5a1;
  --shadow: 0 1px 2px rgba(16,32,28,.06), 0 4px 16px rgba(16,32,28,.06);
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: 'Be Vietnam Pro', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; }
a { color: inherit; }

/* Header */
.top { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; background: var(--brand); color: #fff; position: relative; z-index: 1000; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.14); display: grid; place-items: center; flex: none; }
.logo svg { width: 22px; height: 22px; fill: #fff; }
.top h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top p { margin: 1px 0 0; font-size: 12.5px; opacity: .82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; flex: none; }
.lead span { opacity: .75; }
.lead b { font-weight: 600; font-size: 13.5px; }

/* Layout */
.app { display: grid; grid-template-columns: 440px 1fr; height: calc(100vh - 64px); height: calc(100dvh - 64px); }
.panel { overflow-y: auto; border-right: 1px solid var(--line); background: var(--bg); padding: 16px 16px 24px; scroll-behavior: smooth; }
.mapwrap { position: relative; }
#map { position: absolute; inset: 0; background: #e9eeec; }
.leaflet-control-layers { border: 0 !important; border-radius: 8px !important; box-shadow: 0 1px 4px rgba(0,0,0,.25) !important; font-family: 'Be Vietnam Pro', sans-serif; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.kpi b { display: block; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.kpi span { font-size: 11.5px; color: var(--muted); }
.kpi.gold b { color: var(--gold); }

/* Day tabs */
.days { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -2px 6px; scrollbar-width: thin; }
.day { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 7px 11px; text-align: left; color: var(--ink); transition: .15s; min-width: 74px; }
.day small { display: block; font-size: 11px; color: var(--muted); }
.day b { font-size: 14px; font-weight: 600; }
.day .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.day:hover { border-color: #c5d0cc; }
.day[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.day[aria-selected="true"] small { color: rgba(255,255,255,.7); }

/* Toolbar */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.cars { display: flex; gap: 4px; background: #e6ebe9; padding: 3px; border-radius: 9px; }
.cars:empty { display: none; }
.car { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; font-size: 13px; color: var(--muted); font-weight: 500; }
.car[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.search { flex: 1; min-width: 180px; display: flex; align-items: center; gap: 7px; background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; height: 36px; }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11,93,79,.12); }
.search svg { width: 17px; height: 17px; fill: var(--muted); flex: none; }
.search input { border: 0; outline: 0; flex: 1; font: inherit; background: transparent; min-width: 0; }

/* Summary card */
.sum { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.sum-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sum h2 { margin: 0; font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; }
.sum .area { color: var(--muted); font-size: 13px; margin-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; color: #fff; flex: none; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0; }
.stats div { background: var(--bg); border-radius: 8px; padding: 7px 8px; }
.stats b { display: block; font-size: 15px; font-weight: 700; }
.stats span { font-size: 11px; color: var(--muted); }
.cls { font-size: 12.5px; background: #fff8e6; border: 1px solid #f3e1b0; color: #6b5200; border-radius: 8px; padding: 7px 10px; margin-bottom: 10px; }
.cls b { font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 500; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: #c5d0cc; background: #fafbfb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #094d42; }
.btn svg { width: 16px; height: 16px; fill: currentColor; }

/* Overview */
.ov { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 4px; margin-bottom: 12px; box-shadow: var(--shadow); }
.ov-row { display: grid; grid-template-columns: 6px 1fr auto; gap: 12px; align-items: center; padding: 10px 10px; border-radius: 9px; border: 0; background: transparent; width: 100%; text-align: left; color: var(--ink); }
.ov-row:hover { background: var(--bg); }
.ov-row i { width: 6px; height: 34px; border-radius: 3px; }
.ov-row b { font-size: 13.5px; font-weight: 600; }
.ov-row small { display: block; color: var(--muted); font-size: 12px; }
.ov-row em { font-style: normal; font-size: 12px; color: var(--muted); text-align: right; }
.ov-row em b { display: block; color: var(--ink); font-size: 14px; }

/* List */
.group-h { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 2px 8px; }
.group-h::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.stop { position: relative; display: grid; grid-template-columns: 30px 1fr; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-bottom: 8px; transition: border-color .15s, box-shadow .15s; cursor: pointer; }
.stop:hover { border-color: #c5d0cc; }
.stop.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11,93,79,.12); }
.num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }
.num.ut { box-shadow: 0 0 0 2.5px #fff, 0 0 0 4.5px var(--gold); }
.num.dp { background: #fff !important; color: var(--dp); border: 2px dashed var(--dp); }
.stop h3 { margin: 0 0 3px; font-size: 14px; font-weight: 600; line-height: 1.35; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 5px; }
.tag { font-size: 11px; font-weight: 600; padding: 1.5px 7px; border-radius: 5px; background: var(--bg); color: var(--muted); }
.tag.ut { background: #fff3d6; color: #8a6000; }
.tag.dp { background: #eef0ef; color: #6f7a76; }
.tag.buoi { background: var(--brand-2); color: var(--brand); }
.meta { font-size: 12.5px; color: var(--muted); display: grid; gap: 2px; }
.meta div { display: flex; gap: 6px; }
.meta svg { width: 14px; height: 14px; fill: #94a19c; flex: none; margin-top: 2px; }
.meta a { color: var(--brand); font-weight: 600; text-decoration: none; }
.meta a:hover { text-decoration: underline; }
.stop-act { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.stop-act .btn { padding: 5px 10px; font-size: 12.5px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.note { margin-top: 18px; font-size: 12px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; }

/* Map */
.legend { position: absolute; left: 12px; bottom: 22px; z-index: 500; background: rgba(255,255,255,.96); border-radius: 10px; padding: 8px 12px; box-shadow: var(--shadow); font-size: 12px; display: grid; gap: 4px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.lg { width: 14px; height: 14px; border-radius: 50%; display: inline-block; background: #4b5a56; }
.lg-ut { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--gold); }
.lg-dp { background: #fff; border: 2px dashed var(--dp); }
.fit { position: absolute; right: 12px; top: 136px; z-index: 500; width: 34px; height: 34px; border-radius: 8px; border: 0; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); display: grid; place-items: center; }
.fit svg { width: 18px; height: 18px; fill: #333; }
.leaflet-control-zoom { border: 0 !important; box-shadow: 0 1px 4px rgba(0,0,0,.25) !important; }
.leaflet-top.leaflet-right { top: 0; }

.mk { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 700 12px 'Be Vietnam Pro', sans-serif; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); transition: transform .15s; }
.mk.ut { box-shadow: 0 0 0 2.5px var(--gold), 0 2px 8px rgba(0,0,0,.35); }
.mk.dp { background: #fff !important; color: #6f7a76; border: 2px dashed var(--dp); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.mk.dim { opacity: .28; }
.mk.hl { transform: scale(1.25); }
.leaflet-marker-icon.on-top { z-index: 9999 !important; }

.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.leaflet-popup-content { margin: 12px 14px; font-family: 'Be Vietnam Pro', sans-serif; font-size: 13px; line-height: 1.45; min-width: 230px; }
.pp-h { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.pp-t { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.pp-l { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.pp-l a { color: var(--brand); font-weight: 600; text-decoration: none; }
.pp-a { display: flex; gap: 6px; margin-top: 10px; }
.pp-a a { flex: 1; text-align: center; padding: 6px 8px; border-radius: 7px; background: var(--brand); color: #fff !important; text-decoration: none; font-weight: 600; font-size: 12.5px; }
.pp-a a.ghost { background: var(--bg); color: var(--ink) !important; }
.pp-g { font-size: 11px; color: #8a9692; margin-top: 8px; }

/* Responsive */
@media (max-width: 900px) {
  .top { height: 56px; padding: 0 14px; }
  .top h1 { font-size: 15px; }
  .lead { display: none; }
  .app { grid-template-columns: 1fr; grid-template-rows: 42vh 1fr; height: calc(100dvh - 56px); }
  .mapwrap { order: 1; }
  .panel { order: 2; border-right: 0; border-top: 1px solid var(--line); padding: 12px 12px 24px; }
  .legend { display: none; }
  .fit { top: 136px; }
  .kpis { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .kpi { padding: 7px 8px; }
  .kpi b { font-size: 17px; }
}
@media (max-width: 380px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
