:root {
  color-scheme: light;
  --page: #f6f7f5;
  --surface: #fff;
  --ink: #1e2c28;
  --muted: #535f5a;
  --line: #dce2dc;
  --green: #165c48;
  --green-dark: #12392f;
  --green-light: #edf6f0;
  --warning: #8a570e;
  --warning-light: #fcf0d9;
  --red: #a6463b;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--page); }
button, input, select { font: inherit; }
button { cursor: pointer; color: inherit; }
a { color: var(--green); }
:focus-visible { outline: 2px solid #297e66; outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 2.3vw, 2.1rem); line-height: 1.2; font-weight: 690; letter-spacing: -.035em; }
h2 { font-size: 1rem; line-height: 1.35; font-weight: 690; }

.masthead {
  min-height: 65px;
  display: flex;
  align-items: stretch;
  gap: clamp(1.25rem, 4vw, 3.5rem);
  padding-inline: max(24px, calc((100% - 1410px) / 2));
  color: #f3f8f2;
  background: var(--green-dark);
}
.brand { display: inline-flex; align-items: center; gap: .65rem; color: inherit; text-decoration: none; font-size: 1.13rem; font-weight: 690; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #72a68d; border-radius: 7px; }
.brand-mark span { position: relative; width: 12px; height: 15px; border: solid #a7dec1; border-width: 2px 0 2px 2px; border-radius: 5px 0 0 5px; transform: rotate(-27deg); }
.brand-mark span::after, .brand-mark span::before { content: ""; position: absolute; right: -2px; width: 5px; height: 5px; border-radius: 50%; background: #a7dec1; }
.brand-mark span::before { top: -3px; }
.brand-mark span::after { bottom: -3px; }
.navigation { display: flex; align-items: stretch; gap: .35rem; }
.navigation a { display: grid; place-items: center; padding: .75rem .9rem .6rem; color: #d1e0d8; border-bottom: 3px solid transparent; text-decoration: none; font-size: .91rem; font-weight: 580; }
.navigation a:hover { background: #1a4639; color: #fff; }
.navigation a[aria-current="page"] { color: #fff; border-bottom-color: #9bd3b5; }
.sign-out { align-self: center; margin-left: auto; color: #d1e0d8; font-size: .9rem; border: 1px solid #658879; background: transparent; border-radius: 5px; padding: 4px 9px; }
.sign-out:hover { background: #1a4639; color: #fff; }
.loading { padding: 28px; color: var(--muted); }
.login-screen { min-height: 80vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(100%, 420px); border: 1px solid var(--line); border-radius: 8px; background: white; padding: 24px; }
.login-card p { margin: 9px 0 17px; color: var(--muted); }
.login-card label { display: grid; gap: 5px; margin-bottom: 12px; }
.login-card .form-error { color: var(--red); margin: 0 0 7px; }
#access-link input { margin: 9px 0; }

main { max-width: 1458px; margin-inline: auto; padding: 32px 24px 36px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 17px; }
.page-heading p, .map-head p { color: var(--muted); margin-top: 6px; }
.primary, .secondary, .row-action { min-height: 38px; padding: 7px 13px; border-radius: 6px; border: 1px solid transparent; font-size: .9rem; font-weight: 640; white-space: nowrap; }
.primary { color: #fff; background: var(--green); }
.primary:hover { background: #104937; }
.secondary { background: white; border-color: var(--line); }
.secondary:hover, .row-action:hover { background: #f0f4f0; }
.row-action { border-color: transparent; background: none; color: var(--green); }
.notice { padding: 9px 12px; margin-bottom: 17px; color: #615127; background: #fbf5e7; border: 1px solid #e9dfc7; border-radius: 6px; font-size: .875rem; }
.toast { padding: 9px 12px; margin-bottom: 17px; background: var(--green-light); border: 1px solid #c8dbc9; border-radius: 6px; }
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); margin-bottom: 18px; }
.summary > div { padding: 12px 20px; border-inline-end: 1px solid var(--line); display: flex; align-items: baseline; gap: .65rem; }
.summary > div:last-child { border-inline-end: 0; }
.summary strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; line-height: 1.3; }
.summary span { font-size: .88rem; color: var(--muted); }

.operations-grid { display: grid; grid-template-columns: minmax(280px, 350px) minmax(0, 1fr); gap: 18px; align-items: start; }
.vehicle-panel, .map-panel, .table-wrap { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.panel-head { padding: 14px 14px 0; }
.search { display: block; margin: 12px 0 5px; }
input, select { width: 100%; min-width: 0; min-height: 38px; padding: 7px 9px; border: 1px solid #cbd5ce; border-radius: 5px; background: #fff; color: var(--ink); }
.search input { font-size: .875rem; }
.filters { display: flex; gap: 12px; }
.filters button { border: 0; border-bottom: 2px solid transparent; padding: 8px 0; background: none; font-size: .83rem; color: var(--muted); white-space: nowrap; }
.filters button[aria-pressed="true"] { color: var(--green); border-bottom-color: var(--green); font-weight: 680; }
.vehicle-list { max-height: 560px; overflow-y: auto; border-top: 1px solid var(--line); }
.vehicle-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); padding: 12px 14px; background: #fff; }
.vehicle-row:last-child { border-bottom: 0; }
.vehicle-row:hover { background: #f5f8f5; }
.vehicle-row[aria-pressed="true"] { background: var(--green-light); box-shadow: inset 3px 0 var(--green); }
.vehicle-row:focus-visible { outline-offset: -3px; }
.vehicle-name { font-size: .91rem; font-weight: 680; overflow-wrap: anywhere; }
.vehicle-meta { font-size: .79rem; color: var(--muted); grid-column: 1 / -1; }
.vehicle-destination { font-size: .84rem; margin-top: 2px; grid-column: 1 / -1; overflow-wrap: anywhere; }
.status { justify-self: end; color: var(--muted); font-size: .76rem; font-weight: 650; }
.status.moving, .status.arrived, .status.passed { color: var(--green); }
.status.attention, .status.stale, .status.observation { color: var(--warning); }
.status.issue { color: var(--red); }

.map-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 15px; }
.map-head p { font-size: .82rem; margin-top: 2px; }
.map-stage { position: relative; isolation: isolate; background: #e5ebe3; }
#map { height: clamp(350px, 46vh, 530px); }
.map-warning { position: absolute; z-index: 500; left: 50%; top: 10px; transform: translateX(-50%); width: max-content; max-width: 75%; font-size: .82rem; background: #fff8e9; border: 1px solid #d9cba7; border-radius: 5px; padding: 5px 8px; }
.marker { display: grid; place-items: center; border-radius: 50%; background: #fff; border: 2px solid #416151; box-shadow: 0 1px 4px #243b333d; color: #416151; }
.marker.moving { border-color: #17634d; color: #17634d; }
.marker.arrived { border-color: #426a50; color: #426a50; }
.marker.attention, .marker.stale { border-color: #985e1c; color: #985e1c; }
.marker.is-selected { background: var(--green-dark); border-color: #fff; color: #fff; }
.marker span { height: 8px; width: 8px; border-radius: 50%; background: currentColor; }
.marker.destination { border-radius: 3px; border-color: #283831; color: #fff; background: #283831; font-size: 14px; }
.leaflet-tooltip { font-weight: 650; }
.selected-vehicle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 76px; padding: 12px 15px; border-top: 1px solid var(--line); }
.selected-vehicle strong { font-size: .95rem; overflow-wrap: anywhere; }
.selected-vehicle p { color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }
.selected-vehicle .status { text-align: right; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 12px 16px; border-bottom: 1px solid var(--line); }
th { background: #f3f7f3; text-align: left; font-size: .84rem; color: #43554d; font-weight: 680; white-space: nowrap; }
td { font-size: .93rem; overflow-wrap: anywhere; }
tr:last-child td { border-bottom: 0; }
td:last-child { text-align: right; }
.empty { color: var(--muted); padding: 18px 15px; }
dialog { color: var(--ink); background: var(--surface); border-radius: 8px; border: 1px solid var(--line); padding: 19px 21px; width: min(530px, calc(100% - 32px)); }
dialog::backdrop { background: #18282385; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.dialog-heading h2 { font-size: 1.22rem; }
.close { font-size: 1.45rem; line-height: 1; width: 34px; height: 34px; background: transparent; border: 0; border-radius: 4px; }
.close:hover { background: #f0f4f0; }
.form-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 11px 13px; }
.form-fields label { display: grid; gap: 4px; color: #374740; font-size: .87rem; }
.form-fields label.full { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-error { margin: 9px 0; min-height: 1.3em; font-size: .86rem; color: var(--red); }
#inspection-detail p { margin-bottom: 9px; }
#inspection-detail ul { margin: 0 0 12px; padding-inline-start: 1.3rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; clip: rect(0,0,0,0); overflow: hidden; white-space: nowrap; }

@media (max-width: 960px) {
  .masthead { gap: 15px; }
  .navigation a { padding-inline: .55rem; }
  .operations-grid { grid-template-columns: minmax(248px, 290px) minmax(0, 1fr); gap: 12px; }
  .summary > div { padding: 10px 14px; }
}
@media (max-width: 700px) {
  .masthead { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 12px 16px 0; }
  .navigation { grid-column: 1 / -1; grid-row: 2; gap: 2px; overflow-x: auto; }
  .sign-out { grid-column: 2; grid-row: 1; }
  main { padding: 20px 12px 24px; }
  .page-heading { align-items: flex-start; }
  .page-heading p { font-size: .9rem; }
  .operations-grid { grid-template-columns: 1fr; }
  .vehicle-list { max-height: 255px; }
  .summary > div { display: block; padding: 9px; }
  .summary span { display: block; line-height: 1.2; }
  #map { height: 325px; }
  th, td { padding: 9px 10px; }
}
