/* ============================================================
   The Interaction Atlas — styles
   Brand: deep navy + clinical white + tier-graded accents
   ============================================================ */

:root {
  --c-bg: #f5f7fb;
  --c-surface: #ffffff;
  --c-surface-2: #f0f3f8;
  --c-border: #d6dbe4;
  --c-border-strong: #aab3c2;
  --c-text: #0c2540;
  --c-text-muted: #4b5567;
  --c-text-soft: #6b7280;
  --c-brand: #0c2540;
  --c-brand-2: #1f4e79;
  --c-brand-soft: #e6edf6;
  --c-link: #1f4e79;

  --c-tier-1: #2e8b57;
  --c-tier-2: #c98a00;
  --c-tier-3: #d97706;
  --c-tier-4: #c2410c;
  --c-tier-5: #991b1b;
  --c-tier-6: #581c87;

  --c-tier-1-bg: #e8f5ee;
  --c-tier-2-bg: #fef5e0;
  --c-tier-3-bg: #fef0d8;
  --c-tier-4-bg: #fde2cf;
  --c-tier-5-bg: #fbd5d5;
  --c-tier-6-bg: #ede0fa;

  --c-emergency: #b91c1c;
  --c-emergency-strong: #7f1d1d;

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  --shadow-sm: 0 1px 2px rgba(12,37,64,0.06);
  --shadow-md: 0 4px 12px rgba(12,37,64,0.08);
  --shadow-lg: 0 12px 28px rgba(12,37,64,0.14);

  --header-h: 60px;
  --nav-h: 60px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  padding-top: var(--header-h);
  padding-bottom: var(--nav-h);
  min-height: 100vh;
}

a { color: var(--c-link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ============================================================
   Header taskbar
============================================================ */
#taskbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--c-brand);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.tb-brand {
  background: transparent;
  border: 0;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: var(--r-md);
}
.tb-brand:hover { background: rgba(255,255,255,0.06); }
.tb-logo {
  font-size: 22px;
  font-weight: 700;
  background: rgba(255,255,255,0.12);
  border-radius: 50%;
  width: 34px; height: 34px;
  display: grid; place-items: center;
}
.tb-product {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}
.tb-edition {
  font-weight: 400;
  font-size: 11px;
  opacity: 0.75;
  margin-left: 4px;
}
#web-nav {
  display: none;
  margin-left: 12px;
  align-items: center;
  gap: 4px;
  flex: 1;
}
#web-nav a {
  color: rgba(255,255,255,0.84);
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
#web-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
#web-nav a.active { background: rgba(255,255,255,0.16); color: #fff; }

.tb-context { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.mode-toggle {
  display: flex;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 3px;
}
.mode-btn {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.7);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  white-space: nowrap;
}
.mode-btn[aria-selected="true"] {
  background: #fff;
  color: var(--c-brand);
}
.mode-btn:not([aria-selected="true"]):hover { color: #fff; }

.tb-context-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--r-md);
  position: relative;
}
.tb-context-btn:hover { background: rgba(255,255,255,0.16); }
.tb-context-btn .ni { font-size: 14px; }
.tb-context-count {
  background: #c98a00;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 4px;
}
.tb-context-label { display: none; }

.tb-emergency {
  background: var(--c-emergency);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255,255,255,0.2);
}
.tb-emergency:hover { background: var(--c-emergency-strong); text-decoration: none; }

/* ============================================================
   Bottom navigation (mobile)
============================================================ */
#nav-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  display: flex;
  z-index: 40;
}
.nav-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--c-text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  padding: 6px 4px;
}
.nav-btn .ni { font-size: 18px; }
.nav-btn.active { color: var(--c-brand-2); }
.nav-btn-emergency .ni { color: var(--c-emergency); }
.nav-btn-emergency.active { color: var(--c-emergency); }

/* ============================================================
   Main / app
============================================================ */
#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.screen-header {
  margin: 0 0 16px;
}
.screen-header h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.screen-header p {
  margin: 0;
  color: var(--c-text-muted);
  font-size: 14px;
}

