/* World Food Production Dashboard — dark terminal theme */

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

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1a1a1a;
  --border: rgba(255,255,255,0.08);
  --text: #d4d4d4;
  --text-muted: #737373;
  --accent: #60a5fa;
  --accent-dim: rgba(96,165,250,0.15);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Courier New", "Lucida Console", monospace;
  font-size: 13px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Top bar (mobile) */
#top-bar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: 42px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  align-items: center;
  gap: 8px;
}

#top-bar .sidebar-title {
  font-weight: bold;
  font-size: 14px;
  white-space: nowrap;
}

/* Dashboard layout */
#dashboard {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
#sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
  height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 8px;
}

.sidebar-header .sidebar-title {
  font-weight: bold;
  font-size: 15px;
  flex: 1;
}

.gh-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.gh-link:hover { color: var(--text); }

/* Stats */
.sidebar-stats {
  padding: 8px 0;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}
.stat-label { color: var(--text-muted); }
.stat-value { color: var(--accent); font-weight: bold; }

/* Filters */
.filter-row {
  padding: 8px 0;
}
.section-title {
  display: block;
  font-weight: bold;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.filter-row label {
  display: inline !important;
  padding: 2px 8px 2px 0;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.filter-row label:hover { color: #fff; }

.filter-row input[type="radio"] {
  display: inline !important;
  width: auto !important;
  height: auto !important;
  margin-right: 3px;
  vertical-align: middle;
  accent-color: var(--accent);
}

.cat-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 2px;
}

.info-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px;
  border-radius: 2px;
  vertical-align: middle;
}
.info-btn:hover { color: var(--text); border-color: var(--text-muted); }

.sidebar-updated {
  color: var(--text-muted);
  font-size: 11px;
  padding: 8px 0;
}

/* TuiCss overrides */
.tui-divider {
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* Charts area */
#charts-area {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.view-panel { display: none; }
.view-panel.active { display: block; }

.chart-row {
  margin-bottom: 16px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px;
}

.chart-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: bold;
  color: var(--text);
}

.chart-wrap {
  position: relative;
  height: 360px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Item select dropdown */
.item-select-wrap {
  margin-bottom: 12px;
}

.item-select-wrap select,
.cons-controls select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 2px;
  cursor: pointer;
  min-width: 200px;
}

/* Consumption overlay controls */
.cons-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.chart-note {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay[hidden] { display: none; }

.modal-overlay .tui-window {
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px;
}

.modal-overlay .tui-fieldset {
  border-color: var(--border);
}
.modal-overlay legend {
  color: var(--accent);
  font-weight: bold;
}

.modal-close {
  float: right;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: #fff; }

.modal-intro {
  margin: 8px 0 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.modal-attrib {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
}
.modal-attrib a { color: var(--accent); }

/* TUI table overrides */
.tui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.tui-table th, .tui-table td {
  padding: 4px 8px;
  border: 1px solid var(--border);
  text-align: left;
}
.tui-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: bold;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}
.tui-table a { color: var(--accent); }

/* Responsive */
@media (max-width: 800px) {
  #top-bar { display: flex; }

  #dashboard {
    flex-direction: column;
    padding-top: 42px;
  }

  #sidebar {
    width: 100%;
    min-width: unset;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-header { display: none; }

  .chart-wrap { height: 260px; }

  #charts-area { padding: 12px; }
}

@media (min-width: 1200px) {
  .chart-wrap { height: 420px; }
}

/* Scarcity thesis text */
.thesis-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 12px 0 0;
  padding: 10px 0 2px;
  text-align: center;
  letter-spacing: 0.01em;
  border-top: 1px dashed var(--border);
}
.thesis-text em {
  color: var(--accent);
  font-style: italic;
}

/* Integrity view intro */
.integrity-intro {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  text-align: center;
  margin: 4px 0 0;
  padding: 6px 12px;
  border-left: 3px solid var(--accent);
  background: rgba(255,255,255,0.02);
}

/* Corroboration table */
.table-scroll {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
}
.table-scroll table { font-size: 12px; }
.table-scroll th, .table-scroll td { white-space: nowrap; padding: 4px 8px; }
.verdict-corroborated { color: #34d399; font-weight: bold; }
.verdict-suspicious   { color: #f87171; font-weight: bold; }
.verdict-inconclusive { color: #fbbf24; }
.pct-positive { color: #34d399; }
.pct-negative { color: #f87171; }
