/* ============================================================
   Annada — Potato Supply Chain Ledger
   Design language: a field agronomist's ledger book kept at night
   by lamplight. Warm dark soil surface, parchment text, harvest-
   gold and rust-red signal colors borrowed from ripening/rotting
   produce, IBM Plex Mono for data because a ledger's numbers are
   typed, not handwritten.
   ============================================================ */

:root {
  --soil-black: #14120f;
  --surface: #1d1912;
  --surface-raised: #262015;
  --surface-line: #35301f;
  --parchment: #ede6d6;
  --parchment-dim: #b9b09b;
  --slate: #8a8272;
  --ochre: #c9932e;
  --ochre-dim: #7a5c1f;
  --rust: #c0503a;
  --rust-dim: #5e2c22;
  --moss: #7c9a6c;
  --moss-dim: #3c4a34;

  --font-display: "Fraunces", "Iowan Old Style", "Georgia", serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", Consolas, monospace;

  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--soil-black);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

body {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(237, 230, 214, 0.035) 1px, transparent 0);
  background-size: 22px 22px;
}

a { color: var(--ochre); text-decoration: none; }

.skip-link:focus {
  position: fixed; top: 8px; left: 8px; z-index: 100;
  background: var(--ochre); color: var(--soil-black); padding: 6px 12px;
  border-radius: var(--radius);
}

/* ---------- Masthead ---------- */

.masthead {
  border-bottom: 2px solid var(--surface-line);
  padding: 22px 28px 16px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.masthead__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: 0.01em;
  color: var(--parchment);
  margin: 0;
}

.masthead__title small {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ochre);
  margin-top: 4px;
}

.masthead__meta {
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--slate);
}

.masthead__meta .divider { color: var(--surface-line); }

.region-select {
  background: var(--surface);
  border: 1px solid var(--surface-line);
  color: var(--parchment);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius);
}

.masthead__status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--slate);
}
.status-dot.ok { background: var(--moss); box-shadow: 0 0 6px var(--moss); }
.status-dot.down { background: var(--rust); box-shadow: 0 0 6px var(--rust); }
.status-dot.stale { background: var(--ochre, #c9932e); box-shadow: 0 0 6px var(--ochre, #c9932e); }

.feed-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: var(--ink-soft, inherit);
  padding: 0.4rem 0;
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  min-height: calc(100vh - 90px);
}

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

/* ---------- Sidebar ---------- */

.sidebar {
  border-right: 1px solid var(--surface-line);
  padding: 22px 20px;
}

.sidebar__label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--slate);
  margin: 0 0 12px;
}

.scenario-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 22px;
}

.scenario-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  background: transparent;
  color: var(--parchment-dim);
  font-family: var(--font-body);
  font-size: 13.5px;
  text-align: left;
  width: 100%;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.scenario-item:hover {
  border-color: var(--surface-line);
  background: var(--surface);
}

.scenario-item.active {
  color: var(--parchment);
  border-color: var(--ochre-dim);
  background: var(--surface-raised);
}

.scenario-item .tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ochre);
  opacity: 0;
  transition: opacity 120ms ease;
}
.scenario-item.active .tag { opacity: 1; }

.custom-shock {
  border-top: 1px dashed var(--surface-line);
  padding-top: 16px;
  margin-top: 4px;
}

.custom-shock label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--slate);
  margin-bottom: 6px;
}

.custom-shock select, .custom-shock input[type="range"] {
  width: 100%;
}

.custom-shock select {
  background: var(--surface);
  border: 1px solid var(--surface-line);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 7px 8px;
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.custom-shock .range-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.custom-shock output {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ochre);
  min-width: 38px;
  text-align: right;
}

button.btn {
  width: 100%;
  background: var(--ochre);
  color: var(--soil-black);
  border: none;
  border-radius: var(--radius);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: filter 120ms ease, transform 120ms ease;
}
button.btn:hover { filter: brightness(1.08); }
button.btn:active { transform: translateY(1px); }
button.btn:focus-visible { outline: 2px solid var(--parchment); outline-offset: 2px; }
button.btn:disabled { opacity: 0.5; cursor: wait; }

button.btn.secondary {
  background: transparent;
  color: var(--parchment-dim);
  border: 1px solid var(--surface-line);
  margin-top: 8px;
}
button.btn.secondary:hover { border-color: var(--slate); color: var(--parchment); }

/* ---------- Main ---------- */

.main { padding: 22px 28px 40px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  margin-bottom: 22px;
}

.panel__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--surface-line);
}

.panel__header h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--parchment);
}

.panel__header .hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--slate);
}

.panel__body { padding: 16px 18px; }

/* ---------- Field map (graph) ---------- */

#field-map {
  width: 100%;
  height: 420px;
  display: block;
}

.field-map-wrap { position: relative; }

.field-map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slate);
  font-family: var(--font-mono);
  font-size: 12px;
  pointer-events: none;
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 18px 16px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--slate);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- Two-column results ---------- */

.results-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 22px;
}

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

/* Ledger table */

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.ledger-table th {
  text-align: left;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
  font-weight: 500;
  padding: 4px 8px 8px 0;
  border-bottom: 1px solid var(--surface-line);
}

.ledger-table td {
  padding: 8px 8px 8px 0;
  border-bottom: 1px solid var(--surface-line);
  vertical-align: baseline;
}

.ledger-table tr:last-child td { border-bottom: none; }

.ledger-table .node-name { color: var(--parchment); }
.ledger-table .category {
  color: var(--slate);
  font-size: 10.5px;
}

.mag {
  font-weight: 600;
  text-align: right;
  display: inline-block;
  min-width: 56px;
}
.mag.increase { color: var(--ochre); }
.mag.decrease { color: var(--rust); }
.mag.negligible { color: var(--slate); }

.dir-arrow { display: inline-block; margin-right: 4px; }

.empty-state {
  color: var(--slate);
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 6px 0;
}

/* Advisory notices */

.notices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.agent-tab {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 10px;
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--parchment-dim);
  cursor: pointer;
}
.agent-tab.active { background: var(--surface-raised); color: var(--ochre); border-color: var(--ochre-dim); }

.notice {
  border-left: 2px solid var(--moss);
  background: var(--surface-raised);
  padding: 10px 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
  animation: notice-in 220ms ease both;
}

@keyframes notice-in {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}

.notice__action {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--parchment);
  text-transform: capitalize;
}

.notice__rationale {
  font-size: 12.5px;
  color: var(--parchment-dim);
  margin: 4px 0 6px;
}

.notice__meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--slate);
}

.notice__score {
  float: right;
  font-family: var(--font-mono);
  color: var(--ochre);
}

footer.colophon {
  padding: 18px 28px 30px;
  color: var(--slate);
  font-family: var(--font-mono);
  font-size: 11px;
  border-top: 1px solid var(--surface-line);
}

@media (prefers-reduced-motion: reduce) {
  .notice { animation: none; }
  * { transition: none !important; }
}