/* ============================================================
   Cards / panels
============================================================ */
.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
}
.panel h3 {
  margin: 16px 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--c-brand);
}
.panel-body p { margin: 0 0 8px; }

/* ============================================================
   Inputs
============================================================ */
.search-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  outline: none;
}
.search-input:focus { border-color: var(--c-brand-2); box-shadow: 0 0 0 3px rgba(31,78,121,0.16); }
select, input[type="number"], input[type="text"] {
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 7px 9px;
  font-size: 14px;
  background: var(--c-surface);
  color: var(--c-text);
}

/* ============================================================
   Drug list / cards
============================================================ */
.drug-list { list-style: none; margin: 0; padding: 0; }
.drug-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.drug-row:hover { background: var(--c-surface-2); }
.drug-row .name { font-weight: 600; }
.drug-row .meta { color: var(--c-text-muted); font-size: 12px; }
.drug-row .meta > * + *::before { content: "·"; margin: 0 6px; color: var(--c-text-soft); }

.group-badge {
  display: inline-block;
  background: var(--c-brand-soft);
  color: var(--c-brand);
  border: 1px solid #cdd9ea;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chip {
  display: inline-block;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  border: 1px solid var(--c-border);
  margin: 2px 4px 2px 0;
  text-decoration: none;
}
.chip:hover { background: #e8edf3; text-decoration: none; }
.chip.chip-cyp { background: #fef9e7; border-color: #f1d97a; color: #6d5210; }
.chip.chip-transport { background: #e7f3fe; border-color: #9ec7f0; color: #0e3e6d; }
.chip.chip-risk { background: #fdecea; border-color: #f5b8b4; color: #7a1a14; }
.chip.chip-syndrome { background: #f4e7ff; border-color: #cba0f6; color: #4a1980; }

/* ============================================================
   Tier badge
============================================================ */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--r-md);
  border: 1px solid;
  white-space: nowrap;
}
.tier-1 { background: var(--c-tier-1-bg); color: var(--c-tier-1); border-color: #b6dec5; }
.tier-2 { background: var(--c-tier-2-bg); color: var(--c-tier-2); border-color: #f0d68a; }
.tier-3 { background: var(--c-tier-3-bg); color: var(--c-tier-3); border-color: #f4c389; }
.tier-4 { background: var(--c-tier-4-bg); color: var(--c-tier-4); border-color: #f3a979; }
.tier-5 { background: var(--c-tier-5-bg); color: var(--c-tier-5); border-color: #f0a39e; }
.tier-6 { background: var(--c-tier-6-bg); color: var(--c-tier-6); border-color: #c79bf2; }

/* ============================================================
   Detail screens
============================================================ */
.hero {
  background: linear-gradient(135deg, #0c2540 0%, #1f4e79 100%);
  color: #fff;
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.hero h1 { margin: 0 0 4px; font-size: 26px; font-weight: 700; }
.hero .alias { opacity: 0.78; font-size: 13px; }
.hero .meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.hero .meta-line .pill {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.22);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  row-gap: 8px;
  column-gap: 14px;
  font-size: 14px;
}
.kv dt {
  color: var(--c-text-muted);
  font-weight: 500;
}
.kv dd { margin: 0; }
.kv-subtle dt { color: var(--c-text-soft); font-weight: 400; font-size: 13px; }

.body-copy {
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.body-copy.clinician { font-size: 14px; }
.body-copy.carer { font-size: 15px; }
.body-copy.participant { font-size: 16px; line-height: 1.6; }

/* Section markers in mode-aware copy */
.body-copy strong, .body-copy h4 { color: var(--c-brand); }

/* ============================================================
   DDI screen
============================================================ */
.ddi-grid {
  display: grid;
  grid-template-columns: 1fr 60px 1fr;
  gap: 10px;
  align-items: stretch;
}
.ddi-grid .vs {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--c-text-soft);
}
.ddi-picker {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 12px;
}
.ddi-picker .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-muted);
  margin-bottom: 6px;
}
.ddi-picker .selected {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}
.ddi-picker .selected.empty { color: var(--c-text-soft); font-weight: 500; }
.ddi-picker .clear-btn {
  background: transparent;
  border: 0;
  color: var(--c-link);
  font-size: 12px;
  padding: 0;
  text-decoration: underline;
}
.pair-result { margin-top: 14px; }
.pair-tier-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.pair-headline {
  font-size: 17px;
  font-weight: 600;
  margin: 4px 0 12px;
  color: var(--c-brand);
}
.pair-action {
  background: var(--c-surface-2);
  border-left: 4px solid var(--c-brand-2);
  padding: 12px 14px;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  margin: 12px 0;
  white-space: pre-wrap;
}
.pair-action.tier-5, .pair-action.tier-6 {
  background: var(--c-tier-5-bg);
  border-left-color: var(--c-tier-5);
}
.modifier-banner {
  background: #fef5e0;
  border: 1px solid #f0d68a;
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 13px;
  color: #6d5210;
  margin: 10px 0;
}
.modifier-banner ul { margin: 6px 0 0 18px; }

/* ============================================================
   Search dropdown / results
============================================================ */
.search-wrap { position: relative; margin-bottom: 14px; }
.search-results {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  max-height: 360px;
  overflow-y: auto;
  z-index: 20;
  margin-top: 4px;
}

/* ============================================================
   Modal / sheet
============================================================ */
#modal-root.open { display: block; }
.modal-shade {
  position: fixed; inset: 0;
  background: rgba(12, 37, 64, 0.45);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border);
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-close {
  background: transparent;
  border: 0;
  font-size: 24px;
  line-height: 1;
  color: var(--c-text-muted);
  padding: 4px 8px;
}
.modal-body { padding: 16px 18px; }
.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  font-weight: 500;
  font-size: 14px;
}
.btn:hover { background: var(--c-surface-2); }
.btn-primary { background: var(--c-brand); color: #fff; border-color: var(--c-brand); }
.btn-primary:hover { background: #1a3554; }
.btn-emergency { background: var(--c-emergency); color: #fff; border-color: var(--c-emergency); }
.btn-emergency:hover { background: var(--c-emergency-strong); }

/* ============================================================
   Tabs
============================================================ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 14px;
  overflow-x: auto;
}
.tab {
  background: transparent;
  border: 0;
  padding: 10px 14px;
  color: var(--c-text-muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab[aria-selected="true"] {
  color: var(--c-brand);
  border-bottom-color: var(--c-brand);
}

/* ============================================================
   PK timeline
============================================================ */
.pk-chart {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 14px;
}
.pk-chart svg { width: 100%; height: auto; display: block; }

/* ============================================================
   Loading
============================================================ */
.loading-shade {
  position: fixed; inset: 0;
  background: rgba(245,247,251,0.92);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.loading-card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  padding: 24px 30px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-lg);
}
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-brand-2);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Toast
============================================================ */
#toast-root {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--c-text);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
}

/* ============================================================
   Emergency screen
============================================================ */
.emergency-banner {
  background: var(--c-emergency);
  color: #fff;
  padding: 16px;
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.emergency-banner .call-btn {
  background: #fff;
  color: var(--c-emergency);
  font-size: 22px;
  font-weight: 800;
  padding: 14px 22px;
  border-radius: var(--r-md);
  text-decoration: none;
  letter-spacing: 0.02em;
  border: 0;
}
.emergency-banner .desc { font-size: 14px; line-height: 1.4; }

.protocol-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-emergency);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 12px;
  cursor: pointer;
}
.protocol-card:hover { background: var(--c-surface-2); }
.protocol-card h3 { margin: 0 0 4px; font-size: 16px; }
.protocol-card .threshold { font-size: 12px; color: var(--c-text-muted); }

/* ============================================================
   Helpers
============================================================ */
.muted { color: var(--c-text-muted); }
.small { font-size: 12px; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-brand);
  margin: 16px 0 6px;
}
.divider { height: 1px; background: var(--c-border); margin: 14px 0; }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--c-text-soft);
}
.empty-state .big { font-size: 36px; margin-bottom: 8px; }

/* ============================================================
   References + DOIs
============================================================ */
.ref-list { font-family: var(--font-mono); font-size: 12px; }
.ref-list .ref { display: inline-block; margin-right: 8px; padding: 1px 6px; background: var(--c-surface-2); border-radius: var(--r-sm); }

.ref-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ref-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 13px;
}
.ref-id {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--c-brand);
  font-size: 12px;
}
.ref-link {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--c-link);
  word-break: break-all;
}
.ref-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--c-text-muted);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Severity-by-symptom table */
.severity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.severity-table th, .severity-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}
.severity-table thead th {
  background: var(--c-surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-muted);
}
.sev-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.sym-cell-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.sym-name {
  font-size: 14px;
  color: var(--c-text);
}
.sym-code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-text-soft);
  background: var(--c-surface-2);
  padding: 1px 7px;
  border-radius: var(--r-sm);
}
.sev-pill.sev-low { background: var(--c-tier-1-bg); color: var(--c-tier-1); }
.sev-pill.sev-mid { background: var(--c-tier-3-bg); color: var(--c-tier-3); }
.sev-pill.sev-high { background: var(--c-tier-5-bg); color: var(--c-tier-5); }
.sev-pill.sev-em { background: var(--c-emergency); color: #fff; }

/* ============================================================
   Patient context drawer
============================================================ */
.context-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.context-form .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.context-form label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.context-form select, .context-form input {
  width: 100%;
}

/* ============================================================
   Cohort triage
============================================================ */
.cohort-counts {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.count-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  min-width: 110px;
  flex: 1 0 110px;
}
.count-num { font-size: 28px; font-weight: 700; line-height: 1; }
.count-label { font-size: 12px; font-weight: 600; color: var(--c-text-muted); margin-top: 4px; }

.cohort-filters {
  padding: 12px 14px;
  margin-bottom: 14px;
}
.filter-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.filter-row:last-child { margin-bottom: 0; }
.filter-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-muted);
  min-width: 80px;
}

