/* =========================
 *   Theme variables
 *   Default: light
 * ========================= */

:root {
  /* Core colours */
  --bg: #f7f7f9;
  --text: #111;
  --muted-text: #555;

  --card-bg: #ffffff;
  --border: #e5e5e5;
  --table-header: #fafafa;

  /* Accent & emphasis */
  --accent: #6b5cff;

  /* Links */
  --link: #4a42d4;
  --link-hover: #372fb3;
  --link-visited: #5b54c9;

  /* Tooltips */
  --tooltip-bg: #111;
  --tooltip-text: #fff;

  /* Effects */
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

/* =========================
 *   System dark mode
 *   (only when no manual choice)
 * ========================= */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0f1117;
    --text: #e6e6eb;
    --muted-text: #a0a0b2;

    --card-bg: #161925;
    --border: #2a2d3a;
    --table-header: #1c2030;

    --accent: #8f85ff;

    --link: #9aa3ff;
    --link-hover: #b2b8ff;
    --link-visited: #8a90e8;

    --tooltip-bg: #e6e6eb;
    --tooltip-text: #0f1117;

    --shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  }
}

/* =========================
 *   Manual dark mode
 * ========================= */

:root[data-theme="dark"] {
  --bg: #0f1117;
  --text: #e6e6eb;
  --muted-text: #a0a0b2;

  --card-bg: #161925;
  --border: #2a2d3a;
  --table-header: #1c2030;

  --accent: #8f85ff;

  --link: #9aa3ff;
  --link-hover: #b2b8ff;
  --link-visited: #8a90e8;

  --tooltip-bg: #e6e6eb;
  --tooltip-text: #0f1117;

  --shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

/* =========================
 *   Manual light mode
 *   (explicit override)
 * ========================= */

:root[data-theme="light"] {
  /* Intentionally mirrors default
   *     for clarity and future tweaks */
}

/* =========================
 *   Theme toggle button
 * ========================= */

.theme-toggle {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;

  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.6rem;

  font-size: 1rem;
  cursor: pointer;
  color: var(--text);
}

.theme-toggle:hover {
  background: var(--card-bg);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* =========================
 *   Base layout
 *   ========================= */

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 2rem;
  background: var(--bg);
  color: var(--text);
}

header {
  margin-bottom: 2rem;
}

h1 {
  margin: 0 0 0.5rem 0;
  font-size: 2rem;
}

.subtitle {
  color: var(--muted-text);
  font-size: 1rem;
}

/* =========================
 *   Links
 *   ========================= */

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--link-hover);
}

a:visited {
  color: var(--link-visited);
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* =========================
 *   Cards & metrics
 *   ========================= */

.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.metric {
  border-left: 4px solid var(--accent);
  padding-left: 1rem;
}

.metric h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-text);
}


.metric-heading {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.metric-heading h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-text);
}

.metric > p {
  margin: 0.3rem 0 0 0;
  font-size: 1.6rem;
  font-weight: 700;
}

.clinic-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-full {
  background-color: #2ecc71; /* green */
}

.status-partial {
  background-color: #f39c12; /* orange */
}

.status-none {
  background-color: #e74c3c; /* red */
}

/* =========================
 *   Tables
 *   ========================= */

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table {
  min-width: 600px;
  border-collapse: collapse;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.95rem;
}

th,
td {
  padding: 0.6rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--table-header);
  font-weight: 600;
}

.table-scroll::after {
  display: block;
  font-size: 0.75rem;
  text-align: right;
  color: var(--muted-text);
  padding: 0.25rem 0;
}

/* =========================
 *   Notes & footer
 *   ========================= */

.note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted-text);
}

.toolnote {
  font-size: 0.9rem;
  color: var(--muted-text);
  margin-top: 1rem;
}

footer {
  margin-top: 3rem;
  font-size: 0.85rem;
  color: var(--muted-text);
}

.data-availability-legend {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}


/* =========================
 *   Tooltips
 *   ========================= */

.tooltip {
  position: relative;
  cursor: help;
  font-weight: 600;
  font-size: 0.85em;
  color: var(--accent);
}

.tooltip-content {
  all: unset;
  position: absolute;
  left: 50%;
  top: 1.6em;
  transform: translateX(-50%);
  width: 260px;

  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  padding: 0.75rem;
  border-radius: 8px;

  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.85rem;
  line-height: 1.3;

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1000;
}

.tooltip:focus .tooltip-content,
.tooltip:hover .tooltip-content {
  opacity: 1;
  pointer-events: auto;
}

/* =========================
 *   Formula display
 *   ========================= */

.formula {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.5rem 0;
}

.fraction {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.divider {
  width: 100%;
  height: 1px;
  background: currentColor;
  margin: 0.15rem 0;
}

.suffix {
  margin-left: 0.4rem;
  white-space: nowrap;
}

/* =========================
 *   Responsive tweaks
 *   ========================= */

@media (max-width: 640px) {
  .hide-mobile {
    display: none;
  }
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

