:root {
  color-scheme: light dark;
  --ink: #17202a;
  --muted: #64717f;
  --line: #d9e0e7;
  --panel: #ffffff;
  --surface: #f3f6f8;
  --primary: #0d6b63;
  --primary-dark: #084f49;
  --accent: #c94f2f;
  --danger: #a83232;
  --shadow: 0 18px 48px rgba(20, 35, 48, 0.16);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8eef2;
    --muted: #9caab4;
    --line: #29404c;
    --panel: #111f27;
    --surface: #07161c;
    --primary: #55c1b6;
    --primary-dark: #8de0d6;
    --accent: #d46b4f;
    --danger: #ef7770;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --ink: #17202a;
  --muted: #64717f;
  --line: #d9e0e7;
  --panel: #ffffff;
  --surface: #f3f6f8;
  --primary: #0d6b63;
  --primary-dark: #084f49;
  --accent: #c94f2f;
  --danger: #a83232;
  --shadow: 0 18px 48px rgba(20, 35, 48, 0.16);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8eef2;
  --muted: #9caab4;
  --line: #29404c;
  --panel: #111f27;
  --surface: #07161c;
  --primary: #55c1b6;
  --primary-dark: #8de0d6;
  --accent: #d46b4f;
  --danger: #ef7770;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface);
}

