:root {
  --bg: #eef5f7;
  --ink: #132433;
  --muted: #5f7383;
  --panel: rgba(255, 255, 255, 0.9);
  --border: #cbd8e4;
  --accent: #0f4f73;
  --accent-soft: #dcecf5;
  --farm: #81c784;
  --farm-secondary: #9fd58d;
  --farm-tertiary: #bddf95;
  --river: #66a8de;
  --road: #7a7260;
  --route: #156f98;
  --facility: #f0a035;
  --port: #e86868;
  --ready-bg: #d8f3df;
  --ready-ink: #11652f;
  --provisional-bg: #fff2cf;
  --provisional-ink: #8d5a00;
  --attention-bg: #ffe4dd;
  --attention-ink: #9d3429;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Aptos, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(202, 234, 216, 0.7), transparent 32%),
    radial-gradient(circle at 92% 12%, rgba(170, 210, 236, 0.35), transparent 28%),
    linear-gradient(180deg, #f6fbfc 0%, #edf3f7 100%);
}

header {
  padding: 22px 24px;
  background: linear-gradient(110deg, #123e5f 0%, #1f6486 70%, #3a8ea6 100%);
  color: #fff;
}

header h1,
.map-header h2,
.panel-card h2,
.panel-card h3 {
  margin: 0 0 8px;
}

header p,
#phaseNarrative {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.84);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.controls select,
.assumption-panel select,
.assumption-panel input,
.assumption-panel button {
  font: inherit;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(320px, 1fr);
  gap: 18px;
  padding: 18px;
}

.map-card,
.panel-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 16px 35px rgba(25, 51, 74, 0.08);
}

.panel-card {
  background: #f0f4f8;
  border-color: #d0dce9;
}

.map-card {
  background: var(--panel);
  border: 1px solid var(--border);
}

.map-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

#phaseNarrative {
  color: var(--muted);
  max-width: 580px;
}

.map-hint {
  max-width: 280px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #eff7fb;
  color: #295064;
  font-size: 13px;
  line-height: 1.45;
}

#opsMap {
  width: 100%;
  height: auto;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
}

