/* Medical History - shared styles */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e2e5eb;
  --text: #1f2530;
  --text-soft: #5b6472;
  --text-faint: #8892a0;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 32, 0.04), 0 1px 8px rgba(20, 24, 32, 0.04);
  --flag-normal: #16a34a;
  --flag-high: #dc2626;
  --flag-low: #d97706;
  --flag-abnormal: #dc2626;
  --flag-na: #8892a0;
  --maxw: 1100px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- Header / nav ---------- */
header.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
header.site-header .inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.site-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  white-space: nowrap;
}
.site-title small {
  display: block;
  font-weight: 400;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 1px;
}
nav.main-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: auto;
}
nav.main-nav a {
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 7px;
}
nav.main-nav a:hover { background: var(--bg); text-decoration: none; }
nav.main-nav a.active { background: var(--accent-soft); color: var(--accent); }

main { padding: 28px 0 60px; }

h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 19px; margin: 0 0 10px; letter-spacing: -0.01em; }
h3 { font-size: 15.5px; margin: 0 0 6px; }
.page-subtitle { color: var(--text-soft); font-size: 14.5px; margin: 0 0 26px; max-width: 680px; }
.section { margin-bottom: 34px; }

/* ---------- Condition chip ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.6;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}
.condition-card {
  border-top: 4px solid var(--accent);
}
.condition-card .chip { margin-bottom: 12px; }
.condition-card p.desc { color: var(--text-soft); font-size: 13.8px; margin: 0 0 14px; }
.condition-card .status-block { font-size: 13.5px; margin-bottom: 4px; }
.condition-card .status-block dt { font-weight: 600; color: var(--text-soft); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; margin-top: 10px; }
.condition-card .status-block dd { margin: 2px 0 0; }
.condition-card .card-links { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.btn-link {
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 11px;
  color: var(--text);
  background: var(--bg);
}
.btn-link:hover { text-decoration: none; background: #eef0f4; }
.small-note { font-size: 12px; color: var(--text-faint); margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 10px; }

/* ---------- Flag pill ---------- */
.flag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; text-transform: uppercase; letter-spacing: .02em; }
.flag-normal { color: var(--flag-normal); background: #dcfce7; }
.flag-high, .flag-abnormal { color: var(--flag-high); background: #fee2e2; }
.flag-low { color: var(--flag-low); background: #fef3c7; }
.flag-na { color: var(--flag-na); background: #eef0f4; }

/* ---------- Timeline ---------- */
.timeline { position: relative; margin-left: 6px; padding-left: 26px; border-left: 2px solid var(--border); }
.timeline-item { position: relative; padding-bottom: 26px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -32px;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--dot-color, var(--accent));
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--border);
}
.timeline-date { font-size: 12px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: .03em; }
.timeline-title { font-size: 15.5px; font-weight: 700; margin: 3px 0 6px; }
.timeline-summary { font-size: 13.8px; color: var(--text-soft); }
.timeline-item .chip { margin-bottom: 6px; }
.timeline-link { font-size: 12.5px; margin-top: 8px; display: inline-block; }
details.timeline-details summary { cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 600; list-style: none; }
details.timeline-details summary::-webkit-details-marker { display: none; }
details.timeline-details[open] summary { margin-bottom: 6px; }

/* ---------- Tables ---------- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.3px; }
table.data-table th, table.data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.data-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-faint); font-weight: 700; cursor: pointer; user-select: none; white-space: nowrap; }
table.data-table th:hover { color: var(--text); }
table.data-table th .sort-arrow { font-size: 10px; opacity: .5; margin-left: 3px; }
table.data-table tbody tr:hover { background: #fafbfc; }
.table-scroll { overflow-x: auto; }

/* ---------- Chart block ---------- */
.chart-block { margin-bottom: 30px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chart-head h3 { margin: 0; }
.chart-meta { font-size: 12px; color: var(--text-faint); }
.chart-canvas-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 6px; box-shadow: var(--shadow); height: 260px; }

/* ---------- Filters (documents page) ---------- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.filter-bar input[type=search], .filter-bar select {
  font-size: 13.5px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
}
.filter-bar input[type=search] { flex: 1; min-width: 180px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: var(--surface); padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--text-soft); cursor: pointer; }
.seg button.active { background: var(--accent); color: #fff; }
.doc-group-heading { font-size: 13px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: .03em; margin: 22px 0 8px; }
.doc-group-heading:first-child { margin-top: 0; }

/* ---------- In-page tabs (condition pages) ---------- */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 30px 0 22px;
  flex-wrap: wrap;
}
.tab-btn {
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  padding: 10px 4px;
  margin-right: 22px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  position: relative;
  top: 1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel[hidden] { display: none; }

/* ---------- Condition summary block (dedicated page) ---------- */
.summary-block dt { font-weight: 600; color: var(--text-soft); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; margin-top: 16px; }
.summary-block dt:first-child { margin-top: 0; }
.summary-block dd { margin: 4px 0 0; font-size: 14px; }

/* ---------- Simple tile (landing page) ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  color: var(--text);
}
.tile:hover { text-decoration: none; box-shadow: 0 2px 4px rgba(20,24,32,.06), 0 4px 14px rgba(20,24,32,.07); transform: translateY(-1px); }
.tile { transition: box-shadow .12s ease, transform .12s ease; }
.tile .chip { margin-bottom: 10px; pointer-events: none; }
.tile .tile-status { font-size: 14px; font-weight: 600; margin: 0 0 6px; }
.tile .tile-plan { font-size: 13px; color: var(--text-soft); margin: 0; }
.tile .tile-arrow { font-size: 12.5px; color: var(--accent); font-weight: 600; margin-top: 12px; display: inline-block; }

/* ---------- Legend for all-conditions view ---------- */
.legend { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }

/* ---------- Footer ---------- */
footer.site-footer { border-top: 1px solid var(--border); padding: 22px 0 40px; color: var(--text-faint); font-size: 12px; }

/* ---------- Ambiguous / flag callouts ---------- */
.callout {
  border: 1px solid #fde68a;
  background: #fffbeb;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  color: #78350f;
}

/* ---------- Print styles ---------- */
@media print {
  header.site-header, footer.site-footer, .filter-bar, .no-print { display: none !important; }
  body { background: #fff; }
  .card, .chart-canvas-wrap { box-shadow: none; border: 1px solid #ccc; }
  main { padding: 0; }
  a[href]::after { content: ""; }
  .timeline-item::before { background: #333 !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  header.site-header .inner { gap: 10px; }
  nav.main-nav { gap: 2px; }
  nav.main-nav a { padding: 6px 8px; font-size: 12.5px; }
  h1 { font-size: 21px; }
  .card { padding: 16px; }
  .chart-canvas-wrap { height: 220px; }
}