body.app-page {
  width: 100%;
  max-width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 2000;
  transform: translateY(-160%);
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  color: #084f49;
  font-weight: 900;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.skip-link:focus {
  transform: translateY(0);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  height: 64px;
  min-height: 64px;
  padding: 10px clamp(14px, 2.6vw, 28px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: relative;
  z-index: 3000;
  background: #102832;
  color: #fff;
}

.brand,
.account,
.field-row,
.form-actions,
.coords,
.inline-heading,
.report-card-header {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
}

.brand h1 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 0;
  background: #c94f2f;
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 3px;
  color: #82919e;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: #b8c7d1;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.35rem, 3vw, 2rem);
}

h2 {
  font-size: 1.05rem;
}

.account {
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.menu-account-status {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  color: #526371;
  font-size: 0.86rem;
  font-weight: 800;
}

.account-status {
  color: #d9e6ed;
  font-size: 0.9rem;
}

.header-menu {
  position: relative;
}

.header-menu summary {
  min-height: 36px;
  width: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  list-style: none;
}

.header-menu summary::-webkit-details-marker {
  display: none;
}

.hamburger-icon,
.hamburger-icon::before,
.hamburger-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.hamburger-icon {
  position: relative;
}

.hamburger-icon::before,
.hamburger-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.hamburger-icon::before {
  top: -6px;
}

.hamburger-icon::after {
  top: 6px;
}

.header-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 3100;
  width: 220px;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.header-menu-panel a,
.header-menu-action {
  min-height: 38px;
  display: grid;
  align-items: center;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #24323c;
  cursor: pointer;
  font: inherit;
  font-weight: 850;
  text-align: left;
  text-decoration: none;
}

.header-menu-panel a:hover,
.header-menu-action:hover,
.header-menu-action.active {
  background: #e8f1ef;
  color: var(--primary-dark);
}

.shell {
  width: 100%;
  max-width: 100vw;
  height: calc(100dvh - 64px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  overflow: hidden;
}

.map-panel {
  position: relative;
  min-width: 0;
  min-height: 420px;
  overflow: hidden;
}

.map-search-control {
  position: absolute;
  top: 12px;
  left: 62px;
  z-index: 1050;
  width: min(480px, calc(100% - 126px));
}

.map-search-control form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 24px rgba(20, 35, 48, 0.2);
}

.map-search-control input {
  min-height: 42px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.map-search-button {
  position: relative;
  border: 0;
  border-left: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.map-search-button::before {
  content: "";
  width: 13px;
  height: 13px;
  position: absolute;
  left: 12px;
  top: 11px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.map-search-button::after {
  content: "";
  width: 8px;
  height: 2px;
  position: absolute;
  left: 25px;
  top: 27px;
  transform: rotate(45deg);
  background: currentColor;
}

.map-search-results {
  max-height: min(360px, 48vh);
  margin-top: 6px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(20, 35, 48, 0.22);
}

.map-search-result {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.map-search-result:last-child {
  border-bottom: 0;
}

.map-search-result:hover,
.map-search-result:focus-visible {
  background: #e8f1ef;
}

.map-search-result strong {
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.map-search-result span,
.map-search-empty {
  color: var(--muted);
  font-size: 0.76rem;
}

.map-search-empty {
  margin: 0;
  padding: 12px;
}

#map {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #d9e5eb;
}

/* Local Leaflet layout fallback for offline/restricted preview environments. */
.leaflet-container {
  overflow: hidden;
  position: relative;
  z-index: 0;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control-zoom {
  margin: 12px 0 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 24px rgba(20, 35, 48, 0.18);
}

.leaflet-control-zoom a {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
  background: #fff;
}

.leaflet-control-zoom a + a {
  border-top: 1px solid var(--line);
}

.leaflet-control-attribution {
  margin: 0 6px 4px 0;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.82);
  color: #46535e;
  font-size: 0.68rem;
}

.leaflet-control-layers {
  margin: 12px 12px 0 0;
  padding: 9px 10px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(20, 35, 48, 0.16);
  color: #24323c;
  font-size: 0.82rem;
  font-weight: 750;
}

.leaflet-control-layers label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.leaflet-control-layers input {
  width: auto;
  min-height: auto;
  margin: 0;
  padding: 0;
}

.leaflet-control-layers-separator,
.leaflet-control-layers-base {
  display: none;
}

.leaflet-popup {
  position: absolute;
  text-align: center;
  margin-bottom: 20px;
}

.leaflet-popup-content-wrapper {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.leaflet-popup-content {
  margin: 0;
  line-height: 1.35;
}

.leaflet-popup-tip-container {
  width: 40px;
  height: 20px;
  position: absolute;
  left: 50%;
  margin-left: -20px;
  overflow: hidden;
  pointer-events: none;
}

.leaflet-popup-tip {
  width: 14px;
  height: 14px;
  margin: -7px auto 0;
  transform: rotate(45deg);
  background: #fff;
  box-shadow: var(--shadow);
}

.train-marker-shell {
  background: transparent;
  border: 0;
}

.train-marker {
  width: 92px;
  min-height: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  position: relative;
  border: 3px solid #fff;
  border-radius: 10px;
  background: var(--accent);
  padding: 5px 8px;
  box-shadow: 0 8px 20px rgba(20, 35, 48, 0.3);
  opacity: var(--marker-opacity, 1);
}

.train-marker__railroad,
.train-marker__main {
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-align: center;
  max-width: 78px;
}

.train-marker__railroad {
  font-size: 0.56rem;
  opacity: 0.86;
}

.train-marker__main {
  font-size: 0.76rem;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.train-marker__main.compact {
  font-size: 0.66rem;
}

.train-marker__special {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #d3222a;
  box-shadow: 0 2px 7px rgba(20, 35, 48, 0.28);
}

.train-marker--passenger {
  border-color: #dbeafe;
  box-shadow: 0 8px 20px rgba(10, 111, 186, 0.28);
}

.train-marker--feed-stale {
  border-style: dashed;
  filter: grayscale(0.35) saturate(0.72);
  box-shadow: 0 0 0 3px rgba(77, 79, 82, 0.22), 0 8px 20px rgba(20, 35, 48, 0.22);
}

.train-marker--feed-stale::after {
  content: "STALE";
  position: absolute;
  left: 50%;
  bottom: -16px;
  transform: translateX(-50%);
  padding: 2px 5px;
  border-radius: 4px;
  background: #111f27;
  color: #e8eef2;
  font-size: 0.52rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 2px 7px rgba(20, 35, 48, 0.25);
}

.train-marker--feed-unavailable {
  border-style: dotted;
  filter: grayscale(0.55) opacity(0.82);
}

.train-marker--northbound {
  background: #087e8b;
}

.train-marker--southbound {
  background: #9c2c77;
}

.train-marker--eastbound {
  background: #315da8;
}

.train-marker--westbound {
  background: #6546a6;
}

.train-marker--unknown {
  border-color: #111;
  background: #fff;
}

.train-marker--unknown .train-marker__railroad,
.train-marker--unknown .train-marker__main {
  color: #111;
}

.train-cluster {
  width: 70px;
  height: 46px;
  display: grid;
  place-items: center;
  align-content: center;
  border: 3px solid #fff;
  border-radius: 14px;
  background: #102832;
  color: #fff;
  box-shadow: 0 10px 24px rgba(20, 35, 48, 0.32);
}

.train-cluster--mixed {
  background: #0a4f7a;
}

.train-cluster strong,
.train-cluster span {
  display: block;
  line-height: 1;
  letter-spacing: 0;
}

.train-cluster strong {
  font-size: 1.05rem;
}

.train-cluster span {
  margin-top: 2px;
  font-size: 0.58rem;
  font-weight: 900;
  text-transform: uppercase;
}

.button.map-locate-button {
  position: absolute;
  left: 12px;
  top: 92px;
  z-index: 850;
  width: 38px;
  height: 38px;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  line-height: 1;
  box-shadow: 0 12px 34px rgba(20, 35, 48, 0.13);
}

.locate-icon {
  position: relative;
  width: 18px;
  height: 18px;
  display: block;
  border: 2px solid var(--primary-dark);
  border-radius: 999px;
}

.locate-icon::before,
.locate-icon::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 24px;
  height: 2px;
  background: var(--primary-dark);
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.locate-icon::after {
  width: 2px;
  height: 24px;
}

.map-locate-button:hover .locate-icon,
.map-locate-button:focus-visible .locate-icon {
  border-color: var(--primary);
}

.map-locate-button:hover .locate-icon::before,
.map-locate-button:hover .locate-icon::after,
.map-locate-button:focus-visible .locate-icon::before,
.map-locate-button:focus-visible .locate-icon::after {
  background: var(--primary);
}

.drop-pin-shell {
  background: transparent;
  border: 0;
}

.drop-pin {
  width: 28px;
  height: 28px;
  display: block;
  position: relative;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  background: var(--primary);
  box-shadow: 0 8px 20px rgba(20, 35, 48, 0.34);
  transform: rotate(-45deg);
}

.drop-pin::after {
  content: "";
  width: 9px;
  height: 9px;
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
}

.side-panel {
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
}

.side-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 246, 248, 0.96);
}

.side-tabs:has(.side-tab[hidden]) {
  grid-template-columns: 1fr;
}

.side-tab {
  min-width: 0;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
}

.side-tab.active {
  border-color: #cfe1de;
  background: #e8f1ef;
  color: var(--primary-dark);
}

.app-panel {
  display: none;
}

.app-panel.active-panel {
  display: block;
}

.sheet-handle {
  display: none;
}

.panel-section {
  margin: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-section + .panel-section {
  margin-top: 10px;
}

.app-nav {
  display: none;
}

.section-heading {
  margin-bottom: 14px;
}

.inline-heading {
  justify-content: space-between;
  gap: 12px;
}

.helper {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.account-summary {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  color: #33414b;
  font-size: 0.88rem;
  font-weight: 750;
  line-height: 1.4;
}

.form-grid {
  display: grid;
  gap: 13px;
  min-width: 0;
}

.account-tools {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.account-tools h3 {
  margin: 0;
  font-size: 0.98rem;
}

.form-grid label,
.form-grid > *,
.panel-section,
.side-panel {
  min-width: 0;
}

label {
  display: grid;
  gap: 6px;
  color: #35424d;
  font-size: 0.86rem;
  font-weight: 750;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field > label:first-child {
  display: block;
}

.train-identity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 10px;
  align-items: start;
}

.origin-date-field {
  min-width: 0;
}

.origin-date-field input {
  text-align: center;
}

.inline-checkbox {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 0.82rem;
}

.inline-checkbox input {
  width: 17px;
  min-height: 17px;
  margin: 0;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  font-size: 16px;
  border: 1px solid #cbd5de;
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

input[type="datetime-local"] {
  min-width: 0;
  max-width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(13, 107, 99, 0.18);
  border-color: var(--primary);
}

.coords {
  gap: 10px;
}

.coords label {
  flex: 1 1 0;
}

.location-grid,
.search-grid {
  display: grid;
  gap: 10px;
}

.location-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-hint {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.35;
}

.field-row {
  gap: 8px;
  align-items: end;
}

.field-row label {
  flex: 1 1 auto;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.checkbox-line input {
  width: auto;
}

.report-checkbox {
  justify-content: flex-start;
  padding: 2px 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e8f1ef;
  color: #164f49;
  font-size: 0.82rem;
  font-weight: 800;
}

.chip button {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  color: inherit;
  background: rgba(13, 107, 99, 0.13);
  cursor: pointer;
}

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 13px;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}

.button-primary {
  background: var(--primary);
  color: #fff;
}

.button-primary:hover {
  background: var(--primary-dark);
}

.button-secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--primary-dark);
}

.button.active,
.button[aria-pressed="true"] {
  background: var(--primary-dark);
  color: #fff;
}

.button-ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: #24323c;
}

.button-danger {
  background: var(--danger);
  color: #fff;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  background: #102832;
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
}

.form-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) repeat(2, minmax(0, 0.85fr));
  gap: 8px;
}

.form-actions .button {
  width: 100%;
  min-width: 0;
  padding-inline: 10px;
  line-height: 1.15;
}

.form-actions button[type="submit"] {
  grid-column: 1 / -1;
}

.locked {
  opacity: 0.55;
}

.locked form {
  pointer-events: none;
}

.locked #lastReportButton {
  pointer-events: auto;
}

.report-list {
  display: grid;
  gap: 10px;
}

.admin-list,
.page-stack,
.user-list {
  display: grid;
  gap: 10px;
}

.search-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.search-grid .button {
  grid-column: 1 / -1;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: -4px 0 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.history-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -4px 0 12px;
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--muted);
}

.history-filter select {
  width: auto;
  min-width: 118px;
}

.passenger-toggle {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: -3px 0 2px;
  font-size: 0.86rem;
  font-weight: 850;
}

.passenger-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.passenger-status {
  margin: 0 0 10px;
}

.report-search {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.report-search summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  color: #24323c;
  cursor: pointer;
  font-weight: 900;
  list-style: none;
}

.report-search summary::-webkit-details-marker {
  display: none;
}

.report-search summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}

.report-search[open] summary::after {
  transform: rotate(225deg) translateY(-2px);
}

.tab-button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 850;
}

.tab-button.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 4px 14px rgba(20, 35, 48, 0.1);
}

