/* Kahu care management — interface styles. Colors can be changed in Settings → Branding. */
:root {
  --ink: #16222E;
  --ink-2: #3F4D59;
  --muted: #6B7A86;
  --line: #D8DFE3;
  --line-2: #EBF0F2;
  --paper: #F3F6F7;
  --surface: #FFFFFF;
  --surface-2: #F8FAFA;
  --primary: #0F5E6B;
  --primary-deep: #0A3F49;
  --primary-soft: #E1EEF0;
  --accent: #C98A2B;
  --accent-soft: #FBF1DF;
  --ok: #2E7D4F; --ok-soft: #E3F3E8;
  --warn: #B9731F; --warn-soft: #FBF0DC;
  --bad: #B7362E; --bad-soft: #F9E4E2;
  --info: #2B5F8E; --info-soft: #E3ECF5;
  --radius: 6px; --radius-lg: 10px;
  --shadow: 0 1px 2px rgba(22, 34, 46, 0.08), 0 4px 16px rgba(22, 34, 46, 0.06);
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Roboto, Arial, sans-serif;
  --sidebar: 224px;
  --topbar: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 22px; letter-spacing: -0.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); }
.mono, .num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; } .mt-s { margin-top: 8px; } .mb-s { margin-bottom: 8px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flex.between { justify-content: space-between; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout ---------- */
#app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--primary-deep); color: #E8F0F1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.brand .app-name { font-size: 18px; font-weight: 700; letter-spacing: 0.01em; color: #fff; }
.brand .practice-name { font-size: 12px; color: rgba(232,240,241,0.75); margin-top: 2px; }
.nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
.nav a { color: rgba(232,240,241,0.85); padding: 9px 12px; border-radius: var(--radius); display: flex; align-items: center; gap: 10px; font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,0.14); color: #fff; font-weight: 600; }
.nav a .count { margin-left: auto; background: var(--accent); color: #1a1a1a; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.nav .sep { margin: 8px 12px 4px; font-size: 11px; letter-spacing: 0.04em; color: rgba(232,240,241,0.5); text-transform: uppercase; }
.sidebar .me { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 13px; }
.sidebar .me a { color: rgba(232,240,241,0.8); }
.sidebar .me strong { display: block; color: #fff; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar); background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 20; }
.topbar .search { flex: 0 1 360px; position: relative; }
.topbar .search input { width: 100%; padding-left: 32px; }
.topbar .search::before { content: "⌕"; position: absolute; left: 10px; top: 6px; color: var(--muted); font-size: 16px; }
.search-results { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 4px; max-height: 320px; overflow: auto; z-index: 30; }
.search-results a { display: flex; justify-content: space-between; padding: 8px 12px; color: var(--ink); border-bottom: 1px solid var(--line-2); }
.search-results a:hover, .search-results a.sel { background: var(--primary-soft); text-decoration: none; }
.content { padding: 22px 24px 60px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.menu-btn { display: none; }

/* ---------- timer bar ---------- */
.timer { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.timer .btn { padding: 6px 12px; }
.timer-live { display: flex; align-items: center; gap: 10px; background: var(--primary); color: #fff; padding: 5px 8px 5px 12px; border-radius: 20px; font-size: 13px; }
.timer-live .pulse { width: 8px; height: 8px; border-radius: 50%; background: #7CE0C3; box-shadow: 0 0 0 0 rgba(124,224,195,0.7); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(124,224,195,0.6); } 70% { box-shadow: 0 0 0 8px rgba(124,224,195,0); } 100% { box-shadow: 0 0 0 0 rgba(124,224,195,0); } }
.timer-live .clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; min-width: 52px; }
.timer-live .who { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer-live button { background: #fff; color: var(--primary-deep); border: 0; border-radius: 14px; padding: 4px 10px; font-weight: 600; cursor: pointer; font-size: 12.5px; }
.timer-live button.ghost { background: transparent; color: #fff; opacity: 0.85; }
@media (prefers-reduced-motion: reduce) { .timer-live .pulse { animation: none; } }

/* ---------- cards & tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-head h2 { font-size: 15px; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px 14px; }
.kpi .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.kpi.accent .v { color: var(--primary); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #FAFCFC; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .actions { white-space: nowrap; text-align: right; }
.tbl-wrap { overflow: auto; }
.tbl.compact td, .tbl.compact th { padding: 5px 8px; }
.tbl tr.clickable { cursor: pointer; }
.plink { font-weight: 600; color: var(--ink); }
.plink:hover { color: var(--primary); }

/* ---------- badges, meters ---------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; line-height: 18px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--line-2); color: var(--muted); }
.badge.prog { background: var(--primary-soft); color: var(--primary-deep); }
.badge.accent { background: var(--accent-soft); color: #8A5A10; }
.meter { position: relative; height: 10px; background: var(--line-2); border-radius: 5px; min-width: 120px; }
.meter .meter-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; background: var(--muted); transition: width .3s; }
.meter.ok .meter-fill { background: var(--ok); }
.meter.warn .meter-fill { background: var(--accent); }
.meter.bad .meter-fill { background: var(--bad); }
.meter .tick { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--surface); border-left: 2px solid var(--ink-2); opacity: 0.55; }
.meter .tick.hit { border-color: var(--ok); opacity: 0.9; }
.meter .tick::after { content: attr(data-t); position: absolute; top: 15px; left: -8px; font-size: 10px; color: var(--muted); }
.meter .meter-label { position: absolute; right: 0; top: -18px; font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.meter-wrap { padding: 18px 0 14px; }
.meter.lg { height: 14px; }

/* ---------- buttons, forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-deep); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.icon-btn { background: transparent; border: 0; font-size: 16px; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: var(--radius); }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px; width: 100%; }
input[type=checkbox] { width: auto; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 94, 107, 0.25); border-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .field-full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.field-check { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; padding-top: 22px; }
.field-check input { margin-top: 3px; }
.field-check small { display: block; }
.field .req { color: var(--bad); }
.form-error { color: var(--bad); background: var(--bad-soft); padding: 8px 12px; border-radius: var(--radius); font-size: 13px; }
.intro { color: var(--ink-2); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 140px; max-width: 280px; }
.flex > select, .flex > input:not([type=checkbox]) { width: auto; }
.card { overflow-x: auto; }
.tbl td.actions .icon-btn { padding: 2px 5px; }
.filters .search-box { min-width: 240px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.inline-form .field { min-width: 120px; }
.inline-form input, .inline-form select { width: auto; }

/* ---------- modal, toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 30, 36, 0.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow: auto; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 640px; box-shadow: 0 10px 40px rgba(0,0,0,0.25); }
.modal-wide { max-width: 980px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 18px; max-height: 70vh; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow); max-width: 420px; font-size: 13.5px; transition: opacity .3s, transform .3s; }
.toast-error { background: var(--bad); }
.toast-success { background: var(--ok); }
.toast.out { opacity: 0; transform: translateY(6px); }
.empty { padding: 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.loading { display: flex; gap: 6px; justify-content: center; padding: 30px; }
.loading .dot { width: 8px; height: 8px; background: var(--primary); border-radius: 50%; animation: bounce 1s infinite; }
.loading .dot:nth-child(2) { animation-delay: .15s; } .loading .dot:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-6px); opacity: 1; } }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; font-weight: 600; font-size: 13.5px; }
.tabs a:hover { text-decoration: none; color: var(--primary); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs a .count { margin-left: 6px; background: var(--line-2); border-radius: 10px; padding: 0 7px; font-size: 11px; }

/* ---------- patient header ---------- */
.patient-head { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 20px; margin-bottom: 16px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px 32px; }
.patient-head .name { font-size: 20px; font-weight: 700; }
.patient-head .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 18px; margin-top: 8px; font-size: 13px; }
.patient-head .facts span { color: var(--muted); display: block; font-size: 11.5px; }
.program-strip { display: flex; flex-direction: column; gap: 10px; }
.program-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; }
.program-row .meter-wrap { padding: 16px 0 12px; }
.program-row .st { font-size: 12px; white-space: nowrap; }
.alert-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.callout { padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); font-size: 13.5px; }
.callout.warn { background: var(--warn-soft); border-color: #EAD3AE; color: #7A4B0C; }
.callout.bad { background: var(--bad-soft); border-color: #EDC3BF; color: #7E2620; }
.callout.ok { background: var(--ok-soft); border-color: #BFE0CB; color: #1F5A38; }
.callout.info { background: var(--info-soft); border-color: #C3D4E6; color: #1F4669; }
.callout ul { margin: 6px 0 0; padding-left: 18px; }
.req-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.req-list li { padding-left: 22px; position: relative; font-size: 13px; }
.req-list li::before { content: "✓"; position: absolute; left: 2px; color: var(--ok); font-weight: 700; }
.req-list li.no::before { content: "✕"; color: var(--bad); }
.req-list li.no { color: var(--bad); }
.code-chip { display: inline-block; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; background: var(--primary-soft); color: var(--primary-deep); border-radius: 4px; padding: 1px 6px; margin-right: 4px; }

/* ---------- monthly care plan ---------- */
.plan-card { padding: 0; overflow: visible; }
.plan-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.plan-month { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-month select { width: auto; font-weight: 600; }
.plan-month .icon-btn.disabled { pointer-events: none; opacity: 0.35; }
.plan-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.status-badge { font-size: 12.5px; padding: 3px 10px; }
.plan-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 18px; padding: 12px 18px; font-size: 13px; background: var(--surface-2); border-bottom: 1px solid var(--line-2); }
.plan-meta > div > span { display: block; color: var(--muted); font-size: 11.5px; margin-bottom: 2px; }
.plan-meta select, .plan-meta input { padding: 4px 8px; font-size: 13px; width: auto; max-width: 100%; }
.plan-card > .callout { margin: 12px 18px 0; }
.plan-missing { padding: 18px; }
.plan-missing h3 { margin-bottom: 6px; }
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 6px 12px 0; overflow-x: auto; }
.subtabs a { padding: 8px 12px; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; font-weight: 600; font-size: 13px; }
.subtabs a:hover { text-decoration: none; color: var(--primary); }
.subtabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.subtabs a .count { margin-left: 6px; background: var(--line-2); border-radius: 10px; padding: 0 7px; font-size: 11px; }
#plan-sub { padding: 16px 18px 18px; }
.sub-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sub-head h3 { font-size: 15px; margin-bottom: 2px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-size: 12.5px; cursor: pointer; text-decoration: underline; }
details.dropdown { position: relative; }
details.dropdown summary { list-style: none; cursor: pointer; }
details.dropdown summary::-webkit-details-marker { display: none; }
details.dropdown .menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 240px; z-index: 40; padding: 6px; display: flex; flex-direction: column; }
details.dropdown .menu a, details.dropdown .menu button { text-align: left; background: none; border: 0; padding: 8px 10px; font: inherit; font-size: 13.5px; color: var(--ink); border-radius: 4px; cursor: pointer; text-decoration: none; }
details.dropdown .menu a:hover, details.dropdown .menu button:hover { background: var(--primary-soft); }
details.dropdown .menu button.danger { color: var(--bad); }
details.dropdown .menu button[disabled] { color: var(--muted); cursor: not-allowed; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { width: 36px; height: 20px; background: var(--line); border-radius: 10px; position: relative; transition: background .2s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { left: 18px; }
.switch em { font-style: normal; font-size: 13px; }
.cond-card { border: 1px solid var(--line); border-radius: var(--radius-lg); margin-bottom: 12px; background: var(--surface); }
.cond-card.incomplete { border-left: 3px solid var(--accent); }
.cond-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; flex-wrap: wrap; }
.cond-body { display: none; border-top: 1px solid var(--line-2); padding: 6px 14px 10px; }
.cond-card.open .cond-body { display: block; }
.cond-sec { padding: 8px 0; border-bottom: 1px dashed var(--line-2); }
.cond-sec:last-child { border-bottom: 0; }
.cond-sec .sec-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cond-sec h4 { font-size: 12.5px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.03em; }
.cond-sec .sec-text { white-space: pre-wrap; font-size: 13.5px; margin-top: 2px; }
.cond-sec textarea { display: none; margin-top: 6px; }
.cond-sec .sec-tools .btn { display: none; }
.cond-sec.editing .sec-text { display: none; }
.cond-sec.editing textarea { display: block; }
.cond-sec.editing .sec-tools .btn { display: inline-flex; }
.cond-sec.editing .sec-tools .link-btn { display: none; }
.cond-sec.blank .sec-text { color: var(--muted); }
.cond-results { display: flex; flex-direction: column; gap: 4px; max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; }
.tpl-row { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; text-align: left; background: var(--surface); border: 1px solid transparent; border-radius: var(--radius); padding: 8px 10px; font: inherit; cursor: pointer; width: 100%; }
.tpl-row:hover { background: var(--primary-soft); border-color: var(--line); }
.tpl-row[disabled] { opacity: 0.55; cursor: not-allowed; }
.chip { background: var(--primary-soft); color: var(--primary-deep); border: 0; border-radius: 12px; padding: 2px 10px; font: inherit; font-size: 12.5px; cursor: pointer; margin: 2px 4px 2px 0; }
.chip:hover { background: var(--line); }
.scr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; }
.scr-opt { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; }
.scr-opt:hover { background: var(--surface-2); }
.scr-opt.disabled { opacity: 0.55; cursor: default; }
.scr-opt input { margin-top: 3px; }
.scr-q .scr-item { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.scr-q .q { font-weight: 600; margin-bottom: 6px; }
.scr-q .q .n { color: var(--muted); font-weight: 400; margin-right: 4px; }
.scr-q .opts { display: flex; gap: 6px 16px; flex-wrap: wrap; }
.scr-q .opts label { display: inline-flex; gap: 6px; align-items: center; font-size: 13.5px; cursor: pointer; }
.scr-q .follow { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.scr-q .follow input[type=text], .scr-q .follow input:not([type]) { width: auto; flex: 1; min-width: 180px; padding: 4px 8px; }
.upload-box { border: 2px dashed var(--line); border-radius: var(--radius-lg); padding: 18px; text-align: center; margin-bottom: 14px; background: var(--surface-2); display: grid; gap: 6px; justify-items: center; }
.upload-box.over { border-color: var(--primary); background: var(--primary-soft); }
.upload-box select { width: auto; padding: 3px 8px; font-size: 12.5px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 18px; font-size: 13px; }
.facts span { color: var(--muted); display: block; font-size: 11.5px; }

/* ---------- monthly rhythm ---------- */
.rhythm { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px 14px; margin-bottom: 14px; background: var(--surface-2); }
.rhythm h4 { font-size: 13.5px; }
.rhythm .req-list { margin: 8px 0; }
.rhythm .req-list li.todo::before { content: "○"; color: var(--muted); }
.rhythm .req-list li.todo { color: var(--ink); }
.rhythm .wk { display: inline-block; min-width: 54px; font-weight: 600; color: var(--ink-2); font-size: 12px; }
select optgroup { font-weight: 600; color: var(--ink-2); }
select optgroup option { font-weight: 400; color: var(--ink); }

/* ---------- notes / timeline ---------- */
.note { border-left: 3px solid var(--primary-soft); padding: 8px 12px; margin-bottom: 10px; background: var(--surface-2); border-radius: 0 var(--radius) var(--radius) 0; }
.note.pinned { border-left-color: var(--accent); }
.note .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; justify-content: space-between; margin-bottom: 4px; }
.note .body { white-space: pre-wrap; }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--muted); }
.chart .axis { stroke: var(--line); }
.chart .grid { stroke: var(--line-2); }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2; }
.chart .line2 { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .bar { fill: var(--primary); }
.chart .bar2 { fill: var(--accent); }
.chart .band { fill: var(--ok-soft); }
.chart .pt { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.chart .pt.flag { fill: var(--bad); stroke: var(--bad); }

/* ---------- login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--primary-deep), var(--primary) 70%, #1C7C8C); padding: 20px; }
.auth-card { background: var(--surface); border-radius: var(--radius-lg); padding: 32px 30px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.auth-card h1 { font-size: 24px; margin-bottom: 2px; color: var(--primary-deep); }
.auth-card .sub { color: var(--muted); margin-bottom: 20px; }
.auth-card .form-grid { grid-template-columns: 1fr; }
.auth-card .btn-primary { width: 100%; justify-content: center; padding: 10px; margin-top: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,0.4); }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .patient-head { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  #plan-sub { padding: 12px; }
  .plan-head, .plan-meta { padding-left: 12px; padding-right: 12px; }
  .timer-live .who { max-width: 110px; }
  .topbar .search { flex: 1; }
}
@media print { .sidebar, .topbar, .btn, .tabs { display: none !important; } .content { padding: 0; } }

/* import dialogs */
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; cursor: pointer; }
label.check input { margin: 0; }
.flex.gap { gap: 8px 18px; }
ul.plain { margin: 8px 0 0; padding-left: 18px; }
ul.plain li { margin: 2px 0; }
