:root {
  --ink: #17212b;
  --muted: #647383;
  --line: #dce4ea;
  --canvas: #eef3f6;
  --panel: #ffffff;
  --navy: #183247;
  --teal: #087f75;
  --teal-soft: #e4f4f1;
  --red: #c94b4b;
  --blue: #2d6c9f;
  --amber: #a56a13;
  --shadow: 0 12px 32px rgba(24, 50, 71, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  min-height: 100vh;
}

.control-sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 100vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  z-index: 2;
}

.app-header {
  padding: 2px 2px 6px;
}

.app-header h1 {
  color: var(--navy);
  font-size: 24px;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.app-header p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  margin-top: 8px;
}

.honesty-strip {
  background: #f7fafb;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  color: #536575;
  font-size: 11px;
  line-height: 1.45;
  padding: 10px 12px;
}

.recommendation-banner {
  background: var(--teal-soft);
  border: 1px solid #b9e2dc;
  border-radius: 12px;
  color: #14564f;
  display: flex;
  flex-direction: column;
  gap: 5px;
  line-height: 1.45;
  padding: 14px;
}

.recommendation-banner strong {
  color: var(--teal);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.recommendation-banner span {
  font-size: 14px;
  font-weight: 600;
}

.panel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(24, 50, 71, 0.035);
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 16px;
}

