/* Surgical Antibiotic Prophylaxis — styles */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #667281;
  --line: #e3e8ee;
  --brand: #0f6f6a;        /* teal — clinical, calm */
  --brand-dark: #0a514d;
  --accent: #1763a6;       /* blue for ASHP column accent */
  --warn: #b9521b;
  --danger: #c0392b;
  --ok: #2f8f4e;
  --pending: #9a6700;
  --radius: 12px;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
/* keep content clear of the notch / rounded corners in iOS landscape (0 elsewhere) */
.wrap { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }

/* header */
/* padding-top fills the iOS status-bar area with the header green (env inset is 0 off-iOS) */
.topbar { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; padding: max(22px, env(safe-area-inset-top)) 0 18px; }
.topbar h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.01em; }
.tagline { margin: 4px 0 0; opacity: 0.92; font-size: 0.9rem; }

/* disclaimer */
.disclaimer { background: #fff7e6; border-bottom: 1px solid #f0dca8; color: #6a4e10; font-size: 0.85rem; }
.disclaimer .wrap { padding: 10px 20px; }

/* layout */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-areas:
    "inputs result"
    "timer  principles";
  gap: 18px;
  padding-top: 22px;
  padding-bottom: 40px;
  align-items: start;
}
.inputs { grid-area: inputs; }
.result-card { grid-area: result; }
.timer-card { grid-area: timer; }
.principles-card { grid-area: principles; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "inputs" "result" "timer" "principles"; }
}

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 2px rgba(16,40,60,0.04); }
.card h2 { margin: 0 0 14px; font-size: 1.05rem; }

/* form fields */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
select, input[type="number"], input[type="time"] {
  width: 100%; padding: 9px 10px; font-size: 0.95rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
select:focus, input:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--ink); cursor: pointer; }

/* result */
.placeholder { color: var(--muted); margin: 6px 0; }
#result h2 { margin: 0 0 10px; font-size: 1.2rem; }
.diverge { background: #eef6ff; border: 1px solid #cfe3f7; color: #134e7e; padding: 8px 10px; border-radius: 8px; font-size: 0.85rem; margin: 0 0 14px; }

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .columns { grid-template-columns: 1fr; } }

.framework { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #fbfcfe; }
.framework:first-child { border-top: 3px solid var(--brand); }
.framework:last-child { border-top: 3px solid var(--accent); }
.framework-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.framework-head h3 { margin: 0; font-size: 0.95rem; }

.regimen { list-style: none; margin: 12px 0 8px; padding: 0; }
.regimen li { padding: 9px 0; border-top: 1px solid var(--line); }
.regimen li:first-child { border-top: none; }
.drug-head { display: flex; align-items: center; gap: 8px; }
.drug-name { font-weight: 700; }
.drug-dose { font-size: 1.05rem; margin-top: 2px; }
.drug-note { font-size: 0.78rem; color: var(--warn); margin-top: 4px; }

.redose { display: inline-block; font-size: 0.72rem; font-weight: 600; color: var(--brand-dark); background: #e4f1f0; padding: 1px 7px; border-radius: 20px; margin-left: 6px; vertical-align: middle; }
.redose-none { color: var(--muted); background: #eef0f3; }

.col-notes { font-size: 0.8rem; color: var(--muted); margin: 8px 0 6px; }
.source { font-size: 0.72rem; color: var(--muted); margin: 8px 0 0; font-style: italic; }

/* tags & badges */
.tag { font-size: 0.68rem; padding: 1px 6px; border-radius: 20px; font-weight: 700; }
.tag-adjunct { background: #efe9fb; color: #5b3da8; }
.badge { font-size: 0.66rem; font-weight: 700; padding: 2px 7px; border-radius: 20px; letter-spacing: 0.02em; white-space: nowrap; }
.badge-ok { background: #e3f5e9; color: var(--ok); }
.badge-pending { background: #fbeecb; color: var(--pending); }
.badge-swap { background: #fde8e6; color: var(--danger); }
.badge-mrsa { background: #e8eefc; color: #3b5bbf; }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }

/* timer */
.timer-inputs { display: grid; grid-template-columns: 1fr; gap: 12px; }
.time-row { display: flex; gap: 8px; }
.time-row input { flex: 1; }
.btn { border: 1px solid var(--brand); background: var(--brand); color: #fff; border-radius: 8px; padding: 0 14px; font-weight: 600; cursor: pointer; font-size: 0.9rem; }
.btn:hover { background: var(--brand-dark); }
.radios { display: flex; flex-direction: column; gap: 6px; }
.radio { display: flex; align-items: center; gap: 7px; font-size: 0.9rem; cursor: pointer; }
.muted { color: var(--muted); font-size: 0.85rem; }

.timer-board { margin-top: 14px; border-radius: 10px; padding: 14px; border: 1px solid var(--line); background: #fbfcfe; }
.timer-board.is-ok { border-color: #bfe3cb; background: #f1fbf4; }
.timer-board.is-soon { border-color: #f3d9a6; background: #fff7e8; }
.timer-board.is-overdue { border-color: #f0b8b1; background: #fdeceb; }
.timer-drug { font-weight: 700; font-size: 0.9rem; }
.timer-due { margin-top: 6px; font-size: 0.95rem; }
.timer-count { margin-top: 4px; font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; }
.is-overdue .timer-count { color: var(--danger); }
.is-soon .timer-count { color: var(--warn); }
.is-ok .timer-count { color: var(--ok); }
.timer-hint { margin-top: 6px; font-size: 0.76rem; color: var(--muted); }

/* principles */
.principles { margin: 0; padding-left: 18px; }
.principles li { font-size: 0.85rem; margin-bottom: 8px; color: #34414f; }

/* footer */
.foot { border-top: 1px solid var(--line); background: #fff; padding: 18px 0; margin-top: 10px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.foot p { margin: 0 0 6px; font-size: 0.78rem; color: var(--muted); }
.fineprint { font-style: italic; }

/* install banner (Add to Home Screen) */
.install-banner {
  position: fixed; left: 12px; right: 12px; z-index: 1000;
  max-width: 460px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 6px 24px rgba(16, 40, 60, 0.18);
  font-size: 0.85rem; color: var(--ink);
}
.install-banner.is-android { top: 12px; }
.install-banner.is-ios { bottom: 16px; }
.ib-logo { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 7px; background: url("/icon.svg") center/contain no-repeat; }
.ib-msg { flex: 1 1 auto; line-height: 1.35; }
.ib-share { vertical-align: -4px; color: var(--brand); }
.ib-menu { font-weight: 800; }
.ib-x { flex: 0 0 auto; border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 1rem; padding: 4px; line-height: 1; }
.ib-x:hover { color: var(--ink); }
/* iOS: little arrow under the banner pointing at the Share button in the toolbar */
.install-banner.is-ios::after {
  content: ""; position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent;
  border-top: 10px solid #fff; filter: drop-shadow(0 3px 2px rgba(16, 40, 60, 0.14));
}