.triage-table-wrap {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: auto;
}
.triage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.triage-table th, .triage-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}
.triage-table thead th {
  background: var(--c-surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-muted);
  white-space: nowrap;
  position: sticky; top: 0;
}
.triage-table th.sortable { cursor: pointer; user-select: none; }
.triage-table th.sortable.active { color: var(--c-brand); }
.triage-table th.sortable:hover { color: var(--c-brand); }
.triage-row.band-urgent { background: linear-gradient(90deg, rgba(153,27,27,0.04), transparent 30%); }
.triage-row.band-caution { background: linear-gradient(90deg, rgba(194,65,12,0.03), transparent 30%); }
.triage-row.band-monitor { background: linear-gradient(90deg, rgba(217,119,6,0.03), transparent 30%); }
.triage-row:hover { background: var(--c-surface-2); }
.patient-link { text-decoration: none; color: inherit; display: block; }
.patient-link .name { font-weight: 600; }
.patient-link:hover .name { color: var(--c-link); }

.tier-mini, .assess-mini {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}
.tier-mini.tier-1 { background: var(--c-tier-1-bg); color: var(--c-tier-1); }
.tier-mini.tier-2 { background: var(--c-tier-2-bg); color: var(--c-tier-2); }
.tier-mini.tier-3 { background: var(--c-tier-3-bg); color: var(--c-tier-3); }
.tier-mini.tier-4 { background: var(--c-tier-4-bg); color: var(--c-tier-4); }
.tier-mini.tier-5 { background: var(--c-tier-5-bg); color: var(--c-tier-5); }
.tier-mini.tier-6 { background: var(--c-tier-6-bg); color: var(--c-tier-6); }

