:root {
  --bg: #eef3f1;
  --surface: #ffffff;
  --ink: #102321;
  --muted: #5d706d;
  --line: #ccd9d6;
  --teal: #007c78;
  --teal-soft: #d9eeeb;
  --amber: #c27b16;
  --amber-soft: #f7e5c7;
  --red: #b64232;
  --shadow: 0 18px 46px rgba(19, 56, 54, 0.12);
  --radius: 8px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--ink);
  margin: 0;
}

a {
  color: var(--teal);
  font-weight: 800;
  text-decoration: none;
}

.button-link {
  align-items: center;
  background: var(--teal);
  border: 1px solid var(--teal);
  border-radius: var(--radius);
  color: white;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 38px;
  padding: 0 13px;
}

.button-link.secondary {
  background: var(--surface);
  color: var(--teal);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

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

button {
  background: var(--teal);
  border: 1px solid var(--teal);
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  font-weight: 850;
  min-height: 38px;
  padding: 0 13px;
}

.topbar {
  align-items: center;
  background: rgba(238, 243, 241, 0.96);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 12px 18px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  gap: 10px;
}

.brand.compact {
  margin-bottom: 18px;
}

.brand-mark {
  align-items: center;
  background: var(--ink);
  border-radius: var(--radius);
  color: #d8fff2;
  display: inline-flex;
  font-weight: 950;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.main-nav a,
.account button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 850;
  min-height: 34px;
  padding: 8px 10px;
}

.main-nav a.primary-nav-link {
  background: var(--ink);
  border-color: var(--ink);
  color: #d8fff2;
}

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

.account form {
  margin: 0;
}

.staging-banner {
  background: var(--amber-soft);
  border-bottom: 1px solid #e1be7c;
  color: #7d4a09;
  font-size: 0.8rem;
  font-weight: 950;
  padding: 8px 18px;
  text-align: center;
}

.page {
  padding: 16px;
}

.hero-grid,
.dashboard-grid,
.detail-grid {
  display: grid;
  gap: 14px;
}

.hero-grid {
  align-items: stretch;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
  margin-bottom: 14px;
}

.hero-grid h1 {
  font-size: clamp(1.65rem, 3vw, 2.6rem);
  margin: 0 0 8px;
}

.hero-grid p,
.muted {
  color: var(--muted);
  font-weight: 650;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.status-pill {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 900;
  min-height: 30px;
  padding: 7px 10px;
}

.status-pill.baseline {
  background: #f7fbfa;
  color: var(--muted);
}

.status-pill.low {
  background: var(--teal-soft);
  color: var(--teal);
}

.status-pill.medium {
  background: var(--amber-soft);
  color: #7d4a09;
}

.status-pill.high {
  background: #f4d4cf;
  color: var(--red);
}

.hero-stats {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, 1fr);
}

.hero-stats article,
.panel,
.login-card,
.detail-grid div {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-stats article,
.detail-grid div {
  padding: 14px;
}

.hero-stats strong {
  display: block;
  font-size: 1.55rem;
  font-weight: 950;
}

.hero-stats span,
.detail-grid span,
.detail-grid strong {
  display: block;
}

.hero-stats span,
.detail-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
}

.panel {
  min-width: 0;
  padding: 14px;
}

.panel-heading {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-heading h1,
.panel-heading h2 {
  font-size: 1rem;
  font-weight: 950;
  line-height: 1.15;
  margin: 0;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 780;
}

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

.panel-actions a {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.78rem;
  min-height: 30px;
  padding: 6px 9px;
}

.map-panel {
  min-height: 420px;
}

.coordinate-route-preview {
  background: #f7fbfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 392px;
  overflow: hidden;
  position: relative;
}

.coordinate-route-map {
  background: #dfe8e5;
  height: clamp(460px, 54vh, 680px);
  min-height: 460px;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.coordinate-route-map.leaflet-container {
  display: block;
}

.coordinate-route-map.leaflet-container .map-loading-fallback {
  display: none;
}

.dashboard-route-marker {
  align-items: center;
  background: var(--ink);
  border: 3px solid #d8fff2;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(16, 35, 33, 0.24);
  color: #d8fff2;
  display: flex;
  font-size: 0.82rem;
  font-weight: 950;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.dashboard-route-marker-pickup {
  background: var(--teal);
}

.dashboard-route-marker-truck {
  background: var(--amber);
  color: #102321;
}

.dashboard-route-marker-finish {
  background: var(--red);
}

.dashboard-route-marker span {
  line-height: 1;
}

.coordinate-map-svg {
  display: block;
  height: 100%;
  width: 100%;
}

.coord-map-base {
  fill: #e6eeeb;
}

.coord-map-park {
  fill: #cfe3d3;
}

.coord-map-water {
  fill: #b7dce8;
}

.coord-road {
  fill: none;
  stroke-linecap: round;
}

.coord-road.minor {
  stroke: #ffffff;
  stroke-width: 7;
}

.coord-road.local {
  stroke: #fff4d5;
  stroke-width: 11;
}

.coord-road.major {
  stroke: #f4cf8c;
  stroke-width: 15;
}

.coord-road.highway {
  stroke: #ffffff;
  stroke-width: 19;
}

.coord-route-shadow {
  fill: none;
  stroke: rgba(16, 35, 33, 0.32);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 17;
}

.coord-route-line {
  fill: none;
  stroke: #102321;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 13;
}

.coord-route-pulse {
  fill: none;
  stroke: #00a591;
  stroke-dasharray: 2 20;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
}

.coord-marker circle {
  fill: #ffffff;
  stroke: #102321;
  stroke-width: 5;
}

.coord-marker text {
  fill: #102321;
  font-size: 16px;
  font-weight: 950;
  text-anchor: middle;
}

.coord-marker.pickup circle {
  stroke: var(--teal);
}

.coord-marker.truck circle {
  fill: var(--ink);
  stroke: #d8fff2;
}

.coord-marker.truck text {
  fill: #d8fff2;
}

.coord-marker.finish circle {
  stroke: var(--red);
}

.coord-label {
  fill: #5d706d;
  font-size: 12px;
  font-weight: 850;
  text-anchor: middle;
}

.coordinate-map-empty {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-weight: 850;
  height: 100%;
  justify-content: center;
  padding: 18px;
  text-align: center;
}

.map-status-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  left: 14px;
  padding: 10px 12px;
  position: absolute;
  top: 14px;
}

.map-status-card strong,
.map-status-card span {
  display: block;
}

.map-status-card span,
.route-summary-row span,
.route-summary-row a {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.route-summary-row a {
  color: var(--teal);
  text-align: right;
}

.route-summary-row {
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  bottom: 0;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
  left: 0;
  padding: 10px 12px;
  position: absolute;
  width: 100%;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

td {
  font-size: 0.86rem;
  font-weight: 650;
}

td small {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  font-weight: 720;
  margin-top: 3px;
}

.status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.74rem;
  font-weight: 950;
  padding: 5px 8px;
}

.status.active {
  background: var(--teal-soft);
  color: var(--teal);
}

.status.stale {
  background: var(--amber-soft);
  color: #7d4a09;
}

.selected-row td {
  background: var(--teal-soft);
}

.feed-list {
  display: grid;
  gap: 8px;
}

.feed-list div,
.message {
  background: #f7fbfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.download-ready,
.download-missing {
  align-items: center;
  background: #f7fbfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 12px;
}

.download-missing {
  align-items: flex-start;
  background: var(--amber-soft);
  color: #7d4a09;
  display: grid;
}

.download-ready strong,
.download-ready span,
.download-missing strong,
.download-missing span {
  display: block;
}

.download-ready span,
.download-missing span {
  font-size: 0.82rem;
  font-weight: 750;
}

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

.install-notes h2 {
  font-size: 1rem;
  margin: 0 0 8px;
}

.install-notes li {
  margin-bottom: 6px;
}

.feed-list strong,
.feed-list span,
.feed-list small {
  display: block;
}

.feed-list small {
  color: var(--muted);
  font-weight: 700;
}

.stack-form,
.checklist-form {
  display: grid;
  gap: 10px;
}

.stack-form p,
.checklist-form p {
  display: grid;
  gap: 5px;
  margin: 0;
}

.stack-form input,
.stack-form select,
.stack-form textarea,
.checklist-form input,
.checklist-form select,
.checklist-form textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 38px;
  padding: 8px;
  width: 100%;
}

.checklist-form p:has(input[type="checkbox"]) {
  align-items: center;
  display: flex;
  gap: 8px;
}

.checklist-form input[type="checkbox"] {
  min-height: auto;
  width: auto;
}

.scenario-grid,
.three-fields {
  display: grid;
  gap: 8px;
}

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

.scenario-grid form {
  margin: 0;
}

.scenario-grid button {
  width: 100%;
}

.scenario-grid button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #d8fff2;
  box-shadow: inset 0 0 0 2px rgba(216, 255, 242, 0.22);
}

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

.review-score {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 12px;
}

.review-score.baseline {
  background: #f7fbfa;
}

.review-score.low {
  background: var(--teal-soft);
  color: var(--teal);
}

.review-score.medium {
  background: var(--amber-soft);
  color: #7d4a09;
}

.review-score.high {
  background: #f4d4cf;
  color: var(--red);
}

.signal-list {
  display: grid;
  gap: 8px;
}

.signal {
  background: #f7fbfa;
  border: 1px solid var(--line);
  border-left: 6px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.signal.low {
  border-left-color: var(--teal);
}

.signal.medium {
  border-left-color: var(--amber);
}

.signal.high {
  border-left-color: var(--red);
}

.signal strong,
.signal span,
.signal small {
  display: block;
}

.signal p {
  margin: 7px 0;
}

.signal small,
.error-text {
  color: var(--muted);
  font-weight: 750;
}

.error-text {
  color: var(--red);
}

.dispatch-watch-map-panel {
  display: grid;
  gap: 10px;
}

.dispatch-watch-map {
  background: #dfe8e5;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  height: clamp(460px, 54vh, 680px);
  min-height: 460px;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.dispatch-watch-map.leaflet-container {
  display: block;
}

.map-loading-fallback {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-weight: 900;
  height: 100%;
  justify-content: center;
  padding: 18px;
  text-align: center;
}

.dispatch-watch-map.leaflet-container .map-loading-fallback {
  display: none;
}

.dispatch-watch-marker {
  align-items: center;
  background: var(--ink);
  border: 3px solid #d8fff2;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(16, 35, 33, 0.22);
  color: #d8fff2;
  display: flex;
  font-size: 0.8rem;
  font-weight: 950;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.dispatch-watch-marker span {
  line-height: 1;
}

.login-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  max-width: 420px;
  padding: 18px;
  width: 100%;
}

.login-card form {
  display: grid;
  gap: 10px;
}

.login-card p {
  display: grid;
  gap: 5px;
  margin: 0;
}

.login-card input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 40px;
  padding: 8px;
}

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

@media (max-width: 1000px) {
  .topbar,
  .hero-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    display: grid;
  }

  .hero-stats,
  .detail-grid,
  .three-fields {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .page {
    padding: 10px;
  }

  .hero-stats,
  .detail-grid,
  .scenario-grid,
  .three-fields {
    grid-template-columns: 1fr;
  }
}
