:root {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  color: #132635;
  background: #edf2f5;
  --muted: #506272;
  --line: #dbe5eb;
  --sea: #126e84;
  --ink: #0c2b39;
  --shop: #11785f;
  --review: #a1570d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #4ab3d2; outline-offset: 2px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.1rem); letter-spacing: -.055em; line-height: 1.05; }
h2 { font-size: 1.06rem; }
small { display: block; }
header { background: var(--ink); color: #fff; }
.top { min-height: 72px; max-width: 1540px; padding: 12px 32px; margin: auto; display: flex; align-items: center; gap: 32px; }
.identity { display: flex; align-items: center; gap: 11px; white-space: nowrap; }
.identity strong { display: block; font-size: 1rem; }
.identity small { color: inherit; opacity: .76; font-size: .75rem; }
.logo { width: 37px; height: 37px; border-radius: 9px; display: grid; place-items: center; font-weight: 850; background: #c1f2ff; color: #16465e; letter-spacing: -.05em; }
nav { display: flex; gap: 7px; }
header button { border: none; border-radius: 6px; padding: 9px 10px; background: transparent; color: #deedf4; font-size: .85rem; }
nav [aria-current="page"], header button:hover { background: #224553; color: white; }
.user { margin-left: auto; display: flex; gap: 7px; align-items: center; font-size: .82rem; }
main { max-width: 1540px; margin: auto; padding: 28px 32px 42px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin: 5px 0 22px; }
.eyebrow { color: var(--sea); font-size: .69rem; letter-spacing: .13em; text-transform: uppercase; font-weight: 780; margin-bottom: 7px; }
.eyebrow:empty { display: none; }
.sub { color: var(--muted); margin-top: 5px; font-size: .88rem; line-height: 1.45; }
.filters { display: flex; gap: 9px; align-items: end; flex-wrap: wrap; }
label { display: grid; gap: 5px; font-size: .77rem; font-weight: 685; color: #354d60; }
input, select { min-width: 0; width: 100%; height: 38px; border: 1px solid #c8d7df; border-radius: 6px; background: #fff; color: #153142; padding: 6px 9px; }
.filters select { min-width: 125px; }
.primary, .secondary { padding: 9px 13px; min-height: 38px; border-radius: 6px; font-size: .83rem; font-weight: 700; }
.primary { background: var(--sea); color: #fff; border: 1px solid var(--sea); }
.primary:hover { background: #09596c; }
.secondary { background: #fff; color: #1b4d60; border: 1px solid #c8d7df; }
.secondary:hover:not(:disabled) { background: #eaf7fa; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 15px; }
.metrics .panel { padding: 14px 17px; }
.metrics span { color: var(--muted); display: block; font-size: .79rem; margin-bottom: 5px; }
.metrics strong { font-size: 1.54rem; letter-spacing: -.04em; }
.route-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(290px, 1fr); gap: 15px; align-items: start; }
.map-panel, .timeline-panel { overflow: hidden; }
.section-heading { padding: 14px 16px; min-height: 65px; display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.section-heading .sub { font-size: .78rem; }
.pill { border-radius: 50px; padding: 4px 9px; background: #e9f2f6; color: #38566b; font-size: .72rem; font-weight: 690; white-space: nowrap; }
.pill:empty { display: none; }
#map, #fallback-map { background: #dcebf0; width: 100%; height: clamp(350px, 57vh, 660px); }
.legend { padding: 12px 16px; display: flex; gap: 10px 14px; flex-wrap: wrap; color: var(--muted); font-size: .74rem; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { height: 9px; width: 9px; border-radius: 50%; display: inline-block; background: #587486; }
.legend .route-key { width: 15px; height: 4px; border-radius: 3px; background: #13779d; }
.legend .shop-key { background: var(--shop); }
.legend .review-key { background: var(--review); }
#timeline { list-style: none; padding: 0; margin: 0; max-height: min(66vh, 690px); min-height: 100px; overflow: auto; }
#timeline li { border-top: 1px solid var(--line); padding: 13px 15px; }
.stop-top { display: flex; gap: 9px; align-items: center; width: 100%; text-align: left; margin-bottom: 5px; background: none; border: 0; color: var(--ink); padding: 0; }
.stop-top:hover strong { text-decoration: underline; }
.stop-top .pill { margin-left: auto; }
.stop-time, .candidate { padding-left: 32px; font-size: .79rem; color: var(--muted); }
.candidate { margin-top: 4px; }
.marker { border-radius: 50%; display: grid; place-items: center; background: #587486; color: #fff; width: 24px; height: 24px; flex: 0 0 24px; font-weight: 760; font-size: .74rem; }
.leaflet-stop .marker { box-shadow: 0 0 0 2px #fff, 0 1px 5px #294758a0; }
.marker.matched, .marker.confirmed { background: var(--shop); }
.marker.review, .marker.unknown { background: var(--review); }
.stop-review { display: flex; padding: 8px 0 0 32px; gap: 6px; }
.stop-review select, .stop-review button { font-size: .74rem; }
.empty { padding: 16px; color: var(--muted); font-size: .85rem; }
.admin-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; align-items: start; }
.admin-panel { padding: 16px; }
.admin-panel ul { padding: 0; list-style: none; max-height: 320px; overflow: auto; margin: 12px 0 16px; }
.admin-panel li { border-bottom: 1px solid var(--line); padding: 8px 0; font-size: .85rem; }
.admin-panel form, .login { display: grid; gap: 10px; }
.form-row, .user-edit { display: flex; gap: 7px; align-items: center; }
.form-row label { flex: 1; min-width: 0; }
.user-edit { margin-top: 5px; }
.user-edit select { width: auto; font-size: .78rem; }
.user-edit input { width: 15px; height: 15px; }
.signin { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(145deg, #0c2b39 0%, #164d61 100%); }
.login { width: min(100%, 380px); padding: 26px; gap: 14px; }
.login h1 { font-size: 1.9rem; margin: 8px 0 3px; }
.error { color: #8d3227; background: #f9ebe8; border-radius: 6px; padding: 9px 11px; font-size: .85rem; margin-bottom: 9px; }
.error:empty { display: none; }
@media (max-width: 950px) {
  .top, main { padding-left: 18px; padding-right: 18px; }
  .route-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  #timeline { max-height: none; }
}
@media (max-width: 620px) {
  .top { flex-wrap: wrap; gap: 8px 15px; }
  nav { order: 3; flex-basis: 100%; }
  .user span { display: none; }
  main { padding-top: 15px; }
  .page-heading { flex-direction: column; align-items: stretch; }
  .metrics { grid-template-columns: repeat(2,1fr); gap: 8px; }
  .admin-grid { grid-template-columns: 1fr; }
}
