/* Andes Tracking — dashboard styles (extends styles.css) */

:root {
  --status-confirmed: #b83232;
  --status-suspected: oklch(0.58 0.15 45);
  --status-monitored: #2472a4;
  --status-recovered: #2a7a4b;

  --event-case: var(--status-confirmed);
  --event-alert: var(--status-suspected);
  --event-travel: var(--status-monitored);
  --event-response: var(--status-recovered);

  --risk-high: var(--status-confirmed);
  --risk-medium: var(--status-suspected);
  --risk-low: var(--status-monitored);

  --card-bg: var(--bg-2);
  --card-border: var(--rule);
  --tab-h: 48px;
}

/* ---------- Page hero strip ---------- */
.at-hero {
  border-bottom: 1px solid var(--rule);
  padding: clamp(32px, 5vw, 56px) 0 clamp(24px, 4vw, 40px);
}
.at-hero .wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.at-hero h1 {
  font-size: clamp(28px, 4vw, 48px);
}
.at-hero .at-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}
.at-hero .at-meta .at-status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.at-hero .at-meta .at-status-dot::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-confirmed);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---------- Tab bar ---------- */
.at-tabs {
  position: sticky;
  top: 61px; /* below nav */
  z-index: 40;
  background: color-mix(in oklch, var(--bg) 92%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.at-tabs-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.at-tabs-inner::-webkit-scrollbar { display: none; }
.at-tab-btn {
  flex-shrink: 0;
  height: var(--tab-h);
  padding: 0 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.at-tab-btn:hover { color: var(--ink-2); }
.at-tab-btn.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ---------- Content area ---------- */
.at-content {
  padding: clamp(32px, 5vw, 56px) 0 clamp(60px, 9vw, 120px);
}
.at-panel { display: none; }
.at-panel.active { display: block; }

/* ---------- Stat cards ---------- */
.at-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 40px;
}
.at-stat {
  background: var(--bg);
  padding: 24px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.at-stat .at-stat-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.at-stat .at-stat-val {
  font-family: var(--serif);
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.at-stat .at-stat-sub {
  font-size: 12px;
  color: var(--muted);
}
.at-stat.confirmed .at-stat-val { color: var(--status-confirmed); }
.at-stat.suspected .at-stat-val { color: var(--status-suspected); }
.at-stat.monitored .at-stat-val { color: var(--status-monitored); }

@media (max-width: 820px) {
  .at-stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .at-stat-grid { grid-template-columns: 1fr; }
}

/* ---------- Outbreak metadata ---------- */
.at-outbreak-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 40px;
}
.at-meta-item {
  background: var(--bg-2);
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.at-meta-item dt {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.at-meta-item dd {
  font-size: 14px;
  color: var(--ink);
  margin: 0;
}
@media (max-width: 600px) {
  .at-outbreak-meta { grid-template-columns: 1fr 1fr; }
}

/* ---------- Chart container ---------- */
.at-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 40px;
}
@media (max-width: 820px) {
  .at-charts-row { grid-template-columns: 1fr; }
}
.at-chart-wrap {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 28px;
  background: var(--bg);
  margin-bottom: 0;
}
.at-chart-wrap h3 {
  font-size: 14px;
  font-family: var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}
.at-chart-wrap--full {
  margin-bottom: 24px;
}

/* ---------- Section heading ---------- */
.at-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.at-section-head h2 {
  font-size: clamp(18px, 2vw, 22px);
}
.at-section-head .at-count {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Tables ---------- */
.at-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 6px;
}
.at-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.at-table thead {
  background: var(--bg-2);
  border-bottom: 1px solid var(--rule);
}
.at-table th {
  padding: 10px 14px;
  text-align: left;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.at-table th:hover { color: var(--ink-2); }
.at-table th.sort-asc::after { content: " ↑"; }
.at-table th.sort-desc::after { content: " ↓"; }
.at-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-2);
  vertical-align: top;
  white-space: nowrap;
}
.at-table tr:last-child td { border-bottom: none; }
.at-table tbody tr:hover td { background: var(--bg-2); }
.at-table .at-notes {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}

/* ---------- Status badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  white-space: nowrap;
}
.badge-confirmed { background: color-mix(in oklch, var(--status-confirmed) 12%, transparent); color: var(--status-confirmed); }
.badge-suspected { background: color-mix(in oklch, var(--status-suspected) 14%, transparent); color: var(--status-suspected); }
.badge-monitored { background: color-mix(in oklch, var(--status-monitored) 12%, transparent); color: var(--status-monitored); }
.badge-recovered { background: color-mix(in oklch, var(--status-recovered) 12%, transparent); color: var(--status-recovered); }
.badge-active { background: color-mix(in oklch, var(--status-monitored) 12%, transparent); color: var(--status-monitored); }
.badge-completed { background: color-mix(in oklch, var(--status-recovered) 12%, transparent); color: var(--status-recovered); }
.badge-lost { background: color-mix(in oklch, var(--status-confirmed) 12%, transparent); color: var(--status-confirmed); }
.badge-close { background: color-mix(in oklch, var(--status-confirmed) 10%, transparent); color: var(--status-confirmed); }
.badge-casual { background: color-mix(in oklch, var(--ink) 8%, transparent); color: var(--muted); }
.badge-deceased { background: color-mix(in oklch, var(--ink) 10%, transparent); color: var(--ink); }

/* ---------- Source tier badges ---------- */
.tier-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.tier-1 { background: #d4edda; color: #1a6b3a; }
.tier-2 { background: #d0e8f5; color: #1a5276; }
.tier-3 { background: #fef3cd; color: #7d5a00; }
.tier-4 { background: #fde5cc; color: #7d3800; }
.tier-5 { background: #f5d5d5; color: #7d1a1a; }

.confidence-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.confidence-pip {
  width: 32px;
  height: 3px;
  border-radius: 2px;
  background: var(--rule);
  flex-shrink: 0;
}
.confidence-pip-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--status-monitored);
}
.confidence-pip-fill.hi  { background: var(--status-recovered); }
.confidence-pip-fill.mid { background: var(--status-suspected); }
.confidence-pip-fill.lo  { background: var(--status-confirmed); }
.confidence-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

/* ---------- Tier legend ---------- */
.at-tier-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 14px 18px;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 6px;
  margin-bottom: 20px;
}
.at-tier-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-2);
}

/* ---------- Risk score bar ---------- */
.at-risk {
  display: flex;
  align-items: center;
  gap: 8px;
}
.at-risk-bar {
  flex: 1;
  height: 4px;
  background: var(--rule);
  border-radius: 2px;
  min-width: 60px;
}
.at-risk-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--status-monitored);
  transition: width .3s ease;
}
.at-risk-fill.high { background: var(--status-confirmed); }
.at-risk-fill.medium { background: var(--status-suspected); }
.at-risk-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  min-width: 24px;
  text-align: right;
}

