:root {
  --blue: #3391ff;
  --blue-dark: #1f74db;
  --bg: #050d1c;
  --bg-2: #0a1830;
  --card: #0e1f3b;
  --card-2: #13284a;
  --line: #1d3458;
  --text: #e8eef8;
  --muted: #9fb0c9;
  --green: #12b886;
  --yellow: #f2b705;
  --orange: #f08c2a;
  --red: #e5484d;
  --grey: #8a93a6;
  --pink: #e0237f;
  --radius: 8px;
  font-family: 'Ubuntu', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { display: flex; flex-direction: column; min-height: 100vh; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
.wrap { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 18px; }
.small { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- top bars ---------- */
.nav { background: var(--blue); position: sticky; top: 0; z-index: 1000; }
.nav-inner { display: flex; align-items: center; gap: 22px; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 20px; white-space: nowrap; }
.links { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.links a { color: #fff; text-decoration: none; padding: 7px 11px; border-radius: 6px; font-size: 15px; white-space: nowrap; opacity: .92; }
.links a:hover { background: rgba(255,255,255,.14); opacity: 1; }
.links a.active { background: rgba(5,13,28,.25); opacity: 1; }
.clock { font-family: 'Ubuntu Mono', ui-monospace, monospace; background: var(--bg); color: #fff; padding: 7px 12px; border-radius: 6px; font-size: 14px; letter-spacing: .5px; white-space: nowrap; }
.subnav { background: var(--bg-2); border-bottom: 1px solid var(--line); }
.subnav-inner { display: flex; gap: 10px; align-items: center; height: 46px; }
.pill { display: inline-flex; align-items: center; gap: 7px; background: #172a4a; padding: 5px 11px; border-radius: 6px; font-size: 13px; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grey); }
.pill.live .dot { background: var(--green); box-shadow: 0 0 0 0 rgba(18,184,134,.6); animation: pulse 2s infinite; }
.pill.down .dot { background: var(--red); }
.pill.demo { background: #3a2a05; color: #ffd66b; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(18,184,134,.55); } 70% { box-shadow: 0 0 0 7px rgba(18,184,134,0); } 100% { box-shadow: 0 0 0 0 rgba(18,184,134,0); } }

main.wrap { flex: 1; padding-top: 26px; padding-bottom: 40px; }

/* ---------- home ---------- */
.hero { background: var(--blue); text-align: center; padding: 34px 18px 38px; margin: -26px calc(50% - 50vw) 28px; }
.hero h1 { font-size: 34px; color: #fff; display: inline-flex; gap: 12px; align-items: center; }
.hero p { color: #e8f2ff; margin: 10px 0 0; font-size: 17px; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tile { background: var(--card); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; text-decoration: none; transition: transform .15s, box-shadow .15s; }
a.tile:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.tile-art { height: 120px; display: grid; place-items: center; background: linear-gradient(135deg, #12305a, #0b1a33); }
.tile-body { padding: 18px 20px; flex: 1; }
.tile-body h3 { font-size: 19px; margin-bottom: 10px; }
.tile-body p { color: #c9d5e8; margin: 0 0 10px; font-size: 14px; line-height: 1.5; }
.tile-foot { padding: 10px; text-align: center; font-weight: 500; font-size: 14px; color: #fff; }
.c-green { color: var(--green); } .c-yellow { color: var(--yellow); } .c-orange { color: var(--orange); } .c-red { color: var(--red); } .c-blue { color: var(--blue); }
.bg-green { background: var(--green); } .bg-yellow { background: var(--yellow); } .bg-orange { background: var(--orange); } .bg-red { background: var(--red); } .bg-grey { background: var(--grey); } .bg-blue { background: var(--blue); }

/* ---------- stat boxes ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--card); border-radius: var(--radius); padding: 18px 10px; gap: 14px 6px; margin-bottom: 26px; }
.stat { text-align: center; }
.stat b { display: block; font-size: 22px; font-weight: 700; }
.stat span { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: #c9d5e8; }
.section-title { font-size: 22px; margin: 0 0 14px; color: var(--orange); }
.section-title.red { color: var(--red); }
.page-title { font-size: 28px; margin-bottom: 18px; display: flex; align-items: center; gap: 10px; }

/* ---------- search ---------- */
.search { display: flex; margin-bottom: 20px; border: 1px solid var(--blue); border-radius: 7px; overflow: hidden; }
.search input { flex: 1; background: transparent; border: 0; color: var(--text); font: inherit; padding: 11px 14px; outline: none; min-width: 0; }
.search input::placeholder { color: #7f91ad; }
.search span { background: var(--blue); padding: 0 18px; display: flex; align-items: center; gap: 6px; color: #fff; }

/* ---------- server cards ---------- */
.servers { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.server { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.server-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-weight: 500; font-size: 15px; background: #172a4a; }
.server-head small { font-size: 12px; font-weight: 700; }
.row { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; color: #fff; font-size: 14px; text-decoration: none; }
.row + .row { border-top: 1px solid rgba(0,0,0,.18); }
.badge { background: #0b1220; color: #fff; border-radius: 999px; min-width: 22px; padding: 2px 8px; text-align: center; font-size: 12px; font-weight: 700; }
.route-chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- route badges ---------- */
.rb { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 28px; padding: 0 8px; border-radius: 5px; font-weight: 700; color: #fff; background: var(--red); font-size: 15px; text-decoration: none; }
.rb.sm { min-width: 34px; height: 22px; font-size: 12px; }
.rb.nis { background: #4a5568; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 11px 12px; background: #172a4a; }
.table td { padding: 11px 12px; border-top: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--card-2); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.dest { font-weight: 500; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.bar { height: 7px; background: #20385f; border-radius: 99px; overflow: hidden; min-width: 90px; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width 1s linear; }
.eta { font-weight: 700; white-space: nowrap; }
.eta.due { color: var(--green); }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 4px; background: #23395e; color: #cfe0ff; margin-left: 6px; vertical-align: middle; }
.tag.warn { background: #4a2d06; color: #ffcf7a; }
.tag.ok { background: #083d2e; color: #6ff0c3; }

.empty { background: var(--card); border-radius: var(--radius); padding: 34px 20px; text-align: center; color: var(--muted); }
.empty b { color: var(--text); display: block; font-size: 17px; margin-bottom: 6px; font-weight: 500; }
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--blue); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--blue-dark); }
.btn.ghost { background: #172a4a; }
.btn.ghost:hover { background: #1f3760; }

/* ---------- route page line diagram ---------- */
.route-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.route-head h1 { font-size: 26px; }
.line { position: relative; background: var(--card); border-radius: var(--radius); padding: 18px 18px 18px 22px; }
.line-stop { position: relative; padding: 0 0 22px 34px; min-height: 30px; }
.line-stop:last-child { padding-bottom: 0; }
.line-stop::before { content: ''; position: absolute; left: 9px; top: 6px; bottom: -6px; width: 4px; background: var(--red); }
.line-stop:last-child::before { display: none; }
.line-stop::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--card); border: 4px solid var(--red); box-sizing: border-box; }
.line-stop.passed::after { border-color: #556179; }
.line-stop.passed::before { background: #556179; }
.line-stop.next::after { background: var(--yellow); border-color: var(--yellow); }
.line-stop .name { font-weight: 500; }
.line-stop.passed .name { color: var(--muted); }
.line-stop .right { float: right; text-align: right; }
.line-bus { margin: 4px 0 0; display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; gap: 6px; align-items: center; background: #172a4a; border-radius: 5px; padding: 4px 8px; font-size: 12px; text-decoration: none; }
.chip:hover { background: #1f3760; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 820px) { .two { grid-template-columns: 1fr; } }

/* ---------- live map view ---------- */
#mapview { display: grid; grid-template-columns: 370px 1fr; height: calc(100vh - 102px); }
.map-holder { position: relative; min-height: 300px; }
#map { position: absolute; inset: 0; background: #0b1628; }
.map-btn { position: absolute; z-index: 500; right: 12px; top: 12px; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.map-btn:hover { background: var(--card-2); }
.panel { background: var(--bg-2); border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.panel-head { padding: 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-2); z-index: 2; }
.panel-head .search { margin: 10px 0 0; }
.panel-head .search input { padding: 8px 12px; font-size: 14px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.filters button { background: #172a4a; color: var(--text); border: 0; border-radius: 5px; padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.filters button.on { background: var(--blue); }
.blist { list-style: none; margin: 0; padding: 0; }
.blist li { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; }
.blist li:hover { background: var(--card); }
.blist li.sel { background: var(--card-2); }
.blist .info { flex: 1; min-width: 0; }
.blist .info .dest { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail { padding: 16px 14px; }
.detail .back { background: none; border: 0; color: var(--blue); font: inherit; cursor: pointer; padding: 0; margin-bottom: 12px; font-size: 14px; }
.detail-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.detail-head h2 { font-size: 19px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.kv div { background: var(--card); border-radius: 6px; padding: 9px 10px; }
.kv b { display: block; font-size: 16px; }
.kv span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.progress-box { background: var(--card); border-radius: 6px; padding: 12px; margin-bottom: 14px; }
.progress-box .bar { height: 10px; margin: 8px 0 6px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: start; padding: 0 0 14px; position: relative; font-size: 14px; }
.timeline li::before { content: ''; position: absolute; left: 9px; top: 12px; bottom: -2px; width: 3px; background: var(--red); }
.timeline li:last-child::before { display: none; }
.timeline .pt { width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--red); background: var(--bg-2); margin: 2px 0 0 4px; position: relative; z-index: 1; }
.timeline li.passed { color: var(--muted); }
.timeline li.passed .pt { border-color: #556179; }
.timeline li.passed::before { background: #556179; }
.timeline li.next .pt { background: var(--yellow); border-color: var(--yellow); }
.timeline .t { text-align: right; white-space: nowrap; }
.timeline .t small { display: block; color: var(--muted); font-size: 11px; }

/* map markers */
.bus-icon { background: none; border: 0; }
.leaflet-marker-icon.bus-icon { transition: transform 2.9s linear; }
.leaflet-zoom-anim .leaflet-marker-icon.bus-icon, .no-glide .leaflet-marker-icon.bus-icon { transition: none !important; }
.bus { position: relative; width: 40px; height: 40px; }
.bus .arrow { position: absolute; inset: 0; transition: transform .6s; }
.bus .arrow::before { content: ''; position: absolute; left: 50%; top: 0; transform: translateX(-50%); border: 8px solid transparent; border-bottom: 11px solid #fff; border-top: 0; }
.bus .label { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--red); color: #fff; font-weight: 700; font-size: 12px; border-radius: 5px; padding: 3px 6px; border: 2px solid #fff; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.45); }
.bus.nis .label { background: #4a5568; }
.bus.sel .label { background: var(--yellow); color: #111; }
.bus.dim { opacity: .35; }
.stop-label { background: var(--card); color: var(--text); border: 0; border-radius: 4px; font-family: inherit; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.stop-label::before { display: none; }
.leaflet-container { font-family: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--text); }
.leaflet-control-attribution { background: rgba(5,13,28,.75) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar a { background: var(--card); color: var(--text); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--card-2); }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); padding-top: 18px; padding-bottom: 22px; }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.footer h4 { font-size: 15px; margin-bottom: 8px; }
.footer a { display: block; font-size: 13px; color: #c9d5e8; margin-bottom: 6px; }
.footer p { margin: 0; font-size: 13px; color: #c9d5e8; line-height: 1.5; }
.footer > .small { margin: 18px 0 0; }
body.mapmode .footer { display: none; }

@media (max-width: 860px) {
  .brand span { display: none; }
  .nav-inner { gap: 10px; }
  #mapview { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  #mapview .map-holder { order: -1; height: 55vh; }
  .panel { border-right: 0; border-top: 1px solid var(--line); max-height: none; }
  .hide-sm { display: none; }
}
