@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #F1F2F5;
  --surface-3: #E7E9ED;
  --border: #E3E5EA;
  --text: #14161A;
  --text-dim: #565B66;
  --text-faint: #9096A2;

  --accent: #0D9488;
  --accent-hover: #0B7C72;
  --accent-bg: #ECFDF9;
  --accent-dim: #99E4D9;

  --critical: #DC2626;
  --critical-bg: #FEF2F2;
  --critical-border: #FBD5D5;

  --watch: #D97706;
  --watch-bg: #FFFBEB;
  --watch-border: #FCE3AE;

  --ok: #059669;
  --ok-bg: #ECFDF5;
  --ok-border: #B7EED9;

  --policy: #7C3AED;
  --policy-bg: #F5F3FF;
  --policy-border: #DDD3FB;

  --radius: 10px;
  --sidebar-w: 244px;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }

.app-shell {
  display: flex;
  height: 100vh;
}

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
}

.sidebar-scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 20px 14px 8px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 6px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #0B7C72);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  color: #ffffff;
  font-size: 12.5px;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 1px;
}

.sidebar-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  padding: 14px 10px 6px;
}
.sidebar-section-label:first-child { padding-top: 2px; }

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 2px;
  transition: background 0.12s ease, color 0.12s ease;
}

.side-icon { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }

.side-link:hover { background: var(--surface-2); color: var(--text); }

.side-link.active {
  background: var(--accent-bg);
  color: var(--accent-hover);
  font-weight: 600;
}
.side-link.active .side-icon { opacity: 1; }

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
}

.data-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  margin-bottom: 12px;
  padding: 0 2px;
}

.data-note-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-radius: 9px;
  background: var(--surface-2);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--surface-3);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.3; }
.user-role {
  font-size: 10.5px;
  color: var(--text-faint);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}

.main-area {
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 32px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.page-header p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-faint);
}

.page-content {
  padding: 26px 32px 60px;
  max-width: 1600px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 300px;
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  width: 100%;
}
.search-box input::placeholder { color: var(--text-faint); }
.search-box svg { flex-shrink: 0; color: var(--text-faint); }

.filter-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 100px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font-body);
}

.chip:hover { background: var(--surface-2); }

.chip.active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
  font-weight: 500;
}

.chip .tier-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tier-dot.critical { background: var(--critical); }
.tier-dot.watch { background: var(--watch); }
.tier-dot.ok { background: var(--ok); }
.tier-dot.all { background: var(--accent); }

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

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

.stat-card .value {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  line-height: 1;
  color: var(--text);
}

.stat-card .label {
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stat-card.critical .value { color: var(--critical); }
.stat-card.watch .value { color: var(--watch); }
.stat-card.ok .value { color: var(--ok); }
.stat-card.accent .value { color: var(--accent-hover); }

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.list-header h2 {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.sort-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 7px 11px;
  border-radius: 7px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  cursor: pointer;
}

.facility-table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.f-row {
  display: grid;
  grid-template-columns: 84px 2fr 1fr 110px 1fr 90px;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s ease;
}

.f-row:last-child { border-bottom: none; }
.f-row:hover { background: var(--surface-2); }
.f-row.selected { background: var(--surface-3); }

.f-row.header-row {
  cursor: default;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-faint);
}
.f-row.header-row:hover { background: var(--surface-2); }

.f-id { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); }
.f-name { font-weight: 500; color: var(--text); }
.f-town { color: var(--text-faint); font-size: 12px; margin-top: 1px; }
.f-district { color: var(--text-dim); font-size: 13px; }

.meter { display: flex; gap: 3px; align-items: center; }
.meter-tick { width: 14px; height: 6px; border-radius: 2px; background: var(--surface-3); }
.meter-tick.on.critical { background: var(--critical); }
.meter-tick.on.watch { background: var(--watch); }
.meter-tick.on.ok { background: var(--ok); }

.f-flags {
  font-size: 12px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 4px 9px;
  border-radius: 100px;
  justify-self: start;
}

.badge.critical { color: var(--critical); background: var(--critical-bg); border: 1px solid var(--critical-border); }
.badge.watch { color: var(--watch); background: var(--watch-bg); border: 1px solid var(--watch-border); }
.badge.ok { color: var(--ok); background: var(--ok-bg); border: 1px solid var(--ok-border); }

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 13px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 26, 0.35);
  backdrop-filter: blur(1px);
  z-index: 30;
}

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 31;
  overflow-y: auto;
  box-shadow: -24px 0 60px rgba(20,22,26,0.12);
}

.panel-inner { padding: 26px; }

.panel-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.panel-close:hover { color: var(--text); background: var(--surface-3); }

.panel-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  margin: 6px 0 2px;
  padding-right: 40px;
  color: var(--text);
}

.panel-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 18px; }

.panel-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.panel-section h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-faint);
  margin: 0 0 12px;
}

.flag-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--critical-bg);
  border: 1px solid var(--critical-border);
  color: #9A2A1F;
  margin-bottom: 6px;
}

.flag-item.all-clear {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: #036B4C;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 10px;
}