/* ---------- Timeline ---------- */
.at-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.at-timeline-item {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.at-timeline-item:last-child { border-bottom: none; }
.at-timeline-date {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding-top: 2px;
  text-align: right;
}
.at-timeline-body {
  padding-left: 20px;
  border-left: 2px solid var(--rule);
}
.at-timeline-body.type-case { border-left-color: var(--event-case); }
.at-timeline-body.type-alert { border-left-color: var(--event-alert); }
.at-timeline-body.type-travel { border-left-color: var(--event-travel); }
.at-timeline-body.type-response { border-left-color: var(--event-response); }
.at-timeline-event {
  font-weight: 500;
  color: var(--ink);
  font-size: 14px;
  margin-bottom: 4px;
}
.at-timeline-details {
  font-size: 13px;
  color: var(--muted);
}
@media (max-width: 600px) {
  .at-timeline-item { grid-template-columns: 1fr; gap: 6px; }
  .at-timeline-date { text-align: left; }
}

/* ---------- Countries breakdown ---------- */
.at-stat-link {
  cursor: pointer;
  transition: background .15s ease;
}
.at-stat-link:hover { background: var(--bg-2); }
.at-stat-link .at-stat-sub { text-decoration: underline; text-underline-offset: 3px; color: var(--muted); }

.at-countries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
}
.at-country-card {
  background: var(--bg);
  padding: 20px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-left: 3px solid transparent;
  transition: background .15s ease;
}
.at-country-card:hover { background: var(--bg-2); }
.at-country-risk-high   { border-left-color: var(--status-confirmed); }
.at-country-risk-medium { border-left-color: var(--status-suspected); }
.at-country-risk-low    { border-left-color: var(--status-monitored); }
.at-country-name {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.at-country-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.at-country-contacts {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.at-country-risk-bar { margin-top: 2px; }
.at-country-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.at-country-link {
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px 11px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s ease;
}
.at-country-link:hover {
  border-color: var(--ink-2);
  color: var(--ink);
  background: var(--bg-2);
}

/* ---------- Active country filter chip ---------- */
#cases-country-chip,
#contacts-country-chip { margin-bottom: 12px; }
.at-active-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--ink) 8%, transparent);
  border: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-2);
}
.at-active-filter strong { color: var(--ink); }
.at-filter-clear {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
  padding: 0 2px;
  transition: color .15s ease;
}
.at-filter-clear:hover { color: var(--status-confirmed); }

