:root {
  --paper: #f4f0e7;
  --card: #fffdf8;
  --ink: #1b2430;
  --muted: #5e6872;
  --navy: #003060;
  --teal: #0e6070;
  --sea: #5f9d90;
  --line: #e3dacb;
  --rust: #8a3828;
  --rust-bg: #f8ebe6;
  --ok: #1d6842;
  --ok-bg: #e6f3eb;
  --warn: #8a5a12;
  --warn-bg: #f8f1dc;
  --shadow: 0 1px 2px rgba(27, 36, 48, 0.06);
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scrollbar-gutter: stable; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(900px 280px at 0% -40px, rgba(14, 96, 112, 0.16), transparent 55%),
    var(--paper);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.45;
}
a { color: var(--navy); }
img { max-width: 100%; height: auto; }
.skip {
  position: absolute; left: -999px; top: 0;
}
.skip:focus { left: 0.5rem; top: 0.5rem; background: white; padding: 0.4rem 0.6rem; z-index: 5; }
.top, .unverified-strip, main, #offline-note { 
  width: min(52rem, calc(100% - 1.5rem));
  margin-left: auto; margin-right: auto;
}
.top {
  display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end;
  padding: 1rem 0 0.6rem;
}
.brand {
  display: flex; align-items: center; gap: 0.65rem;
  font-family: var(--sans); font-size: 1rem; line-height: 1.05;
  color: var(--navy); text-decoration: none; letter-spacing: 0;
}
.brand img { width: 42px; height: 42px; border-radius: 11px; flex: none; }
.brand img.shield { width: 42px; height: 50px; object-fit: contain; border-radius: 0; background: transparent; }
.brand img.brand-logo {
  width: min(220px, 70vw); height: auto; border-radius: 0;
  background: transparent; padding: 0;
}
body.page-login .top { justify-content: center; }
body.page-login .brand img.brand-logo { width: min(420px, 92vw); }
.brand span { display: flex; flex-direction: column; gap: 0.12rem; }
.brand strong { font-family: var(--serif); font-size: 1.12rem; font-weight: 650; letter-spacing: -0.02em; }
.brand small { color: var(--teal); font-size: 0.68rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.brand-sub, .who { margin: 0; color: var(--muted); font-size: 0.85rem; }
.who { text-align: right; }
.who form { display: inline; }
.linkish {
  background: none; border: 0; color: var(--navy); padding: 0; min-height: 0;
  text-decoration: underline; font: inherit; cursor: pointer;
}
.unverified-strip {
  display: flex; flex-wrap: wrap; gap: 0.35rem 0.7rem;
  padding: 0.45rem 0.7rem; margin-bottom: 0.8rem;
  background: var(--warn-bg); border-left: 3px solid var(--warn); border-radius: 6px;
  font-size: 0.88rem;
}
.unverified-strip a { font-weight: 650; }
main { padding-bottom: 6.2rem; }
h1, h2, h3 { font-family: var(--serif); color: var(--navy); font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 1.7rem; line-height: 1.15; margin: 0 0 0.35rem; }
h2 { font-size: 1.25rem; margin: 1.3rem 0 0.45rem; }
.lede, .hint, .fine { color: var(--muted); }
.lede { margin-top: 0; }
.kicker { margin: 0; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--teal); font-weight: 700; }
.card, .panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 0.9rem 1rem; margin: 0.7rem 0;
}
a.card { display: block; text-decoration: none; color: inherit; }
a.card:hover { border-color: var(--teal); }
.card h2, .card h3 { margin: 0.15rem 0; }
.row { display: flex; justify-content: space-between; gap: 0.45rem 0.75rem; align-items: center; flex-wrap: wrap; }
.row > * { min-width: 0; }
.due { font-family: var(--serif); font-size: 1.35rem; margin: 0.2rem 0; color: var(--navy); }
.mono, .hash { font-family: var(--mono); font-size: 0.78rem; overflow-wrap: anywhere; word-break: break-word; }
.facts { display: grid; grid-template-columns: 8.5rem 1fr; gap: 0.35rem 0.75rem; margin: 0.6rem 0; }
.facts dt { color: var(--muted); font-size: 0.82rem; }
.facts dd { margin: 0; }
.pill {
  display: inline-block; padding: 0.12rem 0.45rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.03em; background: #e7eef2; color: var(--navy);
}
.pill-bad { background: var(--rust-bg); color: var(--rust); }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.banner, .flash, .error {
  padding: 0.7rem 0.8rem; border-radius: 8px; margin: 0.6rem 0;
}
.banner.bad, .flash-error, .error { background: var(--rust-bg); color: var(--rust); }
.banner.warn, .note { background: var(--warn-bg); }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.note { padding: 0.8rem 0.9rem; border-radius: 10px; margin: 0.8rem 0; }
.note h2 { margin-top: 0; }
.note p { margin: 0.4rem 0; }
blockquote { margin: 0.4rem 0; padding-left: 0.7rem; border-left: 3px solid var(--teal); }
.field { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.75rem 0; }
.field span { font-weight: 650; }
.field small, .hint { font-size: 0.85rem; }
input, textarea, select, button {
  font: inherit; color: inherit;
}
input[type="text"], input[type="password"], input[type="date"], input[type="time"], textarea, select {
  width: 100%; max-width: 100%; padding: 0.6rem 0.65rem; border: 1px solid #cfc4b2; border-radius: 8px;
  background: white; font-size: 1rem;
}
input[type="text"]:hover, input[type="password"]:hover, input[type="date"]:hover, input[type="time"]:hover, textarea:hover, select:hover {
  border-color: var(--teal);
}
textarea { min-height: 6.5rem; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus, a:focus {
  outline: 2px solid var(--teal); outline-offset: 2px;
}
.check { display: flex; gap: 0.55rem; align-items: flex-start; margin: 0.8rem 0; }
.check input { width: 1.2rem; height: 1.2rem; margin-top: 0.2rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.8rem 0; }
button, .button {
  min-height: 44px; padding: 0.55rem 0.9rem; border-radius: 8px;
  border: 1px solid var(--navy); background: var(--navy); color: white;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
button.secondary, .button.secondary { background: transparent; color: var(--navy); }
button.danger { background: transparent; color: var(--rust); border-color: var(--rust); }
button:hover, .button:hover { background: #002448; }
button.secondary:hover, .button.secondary:hover { background: #e7eef3; }
button.danger:hover { background: var(--rust-bg); }
.linkish:hover { color: var(--teal); }
.button.primary, button.primary { flex: 0 1 auto; }
.live-warn { color: var(--rust); }
.photos { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
.photo { margin: 0; }
.photo figcaption { font-size: 0.82rem; color: var(--muted); }
.file-note { color: var(--muted); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: #fffdf8; border-top: 1px solid var(--line);
  padding: 0.25rem 0.3rem calc(0.3rem + env(safe-area-inset-bottom));
  z-index: 4;
}
.tabbar a {
  flex: 1; text-align: center; text-decoration: none; color: var(--muted);
  font-size: 0.82rem; font-weight: 700; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  padding: 0.45rem 0.1rem; border-radius: 8px;
}
.tabbar a:hover { color: var(--navy); background: #f4f1ea; }
.tabbar a[aria-current="page"] { color: var(--navy); background: #e7eef3; }
.tabbar a[aria-current="page"]:hover { background: #d9e5ed; }
.bmp-check { padding: 0.7rem 0; border-top: 1px solid var(--line); }
.bmp-check .choices { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.35rem 0; }
.choice {
  display: flex; align-items: flex-start; gap: 0.35rem;
  min-height: 44px; max-width: 100%; padding: 0.35rem 0.6rem; border: 1px solid var(--line); border-radius: 8px; background: white;
}
.choice span { min-width: 0; }
.choice:hover { border-color: var(--teal); }
fieldset.bmp-set { border: 1px solid var(--line); }
fieldset.bmp-set[hidden] { display: none; }
.stack { display: flex; flex-direction: column; gap: 0.2rem; }
.login-card { max-width: 28rem; margin: 0.35rem auto 0; }
body.page-login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0 2rem;
}
body.page-login .top,
body.page-login main {
  width: min(28rem, calc(100% - 1.5rem));
  margin-left: auto;
  margin-right: auto;
}
body.page-login .top { justify-content: center; padding-top: 0; }
body.page-login .brand { justify-content: center; width: 100%; }
body.page-login main { padding-bottom: 0; }
.doors { display: flex; flex-direction: column; gap: 0.55rem; margin: 0.8rem 0 1rem; }
.door {
  width: 100%; min-height: 64px; justify-content: flex-start; text-align: left;
  background: var(--card); color: var(--navy); border: 1px solid var(--line);
  padding: 0.7rem 0.9rem; gap: 0.15rem;
}
.door strong { display: block; font-size: 1.05rem; }
.door small { display: block; color: var(--muted); font-weight: 550; }
.door:hover { border-color: var(--teal); }
.accounts { font-size: 0.92rem; }
.accounts code { font-family: var(--mono); }
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin: 0.9rem 0 0.2rem;
}
.stat {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  min-height: 5rem; padding: 0.75rem 0.7rem; border-radius: 14px; text-decoration: none;
  border: 1px solid transparent;
}
.stat b { font-family: var(--serif); font-size: 2rem; line-height: 1; font-weight: 650; }
.stat span { font-size: 0.82rem; font-weight: 750; margin-top: 0.25rem; }
.stat.overdue { background: var(--rust-bg); color: var(--rust); border-color: #e7cfc7; }
.stat.due { background: var(--warn-bg); color: var(--warn); border-color: #eadcba; }
.stat.done { background: var(--ok-bg); color: var(--ok); border-color: #c7e4d2; }
.stat:hover { border-color: var(--teal); }
.card.status-overdue { border-left: 5px solid var(--rust); }
.card.status-due { border-left: 5px solid #c48a2a; }
.card.status-done { border-left: 5px solid var(--ok); }
.pill-overdue { background: var(--rust-bg); color: var(--rust); }
.pill-due { background: var(--warn-bg); color: var(--warn); }
.pill-done { background: var(--ok-bg); color: var(--ok); }
body.role-client .writer { display: none !important; }
.sheet {
  background: white; border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem 1rem 1.2rem; margin: 0.8rem 0;
}
.sheet header { border-bottom: 3px solid var(--teal); margin-bottom: 0.6rem; padding-bottom: 0.4rem; }
.map-wrap { position: relative; margin: 0.8rem 0; }
.map-wrap img { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.pin {
  position: absolute; transform: translate(-50%, -120%);
  background: var(--navy); color: white; font-size: 0.72rem; font-weight: 700;
  padding: 0.2rem 0.4rem; border-radius: 999px; max-width: 9rem;
}
.sign-line {
  border-bottom: 1px solid var(--ink); min-height: 2.4rem; margin: 0.8rem 0 0.2rem;
  color: var(--muted); font-size: 0.85rem;
}
a.card { min-height: 44px; }
#fleet-map { height: 62vh; min-height: 320px; max-width: 100%; overflow: hidden; border-radius: 14px; border: 1px solid var(--line); margin: 0.6rem 0; }
.leaflet-container img { max-width: none; }
.legend { display: flex; gap: 0.8rem; list-style: none; padding: 0; margin: 0.2rem 0 0.8rem; font-size: 0.88rem; font-weight: 700; }
.legend .dot { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 50%; margin-right: 0.3rem; vertical-align: -1px; border: 2px solid #fff; }
.legend .dot.overdue { background: var(--rust); }
.legend .dot.today { background: var(--warn); }
.legend .dot.ok { background: var(--ok); }
.route-stops { margin: 0.4rem 0 0.8rem; padding-left: 1.2rem; }
.route-stops li { margin: 0.35rem 0; font-size: 1.02rem; }
.route-num {
  background: var(--navy); color: white; border-radius: 50%;
  width: 28px; height: 28px; line-height: 28px; text-align: center; font-weight: 700;
  border: 2px solid white;
}
.leaflet-popup-content .popup-go { display: inline-flex; margin-top: 0.35rem; }
.leaflet-popup-content .popup-line { margin: 0.2rem 0; }
@media (max-width: 640px) {
  .facts { grid-template-columns: 1fr; }
  .facts dt { margin-top: 0.35rem; }
  .top { flex-wrap: wrap; align-items: flex-start; row-gap: 0.35rem; }
  .who { text-align: left; width: 100%; }
  h1 { font-size: 1.45rem; }
  .stats { gap: 0.35rem; }
  .stat { padding: 0.6rem 0.45rem; }
  .stat b { font-size: 1.55rem; }
  .legend { flex-wrap: wrap; gap: 0.35rem 0.8rem; }
}
@media (min-width: 860px) {
  .tabbar {
    top: 0; bottom: 0; left: 0; right: auto; width: 11rem;
    flex-direction: column; justify-content: flex-start; align-items: stretch;
    gap: 0.25rem;
    border-top: 0; border-right: 1px solid var(--line);
    padding: 1rem 0.55rem;
  }
  .tabbar a {
    flex: 0 0 auto;
    text-align: left; justify-content: flex-start;
    padding: 0.55rem 0.75rem; font-size: 0.95rem;
  }
  body:not(.logged-out) .top,
  body:not(.logged-out) .unverified-strip,
  body:not(.logged-out) main,
  body:not(.logged-out) #offline-note {
    margin-left: calc(11rem + max(1.25rem, (100vw - 11rem - 66rem) / 2));
    margin-right: auto;
    width: min(66rem, calc(100vw - 11rem - 2.5rem));
  }
  main { padding-bottom: 2rem; }
  .photos { grid-template-columns: 1fr 1fr; }
}
