/* Applied Drug Safety companion tools. Colours follow the book's palette. */
:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #f2f6fb;
  --ink: #16212b;
  --ink-2: #44515d;
  --ink-3: #5f6b76;
  --line: #d4dde5;
  --navy: #1b4f72;
  --blue: #2e75b6;
  --accent-bg: #e8f1fa;
  --good: #1e7a46;
  --good-bg: #e6f4ec;
  --warn: #8a5a00;
  --warn-bg: #fdf3e0;
  --bad: #a3242c;
  --bad-bg: #fbe9ea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 33, 48, .06), 0 2px 8px rgba(16, 33, 48, .05);
  --header: #1b4f72; --th: #1b4f72;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151b; --surface: #17202a; --surface-2: #1d2833; --ink: #e6edf3; --ink-2: #b8c4cf; --ink-3: #93a1ae;
    --line: #2c3a47; --navy: #8fc1ea; --blue: #6aaee6; --accent-bg: #1b2d3f;
    --good: #6fd39a; --good-bg: #143024; --warn: #f0c066; --warn-bg: #33270f; --bad: #f2898f; --bad-bg: #3a1a1d;
    --shadow: none; --header: #12324a; --th: #12324a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151b; --surface: #17202a; --surface-2: #1d2833; --ink: #e6edf3; --ink-2: #b8c4cf; --ink-3: #93a1ae;
  --line: #2c3a47; --navy: #8fc1ea; --blue: #6aaee6; --accent-bg: #1b2d3f;
  --good: #6fd39a; --good-bg: #143024; --warn: #f0c066; --warn-bg: #33270f; --bad: #f2898f; --bad-bg: #3a1a1d;
  --shadow: none; --header: #12324a; --th: #12324a; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--blue); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, label:focus-within {
  outline: 2px solid var(--blue); outline-offset: 2px;
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 10; }

header.site {
  background: var(--header); color: #fff; padding: 14px 16px;
}
header.site .wrap { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
header.site a { color: #fff; text-decoration: none; }
header.site .brand { font-weight: 700; letter-spacing: .01em; }
header.site .brand small { display: block; font-weight: 400; opacity: .82; font-size: 13px; }
.theme-btn {
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.45); border-radius: 999px;
  padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer;
}

.wrap { max-width: 860px; margin: 0 auto; }
main { padding: 20px 16px 40px; }
h1 { font-size: 1.65rem; line-height: 1.25; margin: 6px 0 6px; color: var(--navy); }
h2 { font-size: 1.15rem; margin: 26px 0 10px; color: var(--navy); }
.lede { color: var(--ink-2); margin: 0 0 18px; }
.crumb { font-size: 14px; color: var(--ink-3); }
.crumb a { color: var(--ink-3); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin: 0 0 14px;
}
.card h3 { margin: 0 0 4px; font-size: 1rem; }
.card p { margin: 4px 0 0; }
.muted { color: var(--ink-3); font-size: 14px; }

/* tool grid on the home page */
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; padding: 0; list-style: none; }
.tools a.card { display: block; text-decoration: none; color: inherit; height: 100%; transition: border-color .15s; }
.tools a.card:hover { border-color: var(--blue); }
.tools .tag { display: inline-block; font-size: 12px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; margin-top: 8px; }

/* questions */
fieldset { border: 0; margin: 0; padding: 0; }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 10px; }
.q legend, .q .qt { font-weight: 600; padding: 0; margin-bottom: 8px; display: block; }
.q legend { float: left; width: 100%; }   /* keeps the legend inside the box instead of on its border */
.q legend + * { clear: both; }
.q .num { color: var(--blue); margin-right: 6px; }
.q .hint { font-weight: 400; color: var(--ink-3); font-size: 14px; display: block; margin-top: 2px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts.stack { flex-direction: column; }
.opt {
  display: flex; align-items: flex-start; gap: 8px; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; cursor: pointer; background: var(--surface); min-height: 44px;
}
.opts:not(.stack) .opt { align-items: center; }
.opt:hover { border-color: var(--blue); }
.opt input { margin: 3px 0 0; accent-color: var(--blue); flex: none; }
.opt .pts { margin-left: auto; padding-left: 10px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 14px; }
.opt:has(input:checked) { border-color: var(--blue); background: var(--accent-bg); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
label.field { display: block; font-weight: 600; font-size: 15px; }
label.field span.u { font-weight: 400; color: var(--ink-3); }
input[type="number"], input[type="text"], input[type="date"], select, textarea {
  width: 100%; margin-top: 4px; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-height: 44px;
}
textarea { min-height: 90px; resize: vertical; }

/* result panel */
.result {
  position: sticky; bottom: 0; z-index: 2; margin-top: 18px;
  background: var(--surface); border: 2px solid var(--blue); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: 0 -4px 16px rgba(16, 33, 48, .08);
}
.result .big { font-size: 1.5rem; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.result .cat { display: inline-block; margin-left: 8px; padding: 2px 10px; border-radius: 999px; font-weight: 600; font-size: 15px; background: var(--accent-bg); color: var(--navy); vertical-align: middle; }
.result .detail { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.result .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.status { border-radius: 8px; padding: 8px 12px; margin-top: 8px; font-size: 15px; }
.status.good { background: var(--good-bg); color: var(--good); }
.status.warn { background: var(--warn-bg); color: var(--warn); }
.status.bad { background: var(--bad-bg); color: var(--bad); }

button.btn {
  font: inherit; font-size: 15px; border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 40px;
  border: 1px solid var(--blue); background: var(--blue); color: #fff;
}
button.btn.ghost { background: transparent; color: var(--blue); }

table.ref { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
table.ref th, table.ref td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
table.ref th { background: var(--th); color: #fff; }
table.ref td.n { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-scroll { overflow-x: auto; }

.notice { border-left: 4px solid var(--blue); background: var(--surface-2); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 14px; color: var(--ink-2); margin: 16px 0; }

footer.site { border-top: 1px solid var(--line); padding: 18px 16px 28px; font-size: 13px; color: var(--ink-3); }
footer.site p { margin: 6px 0; }

@media (max-width: 560px) {
  h1 { font-size: 1.4rem; }
  .opt .pts { padding-left: 6px; }
}
@media print {
  header.site, footer.site .noprint, .noprint, .theme-btn { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .card, .q { box-shadow: none; break-inside: avoid; }
  .result { position: static; box-shadow: none; }
}