/* ---------- Export ---------- */
.at-export-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  max-width: 640px;
}
.at-export-card {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 24px 28px;
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.at-export-card h3 {
  font-size: 16px;
}
.at-export-card p {
  font-size: 13px;
  color: var(--muted);
}
@media (max-width: 520px) {
  .at-export-grid { grid-template-columns: 1fr; }
}

/* ---------- Empty state ---------- */
.at-empty {
  padding: 48px 0;
  text-align: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ---------- Modal ---------- */
body.modal-open { overflow: hidden; }

@keyframes at-modal-in {
  from { opacity: 0; transform: scale(0.97) translateY(6px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);   }
}

.at-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(26, 22, 19, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.at-modal-backdrop[hidden] { display: none; }

.at-modal-panel {
  background: var(--bg);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.06),
    0 24px 64px -16px rgba(26, 22, 19, 0.4);
  animation: at-modal-in .18s ease;
}

.at-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.at-modal-title {
  font-size: clamp(18px, 2vw, 22px);
  margin-top: 6px;
}
.at-modal-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: none;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s ease;
  margin-top: 2px;
}
.at-modal-close:hover { background: var(--bg-2); color: var(--ink); border-color: var(--ink-2); }

.at-modal-body {
  overflow-y: auto;
  padding: 24px 28px 32px;
  flex: 1;
}

/* Detail field grid */
.at-detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0;
}
.at-detail-grid dt {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
}
.at-detail-grid dd {
  padding: 10px 0 10px 16px;
  border-bottom: 1px solid var(--rule);
  margin: 0;
  font-size: 14px;
  color: var(--ink);
  word-break: break-word;
}
.at-detail-grid dt:last-of-type,
.at-detail-grid dd:last-of-type { border-bottom: none; }

/* Notes field — full text, pre-wrap */
.at-detail-notes {
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
}

/* Cross-link pills inside modal */
.at-modal-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  cursor: pointer;
  background: none;
  transition: all .15s ease;
  margin: 2px 4px 2px 0;
}
.at-modal-link:hover { border-color: var(--ink); color: var(--ink); background: var(--bg-2); }

/* Clickable table rows */
.at-table tbody tr { cursor: pointer; }

/* ---------- Filter bar ---------- */
.at-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.at-filter-btn {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s ease;
}
.at-filter-btn:hover { color: var(--ink-2); border-color: var(--ink-2); }
.at-filter-btn.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
