:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --text: #17211c;
  --muted: #5d6b63;
  --border: #dde3df;
  --accent: #0f8a6a;
  --accent-ink: #ffffff;
  --accent-soft: #dff3ec;
  --warn: #b35c00;
  --warn-soft: #fff1df;
  --danger: #b3261e;
  --danger-soft: #fde7e5;
  --chart-line: #0f8a6a;
  --chart-grid: #e6ebe8;
  --chart-baseline: #8a9a91;
  --chart-milestone: #c9a227;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #171e1b;
    --surface-2: #1f2824;
    --text: #e8eeea;
    --muted: #9aaba2;
    --border: #2a3530;
    --accent: #3cc49b;
    --accent-ink: #062117;
    --accent-soft: #173a2f;
    --warn: #f0a24a;
    --warn-soft: #3a2a14;
    --danger: #ff8a80;
    --danger-soft: #3d1c1a;
    --chart-line: #3cc49b;
    --chart-grid: #26312c;
    --chart-baseline: #6f8078;
    --chart-milestone: #e2c14f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin-top: 0.25rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 2;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); display: flex; align-items: center; gap: 0.5rem; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); display: inline-grid; place-items: center; color: var(--accent-ink); font-size: 0.9rem; }
.topbar nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.topbar form { margin: 0; }

main { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; gap: 0.4rem; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 0.5rem 0.9rem; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.05); }
.btn-link { background: none; border: none; color: var(--accent); padding: 0; font-weight: 600; cursor: pointer; font: inherit; }

.pill { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.pill-ok { background: var(--accent-soft); color: var(--accent); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.flags { list-style: none; padding: 0; margin: 0; }
.flags li { padding: 0.55rem 0.75rem; border-radius: 10px; background: var(--warn-soft); color: var(--warn); margin-bottom: 0.4rem; font-weight: 500; }
.flags li.red { background: var(--danger-soft); color: var(--danger); }

.stat { font-size: 1.6rem; font-weight: 700; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .line { fill: none; stroke: var(--chart-line); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .point { fill: var(--surface); stroke: var(--chart-line); stroke-width: 2; }
.chart .point.pb { fill: var(--chart-line); }
.chart .baseline { stroke: var(--chart-baseline); stroke-dasharray: 4 4; }
.chart .milestone { stroke: var(--chart-milestone); stroke-dasharray: 2 5; opacity: 0.7; }
.chart .milestone.reached { opacity: 1; }
.chart .milestone-label { fill: var(--chart-milestone); font-size: 10px; font-weight: 600; }

.symptom { border-left: 3px solid var(--border); padding: 0.4rem 0 0.4rem 0.8rem; margin-bottom: 0.8rem; }
.symptom.review { border-left-color: var(--warn); }
.symptom.red { border-left-color: var(--danger); }
.symptom blockquote { margin: 0.25rem 0; color: var(--muted); font-style: italic; }

form.stack label { display: block; font-weight: 600; font-size: 0.88rem; margin: 0.75rem 0 0.25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 0.55rem 0.7rem; border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit;
}
textarea { min-height: 80px; }
input.num { width: 4.5rem; padding: 0.35rem 0.4rem; }
.hint { font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.error { background: var(--danger-soft); color: var(--danger); padding: 0.6rem 0.8rem; border-radius: 10px; margin-bottom: 1rem; }
.notice { background: var(--accent-soft); color: var(--accent); padding: 0.6rem 0.8rem; border-radius: 10px; margin-bottom: 1rem; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.item-card { border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem; margin-bottom: 0.75rem; background: var(--surface); }
.item-card .fields { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 0.5rem 0; }
.item-card .fields label { font-size: 0.78rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.15rem; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.05rem; letter-spacing: 0.06em; background: var(--surface-2); padding: 0.15rem 0.5rem; border-radius: 6px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(420px, 100%); }

@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; break-inside: avoid; }
}

.symptom.clinician { border-left-color: var(--accent); }
.timeline { list-style: none; padding: 0; margin: 0.4rem 0 0; }
.timeline li { padding: 0.2rem 0; }
details summary { cursor: pointer; }

.pill-live { background: var(--danger-soft); color: var(--danger); }
.live-dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--border); margin-right: 0.3rem; vertical-align: middle; }
.live-dot.on { background: var(--danger); box-shadow: 0 0 0 0 var(--danger); animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); } 70% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); } 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); } }
.live-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; margin: 0.6rem 0; }
.convo { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; }
.bubble { padding: 0.5rem 0.7rem; border-radius: 10px; background: var(--accent-soft); }
.bubble.person { background: var(--surface-2, rgba(127,127,127,0.12)); }
.ask-lele { border: 1px solid var(--accent); }
select { padding: 0.45rem; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: inherit; width: 100%; margin: 0.3rem 0; }

/* Today from Lele: the clinician's daily list */
.brief { margin-bottom: 1rem; }
.brief-head { margin-bottom: 0.5rem; }
.brief-list { list-style: none; margin: 0; padding: 0; }
.brief-item { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.65rem 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.brief-item:first-child { border-top: none; }
.brief-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 0.45rem; background: var(--muted); }
.brief-urgent .brief-dot { background: var(--danger); }
.brief-today .brief-dot { background: var(--warn); }
.brief-urgent .brief-body > span:first-of-type { color: var(--danger); font-weight: 600; }
.brief-body { flex: 1 1 18rem; min-width: 0; }
.brief-body > * { margin-right: 0.35rem; }
.brief-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.brief-actions form { display: flex; gap: 0.4rem; margin: 0; }
.decline-form input[type="text"] { width: 12rem; max-width: 100%; padding: 0.3rem 0.5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 0.85rem; }
.btn-small { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