.assess-mini.assess-green { background: #e8f5ee; color: #2e8b57; }
.assess-mini.assess-amber { background: #fef5e0; color: #c98a00; }
.assess-mini.assess-orange { background: #fde2cf; color: #c2410c; }
.assess-mini.assess-yellow { background: #fef9e7; color: #6d5210; }
.assess-mini.assess-gray { background: var(--c-surface-2); color: var(--c-text-muted); }
.assess-mini.assess-muted { background: var(--c-surface-2); color: var(--c-text-soft); }

.assess-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.assess-pill.assess-green { background: #e8f5ee; color: #2e8b57; border: 1px solid #b6dec5; }
.assess-pill.assess-amber { background: #fef5e0; color: #c98a00; border: 1px solid #f0d68a; }
.assess-pill.assess-orange { background: #fde2cf; color: #c2410c; border: 1px solid #f3a979; }
.assess-pill.assess-yellow { background: #fef9e7; color: #6d5210; border: 1px solid #f1d97a; }
.assess-pill.assess-gray { background: var(--c-surface-2); color: var(--c-text-muted); border: 1px solid var(--c-border); }
.assess-pill.assess-muted { background: var(--c-surface-2); color: var(--c-text-soft); border: 1px solid var(--c-border); }

.band-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.band-badge.band-urgent { background: var(--c-tier-5-bg); color: var(--c-tier-5); }
.band-badge.band-caution { background: var(--c-tier-4-bg); color: var(--c-tier-4); }
.band-badge.band-monitor { background: var(--c-tier-3-bg); color: var(--c-tier-3); }
.band-badge.band-ok { background: var(--c-tier-2-bg); color: var(--c-tier-2); }
.band-badge.band-clear { background: var(--c-surface-2); color: var(--c-text-muted); }

.band-urgent-pill { background: rgba(255,255,255,0.2) !important; border-color: rgba(255,255,255,0.3) !important; }

.ctx-flags { display: flex; flex-wrap: wrap; gap: 3px; }
.ctx-flag {
  display: inline-block;
  font-size: 12px;
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  padding: 2px 8px;
  border-radius: 999px;
}

.btn-small { font-size: 12px; padding: 4px 10px; }

.matrix-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.matrix-row {
  border: 1px solid var(--c-border);
  border-left-width: 4px;
  border-radius: var(--r-md);
  padding: 10px 12px;
  background: var(--c-surface);
}
.matrix-row.tier-row-5, .matrix-row.tier-row-6 { border-left-color: var(--c-tier-5); background: rgba(153,27,27,0.02); }
.matrix-row.tier-row-4 { border-left-color: var(--c-tier-4); }
.matrix-row.tier-row-3 { border-left-color: var(--c-tier-3); }
.matrix-row.tier-row-2 { border-left-color: var(--c-tier-2); }
.matrix-row.tier-row-1 { border-left-color: var(--c-tier-1); }
.matrix-row-head { margin-bottom: 6px; flex-wrap: wrap; gap: 8px; }
.matrix-pair-name { font-weight: 600; }
.matrix-headline { font-size: 14px; color: var(--c-brand); margin-top: 4px; }
.matrix-modifier-banner {
  background: var(--c-tier-2-bg);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  font-size: 12px;
  color: var(--c-tier-2);
  margin-top: 6px;
  display: inline-block;
}

/* ============================================================
   Clinician monograph (drug detail in clinician mode)
============================================================ */
.monograph-panel { padding: 0; overflow: hidden; }
.monograph-panel > h2 { padding: 18px 22px 0; margin: 0 0 4px; font-size: 18px; }

.monograph {
  font-size: 14px;
  line-height: 1.6;
}

.monograph-glance {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: linear-gradient(135deg, #0c2540 0%, #1f4e79 100%);
  color: #fff;
  margin: 14px 0 0;
}
.glance-item {
  flex: 1 0 auto;
  min-width: 110px;
  padding: 12px 18px;
  border-right: 1px solid rgba(255,255,255,0.14);
}
.glance-item:last-child { border-right: 0; }
.glance-key {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  opacity: 0.72;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.glance-val {
  font-size: 15px;
  font-weight: 600;
}

.monograph-section {
  border-top: 1px solid var(--c-border);
  padding: 18px 22px;
}
.monograph-section:first-of-type { border-top: 0; }
.monograph-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text-muted);
}
.monograph-subtitle {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-brand);
}
.monograph-prose {
  margin: 0 0 8px;
  color: var(--c-text);
}
.monograph-prose-soft {
  font-size: 13px;
  color: var(--c-text-muted);
}
.monograph-list {
  margin: 4px 0 0;
  padding-left: 22px;
}
.monograph-list li {
  margin-bottom: 4px;
  color: var(--c-text);
}
.monograph-list-numbered { list-style: decimal; }
.monograph-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px 22px;
}
@media (min-width: 720px) {
  .monograph-grid-2 { grid-template-columns: 1fr 1fr; }
}

/* PK table inside monograph */
.pk-table-wrap { overflow-x: auto; }
.pk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.pk-table th, .pk-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
.pk-table thead th {
  background: var(--c-surface-2);
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-muted);
}

/* Enzyme / transporter grid */
.et-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 720px) {
  .et-grid { grid-template-columns: 1fr 1fr; }
}
.et-cell {
  background: var(--c-surface-2);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
.et-label {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}
.et-role {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--c-brand);
}
.et-class {
  font-size: 11px;
  color: var(--c-text-muted);
}
.et-targets {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.et-target-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
  font-size: 13px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 4px 10px;
}
.et-target-code {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--c-brand);
  white-space: nowrap;
}
.et-target-full {
  flex: 1;
  color: var(--c-text);
}
.et-target-strength {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-muted);
  background: var(--c-surface-2);
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Special populations grid */
.pops-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 720px) {
  .pops-grid { grid-template-columns: 1fr 1fr; }
}
.pops-row {
  background: var(--c-surface-2);
  border-radius: var(--r-md);
  padding: 8px 12px;
}
.pops-key {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}
.pops-key > span:first-child {
  font-weight: 600;
  font-size: 13px;
}
.pops-flag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}
.pops-flag-low { background: var(--c-tier-1-bg); color: var(--c-tier-1); }
.pops-flag-mid { background: var(--c-tier-3-bg); color: var(--c-tier-3); }
.pops-flag-high { background: var(--c-tier-5-bg); color: var(--c-tier-5); }
.pops-notes {
  color: var(--c-text-muted);
  line-height: 1.45;
}

/* Safety ceilings */
.safety-row {
  background: var(--c-surface-2);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-bottom: 8px;
}
.safety-row:last-child { margin-bottom: 0; }
.safety-route {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}
.safety-line {
  font-size: 13px;
  margin-bottom: 2px;
}
.safety-label {
  font-weight: 600;
  color: var(--c-text-muted);
  font-size: 12px;
}

/* ============================================================
   Profile-driven sections (curated class-pair content)
============================================================ */
.profile-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--c-brand-soft);
  color: var(--c-brand);
  border: 1px solid #cdd9ea;
  font-size: 12px;
  font-weight: 600;
}
.profile-mechanism {
  background: var(--c-surface-2);
  border-left: 3px solid var(--c-brand-2);
  padding: 10px 14px;
  margin-top: 8px;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--c-text);
}
.profile-list {
  margin: 4px 0 8px 0;
  padding-left: 22px;
  font-size: 14px;
  line-height: 1.55;
}
.profile-list li {
  margin-bottom: 4px;
}
.profile-thresholds li {
  font-weight: 500;
  color: var(--c-tier-5);
}

