[hidden] { display: none !important; }
:root {
  --navy: #041e42; --bg: #f6f8fb; --card: #fff; --fg: #142033; --muted: #556274; --line: #dde3ea; --accent: #0a5bd3;
  --green: #17693f; --green-bg: #e2f4e9; --amber: #8a5300; --amber-bg: #fdf0d6; --red: #b42318; --red-bg: #fde7e4;
  --blue: #0b5d8c; --blue-bg: #e0eff8; --grey: #556274; --grey-bg: #e9edf2; --dark: #232b35; --dark-bg: #dfe3e9;
  --purple: #5b3cc4; --purple-bg: #ece8fb;
  font-family: Mulish, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--fg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); } .small { font-size: 12px; }

/* header */
.top { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 12px 20px; padding: 10px 20px; flex-wrap: wrap; position: sticky; top: 0; z-index: 15; }
.brand { color: #fff; text-decoration: none; display: flex; flex-direction: column; }
.brand .b1 { font-weight: 800; font-size: 16px; } .brand .b2 { font-size: 12px; opacity: .78; }
.views { display: flex; gap: 4px; background: #ffffff14; border-radius: 999px; padding: 4px; }
.vbtn { font: inherit; font-weight: 700; color: #fff; background: transparent; border: 0; border-radius: 999px; padding: 8px 16px; cursor: pointer; min-height: 40px; display: flex; align-items: center; gap: 8px; text-decoration: none; }
.vbtn:hover { background: #ffffff1f; }
.vbtn[aria-current="page"] { background: #fff; color: var(--navy); }
.vbtn:focus-visible, .btn:focus-visible, .sum:focus-visible { outline: 3px solid #7fb2ff; outline-offset: 2px; }
.hdot { width: 9px; height: 9px; border-radius: 50%; background: #9aa5b1; flex: none; }
.hdot.ok { background: #35c46f; } .hdot.warn { background: #f5b301; } .hdot.bad { background: #f0473a; }
.upd { font-size: 12px; opacity: .8; white-space: nowrap; }
.stale { background: #b42318; color: #fff; padding: 10px 20px; font-weight: 700; position: sticky; top: 0; z-index: 14; }
.issues { border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-weight: 600; }
.issues.ok { background: var(--green-bg); color: var(--green); } .issues.warn { background: var(--amber-bg); color: var(--amber); } .issues.bad { background: var(--red-bg); color: var(--red); }
.issues ul { margin: 4px 0 0; padding-left: 20px; font-weight: 400; }
.daychips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.badge { background: #d92d20; color: #fff; border-radius: 999px; font-size: 12px; padding: 1px 7px; font-weight: 800; }
.top-right { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.date { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.date input { font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 8px; border: 1px solid #ffffff55; background: #ffffff14; color: #fff; color-scheme: dark; }
.who { font-size: 13px; opacity: .9; }

/* buttons */
.btn { font: inherit; font-weight: 700; border: 1px solid var(--line); background: #fff; color: var(--fg); border-radius: 999px; padding: 8px 16px; cursor: pointer; min-height: 40px; }
.btn:hover { border-color: var(--accent); } .btn:disabled { opacity: .5; cursor: wait; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.danger { color: var(--red); border-color: #efbdb7; }
.btn.ghost { background: transparent; } .btn.light { color: #fff; border-color: #ffffff55; }
.btn.small { padding: 5px 12px; min-height: 34px; font-size: 13px; }

/* layout */
.wrap { padding: 16px 20px 32px; max-width: 1800px; margin: 0 auto; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 1360px) { .layout { grid-template-columns: minmax(0, 1fr) 360px; } .panel { position: sticky; top: 76px; max-height: calc(100vh - 92px); } .panel .x { display: none; } }
@media (max-width: 1359px) {
  .panel { position: fixed; top: 0; right: 0; height: 100%; width: min(420px, 100%); z-index: 25; transform: translateX(105%); transition: transform .18s ease; box-shadow: -8px 0 24px #0003; border-radius: 0 !important; }
  .panel.open { transform: none; }
}
.notice { background: var(--blue-bg); color: var(--blue); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px; }

/* summary */
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.sum { font: inherit; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 8px 6px 6px; cursor: pointer; display: flex; gap: 8px; align-items: center; min-height: 40px; }
.sum b { font-variant-numeric: tabular-nums; font-size: 15px; padding-right: 6px; }
.sum[aria-pressed="true"] { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.filters input[type=search] { font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-width: 240px; flex: 1 1 260px; max-width: 420px; min-height: 40px; }
.sortsel { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.sortsel select, .override select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 40px; }
.chk { display: flex; gap: 6px; align-items: center; color: var(--muted); min-height: 40px; } .count { color: var(--muted); margin-left: auto; }
.ms { position: relative; } .ms summary { list-style: none; cursor: pointer; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fff; min-height: 40px; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.ms summary::-webkit-details-marker { display: none; } .ms summary::after { content: "▾"; color: var(--muted); }
.msn { background: var(--navy); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; }
.msn:empty { display: none; }
.msp { position: absolute; top: calc(100% + 4px); left: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px #0002; padding: 8px; z-index: 12; min-width: 240px; max-height: 360px; overflow: auto; }
.msp label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; } .msp label:hover { background: var(--bg); }
.msp .n { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.msp .clear { font: inherit; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 6px 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; background: #fff; padding: 3px; }
.seg button { font: inherit; font-weight: 700; border: 0; background: transparent; border-radius: 999px; padding: 7px 14px; cursor: pointer; min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }

/* tables */
.tablewrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.tablewrap.flat { border: 0; border-radius: 0; }
table.routes { width: 100%; border-collapse: collapse; min-width: 938px; }
table.routes.alerts { min-width: 820px; }
.routes th, table.mini th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fff; white-space: nowrap; }
.routes td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.routes tbody tr { cursor: pointer; } .routes tbody tr:hover td { background: #f8fafd; }
.routes tr.attn td { background: #fff6f5; } .routes tr.sel td { background: #eef4ff; }
.routes td.num, .routes th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); font-size: 12px; display: block; }
.rb { display: flex; gap: 10px; } .acc { width: 4px; border-radius: 2px; align-self: stretch; flex: none; }
.rtag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px 0 4px; margin-left: 6px; }
.sw { width: 10px; height: 10px; border-radius: 50%; border: 1px solid #0003; display: inline-block; }
.chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.c-late, .c-unplanned_stop, .c-no_signal, .c-failing, .c-missed { background: var(--red-bg); color: var(--red); }
.c-bus_off { background: var(--dark-bg); color: var(--dark); }
.c-at_risk, .c-waiting, .c-no_link { background: var(--amber-bg); color: var(--amber); }
.c-early { background: var(--purple-bg); color: var(--purple); }
.c-on_time, .c-moving { background: var(--green-bg); color: var(--green); }
.c-at_stop, .c-stopped { background: var(--blue-bg); color: var(--blue); }
.c-not_started, .c-completed, .c-test { background: var(--grey-bg); color: var(--grey); }
.var-late { color: var(--red); font-weight: 800; } .var-risk { color: var(--amber); font-weight: 800; } .var-early { color: var(--purple); font-weight: 800; }
.mtag { display: inline-block; background: var(--red-bg); color: var(--red); font-size: 11px; font-weight: 800; border-radius: 4px; padding: 1px 6px; margin-left: 6px; }
.mk { display: inline-block; width: 12px; height: 12px; vertical-align: -1px; margin-right: 6px; flex: none; }
.mk.moving { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 11px solid #2e9e5b; }
.mk.idle { border-radius: 50%; background: #2e9e5b; } .mk.off { border-radius: 50%; background: #1d232a; }
.mk.none { border-radius: 50%; border: 2px dashed #8895a2; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 12px; margin-top: 10px; align-items: center; }
.empty { padding: 28px; text-align: center; color: var(--muted); margin: 0; }
.warn-t { color: var(--amber); font-weight: 700; }

/* details panel */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
.panelHead { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); gap: 8px; }
.panelHead h2 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.x { font-size: 26px; background: none; border: 0; cursor: pointer; line-height: 1; padding: 4px 10px; min-height: 40px; }
.panelBody { padding: 14px 16px; overflow-y: auto; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.dl { display: grid; grid-template-columns: 112px 1fr; gap: 6px 10px; margin: 0; } .dl dt { color: var(--muted); } .dl dd { margin: 0; overflow-wrap: anywhere; }
.ok-t { color: var(--green); font-weight: 700; } .nc { background: var(--amber-bg); color: var(--amber); font-size: 11px; font-weight: 800; border-radius: 4px; padding: 1px 6px; }
.stops { list-style: none; margin: 0; padding: 0; }
.stops li { display: grid; grid-template-columns: 20px 1fr auto; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); align-items: start; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #b6c0cc; margin-top: 3px; }
.st-done .dot { background: var(--green); border-color: var(--green); } .st-next .dot { border-color: var(--navy); border-width: 4px; }
.st-missed .dot { background: var(--red); border-color: var(--red); }
.st-next .sn { font-weight: 800; } .st-done .sn { color: var(--muted); }
.stime { text-align: right; font-size: 12px; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* system */
.sysgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(520px, 100%), 1fr)); gap: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.card.wide { grid-column: 1 / -1; }
.cardHead { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.cardHead h2 { margin: 0; font-size: 16px; }
.readers-ctl { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.readers-ctl input { width: 64px; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 8px; min-height: 40px; }
table.mini { width: 100%; border-collapse: collapse; } table.mini td { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.override { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; } .override select { flex: 1 1 260px; }
.pill { border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--green-bg); color: var(--green); } .pill.warn { background: var(--amber-bg); color: var(--amber); } .pill.bad { background: var(--red-bg); color: var(--red); } .pill.grey { background: var(--grey-bg); color: var(--grey); }
.log-item { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* modal, toast, splash */
.modal { position: fixed; inset: 0; background: #0006; display: grid; place-items: center; z-index: 30; padding: 16px; }
.modal-card { background: #fff; border-radius: 12px; padding: 20px; max-width: 440px; width: 100%; }
.modal-card h3 { margin: 0 0 8px; } .modal-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 40; max-width: 90vw; }
.toast.err { background: var(--red); }
.splash { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; background: var(--bg); z-index: 10; color: var(--muted); padding: 16px; }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--navy); border-radius: 50%; margin: 0 auto 10px; animation: r .9s linear infinite; }
@keyframes r { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .top { padding: 10px 16px; position: static; } .wrap { padding: 12px 16px 24px; } .top-right { margin-left: 0; }
  .who, .brand .b2 { display: none; } .stale { padding: 10px 16px; }
  .routes td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: 12px; }
  .routes td.nil { display: none; }
  table.routes { min-width: 0; } .routes thead { display: none; }
  .routes tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .routes td { display: block; border: 0; padding: 3px 12px; } .routes td.num { text-align: left; }
  .count { margin-left: 0; }
}