.metric-row .label { color: var(--text-dim); }
.metric-row .value { font-family: var(--font-mono); color: var(--text); }

.bar-track {
  height: 6px;
  background: var(--surface-3);
  border-radius: 100px;
  overflow: hidden;
  margin-top: 4px;
}
.bar-fill { height: 100%; border-radius: 100px; }
.bar-fill.critical { background: var(--critical); }
.bar-fill.watch { background: var(--watch); }
.bar-fill.ok { background: var(--ok); }

.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 60px;
  margin-top: 10px;
}
.spark-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.spark-bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  background: var(--accent-dim);
  min-height: 3px;
}
.spark-bar.spike { background: var(--critical); }
.spark-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-faint);
}

.outbreak-callout {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--critical-bg);
  border: 1px solid var(--critical-border);
  color: #9A2A1F;
  font-size: 12.5px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.chart-card h3 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text);
}

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

.hbar-row {
  display: grid;
  grid-template-columns: 150px 1fr 40px;
  align-items: center;
  gap: 10px;
}

.hbar-label {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hbar-track {
  height: 10px;
  background: var(--surface-3);
  border-radius: 100px;
  overflow: hidden;
}

.hbar-fill { height: 100%; border-radius: 100px; }
.hbar-fill.critical { background: var(--critical); }
.hbar-fill.watch { background: var(--watch); }
.hbar-fill.ok { background: var(--ok); }
.hbar-fill.accent { background: var(--accent); }

.hbar-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  text-align: right;
}

.trend-legend {
  display: flex;
  gap: 18px;
  margin-bottom: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.legend-item .dot { width: 8px; height: 8px; border-radius: 50%; }

.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 140px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.trend-col {
  flex: 1;
  min-width: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.trend-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 110px;
  width: 100%;
  justify-content: center;
}

.trend-bar { width: 5px; border-radius: 2px 2px 0 0; min-height: 2px; }
.trend-bar.malaria { background: var(--accent); }
.trend-bar.diarrhea { background: var(--watch); }

.trend-label {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-faint);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 26px;
}

.chart-note {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.6;
}

.ask-hero { margin: 0 0 24px; max-width: 720px; }
.ask-hero h2 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0 0 8px;
  color: var(--text);
}
.ask-hero p { color: var(--text-dim); font-size: 13.5px; margin: 0; line-height: 1.6; }

.ask-form {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  max-width: 720px;
}

.ask-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px 16px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
}
.ask-input:focus { border-color: var(--accent); }
.ask-input::placeholder { color: var(--text-faint); }

.ask-submit {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 9px;
  padding: 0 22px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.ask-submit:hover { background: var(--accent-hover); }

.ask-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  max-width: 720px;
}

.suggestion-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  padding: 7px 13px;
  border-radius: 100px;
  cursor: pointer;
  font-family: var(--font-body);
}
.suggestion-chip:hover { background: var(--surface-2); color: var(--text); }

.ask-result { min-height: 20px; max-width: 720px; }

.ask-answer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.ask-question-echo {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.ask-answer-text {
  font-size: 15px;
  color: var(--text);
  line-height: 1.6;
}

.ask-table { margin-top: 16px; overflow-x: auto; }
.ask-table table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ask-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-faint);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.ask-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}

.ask-footnote {
  margin-top: 28px;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.6;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  max-width: 720px;
}

.ask-footnote code {
  font-family: var(--font-mono);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-dim);
}

.insight-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}

.insight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--policy);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.insight-card.severity-high { border-left-color: var(--critical); }
.insight-card.severity-medium { border-left-color: var(--watch); }
.insight-card.severity-low { border-left-color: var(--ok); }

.insight-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.insight-category {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--policy);
  background: var(--policy-bg);
  border: 1px solid var(--policy-border);
  padding: 3px 9px;
  border-radius: 100px;
}

.insight-severity {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 3px 9px;
  border-radius: 100px;
}
.severity-badge-high { color: var(--critical); background: var(--critical-bg); border: 1px solid var(--critical-border); }
.severity-badge-medium { color: var(--watch); background: var(--watch-bg); border: 1px solid var(--watch-border); }
.severity-badge-low { color: var(--ok); background: var(--ok-bg); border: 1px solid var(--ok-border); }

.insight-title {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 600;
  margin: 0 0 12px;
  line-height: 1.35;
  color: var(--text);
}

.insight-block { margin-bottom: 12px; }

.insight-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.insight-text {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.55;
  margin: 0;
}

.insight-action .insight-text { color: var(--text); }

.insight-chip-list { display: flex; flex-wrap: wrap; gap: 6px; }

.insight-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px 9px;
  border-radius: 100px;
}

.insight-ministry {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.insight-ministry-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-faint);
}

.insight-ministry-name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--policy);
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .analysis-grid, .insight-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 40;
  }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .f-row { grid-template-columns: 60px 2fr 90px; }
  .f-district, .f-flags, .meter { display: none; }
  .page-content { padding: 20px 16px 60px; }
  .page-header { padding: 14px 16px; }
}