/* ============================================================
   Class-level interaction note (DDI fallback when no specific pair)
============================================================ */
.class-level-note {
  background: linear-gradient(180deg, #f4ebfc 0%, #f8f3fe 100%);
  border: 1px solid #d4b8f1;
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.class-level-headline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.class-tag {
  display: inline-block;
  background: #fff;
  border: 1px solid #c9a4f0;
  color: #4a1980;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
}
.class-vs {
  color: #4a1980;
  font-size: 18px;
  font-weight: 600;
  opacity: 0.7;
}
.class-level-subtitle {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #2a1640;
}

/* ============================================================
   Assessment-status banner (DDI screen)
============================================================ */
.assessment-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: 12px;
  border: 1px solid;
}
.assessment-banner.assess-green { background: #e8f5ee; color: #2e8b57; border-color: #b6dec5; }
.assessment-banner.assess-amber { background: #fef5e0; color: #c98a00; border-color: #f0d68a; }
.assessment-banner.assess-orange { background: #fde2cf; color: #c2410c; border-color: #f3a979; }
.assessment-banner.assess-yellow { background: #fef9e7; color: #6d5210; border-color: #f1d97a; }
.assessment-banner.assess-gray { background: var(--c-surface-2); color: var(--c-text-muted); border-color: var(--c-border); }
.assessment-banner.assess-muted { background: var(--c-surface-2); color: var(--c-text-soft); border-color: var(--c-border); }
.assessment-banner .icon { font-size: 18px; }
.assessment-banner .body { flex: 1; }
.assessment-banner strong { display: block; font-size: 13px; }
.assessment-banner .small { font-size: 11px; opacity: 0.85; }

/* ============================================================
   Responsive
============================================================ */
@media (min-width: 720px) {
  body { padding-bottom: 18px; }
  #nav-bar { display: none; }
  #web-nav { display: flex; }
  .tb-context-label { display: inline; }
  .ddi-grid { gap: 14px; }
  .context-form { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 980px) {
  #app { padding: 22px 20px 28px; }
  .context-form { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 519px) {
  .tb-product .tb-edition { display: none; }
  .mode-btn { padding: 5px 8px; }
  .tb-emergency { padding: 6px 9px; }
}

/* ============================================================
   Dashboard (Today)
============================================================ */
.dashboard-header { margin-bottom: 12px; }

.dashboard-warnings { border-left: 4px solid var(--c-tier-3); }
.dashboard-warnings h2,
.dashboard-log h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-warning-list { display: flex; flex-direction: column; gap: 8px; }
.dashboard-warning-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  text-decoration: none;
  color: inherit;
}
.dashboard-warning-row:hover {
  background: var(--c-surface-2);
  text-decoration: none;
}
.dashboard-warning-tier-3 { border-left: 4px solid var(--c-tier-3); }
.dashboard-warning-tier-4 { border-left: 4px solid var(--c-tier-4); }
.dashboard-warning-tier-5 { border-left: 4px solid var(--c-tier-5); }
.dashboard-warning-tier-6 { border-left: 4px solid var(--c-tier-6); }
.dashboard-warning-badge {
  font-size: 13px;
  padding: 4px 10px;
  flex-shrink: 0;
}
.dashboard-warning-body { flex: 1; min-width: 0; }
.dashboard-warning-pair { font-weight: 600; }
.dashboard-warning-mech {
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dashboard-warning-chev {
  color: var(--c-text-soft);
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.dashboard-log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dashboard-log-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--c-border);
}
.dashboard-log-row:last-child { border-bottom: 0; }
.dashboard-log-main { flex: 1; min-width: 0; }
.dashboard-log-name {
  font-weight: 600;
  color: var(--c-text);
}
.dashboard-log-name:hover { color: var(--c-link); text-decoration: none; }
.dashboard-log-meta { margin-top: 2px; }
.dashboard-log-time { flex-shrink: 0; }

.dashboard-empty { padding: 12px 0; }
.dashboard-empty p { margin: 0; }

.dashboard-quick-add-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 24px;
}
.dashboard-quick-add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  padding: 12px 24px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}
.dashboard-quick-add .ni { font-size: 20px; line-height: 1; }

/* Log entry modal */
.log-modal { display: flex; flex-direction: column; gap: 12px; }
.log-modal-row { display: flex; gap: 10px; flex-wrap: wrap; }
.log-modal-dose { flex: 1; min-width: 140px; }
.log-modal-route { flex: 1; min-width: 140px; }
.log-modal-error { color: var(--c-tier-5); font-size: 13px; }
