:root {
  color-scheme: light;
  --paper: #f9f6ee;
  --surface: #ffffff;
  --ink: #131a29;
  --ink-2: #4a5163;
  --ink-3: #7d828d;
  --rule: #e5dfd1;
  --rule-strong: #cfc7b5;
  --live: #1e7a4f;
  --live-bg: #e2f1e8;
  --transit: #2f56a6;
  --transit-bg: #e6ecf8;
  --warn: #93590b;
  --warn-bg: #f7ead3;
  --bad: #b42318;
  --bad-bg: #fbe5e2;
  --idle: #6f7480;
  --idle-bg: #ece8de;
  --radius: 10px;
  --shadow: 0 18px 50px rgba(19, 26, 41, 0.18);
  font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--transit); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
:focus-visible { outline: 2px solid var(--transit); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* Top bar ------------------------------------------------------------------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand img { height: 24px; width: auto; display: block; }
.brand span { font-weight: 700; font-size: 17px; padding-left: 12px; border-left: 1.5px solid var(--rule-strong); }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--ink-2); }

.page { max-width: 1240px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 80px; }
.loading { color: var(--ink-3); }

/* Buttons ------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 13px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  color: var(--ink);
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.primary:hover { background: #222b3f; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.linkish { background: none; border: 0; padding: 0; color: var(--transit); font-weight: 600; cursor: pointer; }

/* Sign-in ------------------------------------------------------------------- */

.signin { max-width: 420px; margin: 12vh auto 0; }
.signin h1 { font-size: 30px; font-weight: 800; margin-bottom: 10px; }
.signin p { color: var(--ink-2); margin: 0 0 22px; }
.signin form { display: flex; flex-direction: column; gap: 10px; }
.signin .note { margin-top: 18px; font-size: 14px; }
.signin .note.bad { color: var(--bad); }

/* Fleet: the route ------------------------------------------------------------ */

.fleet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 26px;
}
.fleet-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.01em; }
.fleet-head .sub { color: var(--ink-3); font-size: 14px; margin-top: 4px; }
.fleet-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.route-wrap { overflow-x: auto; margin: 0 -4px 6px; padding: 0 4px 10px; }
.route {
  display: grid;
  grid-template-columns: repeat(5, minmax(108px, 1fr)) 28px repeat(2, minmax(96px, 0.75fr));
  min-width: 760px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.station { position: relative; }
.station button {
  all: unset;
  box-sizing: border-box;
  display: block;
  width: 100%;
  padding: 26px 12px 14px 0;
  cursor: pointer;
  border-radius: 8px;
}
.station button:focus-visible { outline: 2px solid var(--transit); outline-offset: 2px; }
/* the line the stations sit on */
.station::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--ink);
}
.station.last::before { right: auto; width: 12px; }
.station.side::before { background: none; border-top: 2px dashed var(--rule-strong); height: 0; }
.station.side.last::before { width: 12px; }
.station::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--ink);
}
.station.has::after { background: var(--ink); }
.station.side::after { border-color: var(--rule-strong); }
.station.side.has::after { background: var(--bad); border-color: var(--bad); }
.station .gap { display: none; }
.route .spacer { list-style: none; }

.station .count { display: block; font-size: 38px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.station.none .count { color: var(--rule-strong); }
.station .name { display: block; font-weight: 600; font-size: 14px; margin-top: 6px; color: var(--ink-2); }
.station .tiles { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; min-height: 18px; }
.station.selected .name { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }
.station button:hover .name { color: var(--ink); }

.tile {
  width: 12px;
  height: 18px;
  border-radius: 3px;
  background: var(--idle);
  display: inline-block;
}
.tile.live { background: var(--live); }
.tile.transit { background: var(--transit); }
.tile.warn { background: var(--warn); }
.tile.bad { background: var(--bad); }
.tile.idle { background: var(--rule-strong); }

.figures {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 36px;
  margin: 18px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--rule);
}
.figures div { min-width: 120px; }
.figures dt { font-size: 13px; color: var(--ink-3); }
.figures dd { margin: 2px 0 0; font-size: 20px; font-weight: 700; }
.figures dd small { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 4px; }

/* Needs attention ------------------------------------------------------------- */

