@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --pih-red: #C8102E;
  --pih-red-dark: #9e0d24;
  --pih-red-light: #f5e6e9;
  --green: #1a7a4a;
  --green-light: #e8f5ee;
  --yellow: #d4820a;
  --yellow-light: #fef3e2;
  --blue: #1a5fa8;
  --blue-light: #e8f0fb;
  --gray-50: #f8f8f7;
  --gray-100: #f0ede9;
  --gray-200: #e2ddd7;
  --gray-300: #c8c1b8;
  --gray-400: #9e958a;
  --gray-500: #6b6259;
  --gray-600: #4a4238;
  --gray-700: #2e2822;
  --gray-800: #1a1510;
  --white: #ffffff;
  --font: 'IBM Plex Sans', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 6px;
  --radius-lg: 12px;
}

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

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-700);
  font-size: 15px;
  line-height: 1.5;
}

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

/* ── NAV ── */
.nav {
  background: var(--gray-800);
  color: var(--white);
  display: flex;
  align-items: stretch;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  background: var(--pih-red);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  min-width: 180px;
}

.nav-brand .sub {
  font-weight: 300;
  font-size: 10px;
  letter-spacing: 0.08em;
  opacity: 0.85;
  display: block;
  line-height: 1.2;
}

.demo-badge {
  background: var(--yellow);
  color: var(--white);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 4px;
}

.nav-links {
  display: flex;
  align-items: stretch;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.65);
  border-bottom: 3px solid transparent;
  transition: all 0.15s;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.nav-link .fr { font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.9); }
.nav-link .en { font-size: 10px; color: rgba(255,255,255,0.45); margin-top: 1px; }

.nav-link:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-link.active {
  border-bottom-color: var(--pih-red);
  background: rgba(200,16,46,0.12);
  color: white;
}

.nav-link.nextsteps-link {
  margin-left: auto;
  border-left: 1px solid rgba(255,255,255,0.1);
  color: var(--yellow);
}
.nav-link.nextsteps-link .fr { color: var(--yellow); }

/* ── PAGE WRAPPER ── */
.page { display: none; padding: 28px 24px; max-width: 1400px; margin: 0 auto; }
.page.active { display: block; }