.panel-card h2 {
  color: var(--navy);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-card small,
.panel-card label,
.panel-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

.field-row label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

select,
input[type="date"],
input[type="number"],
input[type="file"] {
  background: #fbfcfd;
  border: 1px solid #cbd6de;
  border-radius: 7px;
  color: var(--ink);
  font-size: 13px;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

select:focus,
input:focus,
button:focus-visible {
  outline: 3px solid rgba(45, 108, 159, 0.22);
  outline-offset: 2px;
}

.preset-list,
.date-actions,
.button-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.preset,
.secondary-btn {
  background: #f8fafb;
  border: 1px solid #cbd6de;
  border-radius: 7px;
  color: #365064;
  font-size: 12px;
  font-weight: 650;
  min-height: 36px;
  padding: 8px 10px;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.preset:hover,
.secondary-btn:hover {
  background: #eef5f7;
  border-color: #9eb4c2;
}

.preset:active,
.secondary-btn:active,
.primary-btn:active {
  transform: translateY(1px);
}

.preset.active {
  background: var(--teal-soft);
  border-color: #73c2b8;
  color: #08675f;
}

.primary-btn {
  background: var(--teal);
  border: 1px solid var(--teal);
  border-radius: 7px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 750;
  min-height: 40px;
  padding: 9px 14px;
}

.primary-btn:hover {
  background: #056b63;
}

.primary-btn:disabled,
.secondary-btn:disabled,
.preset:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.advanced-toggle {
  background: none;
  border: 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 650;
  padding: 2px 0;
  text-align: left;
}

.alert-box {
  background: #fff5f3;
  border: 1px solid #f0c7bf;
  border-left: 4px solid var(--red);
  border-radius: 8px;
  color: #87403a;
  font-size: 12px;
  line-height: 1.45;
  padding: 10px 12px;
}

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

.metric-card {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px;
}

.metric-card strong {
  color: var(--navy);
  font-size: 12px;
}

.metric-card span {
  color: var(--ink);
  font-size: 13px;
}

.card-baseline {
  border-top: 3px solid var(--red);
}

.card-resilient {
  border-top: 3px solid var(--teal);
}

.batch-summary {
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  font-size: 12px;
  gap: 6px;
  padding: 10px;
}

.route-steps {
  border-left: 2px solid #c6d9df;
  display: flex;
  flex-direction: column;
  gap: 12px;
  list-style-position: outside;
  max-height: 300px;
  overflow-y: auto;
  padding-left: 24px;
}

.route-steps li {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-left: 3px;
}

.route-steps li::marker {
  color: var(--teal);
  font-weight: 700;
}

.route-steps strong {
  color: var(--navy);
  font-size: 12px;
}

.route-steps span,
.route-steps small {
  color: var(--muted);
  font-size: 11px;
}

.map-stage {
  background: #dfe9ed;
  min-height: 100vh;
  padding: 18px;
  position: relative;
}

.map-wrapper {
  background: #edf3f4;
  border: 1px solid #cbd9df;
  border-radius: 16px;
  box-shadow: var(--shadow);
  height: 100%;
  min-height: calc(100vh - 36px);
  overflow: hidden;
  position: relative;
}

.mapbox-canvas,
.vector-map-svg {
  height: 100%;
  min-height: calc(100vh - 36px);
  width: 100%;
}

.vector-map-svg {
  cursor: crosshair;
}

.loading-skeleton {
  animation: pulse 1.4s ease-in-out infinite;
  background: linear-gradient(120deg, #dce7eb, #edf3f4, #dce7eb);
  background-size: 200% 100%;
  border-radius: 16px;
  height: 100%;
  min-height: calc(100vh - 36px);
  width: 100%;
}

@keyframes pulse {
  50% { background-position: 100% 0; }
}

.map-legend {
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #cad7de;
  border-radius: 10px;
  bottom: 18px;
  box-shadow: 0 6px 18px rgba(24, 50, 71, 0.12);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  font-size: 11px;
  gap: 7px;
  max-width: 290px;
  padding: 12px;
  position: absolute;
  right: 18px;
}

.legend-title {
  color: var(--navy);
  font-size: 12px;
  font-weight: 750;
}

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

.legend-swatch {
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
  height: 5px;
  width: 24px;
}

.swatch-baseline {
  background: var(--red);
}

.swatch-resilient {
  background: var(--teal);
}

.swatch-flood {
  background: #63a8cc;
  border: 1px solid #2d6c9f;
  height: 10px;
}

.legend-note {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.evidence-page {
  background: var(--canvas);
  color: var(--ink);
  min-height: 100vh;
  padding: 28px;
}

.evidence-header,
.evidence-card {
  margin: 0 auto 18px;
  max-width: 1100px;
}

.evidence-header a {
  color: var(--blue);
  font-size: 13px;
}

.evidence-header h1 {
  color: var(--navy);
  font-size: 30px;
  letter-spacing: -0.04em;
  margin: 12px 0 8px;
}

.evidence-header p,
.evidence-card p {
  color: var(--muted);
  line-height: 1.55;
}

.evidence-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(24, 50, 71, 0.035);
  padding: 18px;
}

.evidence-card h2 {
  color: var(--navy);
  font-size: 17px;
  margin-bottom: 12px;
}

.evidence-methods {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.evidence-table-wrap {
  margin-top: 12px;
}

.evidence-table {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
}

.evidence-table th,
.evidence-table td {
  border-bottom: 1px solid var(--line);
  padding: 6px;
  text-align: left;
}

.evidence-table td {
  text-align: right;
}

.evidence-figure {
  display: block;
  height: auto;
  margin: 12px 0;
  max-width: 100%;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-sidebar {
    max-height: none;
    order: 2;
  }

  .map-stage {
    min-height: 58vh;
    order: 1;
  }

  .map-wrapper,
  .mapbox-canvas,
  .vector-map-svg,
  .loading-skeleton {
    min-height: 58vh;
  }
}

@media (max-width: 480px) {
  .control-sidebar {
    padding: 14px;
  }

  .map-stage {
    min-height: 48vh;
    padding: 8px;
  }

  .map-wrapper,
  .mapbox-canvas,
  .vector-map-svg,
  .loading-skeleton {
    min-height: 48vh;
  }

  .app-header h1 {
    font-size: 21px;
  }

  .field-row,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .map-legend {
    bottom: 8px;
    right: 8px;
  }

  .evidence-page {
    padding: 16px;
  }
}
