:root {
  --bg: #f1f5f9;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #e0e7ff 0%, transparent 55%),
             radial-gradient(900px 500px at -10% 10%, #ccfbf1 0%, transparent 50%);
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.12);

  --sev-contraindicated: #dc2626;
  --sev-major: #ea580c;
  --sev-moderate: #d97706;
  --sev-minor: #ca8a04;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
}

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; max-width: 1180px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center; font-size: 24px; color: #fff;
  background: linear-gradient(135deg, #4f46e5, #0d9488);
  box-shadow: 0 6px 18px rgba(79,70,229,.35);
}
.topbar h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.tagline { margin: 0; font-size: 13px; color: var(--muted); }
.disclaimer-pill {
  font-size: 12.5px; font-weight: 600; color: #92400e;
  background: #fef3c7; border: 1px solid #fde68a;
  padding: 8px 14px; border-radius: 999px;
}

/* ---- layout ---- */
.layout {
  max-width: 1180px; margin: 8px auto 40px; padding: 0 28px;
  display: grid; grid-template-columns: 380px 1fr; gap: 22px; align-items: start;
}
@media (max-width: 880px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.profile { position: sticky; top: 16px; }
@media (max-width: 880px) { .profile { position: static; } }
.panel-title { margin: 0 0 16px; font-size: 17px; font-weight: 700; }

/* ---- fields & combobox ---- */
.field { margin-bottom: 22px; }
.field > label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--muted);
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: .4px;
}
.combo { position: relative; }
.combo input {
  width: 100%; padding: 12px 14px; font-size: 14.5px; font-family: inherit;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.combo input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.combo-list {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; padding: 6px;
}
.combo-item {
  padding: 9px 12px; border-radius: 9px; cursor: pointer; font-size: 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.combo-item:hover, .combo-item.active { background: var(--accent-soft); }
.combo-item .ci-sub { font-size: 12px; color: var(--muted); }
.combo-empty { padding: 12px; color: var(--muted); font-size: 13.5px; text-align: center; }

/* ---- chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid #c7d2fe; padding: 6px 8px 6px 12px;
  border-radius: 999px; font-size: 13.5px; font-weight: 600;
  animation: pop .18s ease;
}
.chip.cond { background: #f0fdfa; color: #0d9488; border-color: #99f6e4; }
.chip button {
  border: none; background: rgba(0,0,0,.06); color: inherit; cursor: pointer;
  width: 18px; height: 18px; border-radius: 50%; font-size: 13px; line-height: 1;
  display: grid; place-items: center;
}
.chip button:hover { background: rgba(0,0,0,.14); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.btn-clear {
  width: 100%; padding: 10px; font-family: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--muted); background: #f8fafc; border: 1px solid var(--line);
  border-radius: 11px; cursor: pointer;
}
.btn-clear:hover { background: #f1f5f9; color: var(--ink); }

/* ---- results ---- */
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.results-head .panel-title { margin: 0; }
.summary { display: flex; gap: 8px; flex-wrap: wrap; }
.sum-badge {
  font-size: 12.5px; font-weight: 700; padding: 5px 11px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
}
.sum-badge .dot { width: 8px; height: 8px; border-radius: 50%; }

/* finding card */
.finding {
  position: relative; border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px 16px 22px; margin-bottom: 12px; background: #fff;
  overflow: hidden; animation: rise .22s ease;
}
.finding::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
.finding.contraindicated::before { background: var(--sev-contraindicated); }
.finding.major::before { background: var(--sev-major); }
.finding.moderate::before { background: var(--sev-moderate); }
.finding.minor::before { background: var(--sev-minor); }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.f-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sev-tag {
  font-size: 11.5px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase;
  padding: 4px 9px; border-radius: 7px; color: #fff;
}
.sev-tag.contraindicated { background: var(--sev-contraindicated); }
.sev-tag.major { background: var(--sev-major); }
.sev-tag.moderate { background: var(--sev-moderate); }
.sev-tag.minor { background: var(--sev-minor); }
.kind-tag { font-size: 11.5px; font-weight: 600; color: var(--muted); background: #f1f5f9; padding: 4px 9px; border-radius: 7px; }
.f-title { font-weight: 700; font-size: 15px; margin: 10px 0 8px; }
.f-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.mini-chip { font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.mini-chip.cond { background: #f0fdfa; color: #0d9488; }
.f-body p { margin: 6px 0; font-size: 14px; }
.f-body .lbl { font-weight: 600; color: var(--muted); margin-right: 4px; }

.sources { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.sources summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); list-style: none; }
.sources summary::-webkit-details-marker { display: none; }
.sources summary::before { content: '📎 '; }
.src { font-size: 13px; margin: 8px 0; padding-left: 4px; }
.src a { color: var(--accent); text-decoration: none; }
.src a:hover { text-decoration: underline; }
.src .ok { color: #059669; font-weight: 700; }
.src .warn { color: #b45309; font-weight: 700; }
.src .quote { display: block; color: var(--muted); font-style: italic; font-size: 12.5px; margin-top: 3px; border-left: 2px solid var(--line); padding-left: 8px; }

/* states */
.state { text-align: center; padding: 48px 20px; color: var(--muted); }
.state .ic { font-size: 44px; margin-bottom: 12px; }
.pharm { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.pharm > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); list-style: none; }
.pharm > summary::-webkit-details-marker { display: none; }
.pharm > summary::before { content: '🧪 '; }
.pharm-body { margin-top: 10px; }
.pharm-sec { margin: 10px 0; padding: 10px 12px; background: #f8fafc; border-radius: 10px; }
.pharm-sec h4 { margin: 0 0 6px; font-size: 13.5px; }
.pharm-sec p { margin: 4px 0; font-size: 13px; }
.pharm-empty { color: var(--muted); font-style: italic; }
.pharm-load { color: var(--muted); font-size: 13px; }

.pharm-profiles { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.pp-title { margin: 0 0 10px; font-size: 14px; font-weight: 700; color: var(--ink); }
.pharm-profiles > .pharm { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.pharm-profiles > .pharm > summary { color: var(--ink); font-size: 14px; }
.pharm-profiles > .pharm > summary::before { content: '💊 '; }

.state.ok { color: #059669; }
.state h3 { margin: 0 0 6px; color: var(--ink); font-size: 16px; }

.foot { max-width: 1180px; margin: 0 auto; padding: 8px 28px 40px; font-size: 12.5px; color: var(--muted); }