/* ── CARDS ── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-400);
  margin-bottom: 12px;
}

/* ── STAT CARDS ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--gray-200);
}

.stat-card.red { border-left-color: var(--pih-red); }
.stat-card.green { border-left-color: var(--green); }
.stat-card.yellow { border-left-color: var(--yellow); }
.stat-card.blue { border-left-color: var(--blue); }

.stat-label-fr { font-size: 12px; font-weight: 600; color: var(--gray-600); }
.stat-label-en { font-size: 10px; color: var(--gray-400); margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--gray-800); line-height: 1; }
.stat-sub { font-size: 11px; color: var(--gray-400); margin-top: 4px; }

/* ── RISK BADGE ── */
.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.risk-badge.critical { background: #fde8ec; color: var(--pih-red); }
.risk-badge.high { background: #fff3e0; color: #c05c00; }
.risk-badge.moderate { background: #fff9e6; color: var(--yellow); }
.risk-badge.low { background: var(--green-light); color: var(--green); }

/* ── TABLES ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--gray-50);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-400);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.data-table tr:hover td { background: var(--gray-50); cursor: pointer; }
.data-table tr:last-child td { border-bottom: none; }

.patient-name { font-weight: 600; color: var(--gray-800); }
.patient-id { font-size: 10px; color: var(--gray-400); font-family: var(--mono); }

/* ── ALERT LOG ── */
.alert-log-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
  animation: fadeIn 0.4s ease;
}
.alert-log-entry:last-child { border-bottom: none; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.alert-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.alert-icon.urgent { background: #fde8ec; }
.alert-icon.daily { background: #e8f5ee; }
.alert-icon.weekly { background: var(--blue-light); }
.alert-icon.escalation { background: #fff3e0; }

.alert-text-fr { font-size: 13px; font-weight: 500; color: var(--gray-700); }
.alert-text-en { font-size: 11px; color: var(--gray-400); }
.alert-time { font-size: 10px; color: var(--gray-400); font-family: var(--mono); margin-top: 2px; }
.alert-channel {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.alert-channel.whatsapp { background: #e8f8ef; color: #1a7a4a; }
.alert-channel.email { background: var(--blue-light); color: var(--blue); }

/* ── PROGRESS BAR ── */
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease;
}

/* ── WEIGHT CHART ── */
.chart-container {
  position: relative;
  height: 180px;
  margin-top: 8px;
}

/* ── SECTION HEADERS ── */
.section-header {
  margin-bottom: 20px;
}
.section-title-fr {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.2;
}
.section-title-en {
  font-size: 13px;
  color: var(--gray-400);
  font-weight: 400;
  margin-top: 2px;
}
.section-desc {
  margin-top: 8px;
  font-size: 13px;
  color: var(--gray-500);
  max-width: 700px;
}

/* ── VIEW INFO BANNER ── */
.view-info {
  background: var(--blue-light);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 22px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.view-info-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.view-info-fr { font-size: 13px; font-weight: 600; color: var(--blue); }
.view-info-en { font-size: 11px; color: #3a6ea8; }

/* ── GRID LAYOUTS ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.main-side { display: grid; grid-template-columns: 1fr 360px; gap: 20px; margin-bottom: 20px; }
.main-side-wide { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }

/* ── TIME SLIDER ── */
.sim-bar {
  background: var(--gray-800);
  color: var(--white);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  position: sticky;
  bottom: 0;
  z-index: 50;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.15);
}
.sim-bar label { font-size: 11px; color: rgba(255,255,255,0.6); white-space: nowrap; }
.sim-bar input[type=range] {
  flex: 1;
  accent-color: var(--pih-red);
  max-width: 300px;
}
.sim-date {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--yellow);
  min-width: 120px;
}
.sim-btn {
  background: var(--pih-red);
  color: white;
  border: none;
  padding: 6px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.sim-btn:hover { background: var(--pih-red-dark); }

/* ── SITE HEATMAP ── */
.site-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}
.site-row:last-child { border-bottom: none; }
.site-name-fr { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.site-name-en { font-size: 10px; color: var(--gray-400); }
.site-bar-wrap { flex: 1; }
.site-count { font-size: 12px; font-weight: 700; color: var(--gray-600); min-width: 30px; text-align: right; }
.site-alerts { font-size: 10px; color: var(--pih-red); font-weight: 600; min-width: 60px; text-align: right; }

/* ── PATIENT DETAIL PANEL ── */
.patient-panel {
  background: var(--white);
  border-left: 3px solid var(--pih-red);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.patient-panel-name { font-size: 18px; font-weight: 700; color: var(--gray-800); }
.patient-panel-meta { font-size: 12px; color: var(--gray-400); font-family: var(--mono); margin-bottom: 14px; }

.visit-timeline {
  position: relative;
  padding-left: 20px;
}
.visit-timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--gray-200);
}
.visit-dot {
  position: absolute;
  left: -20px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--white);
  top: 4px;
}
.visit-item {
  position: relative;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
  font-size: 12px;
}
.visit-item.latest { background: var(--blue-light); }
.visit-date { font-weight: 600; color: var(--gray-700); font-size: 11px; font-family: var(--mono); }
.visit-metrics { display: flex; gap: 14px; margin-top: 4px; flex-wrap: wrap; }
.visit-metric { }
.visit-metric span { font-weight: 700; color: var(--gray-800); }

/* ── CHW VIEW ── */
.chw-patient-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  border-left: 5px solid var(--gray-200);
  transition: box-shadow 0.15s;
}
.chw-patient-card:hover { box-shadow: var(--shadow-lg); }
.chw-patient-card.critical { border-left-color: var(--pih-red); }
.chw-patient-card.high { border-left-color: #c05c00; }
.chw-patient-card.moderate { border-left-color: var(--yellow); }
.chw-patient-card.low { border-left-color: var(--green); }

.chw-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.chw-card-name { font-size: 15px; font-weight: 700; color: var(--gray-800); }
.chw-card-meta { font-size: 11px; color: var(--gray-400); margin-top: 2px; }
.chw-card-action {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
}
.chw-card-action.urgent { background: #fde8ec; color: var(--pih-red); }
.chw-card-action.normal { background: var(--gray-50); color: var(--gray-600); }

/* ── TAGS ── */
.tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  margin-right: 4px;
}
.tag.usn { background: #fde8ec; color: var(--pih-red); }
.tag.pta { background: var(--blue-light); color: var(--blue); }
.tag.pns { background: var(--green-light); color: var(--green); }
.tag.sam { background: #fde8ec; color: var(--pih-red); }
.tag.mam { background: var(--yellow-light); color: var(--yellow); }

/* ── OEDEMA FLAG ── */
.oedema-flag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  color: var(--pih-red);
  background: #fde8ec;
  padding: 2px 6px;
  border-radius: 3px;
}

/* ── INTRO PAGE ── */
.intro-hero {
  background: var(--gray-800);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 48px 52px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
.intro-hero::before {
  content: '';
  position: absolute;
  right: -60px;
  top: -60px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(200,16,46,0.15);
}
.intro-hero::after {
  content: '';
  position: absolute;
  right: 40px;
  bottom: -80px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(200,16,46,0.08);
}
.intro-demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--yellow);
  color: white;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 4px;
  margin-bottom: 20px;
}
.intro-tagline-fr {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}
.intro-tagline-en {
  font-size: 18px;
  font-weight: 300;
  color: rgba(255,255,255,0.55);
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}
.intro-desc {
  font-size: 15px;
  color: rgba(255,255,255,0.75);
  max-width: 600px;
  line-height: 1.6;
  position: relative;
  z-index: 1;
}

.intro-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.intro-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}
.intro-card-icon { font-size: 28px; margin-bottom: 12px; }
.intro-card-title-fr { font-size: 16px; font-weight: 700; color: var(--gray-800); }
.intro-card-title-en { font-size: 11px; color: var(--gray-400); margin-bottom: 10px; }
.intro-card p { font-size: 13px; color: var(--gray-600); line-height: 1.6; }

.vs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.vs-table th { background: var(--gray-50); padding: 10px 14px; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gray-400); border-bottom: 2px solid var(--gray-200); }
.vs-table td { padding: 10px 14px; border-bottom: 1px solid var(--gray-100); }
.vs-table tr:last-child td { border-bottom: none; }
.check { color: var(--green); font-weight: 700; }
.cross { color: var(--gray-300); }
.partial { color: var(--yellow); }

.data-assumption { padding: 8px 0; border-bottom: 1px solid var(--gray-100); font-size: 13px; color: var(--gray-600); }
.data-assumption:last-child { border-bottom: none; }
.data-assumption strong { color: var(--gray-800); }

/* ── NEXT STEPS ── */
.step-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  border-left: 4px solid var(--gray-200);
}
.step-card.priority-high { border-left-color: var(--pih-red); }
.step-card.priority-med { border-left-color: var(--yellow); }
.step-card.priority-low { border-left-color: var(--blue); }

.step-phase {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray-400);
  margin-bottom: 4px;
}
.step-title-fr { font-size: 16px; font-weight: 700; color: var(--gray-800); }
.step-title-en { font-size: 12px; color: var(--gray-400); margin-bottom: 10px; }
.step-desc { font-size: 13px; color: var(--gray-600); line-height: 1.6; }

/* ── ANALYTICS ── */
.cohort-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12px;
}
.cohort-label { width: 80px; color: var(--gray-600); font-weight: 500; text-align: right; }
.cohort-bars { flex: 1; display: flex; gap: 3px; height: 22px; border-radius: 4px; overflow: hidden; }
.cohort-segment { height: 100%; transition: width 0.6s ease; }
.cohort-segment.recovered { background: var(--green); }
.cohort-segment.defaulted { background: var(--yellow); }
.cohort-segment.transferred { background: var(--blue); }
.cohort-segment.deceased { background: var(--pih-red); }
.cohort-segment.active { background: var(--gray-300); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--gray-500); }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* ── FILTER BAR ── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-700);
  cursor: pointer;
}
.filter-bar select:focus, .filter-bar input:focus {
  outline: none;
  border-color: var(--blue);
}

/* ── SCROLLABLE CARD ── */
.scrollable { overflow-y: auto; max-height: 420px; }
.scrollable::-webkit-scrollbar { width: 4px; }
.scrollable::-webkit-scrollbar-track { background: var(--gray-100); }
.scrollable::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

/* ── MOBILE ── */
@media (max-width: 768px) {
  .page { padding: 16px 14px; }
  .two-col, .three-col, .main-side, .main-side-wide, .intro-grid { grid-template-columns: 1fr; }
  .intro-hero { padding: 28px 24px; }
  .intro-tagline-fr { font-size: 24px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-brand .sub { display: none; }
}

/* ── MINI SPARKLINE ── */
.sparkline { display: inline-flex; align-items: flex-end; gap: 2px; height: 24px; }
.spark-bar { width: 5px; border-radius: 2px 2px 0 0; background: var(--gray-300); }
.spark-bar.up { background: var(--green); }
.spark-bar.down { background: var(--pih-red); }

/* ── TOOLTIP ── */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800);
  color: white;
  font-size: 11px;
  padding: 5px 9px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
}
[data-tooltip]:hover::after { opacity: 1; }
