:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #5d6779;
  --line: #e2e5eb;
  --accent: #1f5fae;
  --accent-soft: #e6eef8;
  --danger: #b4282e;
  --danger-soft: #fbe9ea;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --surface: #1b2029; --text: #e6e9ef; --muted: #9aa3b2;
    --line: #2c3340; --accent: #6ea3e6; --accent-soft: #1d2b3e;
    --danger: #ef7a7f; --danger-soft: #3a1f22; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }

.topbar {
  display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: flex-end; justify-content: space-between;
  padding: 20px 24px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; padding-bottom: 8px; }
select, input[type=search], button {
  font: inherit; font-size: 14px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
button { background: var(--accent); color: #fff; border-color: var(--accent); cursor: pointer; font-weight: 600; }
button.ghost { background: transparent; color: var(--accent); }
button:disabled { opacity: .6; cursor: wait; }

.tabs { display: flex; gap: 4px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  background: none; border: none; border-bottom: 3px solid transparent; border-radius: 0;
  color: var(--muted); padding: 12px 14px; white-space: nowrap;
}
.tabs button[aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }

main { padding: 20px 24px; max-width: 1400px; margin: 0 auto; }
.status { margin: 16px 24px 0; padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); }
.status.error { background: var(--danger-soft); color: var(--danger); }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.toolbar label { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; }
.toolbar input[type=search] { min-width: 260px; flex: 1; max-width: 480px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .s { color: var(--muted); font-size: 12px; }

.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; min-width: 0; }
.grid .card { margin-bottom: 0; }
.card h3 { margin: 0 0 10px; font-size: 14px; }
.card h3:not(:first-child) { margin-top: 18px; }
.chart { position: relative; height: 260px; }
.chart.tall { height: 520px; }
.chart.small { height: 180px; }
.note { color: var(--muted); font-size: 13px; margin: -4px 0 12px; }

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.sig td { background: var(--danger-soft); }
.linkish { background: none; border: none; padding: 0; color: var(--accent); font-weight: 500; text-align: left; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.bar { display: inline-block; height: 8px; border-radius: 4px; background: var(--accent); opacity: .55; vertical-align: middle; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.badge.sig { background: var(--danger); color: #fff; }

.mini td { padding: 5px 4px; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
#drug-title { margin: 0 0 12px; font-size: 20px; }
footer { color: var(--muted); font-size: 12px; padding: 8px 24px 32px; max-width: 1400px; margin: 0 auto; }

@media (max-width: 640px) {
  .topbar, main { padding-left: 16px; padding-right: 16px; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .chart.tall { height: 640px; }
}