.attention { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.section-head h2 { font-size: 19px; font-weight: 700; }
.section-head .count { color: var(--ink-3); font-weight: 600; }
.attention ul { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.attention li {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px 12px 0;
  border-top: 1px solid var(--rule);
}
.attention li:first-child { border-top: 0; }
.attention .bar { align-self: stretch; border-radius: 0 3px 3px 0; background: var(--idle); }
.attention .bar.bad { background: var(--bad); }
.attention .bar.warn { background: var(--warn); }
.attention .bar.idle { background: var(--rule-strong); }
.attention .what { font-weight: 600; }
.attention .detail { color: var(--ink-2); font-size: 14px; }
.attention .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.attention .empty { padding: 16px; color: var(--ink-2); grid-template-columns: 1fr; }
.attention .more { padding: 10px 16px; display: block; }

/* Tabs and tables --------------------------------------------------------------- */

.tabs { display: flex; gap: 22px; margin: 44px 0 0; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.tabs button {
  all: unset;
  cursor: pointer;
  padding: 10px 0;
  font-weight: 600;
  color: var(--ink-3);
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
}
.tabs button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button:focus-visible { outline: 2px solid var(--transit); outline-offset: 2px; }
.tabs .n { color: var(--ink-3); font-weight: 500; margin-left: 4px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0 12px; }
.toolbar input[type='search'] { min-width: 220px; }
.chip {
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.chip[aria-pressed='true'] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  padding: 11px 14px;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
td { padding: 12px 14px; border-top: 1px solid var(--rule); vertical-align: top; }
tbody tr:first-child td { border-top: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: #fcfbf7; }
td.num, th.num { text-align: right; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.empty-row td { color: var(--ink-2); padding: 22px 14px; }

.pill {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--idle-bg);
  color: var(--idle);
  white-space: nowrap;
}
.pill.live { background: var(--live-bg); color: var(--live); }
.pill.transit { background: var(--transit-bg); color: var(--transit); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--rule-strong); vertical-align: 1px; }
.dot.live { background: var(--live); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }
.muted { color: var(--ink-3); }
.bad-text { color: var(--bad); }
.warn-text { color: var(--warn); }

/* Activity -------------------------------------------------------------------- */

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-day { font-size: 13px; font-weight: 700; color: var(--ink-3); margin: 18px 0 6px; }
.activity-item { display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--rule); }
.activity-item time { color: var(--ink-3); font-size: 13px; padding-top: 1px; }
.activity-item .msg { font-size: 14.5px; }
.activity-item .meta { font-size: 13px; color: var(--ink-3); }
.activity-item.note .msg { font-weight: 600; }
.note-form { display: flex; gap: 8px; align-items: flex-start; margin: 14px 0 6px; flex-wrap: wrap; }
.note-form textarea { flex: 1 1 260px; min-height: 42px; }

/* Inputs ---------------------------------------------------------------------- */

input[type='text'], input[type='email'], input[type='tel'], input[type='url'], input[type='number'],
input[type='date'], input[type='search'], select, textarea {
  width: 100%;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14.5px;
}
textarea { resize: vertical; min-height: 70px; }
.toolbar input, .toolbar select { width: auto; }

/* Drawer ---------------------------------------------------------------------- */

.scrim { position: fixed; inset: 0; background: rgba(19, 26, 41, 0.28); z-index: 20; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(600px, 100vw);
  background: var(--paper);
  z-index: 21;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slide-in 180ms ease-out;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }
.drawer-head {
  position: sticky;
  top: 0;
  background: var(--paper);
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--rule);
  z-index: 1;
}
.drawer-head .row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-head h2 { font-size: 24px; font-weight: 800; }
.drawer-head .sub { color: var(--ink-3); font-size: 14px; margin-top: 4px; }
.drawer-head .acts { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.close {
  border: 0;
  background: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-2);
  padding: 2px 6px;
}
.drawer section { padding: 18px 24px; border-bottom: 1px solid var(--rule); }
.drawer section h3 { font-size: 15px; font-weight: 700; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.item { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; }
.item .line { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.item .title { font-weight: 700; }
.item .facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 14px; margin-top: 8px; font-size: 14px; }
.item .facts dt { color: var(--ink-3); font-size: 12.5px; }
.item .facts dd { margin: 0; }
.item .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.hint { color: var(--ink-2); font-size: 14px; margin: 0 0 8px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; word-break: break-word; }
.mini-table { width: 100%; font-size: 14px; }
.mini-table td, .mini-table th { padding: 6px 8px 6px 0; border: 0; border-top: 1px solid var(--rule); }
.mini-table th { border-top: 0; padding-top: 0; }

/* Form dialog ----------------------------------------------------------------- */

.form-dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  box-shadow: var(--shadow);
  background: var(--paper);
  color: var(--ink);
}
.form-dialog::backdrop { background: rgba(19, 26, 41, 0.35); }
.sheet header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 8px; }
.sheet header h2 { font-size: 20px; font-weight: 800; }
.sheet .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; padding: 8px 22px 6px; }
.sheet .field { display: flex; flex-direction: column; gap: 4px; }
.sheet .field.wide { grid-column: 1 / -1; }
.sheet label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.sheet .help { font-size: 12.5px; color: var(--ink-3); }
.sheet .form-error { color: var(--bad); font-size: 14px; margin: 8px 22px 0; }
.sheet footer { display: flex; gap: 8px; align-items: center; padding: 16px 22px 20px; }
.sheet footer .grow { flex: 1; }

/* Toast ----------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms;
  z-index: 40;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; }

@media (max-width: 720px) {
  .attention li { grid-template-columns: 4px 1fr; }
  .attention .acts { grid-column: 2; justify-content: flex-start; }
  .sheet .fields { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dd { margin-bottom: 8px; }
  .who .email { display: none; }
  .fleet-head h1 { font-size: 26px; }
}