.report-card {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
}

.report-card.selected-report {
  border-color: #86b7ad;
  box-shadow: 0 10px 28px rgba(13, 107, 99, 0.14);
}

.passenger-report-card {
  border-color: #bfdbfe;
}

.report-detail {
  margin: 12px 0;
  padding: 14px;
  border: 1px solid #b8d2cc;
  border-left: 5px solid var(--primary);
  border-radius: 8px;
  background: #f7fbfa;
}

.report-detail h3 {
  margin: 0;
  font-size: 1.05rem;
}

.report-detail dl {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 12px 0 0;
}

.report-detail dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.report-detail dd {
  margin: 0;
  color: #26343e;
  font-weight: 700;
}

.report-detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.admin-card,
.user-card,
.info-page,
.moderation-tools {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-card p,
.user-card p,
.info-page p,
.moderation-tools p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.admin-subsection {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.admin-subsection h3 {
  margin: 0;
  font-size: 0.95rem;
}

.admin-create-user-form {
  display: grid;
  gap: 12px;
  margin: 16px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-create-user-form h3 {
  margin: 0;
  font-size: 1rem;
}

.admin-create-user-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.user-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 172px;
  align-items: center;
  gap: 12px;
}

.user-actions {
  display: grid;
  gap: 8px;
}

.user-role {
  min-height: 38px;
}

.info-page h3 {
  margin: 0;
  font-size: 0.98rem;
}

.admin-badge {
  padding: 5px 8px;
  border-radius: 999px;
  background: #e8f1ef;
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.report-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.report-card-actions .button {
  flex: 1 1 150px;
}

.admin-page-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.admin-page-section {
  display: none;
}

.admin-page-section.active-admin-section {
  display: block;
}

.flag-status {
  padding: 4px 7px;
  border-radius: 999px;
  background: #fff1dc;
  color: #84510f;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.flag-reason {
  color: #26343e;
  font-weight: 650;
}

.admin-edit-form,
.report-edit-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.report-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.report-edit-form[hidden],
.admin-edit-form[hidden] {
  display: none;
}

.admin-title {
  font-size: 0.96rem;
}

.admin-meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.report-card-header {
  justify-content: space-between;
  gap: 10px;
}

.report-summary {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border: 0;
  border-left: 5px solid var(--accent);
  background: #fff;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.selected-report .report-summary {
  border-left-color: var(--primary);
  background: #f7fbfa;
}

.report-title {
  display: block;
  color: var(--ink);
  font-size: 0.98rem;
}

.report-direction {
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 850;
}

.report-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.35;
}

.report-chevron {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-right: 2px solid #64717f;
  border-bottom: 2px solid #64717f;
  transform: rotate(45deg);
}

.selected-report .report-chevron {
  transform: rotate(225deg);
}

.report-card-body {
  padding: 0 12px 13px 17px;
  background: #fff;
}

.report-card-body dl {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 7px 10px;
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.report-card-body dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.report-card-body dd {
  margin: 0;
  color: #33414b;
  font-size: 0.88rem;
  font-weight: 650;
}

.report-center {
  margin-top: 0;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #b9c5ce;
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfd;
  text-align: center;
}

.standalone-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--surface);
}

.standalone-card {
  width: min(100%, 520px);
  margin: 0;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.standalone-link {
  display: inline-grid;
  place-items: center;
  margin-top: 12px;
  text-decoration: none;
}

.content-page,
.account-page {
  min-height: 100vh;
  background: #f6f8fa;
}

.content-header {
  padding: 20px clamp(18px, 5vw, 54px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #102832;
  color: #fff;
}

.content-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.content-header a {
  color: #dff5f1;
  font-weight: 900;
  text-decoration: none;
}

.content-brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 1.05rem;
}

.content-home-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #dff5f1;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  text-decoration: none;
}

.content-home-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.content-menu {
  flex: 0 0 auto;
}

.content-menu .header-menu-panel {
  width: 230px;
}

.content-main {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.admin-main {
  width: min(1120px, calc(100% - 32px));
}

.content-section {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(20, 35, 48, 0.08);
}

.content-section + .content-section {
  margin-top: 16px;
}

.content-section h1,
.content-section h2 {
  margin-top: 0;
}

.content-section p,
.content-section li {
  color: #344450;
  line-height: 1.6;
}

.contact-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.contact-form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.contact-submit {
  width: fit-content;
  min-width: 150px;
}

.version-history {
  display: grid;
  gap: 0;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.version-history li {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 18px;
  position: relative;
  padding: 0 0 24px 22px;
  border-left: 2px solid var(--line);
}

.version-history li:last-child {
  padding-bottom: 0;
}

.version-history li::before {
  position: absolute;
  top: 3px;
  left: -7px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--primary);
  content: "";
}

.version-history time {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.version-history h3 {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 1rem;
}

.version-history p {
  margin: 0;
}

.checkbox-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  color: #344450;
  font-size: 0.92rem;
  font-weight: 700;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.signup-security-field {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.account-result {
  margin-top: 14px;
}

.account-result p {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #eef5f4;
  color: var(--primary-dark);
  font-weight: 800;
}

.account-result--error p {
  background: #fff0eb;
  color: #8c351f;
}

.account-result--success p {
  background: #e8f5ef;
  color: #176043;
}

.leaflet-popup-content {
  min-width: 190px;
}

.popup-title {
  margin: 0 0 6px;
  font-weight: 850;
}

.popup-meta {
  margin: 0;
  color: #52616d;
}

@media (prefers-color-scheme: dark) {
  body,
  .content-page,
  .account-page,
  .standalone-page {
    background: var(--surface);
    color: var(--ink);
  }

  .topbar {
    background: #07161c;
  }

  .side-panel,
  .panel-section,
  .header-menu-panel,
  .report-search,
  .report-card,
  .report-card-body,
  .report-detail,
  .content-section,
  .standalone-card,
  .leaflet-popup-content-wrapper,
  .leaflet-popup-tip {
    border-color: var(--line);
    background: var(--panel);
    color: var(--ink);
  }

  .map-panel,
  #map {
    background: #1a303a;
  }

  input,
  select,
  textarea,
  .button-secondary,
  .button-ghost,
  .tab-button.active,
  .sheet-handle,
  .app-nav {
    border-color: var(--line);
    background: #0c1a22;
    color: var(--ink);
  }

  input::placeholder,
  textarea::placeholder {
    color: #7f8f9a;
  }

  label,
  .report-card-body dd,
  .report-title,
  .report-notes,
  .popup-title {
    color: var(--ink);
  }

  .helper,
  .field-hint,
  .report-meta,
  .popup-meta,
  .report-card-body dt {
    color: var(--muted);
  }

  .content-section p,
  .content-section li,
  .checkbox-row,
  .checkbox-row span {
    color: var(--ink);
  }

  .button-primary {
    background: #1b716b;
    color: #fff;
  }

  .button-primary:hover {
    background: #246f6c;
  }

  .account-summary,
  .empty-state,
  .report-search summary,
  .admin-page-tabs,
  .tabs,
  .side-tabs {
    border-color: var(--line);
    background: #0c1a22;
    color: var(--ink);
  }

  .header-menu-panel a,
  .header-menu-action,
  .menu-account-status {
    color: var(--ink);
  }

  .header-menu-panel a:hover,
  .header-menu-action:hover,
  .header-menu-action.active,
  .side-tab.active {
    border-color: #1b4d58;
    background: #11313a;
    color: var(--primary-dark);
  }

  .side-tab {
    color: var(--muted);
  }

  .report-summary,
  .selected-report .report-summary,
  .nav-button.active,
  .tab-button.active {
    background: #11313a;
    color: var(--primary-dark);
  }

  .passenger-report-card {
    border-color: #1d5e86;
  }

  .leaflet-control-zoom {
    background: #0c1a22;
  }

  .leaflet-control-zoom a {
    color: var(--ink);
  }
}

@media (max-width: 1100px) {
  body.app-page {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    padding-bottom: 0;
  }

  .side-tabs {
    display: none;
  }

  .app-page .shell {
    height: calc(100dvh - 64px);
    min-height: 0;
    grid-template-columns: 1fr;
    overflow: hidden;
  }

  .map-panel {
    height: 100%;
    min-height: 0;
  }

  .side-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 78px;
    z-index: 900;
    width: auto;
    max-width: calc(100vw - 20px);
    max-height: min(68vh, 620px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scroll-padding-bottom: 96px;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(243, 246, 248, 0.98);
    box-shadow: var(--shadow);
    transition: max-height 180ms ease, transform 180ms ease;
    -webkit-overflow-scrolling: touch;
  }

  .side-panel.sheet-collapsed {
    max-height: 56px;
    overflow: hidden;
  }

  .sheet-handle {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    width: 100%;
    min-height: 54px;
    place-items: center;
    gap: 5px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    color: var(--primary-dark);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 900;
  }

  .sheet-state-icon {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    color: currentColor;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
  }

  .side-panel.sheet-collapsed .app-panel {
    display: none;
  }

  .panel-section {
    margin: 0;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
    padding-bottom: 22px;
    border: 0;
    border-radius: 12px;
  }

  .app-nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 950;
    width: auto;
    max-width: calc(100vw - 20px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 12px 34px rgba(20, 35, 48, 0.2);
  }

  .app-nav:has(.nav-button[hidden]) {
    grid-template-columns: 1fr;
  }

  .nav-button {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 46px;
    padding: 0 4px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.74rem;
    font-weight: 900;
    line-height: 1.1;
    text-align: center;
  }

  .nav-button.active {
    background: #e8f1ef;
    color: var(--primary-dark);
  }

  .form-actions {
    grid-template-columns: minmax(0, 1.25fr) repeat(2, minmax(0, 0.8fr));
    gap: 7px;
  }

  .auth-panel[hidden] {
    display: none;
  }

  .locked {
    opacity: 1;
  }

  .locked::before {
    content: "Sign in from Account to post reports.";
    display: block;
    margin-bottom: 12px;
    padding: 10px;
    border-radius: 8px;
    background: #fff5df;
    color: #7b4e00;
    font-size: 0.86rem;
    font-weight: 800;
  }

  .locked form {
    opacity: 0.5;
  }

  .side-panel {
    border-left: 0;
  }

  .report-panel {
    scroll-margin-bottom: 96px;
  }

  .form-actions {
    scroll-margin-bottom: 96px;
  }

}

@media (max-width: 620px) {
  .topbar {
    min-height: 64px;
    align-items: center;
    flex-direction: row;
    gap: 10px;
    padding: 10px 12px;
  }

  .account {
    width: auto;
    justify-content: flex-end;
  }

  .account-status {
    display: none;
  }

  .header-menu-panel {
    width: min(260px, calc(100vw - 24px));
  }

  .coords,
  .location-grid,
  .form-actions {
    align-items: stretch;
  }

  .location-grid,
  .search-grid,
  .report-edit-grid {
    grid-template-columns: 1fr;
  }

  .form-actions .button,
  .search-grid .button,
  .admin-actions .button,
  .report-card-actions .button {
    max-width: 100%;
    width: 100%;
  }

  .map-locate-button {
    width: 38px;
    max-width: none;
  }

  .map-search-control {
    left: 58px;
    width: calc(100% - 70px);
  }

  .admin-actions {
    display: grid;
  }

  .report-detail dl {
    grid-template-columns: 1fr;
  }

  .user-card {
    grid-template-columns: 1fr;
  }

  .admin-create-user-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1100px) and (prefers-color-scheme: dark) {
  .app-nav {
    border-color: var(--line) !important;
    background: rgba(12, 26, 34, 0.97) !important;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.42) !important;
  }

  .nav-button {
    color: var(--muted) !important;
    background: transparent !important;
  }

  .nav-button.active {
    background: #11313a !important;
    color: var(--primary-dark) !important;
  }
}

:root[data-theme="dark"] body,
:root[data-theme="dark"] .content-page,
:root[data-theme="dark"] .account-page,
:root[data-theme="dark"] .standalone-page {
  background: var(--surface);
  color: var(--ink);
}

:root[data-theme="dark"] .topbar {
  background: #07161c;
}

:root[data-theme="dark"] .side-panel,
:root[data-theme="dark"] .panel-section,
:root[data-theme="dark"] .header-menu-panel,
:root[data-theme="dark"] .report-search,
:root[data-theme="dark"] .report-card,
:root[data-theme="dark"] .report-card-body,
:root[data-theme="dark"] .report-detail,
:root[data-theme="dark"] .content-section,
:root[data-theme="dark"] .standalone-card,
:root[data-theme="dark"] .leaflet-popup-content-wrapper,
:root[data-theme="dark"] .leaflet-popup-tip,
:root[data-theme="dark"] .admin-card,
:root[data-theme="dark"] .user-card,
:root[data-theme="dark"] .info-page,
:root[data-theme="dark"] .moderation-tools {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

:root[data-theme="dark"] .map-panel,
:root[data-theme="dark"] #map {
  background: #1a303a;
}

:root[data-theme="dark"] .map-search-control form,
:root[data-theme="dark"] .map-search-results,
:root[data-theme="dark"] .map-search-button {
  border-color: var(--line);
  background: #0c1a22;
  color: var(--ink);
}

:root[data-theme="dark"] .map-search-result:hover,
:root[data-theme="dark"] .map-search-result:focus-visible {
  background: #11313a;
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .button-secondary,
:root[data-theme="dark"] .button-ghost,
:root[data-theme="dark"] .tab-button.active,
:root[data-theme="dark"] .sheet-handle,
:root[data-theme="dark"] .app-nav,
:root[data-theme="dark"] .search-grid {
  border-color: var(--line);
  background: #0c1a22;
  color: var(--ink);
}

:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder {
  color: #7f8f9a;
}

:root[data-theme="dark"] label,
:root[data-theme="dark"] .report-card-body dd,
:root[data-theme="dark"] .report-detail dd,
:root[data-theme="dark"] .report-title,
:root[data-theme="dark"] .report-notes,
:root[data-theme="dark"] .popup-title,
:root[data-theme="dark"] .flag-reason,
:root[data-theme="dark"] .content-section p,
:root[data-theme="dark"] .content-section li,
:root[data-theme="dark"] .checkbox-row,
:root[data-theme="dark"] .checkbox-row span {
  color: var(--ink);
}

:root[data-theme="dark"] .helper,
:root[data-theme="dark"] .field-hint,
:root[data-theme="dark"] .report-meta,
:root[data-theme="dark"] .popup-meta,
:root[data-theme="dark"] .report-card-body dt,
:root[data-theme="dark"] .admin-card p,
:root[data-theme="dark"] .user-card p,
:root[data-theme="dark"] .info-page p,
:root[data-theme="dark"] .moderation-tools p,
:root[data-theme="dark"] .admin-meta {
  color: var(--muted);
}

:root[data-theme="dark"] .button-primary {
  background: #1b716b;
  color: #fff;
}

:root[data-theme="dark"] .button-primary:hover {
  background: #246f6c;
}

:root[data-theme="dark"] .account-summary,
:root[data-theme="dark"] .empty-state,
:root[data-theme="dark"] .report-search summary,
:root[data-theme="dark"] .admin-page-tabs,
:root[data-theme="dark"] .tabs,
:root[data-theme="dark"] .side-tabs {
  border-color: var(--line);
  background: #0c1a22;
  color: var(--ink);
}

:root[data-theme="dark"] .header-menu-panel a,
:root[data-theme="dark"] .header-menu-action,
:root[data-theme="dark"] .menu-account-status {
  color: var(--ink);
}

:root[data-theme="dark"] .header-menu-panel a:hover,
:root[data-theme="dark"] .header-menu-action:hover,
:root[data-theme="dark"] .header-menu-action.active,
:root[data-theme="dark"] .side-tab.active {
  border-color: #1b4d58;
  background: #11313a;
  color: var(--primary-dark);
}

:root[data-theme="dark"] .side-tab,
:root[data-theme="dark"] .tab-button,
:root[data-theme="dark"] .nav-button {
  color: var(--muted);
}

:root[data-theme="dark"] .report-summary,
:root[data-theme="dark"] .selected-report .report-summary,
:root[data-theme="dark"] .nav-button.active,
:root[data-theme="dark"] .tab-button.active {
  background: #11313a;
  color: var(--primary-dark);
}

:root[data-theme="dark"] .passenger-report-card {
  border-color: #1d5e86;
}

:root[data-theme="dark"] .leaflet-control-zoom,
:root[data-theme="dark"] .leaflet-control-zoom a,
:root[data-theme="dark"] .leaflet-control-layers,
:root[data-theme="dark"] .leaflet-control-attribution {
  border-color: var(--line);
  background: #0c1a22;
  color: var(--ink);
}

:root[data-theme="dark"] .leaflet-control-attribution a {
  color: #8de0d6;
}

:root[data-theme="dark"] .account-result p {
  background: #0c1a22;
  color: var(--primary-dark);
}

:root[data-theme="dark"] .account-result--error p,
:root[data-theme="dark"] .locked::before {
  background: #3a1d17;
  color: #ffd2c4;
}

:root[data-theme="dark"] .account-result--success p {
  background: #123020;
  color: #8ff0bd;
}

@media (max-width: 1100px) {
  :root[data-theme="dark"] .side-panel {
    background: rgba(12, 26, 34, 0.98);
  }

  :root[data-theme="dark"] .app-nav {
    border-color: var(--line) !important;
    background: rgba(12, 26, 34, 0.97) !important;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.42) !important;
  }

  :root[data-theme="dark"] .nav-button {
    color: var(--muted) !important;
    background: transparent !important;
  }

  :root[data-theme="dark"] .nav-button.active {
    background: #11313a !important;
    color: var(--primary-dark) !important;
  }
}

:root[data-theme="light"] body,
:root[data-theme="light"] .content-page,
:root[data-theme="light"] .account-page {
  background: #f6f8fa;
  color: var(--ink);
}

:root[data-theme="light"] .topbar,
:root[data-theme="light"] .content-header {
  background: #102832;
  color: #fff;
}

:root[data-theme="light"] .header-menu-panel,
:root[data-theme="light"] .report-search,
:root[data-theme="light"] .report-card,
:root[data-theme="light"] .report-card-body,
:root[data-theme="light"] .content-section,
:root[data-theme="light"] .standalone-card,
:root[data-theme="light"] .panel-section,
:root[data-theme="light"] .report-detail,
:root[data-theme="light"] .admin-card,
:root[data-theme="light"] .user-card,
:root[data-theme="light"] .info-page,
:root[data-theme="light"] .moderation-tools {
  background: #fff;
  color: var(--ink);
}

:root[data-theme="light"] .side-panel {
  background: var(--surface);
  color: var(--ink);
}

:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea,
:root[data-theme="light"] .button-secondary,
:root[data-theme="light"] .button-ghost,
:root[data-theme="light"] .tab-button.active,
:root[data-theme="light"] .sheet-handle,
:root[data-theme="light"] .search-grid {
  border-color: #cbd5de;
  background: #fff;
  color: var(--ink);
}

:root[data-theme="light"] label,
:root[data-theme="light"] .eyebrow,
:root[data-theme="light"] .report-card-body dd,
:root[data-theme="light"] .report-detail dd,
:root[data-theme="light"] .report-title,
:root[data-theme="light"] .report-notes,
:root[data-theme="light"] .popup-title,
:root[data-theme="light"] .flag-reason,
:root[data-theme="light"] .content-section p,
:root[data-theme="light"] .content-section li,
:root[data-theme="light"] .checkbox-row,
:root[data-theme="light"] .checkbox-row span {
  color: #344450;
}

:root[data-theme="light"] .helper,
:root[data-theme="light"] .field-hint,
:root[data-theme="light"] .report-meta,
:root[data-theme="light"] .popup-meta,
:root[data-theme="light"] .report-card-body dt,
:root[data-theme="light"] .admin-card p,
:root[data-theme="light"] .user-card p,
:root[data-theme="light"] .info-page p,
:root[data-theme="light"] .moderation-tools p,
:root[data-theme="light"] .admin-meta {
  color: var(--muted);
}

:root[data-theme="light"] .button-primary {
  background: var(--primary);
  color: #fff;
}

:root[data-theme="light"] .button-primary:hover {
  background: var(--primary-dark);
}

:root[data-theme="light"] .account-summary,
:root[data-theme="light"] .empty-state,
:root[data-theme="light"] .report-search summary,
:root[data-theme="light"] .admin-page-tabs,
:root[data-theme="light"] .tabs,
:root[data-theme="light"] .side-tabs {
  border-color: var(--line);
  background: #f8fafb;
  color: var(--ink);
}

:root[data-theme="light"] .header-menu-panel a,
:root[data-theme="light"] .header-menu-action,
:root[data-theme="light"] .menu-account-status {
  color: #24323c;
}

:root[data-theme="light"] .header-menu-panel a:hover,
:root[data-theme="light"] .header-menu-action:hover,
:root[data-theme="light"] .header-menu-action.active,
:root[data-theme="light"] .side-tab.active {
  border-color: #cfe1de;
  background: #e8f1ef;
  color: var(--primary-dark);
}

:root[data-theme="light"] .side-tab,
:root[data-theme="light"] .tab-button,
:root[data-theme="light"] .nav-button {
  color: var(--muted);
}

:root[data-theme="light"] .report-summary {
  background: #fff;
  color: inherit;
}

:root[data-theme="light"] .selected-report .report-summary,
:root[data-theme="light"] .nav-button.active,
:root[data-theme="light"] .tab-button.active {
  background: #e8f1ef;
  color: var(--primary-dark);
}

:root[data-theme="light"] .leaflet-control-zoom,
:root[data-theme="light"] .leaflet-control-zoom a,
:root[data-theme="light"] .leaflet-control-layers,
:root[data-theme="light"] .leaflet-control-attribution {
  border-color: rgba(0, 0, 0, 0.18);
  background: #fff;
  color: #46535e;
}

:root[data-theme="light"] .account-result p {
  background: #eef5f4;
  color: var(--primary-dark);
}

:root[data-theme="light"] .account-result--error p {
  background: #fff0eb;
  color: #8c351f;
}

:root[data-theme="light"] .account-result--success p {
  background: #e8f5ef;
  color: #176043;
}

@media (max-width: 1100px) {
  :root[data-theme="light"] .side-panel {
    background: rgba(243, 246, 248, 0.98);
  }

  :root[data-theme="light"] .app-nav {
    border-color: var(--line) !important;
    background: rgba(255, 255, 255, 0.97) !important;
    box-shadow: 0 12px 34px rgba(20, 35, 48, 0.2) !important;
  }

  :root[data-theme="light"] .nav-button {
    color: var(--muted) !important;
    background: transparent !important;
  }

  :root[data-theme="light"] .nav-button.active {
    background: #e8f1ef !important;
    color: var(--primary-dark) !important;
  }

  :root[data-theme="light"] .locked::before {
    background: #fff5df;
    color: #7b4e00;
  }
}

/* Shared interaction and content-page consistency. */
:where(a, button, summary):focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.content-section a,
.standalone-card a,
.panel-section .helper a {
  color: var(--primary-dark);
  font-weight: 750;
  text-underline-offset: 0.16em;
}

.content-section a:hover,
.standalone-card a:hover,
.panel-section .helper a:hover {
  text-decoration-thickness: 2px;
}

.content-section h1,
.content-section h2 {
  line-height: 1.2;
}

.content-section ul,
.content-section ol {
  padding-left: 1.4rem;
}

.account-page .standalone-page {
  min-height: calc(100dvh - 78px);
}

@media (max-width: 620px) {
  .content-header {
    min-height: 64px;
    padding: 10px 12px;
  }

  .content-brand {
    min-width: 0;
    font-size: 1rem;
  }

  .content-header-actions {
    flex-wrap: nowrap;
  }

  .content-home-button {
    min-height: 36px;
    padding-inline: 10px;
  }

  .content-main {
    width: min(100% - 24px, 920px);
    padding: 16px 0 28px;
  }

  .content-section {
    padding: 18px;
  }

  .standalone-page {
    align-items: start;
    padding: 16px 12px 28px;
  }

  .account-page .standalone-page {
    min-height: calc(100dvh - 64px);
  }

  .standalone-card {
    padding: 18px;
  }
}

/* Unified mobile navigation and tools sheet. */
@media (max-width: 1100px) {
  .side-panel {
    top: auto;
    bottom: max(10px, env(safe-area-inset-bottom));
    height: min(76dvh, calc(100dvh - 142px));
    max-height: none;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    padding-bottom: 0;
    border-radius: 12px;
  }

  .side-panel.sheet-collapsed {
    top: auto;
    height: auto;
    max-height: none;
    overflow: hidden;
    grid-template-rows: auto auto;
  }

  .sheet-handle {
    position: relative;
    min-height: 46px;
    border-radius: 0;
  }

  .side-panel .app-panel.active-panel {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .side-panel.sheet-collapsed .app-panel {
    display: none;
  }

  .app-nav {
    position: relative;
    inset: auto;
    z-index: 3;
    width: 100%;
    max-width: none;
    min-height: 58px;
    padding: 6px;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none !important;
  }

  .side-panel.sheet-collapsed .app-nav {
    display: grid;
  }

  .side-panel .panel-section {
    margin: 0;
    padding-bottom: 18px;
    border-radius: 0;
  }
}

@media (max-width: 620px) {
  .side-panel {
    left: 10px;
    right: 10px;
  }

  .map-search-control {
    z-index: 1050;
  }
}

/* Guided report flow. */
.report-flow,
.report-step {
  display: grid;
  gap: 13px;
}

.report-step[hidden] {
  display: none;
}

.report-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 16px;
}

.report-progress-step {
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.report-progress-step span {
  display: block;
  margin-top: 2px;
}

.report-progress-step.active {
  border-color: var(--primary);
  background: var(--panel);
  color: var(--ink);
}

.report-progress-step.complete {
  color: var(--primary);
}

.report-step-heading h3 {
  margin: 0;
  font-size: 1.1rem;
}

.report-step-heading p:last-child {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.location-confirmation {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.location-confirmation-icon {
  position: relative;
  width: 27px;
  height: 27px;
  border: 2px solid var(--primary);
  border-radius: 50%;
}

.location-confirmation-icon::before,
.location-confirmation-icon::after {
  position: absolute;
  content: "";
  background: var(--primary);
}

.location-confirmation-icon::before {
  top: 5px;
  bottom: 5px;
  left: 11px;
  width: 2px;
}

.location-confirmation-icon::after {
  top: 11px;
  right: 5px;
  left: 5px;
  height: 2px;
}

.location-confirmation strong,
.location-confirmation span {
  display: block;
  overflow-wrap: anywhere;
}

.location-confirmation span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.location-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.adjust-location-button {
  display: none;
}

.report-advanced {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.report-advanced summary {
  padding: 11px 12px;
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
}

.report-advanced > div {
  margin: 0 12px 12px;
}

.report-step-actions {
  display: grid;
  margin-top: 3px;
}

.report-step-actions.split-actions {
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
  gap: 8px;
}

.report-step-actions .button {
  width: 100%;
  min-width: 0;
}

.report-review {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  background: var(--panel);
}

.report-review strong,
.report-review span {
  overflow-wrap: anywhere;
}

.report-review span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.recent-report-picker {
  display: grid;
  gap: 7px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.recent-report-picker > label {
  margin: 0;
}

.recent-report-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.recent-report-controls select,
.recent-report-controls .button {
  min-width: 0;
}

@media (max-width: 420px) {
  .report-progress-step {
    font-size: 0.7rem;
  }

  .train-identity-row {
    grid-template-columns: minmax(0, 1fr) 78px;
    gap: 8px;
  }

  .recent-report-controls {
    grid-template-columns: 1fr;
  }

  .contact-form-row {
    grid-template-columns: 1fr;
  }

  .version-history li {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

@media (max-width: 1100px) {
  .location-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .adjust-location-button {
    display: inline-flex;
  }

  .side-panel.sheet-collapsed .sheet-handle {
    display: grid;
    grid-template-columns: 22px auto;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 46px;
  }

  .side-panel:not(.sheet-collapsed) .sheet-handle {
    grid-template-columns: 22px auto;
    justify-content: center;
    gap: 7px;
  }

  .side-panel.sheet-collapsed .sheet-label {
    line-height: 1;
  }
}
