/* PharmaGuard — interface stylesheet
 *
 * Clinical-system look: navy header bar, white panels on a cool grey field,
 * clinical-blue actions. Colour is reserved for meaning (danger, caution,
 * moved, verified). Type: Public Sans for UI and quoted label text, IBM Plex
 * Mono for times, doses and numbers.
 */

:root {
  --paper: #edf1f5;
  --surface: #ffffff;
  --sunken: #f5f7fa;
  --ink: #0f1b2a;
  --ink-2: #33475b;
  --muted: #5a6b7d;
  --faint: #8e9bab;
  --line: #dce3eb;
  --line-strong: #c2ccd8;

  --accent: #0b5cad;
  --navy: #0f2a44;
  --navy-2: #173a5c;
  --accent-ink: #084887;
  --accent-weak: #e8f1fb;

  --danger: #b42318;
  --danger-weak: #fbefed;
  --danger-line: #f1c4be;
  --warn: #b54708;
  --warn-weak: #fdf4e6;
  --warn-line: #f2d3a6;
  --ok: #1f7a4d;
  --ok-weak: #ecf6f0;
  --ok-line: #b9dcc7;
  --moved: #6941c6;
  --moved-weak: #f3f0fb;
  --moved-line: #d3c7f2;
  --slate: #4b5563;
  --slate-weak: #eef1f4;

  --sans: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: var(--sans);
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --r: 4px;
  --r-lg: 6px;

  /* aliases used by older inline styles */
  --primary: var(--accent);
  --text-muted: var(--muted);
  --border-color: var(--line);
}

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

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.005em; color: var(--ink); }
button { font-family: inherit; }
a { color: var(--accent); }
mark { background: #fbe7a1; color: inherit; padding: 0 2px; border-radius: 2px; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ header */
.navbar { background: var(--navy); color: #fff; }
.nav-container {
  max-width: 1400px; margin: 0 auto; padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon {
  width: 34px; height: 34px; border-radius: var(--r); flex: 0 0 auto;
  display: grid; place-items: center; background: #2f7fd6; color: #fff;
}
.brand-icon svg { width: 20px; height: 20px; }
.brand-text { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; min-width: 0; }
.brand-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.015em; color: #fff; }
.brand-sub { color: #a8bcd1; font-size: 0.9rem; }
.nav-actions { display: flex; align-items: center; gap: 16px; }
.status-indicator {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: #a8bcd1; white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #3fd18f; }

.pipeline-strip {
  list-style: none; max-width: 1400px; margin: 0 auto; padding: 10px 28px 12px;
  border-top: 1px solid rgb(255 255 255 / 0.09);
  display: flex; flex-wrap: wrap; gap: 6px 26px; counter-reset: step;
}
.pl-step, .pl-guard { display: flex; align-items: baseline; gap: 8px; font-size: 0.84rem; color: #9fb3c8; }
.pl-step div, .pl-guard div { display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.pl-num {
  font-family: var(--mono); font-size: 0.75rem; color: #6f8aa6;
}
.pl-num::after { content: "."; }
.pl-step strong, .pl-guard strong { color: #fff; font-weight: 600; }
.pl-step span:not(.pl-num), .pl-guard span { color: #9fb3c8; }
.pl-step b { font-family: var(--mono); font-weight: 500; color: #8cc4ff; }
.pl-guard { margin-left: auto; padding-left: 12px; border-left: 2px solid #ff6b5e; }
.pl-guard strong { color: #ff9a90; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r);
  font-size: 0.88rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  border: 1px solid transparent; transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-ink); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { border-color: var(--ink-2); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 0.82rem; }
.btn-sbar { background: #fff; color: var(--navy); }
.btn-sbar:hover { background: #dbe8f6; }
.btn-scan { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-scan:hover { border-color: var(--ink-2); }
.btn-audit { width: 100%; height: 42px; background: var(--accent); color: #fff; font-size: 0.94rem; }
.btn-audit:hover { background: var(--accent-ink); }
.btn-text {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--muted); font-size: 0.84rem; font-weight: 500; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: var(--line-strong);
}
.btn-text:hover { color: var(--danger); text-decoration-color: currentColor; }

/* ------------------------------------------------------------------ layout */
.main-container { max-width: 1400px; margin: 20px auto 40px; padding: 0 28px; }
.content-grid { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 20px; align-items: start; }
.column-left { display: flex; flex-direction: column; gap: 14px; }
.column-right { min-width: 0; }

.panel, .preset-section {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px;
}
.panel-header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-title-wrap { display: flex; align-items: baseline; gap: 10px; }
.panel-title { font-size: 1rem; font-weight: 600; }
.panel-kicker { font-size: 0.8rem; color: var(--muted); }
.badge { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }

/* ------------------------------------------------------------------ patient */
.patient-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.patient-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.patient-field label { font-size: 0.78rem; font-weight: 500; color: var(--ink-2); }
.patient-field label .unit { font-family: var(--mono); font-size: 0.72rem; color: var(--faint); margin-left: 4px; }
.patient-field input {
  width: 100%; height: 36px; padding: 0 10px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface);
  font: 500 0.95rem var(--sans); color: var(--ink);
}
.patient-field input[type=number] { font-family: var(--mono); }
.patient-field input::placeholder { color: var(--faint); font-family: var(--sans); font-weight: 400; font-size: 0.85rem; }
.patient-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.patient-field.patient-kidney input:not(:placeholder-shown) { border-color: var(--moved); background: var(--moved-weak); }
.patient-hint { margin-top: 10px; font-size: 0.78rem; color: var(--muted); line-height: 1.45; }

/* ------------------------------------------------------------------ examples */
.preset-label { display: block; font-size: 0.78rem; font-weight: 500; color: var(--ink-2); margin-bottom: 8px; }
.preset-buttons { display: flex; flex-direction: column; }
.btn-preset {
  display: flex; align-items: center; width: 100%; text-align: left;
  padding: 7px 10px; margin: 0 -10px; width: calc(100% + 20px);
  background: none; border: 0; border-radius: var(--r); cursor: pointer;
  font-size: 0.88rem; color: var(--ink-2);
}
.btn-preset strong { font-weight: 500; }
.btn-preset::after { content: "→"; margin-left: auto; color: var(--faint); opacity: 0; transition: opacity 0.12s; }
.btn-preset:hover { background: var(--sunken); color: var(--ink); }
.btn-preset:hover::after { opacity: 1; }
.btn-preset.active { background: var(--accent-weak); color: var(--accent-ink); }
.btn-preset.active strong { font-weight: 600; }
.btn-preset.active::after { content: "●"; font-size: 0.6rem; opacity: 1; color: var(--accent); }

/* ------------------------------------------------------------------ medicines */
.add-med-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.input-row { display: flex; gap: 8px; }
.select-wrapper { flex: 1; min-width: 0; }
.select-input {
  width: 100%; height: 36px; padding: 0 10px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 0.9rem var(--sans);
}
.select-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.scan-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.scan-hint { font-size: 0.78rem; color: var(--muted); }
.field-hint { font-size: 0.78rem; color: var(--muted); line-height: 1.45; }

.regimen-list {
  display: flex; flex-direction: column; border-top: 1px solid var(--line);
  max-height: 460px; overflow-y: auto; margin-bottom: 14px;
}
.med-card {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.med-info { min-width: 0; }
.med-info h3 { font-size: 0.94rem; font-weight: 600; }
.med-brand { font-weight: 400; color: var(--muted); font-size: 0.84rem; }
.med-class { font-size: 0.8rem; color: var(--ink-2); }
.med-details-row { display: flex; gap: 6px; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.med-details-row > span:first-child { color: var(--ink-2); }
.med-remove-btn {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: var(--r);
  border: 0; background: none; color: var(--faint); font-size: 1.1rem; cursor: pointer;
}
.med-remove-btn:hover { background: var(--danger-weak); color: var(--danger); }
.med-card-unknown h3 { color: var(--slate); }
.unverified-pill, .dose-source {
  display: inline-block; vertical-align: 1px; margin-left: 4px; padding: 0 5px;
  border-radius: 3px; font: 600 0.66rem var(--mono); letter-spacing: 0.03em;
}
.unverified-pill { background: var(--slate-weak); color: var(--slate); border: 1px solid var(--line-strong); }
.dose-source { background: var(--ok-weak); color: var(--ok); }

.unverified-panel {
  border-left: 2px solid var(--slate); padding: 8px 12px; margin-bottom: 14px; background: var(--sunken);
}
.unverified-title { font-size: 0.86rem; margin-bottom: 2px; }
.unverified-panel p { font-size: 0.8rem; color: var(--muted); }
.unverified-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.unverified-chip {
  font-family: var(--mono); font-size: 0.78rem; padding: 1px 7px; border-radius: 3px;
  border: 1px dashed var(--slate); color: var(--slate);
}
.empty-state { padding: 18px 0; font-size: 0.86rem; color: var(--muted); }

.method-panel { background: transparent; }
.method-panel h3 { font-size: 0.86rem; margin-bottom: 6px; }
.method-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.method-list li { font-size: 0.8rem; color: var(--muted); line-height: 1.45; }
.method-list strong { color: var(--ink-2); font-weight: 600; }

/* ------------------------------------------------------------------ verdict + map */
.overview-row { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.score-card {
  --tone: var(--ok); --tone-weak: var(--ok-weak);
  display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--tone);
  border-radius: var(--r-lg); padding: 16px 18px;
}
.score-card.score-danger { --tone: var(--danger); --tone-weak: var(--danger-weak); }
.score-card.score-warning { --tone: var(--warn); --tone-weak: var(--warn-weak); }
.score-card.score-safe { --tone: var(--ok); --tone-weak: var(--ok-weak); }
.score-card.score-incomplete { --tone: var(--slate); --tone-weak: var(--slate-weak); }
.score-top { display: flex; align-items: baseline; justify-content: space-between; }
.score-label { font-size: 0.78rem; font-weight: 500; color: var(--ink-2); }
.score-circle { display: flex; align-items: baseline; gap: 2px; }
.score-num { font: 600 2.6rem/1 var(--mono); color: var(--tone); letter-spacing: -0.04em; }
.score-max { font: 400 0.95rem var(--mono); color: var(--faint); }
.score-status-badge { font-size: 1.12rem; font-weight: 600; line-height: 1.3; color: var(--tone); }
.score-metrics { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.metric-tag { font-size: 0.82rem; font-weight: 500; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.metric-tag::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--faint); }
.metric-tag.red::before { background: var(--danger); }
.metric-tag.amber::before { background: var(--warn); }
.metric-tag.green::before { background: var(--ok); }
.metric-tag.slate::before { background: var(--slate); }
.score-subtext { font-size: 0.84rem; color: var(--muted); line-height: 1.45; padding-top: 10px; border-top: 1px solid var(--line); }

.overview-row:has(> .graph-container.hidden) { grid-template-columns: 1fr; }
.overview-row:has(> .graph-container.hidden) .score-card { display: grid; grid-template-columns: 180px 1fr; align-items: start; column-gap: 24px; }
.overview-row:has(> .graph-container.hidden) .score-top { flex-direction: column; gap: 6px; }

.graph-container {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px 16px; display: flex; flex-direction: column; min-width: 0;
}
.graph-header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.graph-header h3 { font-size: 0.94rem; }
.graph-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.graph-legend .dot { display: inline-block; width: 14px; height: 2px; margin-left: 8px; }
.graph-legend .dot.red { background: var(--danger); height: 3px; }
.graph-legend .dot.amber { background: var(--warn); }
.interaction-graph { flex: 1; display: flex; align-items: center; }
.interaction-graph svg { width: 100%; height: auto; display: block; }

/* ------------------------------------------------------------------ tabs */
.tab-bar { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 0; margin-bottom: -1px;
  background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer;
  font-size: 0.92rem; font-weight: 500; color: var(--muted);
}
.tab-btn svg { opacity: 0.7; }
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }
#violations-count { font-family: var(--mono); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ------------------------------------------------------------------ problems */
.violations-container { display: flex; flex-direction: column; gap: 12px; }
.evidence-summary { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 16px; padding: 2px 0 6px; }
.es-head { display: contents; }
.es-head strong { font-size: 0.84rem; font-weight: 600; }
.es-head span { grid-column: 2; grid-row: 1; justify-self: end; font-size: 0.82rem; color: var(--muted); }
.es-bar { grid-column: 1 / -1; display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--slate-weak); }
.es-bar span { display: block; height: 100%; }
.es-legend { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.76rem; color: var(--muted); }
.es-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.es-direct { background: var(--ok); }
.es-class { background: var(--warn); }
.es-other { background: var(--faint); }

.violation-card {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--line-strong);
  border-radius: var(--r-lg); padding: 14px 18px 16px;
}
.violation-card.critical { border-left-color: var(--danger); }
.violation-card.moderate { border-left-color: var(--warn); }
.violation-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.violation-title-group { min-width: 0; }
.violation-title-group h4 { font-size: 1.02rem; font-weight: 600; line-height: 1.35; }
.violation-drugs { margin-top: 3px; font-size: 0.84rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.violation-drugs strong { font-weight: 500; color: var(--ink-2); }
.severity-pill {
  flex: 0 0 auto; padding: 2px 8px; border-radius: 3px;
  font-size: 0.76rem; font-weight: 600; letter-spacing: 0.01em;
}
.severity-pill.critical { background: var(--danger); color: #fff; }
.severity-pill.moderate { background: var(--warn-weak); color: var(--warn); border: 1px solid var(--warn-line); }
.spacing-badge, .dosing-badge {
  padding: 0 6px; border-radius: 3px; font-family: var(--mono); font-size: 0.74rem;
  background: var(--sunken); border: 1px solid var(--line); color: var(--ink-2);
}
.dosing-badge { background: var(--moved-weak); border-color: var(--moved-line); color: var(--moved); }
.violation-body { margin-top: 10px; font-size: 0.9rem; color: var(--ink-2); line-height: 1.55; }
.violation-body strong, .violation-action .action-label { font-weight: 600; color: var(--ink); }
.violation-action { margin-top: 8px; font-size: 0.9rem; line-height: 1.55; display: flex; gap: 6px; flex-wrap: wrap; }
.violation-source { margin-top: 10px; font-size: 0.78rem; color: var(--muted); }

/* FDA label evidence: a quotation, set like one */
.label-evidence { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.label-evidence summary {
  cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
}
.label-evidence summary::-webkit-details-marker { display: none; }
.label-evidence summary::before { content: "▸"; color: var(--faint); font-size: 0.75rem; transition: transform 0.12s; }
.label-evidence[open] summary::before { transform: rotate(90deg); }
.ev-badge { font-size: 0.84rem; font-weight: 600; }
.ev-meta { font-size: 0.78rem; color: var(--muted); }
.label-evidence.ev-direct .ev-badge { color: var(--ok); }
.label-evidence.ev-class .ev-badge { color: var(--warn); }
.label-evidence.ev-none { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.label-evidence.ev-none .ev-badge { color: var(--muted); font-weight: 500; }
.label-evidence blockquote {
  margin: 10px 0 8px; padding: 10px 14px; border-left: 3px solid var(--ok);
  background: var(--sunken); border-radius: 0 var(--r) var(--r) 0;
  font-size: 0.94rem; line-height: 1.6; color: var(--ink);
}
.label-evidence.ev-class blockquote { border-left-color: var(--warn); }
.label-evidence a { font-size: 0.82rem; font-weight: 500; text-underline-offset: 3px; }

.dosing-card { border-left-color: var(--moved) !important; }
.dosing-card.critical .severity-pill { background: var(--danger); }
.dosing-not-checked {
  padding: 10px 14px; border-radius: var(--r-lg); border: 1px dashed var(--moved-line);
  background: var(--moved-weak); font-size: 0.86rem; color: var(--ink-2); line-height: 1.5;
}
.dosing-not-checked strong { color: var(--moved); }
.safe-banner { padding: 14px 18px; border: 1px solid var(--ok-line); background: var(--ok-weak); border-radius: var(--r-lg); }
.safe-banner h4 { font-size: 0.96rem; color: var(--ok); }
.safe-banner p { font-size: 0.86rem; color: var(--ink-2); margin-top: 2px; }

/* ------------------------------------------------------------------ daily plan */
.timeline-intro-box { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 14px; }
.timeline-info h3 { font-size: 1rem; }
.timeline-info p { font-size: 0.86rem; color: var(--muted); max-width: 640px; margin-top: 2px; }
.timeline-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.day-ribbon:empty { display: none; }
.day-ribbon { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 14px; }
.day-ribbon svg { width: 100%; height: auto; display: block; }
.ribbon-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 0.92rem; margin-bottom: 4px; }
.ribbon-head strong { font-weight: 600; }
.ribbon-key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--muted); }
.ribbon-key i { display: inline-block; width: 12px; height: 10px; border-radius: 2px; margin-left: 8px; }
.ribbon-key i.ring { background: #fff; border: 2px solid var(--danger); }
.rule-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.rule-chips-title { font-size: 0.8rem; font-weight: 500; color: var(--ink-2); }
.rule-chip { font-size: 0.8rem; }
.rule-chip.ok { color: var(--ok); }
.rule-chip.bad { color: var(--danger); font-weight: 600; }

.timeline-container { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.timeline-slot { display: grid; grid-template-columns: 120px 1fr; border-bottom: 1px solid var(--line); }
.timeline-slot:last-child { border-bottom: 0; }
.slot-time-col { padding: 12px 16px; border-right: 1px solid var(--line); background: var(--sunken); }
.slot-time { font: 600 1.05rem var(--mono); color: var(--ink); }
.slot-label { font-size: 0.76rem; color: var(--muted); }
.slot-content-col { padding: 10px 16px; display: flex; flex-direction: column; gap: 10px; }
.dose-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.slot-med-tag { font-size: 0.92rem; }
.slot-med-tag strong { font-weight: 600; }
.slot-med-tag.rescheduled strong { color: var(--moved); }
.dose-status, .dose-critical {
  font-size: 0.72rem; font-weight: 600; padding: 0 6px; border-radius: 3px; border: 1px solid var(--line);
  color: var(--muted); background: var(--sunken);
}
.dose-status.fasting { color: #0e6b74; border-color: #b9dfe2; background: #e8f5f6; }
.dose-status.with_meal { color: var(--ok); border-color: var(--ok-line); background: var(--ok-weak); }
.dose-status.rescheduled { color: var(--moved); border-color: var(--moved-line); background: var(--moved-weak); }
.dose-critical { color: var(--danger); border-color: var(--danger-line); background: var(--danger-weak); }
.slot-instruction { font-size: 0.84rem; color: var(--muted); line-height: 1.45; margin-top: 2px; }

.weekly-prn-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 14px; }
.weekly-prn-container:empty { display: none; }
.weekly-card, .prn-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 16px; }
.weekly-card h4, .prn-card h4 { font-size: 0.9rem; margin-bottom: 6px; }
.weekly-item, .prn-item { font-size: 0.84rem; padding: 4px 0; border-top: 1px solid var(--line); }
.weekly-warning { color: var(--danger); font-weight: 600; }
.schedule-notes { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.note-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 16px; }
.note-card h4 { font-size: 0.9rem; margin-bottom: 6px; }
.note-card ul { padding-left: 18px; }
.note-card li { font-size: 0.84rem; color: var(--ink-2); margin: 2px 0; }
.note-card.unresolved { border-color: var(--warn-line); background: var(--warn-weak); }
.note-card.unresolved h4 { color: var(--warn); }
.note-card.critical-conflicts { border-color: var(--danger-line); background: var(--danger-weak); }
.note-card.critical-conflicts h4 { color: var(--danger); }
.note-card.critical-conflicts p { font-size: 0.84rem; margin-bottom: 4px; }
.solver-meta { font-family: var(--mono); font-size: 0.74rem; color: var(--faint); text-align: right; }

/* ------------------------------------------------------------------ patient tab */
.patient-advice-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; }
.advice-header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.advice-header h3 { font-size: 1.05rem; }
.reading-badge { font-size: 0.78rem; color: var(--muted); }
.advice-desc { font-size: 0.86rem; color: var(--muted); margin: 4px 0 14px; }
.patient-advice-list { display: flex; flex-direction: column; }
.advice-card { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.advice-card p { font-size: 0.98rem; line-height: 1.55; color: var(--ink); }
.advice-kind { font-size: 0.8rem; font-weight: 600; padding-top: 2px; }
.advice-danger .advice-kind { color: var(--danger); }
.advice-care .advice-kind { color: var(--warn); }
.advice-unknown .advice-kind { color: var(--slate); }
.advice-ok { grid-template-columns: 1fr; }
.patient-disclaimer, .global-disclaimer { font-size: 0.78rem; color: var(--muted); margin-top: 14px; }
.global-disclaimer { text-align: center; margin-top: 28px; }

/* ------------------------------------------------------------------ dialogs */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgb(22 24 29 / 0.5); align-items: center; justify-content: center;
  overflow-y: auto; padding: 24px 16px;
}
.modal-overlay.open { display: flex; }
.modal-card {
  width: 100%; max-width: 720px; max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.45);
}
.scan-modal-card { max-width: 640px; }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-title-group { display: flex; flex-direction: column; gap: 2px; }
.modal-title-group h3 { font-size: 1.08rem; }
.sbar-pill { font-size: 0.8rem; color: var(--muted); }
.modal-close { border: 0; background: none; font-size: 1.5rem; line-height: 1; color: var(--faint); cursor: pointer; width: 30px; height: 30px; border-radius: var(--r); }
.modal-close:hover { background: var(--sunken); color: var(--ink); }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-desc { font-size: 0.88rem; color: var(--muted); margin-bottom: 12px; line-height: 1.5; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--sunken); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.sbar-textarea {
  width: 100%; min-height: 360px; resize: vertical; padding: 14px 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--sunken);
  font: 0.8rem/1.6 var(--mono); color: var(--ink);
}
.scan-paste .sbar-textarea { min-height: 90px; font-family: var(--sans); font-size: 0.86rem; margin: 8px 0; }

.scan-dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--sunken);
  padding: 18px 18px; text-align: center; cursor: pointer; color: var(--muted);
}
.scan-dropzone:hover, .scan-dropzone.dragover { border-color: var(--accent); background: var(--accent-weak); }
.scan-dropzone strong { font-size: 0.92rem; color: var(--ink); font-weight: 600; }
.scan-dropzone span { font-size: 0.78rem; }
.scan-sample-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.scan-preview-wrap { margin-top: 12px; text-align: center; }
.scan-preview { max-width: 100%; max-height: 150px; border-radius: var(--r); border: 1px solid var(--line); }
.scan-progress { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.progress-track { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s ease; }
.scan-progress span { font-size: 0.78rem; color: var(--muted); }
.scan-results { margin-top: 14px; }
.scan-results-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 0.84rem; }
.scan-text {
  max-height: 84px; overflow: auto; padding: 8px 12px; border-radius: var(--r);
  background: var(--sunken); border: 1px solid var(--line);
  font: 0.74rem/1.5 var(--mono); color: var(--ink-2); white-space: pre-wrap;
}
.scan-detected { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.scan-detected-title { font-size: 0.82rem; font-weight: 600; color: var(--ink-2); }
.scan-result-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); cursor: pointer; }
.scan-result-item:hover { border-color: var(--line-strong); }
.scan-result-item input { accent-color: var(--accent); width: 16px; height: 16px; }
.scan-result-main { font-size: 0.9rem; font-weight: 600; }
.scan-result-brand { color: var(--muted); font-weight: 400; margin-left: 4px; }
.scan-result-dose { margin-left: auto; font-family: var(--mono); font-size: 0.82rem; color: var(--ink-2); }
.scan-empty { font-size: 0.84rem; color: var(--muted); }
.scan-empty.error { color: var(--danger); }
.scan-paste { margin-top: 14px; font-size: 0.86rem; }
.scan-paste summary { cursor: pointer; color: var(--ink-2); font-weight: 500; }

/* ------------------------------------------------------------------ toast + footer */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px);
  background: var(--ink); color: #fff; padding: 9px 14px; border-radius: var(--r);
  font-size: 0.84rem; opacity: 0; pointer-events: none; z-index: 200;
  transition: opacity 0.18s, transform 0.18s; max-width: min(520px, 90vw); text-align: center;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--accent-ink); }
.footer { border-top: 1px solid var(--line); }
.footer-container {
  max-width: 1400px; margin: 0 auto; padding: 14px 28px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 0.78rem; color: var(--muted);
}

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .overview-row { grid-template-columns: 1fr; }
  .pl-guard { margin-left: 0; }
}
@media (max-width: 1024px) {
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .nav-container, .pipeline-strip, .main-container, .footer-container { padding-left: 16px; padding-right: 16px; }
  .nav-container { flex-wrap: wrap; }
  .status-indicator { display: none; }
  .timeline-intro-box { flex-direction: column; }
  .timeline-slot { grid-template-columns: 84px 1fr; }
  .advice-card { grid-template-columns: 1fr; gap: 2px; }
  .overview-row:has(> .graph-container.hidden) .score-card { grid-template-columns: 1fr; }
}

/* Unchecked medicines: "no clashes" is not a green light. */
body:has(.score-card.score-incomplete) .safe-banner { border-color: var(--line-strong); background: var(--slate-weak); }
body:has(.score-card.score-incomplete) .safe-banner h4 { color: var(--slate); }