.bg {
  fill: url(#seaGlow);
}

.map-grid line {
  stroke: rgba(93, 128, 151, 0.12);
  stroke-width: 1;
}

.map-grid {
  display: none;
}

.country {
  fill: #d5ead2;
  stroke: #456d57;
  stroke-width: 2.4;
}

[data-asset-id="essequibo-river"] .river-line {
  stroke-width: 9;
  opacity: 0.8;
}

.border-river {
  stroke-dasharray: 8 4;
  opacity: 0.55;
}

.regional-labels text,
.asset-label,
.scale-bar text {
  font-size: 14px;
  fill: #223647;
}

.river-line {
  fill: none;
  stroke: var(--river);
  stroke-width: 5;
  stroke-linecap: round;
  opacity: 0.9;
}

.road-line {
  fill: none;
  stroke: var(--road);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 6 7;
  opacity: 0.85;
}

.farm-zone {
  fill: rgba(129, 199, 132, 0.55);
  stroke: #4c8152;
  stroke-width: 2;
}

.farm-zone.secondary {
  fill: rgba(159, 213, 141, 0.48);
}

.farm-zone.tertiary {
  fill: rgba(189, 223, 149, 0.45);
}

.route {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 10 10;
  animation: pulse 1.3s linear infinite;
}

.route.haul-route {
  stroke: #2a7a55;
}

.route.river-route,
.route.feeder-route {
  stroke: var(--route);
}

.node {
  stroke: #1d3140;
  stroke-width: 2;
}

.plant,
.secondgen {
  fill: var(--facility);
}

.storage {
  fill: #7d8eff;
}

.port {
  fill: var(--port);
}

.cert-gate {
  pointer-events: all;
  cursor: pointer;
}

.cert-gate-box {
  fill: rgba(92, 107, 192, 0.2);
  stroke: #5c6bc0;
  stroke-width: 2;
  transition: all 120ms ease;
}

.cert-gate:hover .cert-gate-box {
  fill: rgba(92, 107, 192, 0.35);
  stroke: #3d4cb8;
  stroke-width: 2.5;
  filter: drop-shadow(0 2px 5px rgba(92, 107, 192, 0.4));
}

.cert-gate-label {
  fill: #5c6bc0;
  font-weight: bold;
  text-anchor: middle;
  font-size: 12px;
}

.cert-gate:hover .cert-gate-label {
  fill: #3d4cb8;
  font-weight: bold;
}

.vehicle {
  r: 6;
  fill: #173042;
}

.scale-bar line {
  stroke: #26485b;
  stroke-width: 2;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.legend-swatch {
  display: inline-block;
  width: 18px;
  height: 10px;
  margin-right: 6px;
  border-radius: 99px;
  vertical-align: middle;
}

.legend-swatch.farms { background: rgba(129, 199, 132, 0.9); }
.legend-swatch.rivers { background: var(--river); }
.legend-swatch.roads { background: var(--road); }
.legend-swatch.routes { background: var(--route); }
.legend-swatch.facilities { background: var(--facility); }

.phase-2-only,
.phase-3-only {
  display: none;
}

body.phase-2 .phase-2-only,
body.phase-3 .phase-2-only,
body.phase-3 .phase-3-only {
  display: inline;
}

[data-asset-id] {
  cursor: pointer;
  transition: opacity 120ms ease, transform 120ms ease;
}

[data-asset-id]:hover,
[data-asset-id].is-active {
  opacity: 1;
  filter: drop-shadow(0 6px 10px rgba(18, 55, 79, 0.18));
}

.gate {
  margin-bottom: 14px;
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.gate.open {
  background: var(--ready-bg);
  color: var(--ready-ink);
}

.gate.caveat {
  background: var(--provisional-bg);
  color: var(--provisional-ink);
}

.gate.blocked,
.gate.attention {
  background: var(--attention-bg);
  color: var(--attention-ink);
}

.metric-list {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: grid;
  gap: 10px;
}

.metric-button {
  width: 100%;
  border: 1px solid #dae4ec;
  border-radius: 14px;
  background: #fff;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.metric-button:hover,
.metric-button:focus-visible {
  transform: translateY(-1px);
  border-color: #8bb6ce;
  box-shadow: 0 10px 18px rgba(30, 68, 95, 0.08);
  outline: none;
}

.metric-topline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.metric-name {
  font-weight: 700;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.metric-subtext {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.badge.ready {
  background: var(--ready-bg);
  color: var(--ready-ink);
}

.badge.provisional {
  background: var(--provisional-bg);
  color: var(--provisional-ink);
}

.badge.attention,
.badge.blocked {
  background: var(--attention-bg);
  color: var(--attention-ink);
}

.hint-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #e8f0f5;
  color: #2c5268;
  font-size: 12px;
  font-weight: 700;
}

.provenance {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid #dbe4ed;
  border-radius: 14px;
  background: #f9fbfd;
  font-size: 13px;
  line-height: 1.55;
}

.detail-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.detail-list,
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chip,
.assumption-chip {
  border: 1px solid #cad9e5;
  background: #fff;
  color: #214258;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.assumption-chip {
  cursor: pointer;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid #e3e8ef;
  padding: 7px 6px;
  font-size: 13px;
  vertical-align: top;
}

.assumption-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e1e8ee;
}

.assumption-intro {
  color: var(--muted);
  line-height: 1.5;
}

.assumption-panel select,
.assumption-panel input {
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid #cad7e1;
  background: #fff;
}

.assumption-meta {
  margin-top: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #eef6fa;
  color: #2b4b5d;
  font-size: 13px;
  line-height: 1.5;
}

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

.assumption-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.assumption-actions button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

.assumption-actions button.secondary {
  background: #355c72;
}

.assumption-actions button.ghost {
  background: #e8eff4;
  color: #29465b;
}

@keyframes pulse {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: 20; }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .map-header {
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  .controls {
    flex-wrap: wrap;
  }

  .assumption-grid {
    grid-template-columns: 1fr;
  }

  .metric-button {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 22px;
  }
}

.top-nav {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.top-nav a {
  text-decoration: none;
  color: #f3fbff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}

.top-nav a.is-active {
  background: rgba(255, 255, 255, 0.2);
}

.layout-single {
  grid-template-columns: 1fr;
}

.layout-split {
  grid-template-columns: 1.6fr 1fr;
}

.controls {
  display: flex !important;
  justify-content: space-between;
}

.controls-left {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.controls-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

.flowchart-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 16px 35px rgba(25, 51, 74, 0.08);
}

.journey-card {
  background: #1a2f3f;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 16px 35px rgba(25, 51, 74, 0.15);
  display: flex;
  flex-direction: column;
}

.journey-card .map-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.journey-card h2 {
  color: #fff;
  margin: 0;
}

.journey-pane {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.journey-station {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: all 120ms ease;
  color: #d0d9e3;
}

.journey-station:hover {
  border-color: rgba(92, 107, 192, 0.5);
  background: rgba(92, 107, 192, 0.08);
  color: #fff;
}

.journey-station.is-active {
  border-color: #5c6bc0;
  background: rgba(92, 107, 192, 0.15);
  color: #fff;
  font-weight: 600;
}

.journey-station-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: inherit;
}

.journey-station-detail {
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.6);
  margin: 4px 0;
}

.journey-station-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.journey-kpi {
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.7);
}

.journey-station.is-active .journey-kpi {
  background: rgba(92, 107, 192, 0.2);
  color: #fff;
}

.tab-row,
.statement-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.view-toggle {
  margin: 0;
}

.tab-row button,
.statement-tabs button,
button.secondary {
  border: 1px solid #8fb4c8;
  border-radius: 999px;
  background: #ffffff;
  color: #20475c;
  padding: 8px 12px;
  cursor: pointer;
}

.tab-row button.is-active,
.statement-tabs button.is-active {
  background: #0f4f73;
  color: #fff;
  border-color: #0f4f73;
}

.statement-tabs {
  padding: 0 18px 8px;
}

#flowchart {
  width: 100%;
  height: auto;
  border-radius: 14px;
  background: linear-gradient(180deg, #f7fdff 0%, #edf5f9 100%);
  border: 1px solid #d6e4ee;
}

.flow-node rect {
  fill: #fff;
  stroke: #89aec2;
  stroke-width: 1.5;
}

.flow-node text {
  fill: #1d3b4f;
  font-size: 12px;
  font-weight: 600;
}

.flow-node.process rect {
  fill: #e8f3f9;
}

.flow-node.commercial rect,
.flow-node.financial rect {
  fill: #f2f8ef;
}

.flow-node.optional rect {
  stroke-dasharray: 6 4;
}

.flow-edge path {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 9 7;
  animation: pulse 1.2s linear infinite;
}

.flow-edge.revenue path {
  stroke: #2d8a56;
}

.flow-edge.cost path {
  stroke: #ad4f44;
}

.flow-edge.loop path {
  stroke: #336f93;
}

.flow-edge.optional path {
  opacity: 0.7;
}

.flow-edge.focused path {
  stroke-width: 5;
}

.flow-edge.material path,
.flow-edge.material-loop path {
  fill: none;
  stroke: #5c6bc0;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: none;
  animation: none;
}

.flow-edge.material-loop path {
  stroke: #7986cb;
  stroke-width: 2.5;
}

.view-toggle {
  gap: 4px;
}

.view-toggle + label {
  margin-left: 14px;
}
.legend-swatch.material { background: #5c6bc0; }

#statementTable .row-btn {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

#statementTable .statement-row.highlight {
  background: #f4fbf6;
  font-weight: 700;
}

#statementTable .statement-row.focused {
  outline: 2px solid #6aa6c7;
  outline-offset: -2px;
}

#masterTable input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #c7d8e5;
}

#masterTable tr.is-overridden {
  background: #fff9e8;
}