/* 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; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0 12px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line, #ddd); }
.auth-card .btn-ms { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 10px; border: 1px solid var(--line, #ccc); background: #fff; color: #222; font-weight: 600; text-decoration: none; border-radius: var(--radius, 8px); }
.auth-card .btn-ms:hover { background: #f5f7f6; }
.auth-hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; text-align: center; }

/* ---------- 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; }

/* ---------- Patient CRM (1.7) ---------- */
.crm-tiles .crm-tile { text-decoration: none; color: inherit; display: block; }
.crm-tiles .crm-tile.active { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.crm-tiles .crm-tile.warn .v { color: var(--bad); }
.crm-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px 16px; margin-bottom: 16px; font-size: 13.5px; }
.crm-strip > div > span { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 2px; }
.card.tint { background: var(--primary-soft); border-color: transparent; }
.card.tint h3 { margin: 0 0 8px; font-size: 14px; }
.fu-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid rgba(0,0,0,.06); }
.fu-row:first-of-type { border-top: 0; }
.ixn { padding: 12px 4px; border-bottom: 1px solid var(--line-2); position: relative; }
.ixn:last-child { border-bottom: 0; }
.ixn.highlight { background: var(--accent-soft); border-radius: var(--radius); padding: 12px; }
.ixn-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-right: 90px; }
.ixn-body { margin: 6px 0; white-space: pre-wrap; }
.ixn-fu { font-size: 13px; margin-top: 4px; }
.ixn-fu.open { color: var(--ink); } .ixn-fu.done { color: var(--muted); }
.ixn-ccm { font-size: 13px; margin-top: 6px; padding: 8px 10px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.ixn-actions { position: absolute; top: 10px; right: 4px; display: flex; gap: 2px; }
.search-group { padding: 6px 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line-2); }
.search-results a.from-tebra { background: #fffdf7; }
.mb { margin-bottom: 12px; } .mt { margin-top: 10px; }

/* phone polish (CRM) */
@media (max-width: 720px) {
  .patient-head .facts { grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .crm-strip { grid-template-columns: 1fr 1fr; padding: 10px 12px; }
  .kpis.crm-tiles { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpis.crm-tiles .kpi { padding: 10px 12px; } .kpis.crm-tiles .kpi .v { font-size: 20px; }
  .tabs { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .card { overflow-x: auto; }
  table.tbl { min-width: 560px; }
  .ixn-head { flex-direction: column; padding-right: 0; }
  .ixn-actions { position: static; justify-content: flex-end; margin-top: 4px; }
  .search-results a { flex-direction: column; gap: 2px; }
  input, select, textarea { font-size: 16px; }
}

/* ---------- Fax (1.8): inbox + fill-and-sign editor ---------- */
.tbl.kv th { text-align: left; width: 220px; color: var(--muted); font-weight: 600; vertical-align: top; }
.fax-list { display: flex; flex-direction: column; gap: 8px; }
.fax-row { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px 16px; color: inherit; }
.fax-row:hover { text-decoration: none; border-color: var(--primary); box-shadow: var(--shadow); }
.fax-row .fax-subject { font-weight: 600; font-size: 14.5px; }
.fax-row .fax-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fax-row .fax-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.fax-pick { max-height: 320px; overflow: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius); }
.fax-pick-row { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line-2); background: var(--surface); font: inherit; cursor: pointer; }
.fax-pick-row:hover { background: var(--primary-soft); }
.fax-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.fax-head h1 { font-size: 19px; margin: 2px 0; cursor: text; }
.fax-head h1[title=""] { cursor: default; }
.fax-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fax-meta select.btn-sm { padding: 5px 8px; font-size: 12.5px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.fax-done { margin-bottom: 10px; }
.fax-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.fax-toolbar { position: sticky; top: var(--topbar); z-index: 15; display: flex; justify-content: space-between; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 6px 8px; margin-bottom: 8px; box-shadow: var(--shadow); }
.fax-tools, .fax-tool-right { display: flex; gap: 4px; align-items: center; }
.fax-toolbar .tool { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; min-width: 52px; padding: 5px 8px; border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--ink-2); font: inherit; font-size: 11px; cursor: pointer; }
.fax-toolbar .tool .ti { font-size: 17px; line-height: 1; }
.fax-toolbar .tool:hover { background: var(--surface-2); border-color: var(--line); }
.fax-toolbar .tool.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-deep); font-weight: 600; }
.fax-toolbar .fax-tool-right .tool { min-width: 36px; font-size: 14px; font-weight: 600; }
.fax-selinfo { font-size: 12px; color: var(--muted); margin-right: 4px; }
.fax-savestate { margin-left: 6px; min-width: 90px; text-align: right; }
.fax-zoom { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.fax-pages { display: flex; flex-direction: column; gap: 14px; align-items: center; overflow: auto; padding-bottom: 40px; }
.fax-page { position: relative; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18), 0 8px 24px rgba(22,34,46,.12); border-radius: 2px; flex: none; }
.fax-page canvas { display: block; }
.fax-overlay { position: absolute; inset: 0; cursor: default; }
.fax-pages[data-tool="text"] .fax-overlay, .fax-pages[data-tool="date"] .fax-overlay, .fax-pages[data-tool="stamp"] .fax-overlay { cursor: text; }
.fax-pages[data-tool="check"] .fax-overlay, .fax-pages[data-tool="cross"] .fax-overlay, .fax-pages[data-tool="signature"] .fax-overlay { cursor: copy; }
.fax-pages[data-tool="ink"] .fax-overlay { cursor: crosshair; touch-action: none; }
.fax-pages.ro .fax-overlay { pointer-events: none; }
.fax-pageno { position: absolute; right: 6px; bottom: 4px; font-size: 10px; color: rgba(0,0,0,.35); pointer-events: none; }
.ink-preview { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ann { position: absolute; box-sizing: border-box; color: #101a3a; touch-action: none; user-select: none; -webkit-user-select: none; }
.ann:not(.sel):hover { outline: 1px dashed rgba(15,94,107,.55); }
.ann.sel { outline: 1.5px solid var(--primary); outline-offset: 1px; z-index: 2; }
.fax-pages.ro .ann { outline: none !important; }
.ann-text, .ann-date, .ann-stamp { font-family: Helvetica, Arial, sans-serif; }
.ann .ann-text { white-space: pre-wrap; word-break: break-word; padding: 1px 0 0 1px; min-height: 1.2em; outline: none; user-select: text; -webkit-user-select: text; cursor: text; }
.ann.empty .ann-text { background: rgba(201,138,43,.18); min-width: 40px; }
.ann-stamp .ann-text { font-weight: 600; }
.ann-check svg, .ann-cross svg { width: 100%; height: 100%; display: block; }
.ann-signature img { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; position: absolute; left: 0; bottom: 0; }
.ann-signature { overflow: visible; }
.ann-signature .ann-cap { position: absolute; left: 0; top: 100%; white-space: nowrap; font-style: italic; color: #1b2a4a; line-height: 1.2; }
.ann-ink svg { width: 100%; height: 100%; display: block; overflow: visible; }
.ann-box { border: 1px solid #101a3a; }
.ann-x { position: absolute; right: -11px; top: -11px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--bad); font: 700 11px/1 var(--font); cursor: pointer; display: none; align-items: center; justify-content: center; padding: 0; box-shadow: var(--shadow); }
.ann-h { position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px; border-radius: 3px; background: var(--primary); border: 2px solid #fff; cursor: nwse-resize; display: none; box-shadow: 0 0 0 1px var(--primary); }
.ann.sel .ann-x, .ann.sel .ann-h { display: flex; }
.sig-pad { position: relative; border: 1px dashed var(--line); border-radius: var(--radius-lg); background: #fff; }
.sig-pad canvas { display: block; width: 100%; height: auto; touch-action: none; border-radius: var(--radius-lg); }
.sig-pad .sig-line { position: absolute; left: 6%; right: 6%; bottom: 26%; border-top: 1px solid var(--line); pointer-events: none; }
@media (max-width: 720px) {
  .fax-row { padding: 10px 12px; }
  .fax-head h1 { font-size: 17px; }
  .fax-actions .btn { padding: 6px 10px; font-size: 12.5px; }
  .fax-toolbar { position: fixed; left: 8px; right: 8px; bottom: 8px; top: auto; z-index: 40; border-radius: 14px; padding: 4px 6px; overflow-x: auto; justify-content: flex-start; }
  .fax-toolbar .tool { min-width: 46px; padding: 4px 6px; font-size: 10px; }
  .fax-toolbar .tool .tl { display: none; }
  .fax-toolbar .tool .ti { font-size: 19px; }
  .fax-tool-right { margin-left: auto; }
  .fax-selinfo, .fax-savestate { display: none; }
  .fax-hint { display: none; }
  .fax-pages { padding-bottom: 90px; }
  .ann-x { width: 24px; height: 24px; right: -16px; top: -16px; font-size: 12px; }
  .ann-h { width: 18px; height: 18px; right: -9px; bottom: -9px; }
}

/* ---------- Work queue (1.9) ---------- */
.tbl.wq .wq-title { font-weight: 600; color: var(--ink); }
.tbl.wq tr.urgent td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.task-rows { border: 1px dashed var(--line); border-radius: var(--radius-lg); padding: 10px 12px; background: var(--surface-2); }
.task-rows .rows { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.task-row { display: grid; grid-template-columns: minmax(160px, 2fr) minmax(150px, 1.2fr) minmax(130px, 1fr) 140px 110px 32px; gap: 6px; align-items: center; }
.task-row input, .task-row select { min-width: 0; }
.team-card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px 14px; margin-top: 10px; background: var(--surface); }
.team-members { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 6px; }
@media (max-width: 720px) {
  .task-row { grid-template-columns: 1fr 1fr; }
  .task-row input[name^="task_title"] { grid-column: 1 / -1; }
}

/* ---------- phone app: bottom tab bar (installable PWA) ---------- */
.phone-tabs { display: none; }
@media (max-width: 720px) {
  .phone-tabs { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: var(--surface); border-top: 1px solid var(--line); padding: 4px 0 calc(4px + env(safe-area-inset-bottom)); }
  .phone-tabs a { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 10.5px; color: var(--muted); padding: 4px 0; position: relative; text-decoration: none; }
  .phone-tabs a span { font-size: 20px; line-height: 1.1; }
  .phone-tabs a.active { color: var(--primary); font-weight: 600; }
  .phone-tabs a.dot::after { content: ""; position: absolute; top: 2px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
  .content { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  body.has-bottom-tool .phone-tabs { display: none; }
  #toasts { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .topbar { padding-top: env(safe-area-inset-top); height: calc(var(--topbar) + env(safe-area-inset-top)); }
  .sidebar { padding-top: env(safe-area-inset-top); }
  .fax-toolbar { bottom: calc(8px + env(safe-area-inset-bottom)); }
}

/* ---------- Orders & referrals tracking (1.10) ---------- */
.oc-summary { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13.5px; color: var(--ink-2); }
.oc-summary b { font-size: 18px; color: var(--primary-deep); margin-right: 4px; }
.order-card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: var(--radius-lg); padding: 12px 16px; margin-bottom: 10px; }
.order-card.closed { border-left-color: var(--ok); opacity: .85; }
.oc-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.oc-type { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.oc-title { font-weight: 600; font-size: 15px; }
.oc-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.oc-body { margin-top: 8px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius); font-size: 13.5px; display: flex; flex-direction: column; gap: 4px; }
.oc-contact { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
.oc-update { font-size: 13px; }
.oc-faxes { margin-top: 6px; }
.oc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
@media (max-width: 720px) { .oc-head { flex-direction: column; } .oc-side { flex-direction: row; align-items: center; } }

/* ---------- 1.11: New patients (referrals) + Portal uploads ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-2 > .card { margin: 0; }
.flex.wrap { flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
.kpi.warn .v { color: var(--bad); }
.kpi.ok .v { color: var(--ok, #2E7D4F); }
.chip-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-pick { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 14px; padding: 4px 10px; font-size: 13px; cursor: pointer; background: var(--surface); }
.chip-pick:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-deep); }
.ref-legend { display: flex; gap: 16px; color: var(--ink-2); margin-bottom: 6px; }
.ref-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.ref-chart { width: 100%; height: auto; display: block; }
.ref-chart path:hover { opacity: .85; }
.ref-kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13.5px; align-content: start; }
.ref-kv .k { color: var(--muted); }
.pu-site { font-weight: 700; letter-spacing: .02em; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } .ref-kv { grid-template-columns: 1fr; } .ref-kv .k { margin-top: 6px; } }
.show-phone { display: none; }
@media (max-width: 720px) { .hide-phone { display: none; } .show-phone { display: block; } }
@media (max-width: 720px) { .table-wrap .tbl td { overflow-wrap: anywhere; } }
.flex.wrap > select, .flex.wrap > input { max-width: 100%; min-width: 0; }
.card { min-width: 0; }
@media (max-width: 720px) { table.tbl.fit { min-width: 0; } }

/* ---------- 1.12: E-mail (Patient Support mailbox) + Teams in the Patient CRM ---------- */
.toast-warn { background: var(--warn); }
.mail { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px; align-items: start; }
.mail-side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; position: sticky; top: calc(var(--topbar) + 12px); max-height: calc(100vh - var(--topbar) - 120px); display: flex; flex-direction: column; }
.mail-tabs { display: flex; gap: 4px; padding: 10px 10px 0; }
.mail-tabs button { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: var(--radius); font: inherit; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; }
.mail-tabs button.on { background: var(--primary); color: #fff; }
.mail-tabs .count { margin-left: 6px; background: var(--accent); color: #1a1a1a; border-radius: 10px; padding: 0 7px; font-size: 11px; }
.mail-srch { display: flex; gap: 8px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); }
.mail-srch input[type=search] { flex: 1; min-width: 0; }
.mail-list { overflow: auto; flex: 1; }
.mail-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line-2); border-left: 3px solid transparent; padding: 9px 12px 9px 14px; cursor: pointer; font: inherit; color: var(--ink); }
.mail-item:hover, .mail-item.on { background: var(--surface-2); }
.mail-item.on { border-left-color: var(--accent); }
.mail-item.unread { border-left-color: var(--primary); }
.mail-item.unread .mail-from, .mail-item.unread .mail-subj { font-weight: 700; }
.mail-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.mail-from, .mail-subj, .mail-prev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.mail-subj { font-size: 13px; margin-top: 1px; }
.mail-prev { font-size: 12px; color: var(--muted); }
.mail-tags { display: flex; gap: 5px; margin-top: 4px; }
.mail-main { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); min-height: calc(100vh - var(--topbar) - 120px); display: flex; flex-direction: column; min-width: 0; }
.mail-empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.mail-head { padding: 14px 18px 8px; border-bottom: 1px solid var(--line); }
.mail-head h2 { margin: 0 0 4px; font-size: 17px; }
.mail-meta { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13.5px; }
.mail-meta .mail-time { margin-left: auto; }
.mail-acts { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.mail-links { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 18px 0; }
.mail-links .chip { text-decoration: none; }
.mail-links .muted-chip { background: var(--line-2); color: var(--ink-2); cursor: default; }
.mail-scroll { padding: 12px 18px; flex: 1; min-width: 0; }
.mail-atts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.mail-att { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 6px 10px; font-size: 13px; }
.mail-text { white-space: pre-wrap; word-break: break-word; font-family: var(--font); font-size: 14px; margin: 0; line-height: 1.5; }
.mail-frame { width: 100%; border: 0; min-height: 200px; background: #fff; }
.mail-compose { border-top: 1px solid var(--line); padding: 12px 18px 16px; background: var(--surface-2); }
.mail-compose textarea { width: 100%; margin-top: 8px; }
.right { text-align: right; }
.ms-btn { background: #fff; display: inline-flex; align-items: center; gap: 8px; }
.card.connect { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.card.connect > div { flex: 1; min-width: 240px; }
/* Teams */
.tm-grp { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 14px 4px; display: flex; align-items: center; gap: 8px; }
.tm-grp.team { color: var(--primary); }
.tm-grp .count { margin-left: auto; background: var(--primary-soft); color: var(--primary-deep); border-radius: 10px; padding: 0 7px; font-size: 10.5px; }
.tm-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-left: 3px solid transparent; padding: 7px 14px 7px 20px; cursor: pointer; font: inherit; font-size: 13.5px; color: var(--ink); line-height: 1.3; }
.tm-item:hover, .tm-item.on { background: var(--surface-2); }
.tm-item.on { border-left-color: var(--accent); font-weight: 600; }
.tm-item .sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-main { height: calc(100vh - var(--topbar) - 120px); }
.tm-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.tm-head h2 { margin: 0; font-size: 16px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-msgs { flex: 1; overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-2); }
.tm-day { align-self: center; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--line-2); border-radius: 999px; padding: 3px 10px; }
.tmsg { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; align-items: start; }
.tmsg .av { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-deep); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.tmsg.me .av { background: var(--accent); color: #1a1a1a; }
.tmsg .who { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tmsg .who b { color: var(--ink); font-size: 13px; }
.tmsg .body { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.45; margin-top: 3px; }
.tmsg.me .body { background: var(--primary-soft); }
.tmsg.important .body { border-color: var(--warn); background: var(--warn-soft); }
.tmsg .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.tmsg .acts button, .tmsg .acts a { border: 1px solid var(--line); background: #fff; border-radius: 999px; color: var(--primary); font: inherit; font-size: 11.5px; font-weight: 600; padding: 3px 9px; cursor: pointer; text-decoration: none; }
.tmsg .acts button:hover, .tmsg .acts a:hover { border-color: var(--primary); background: var(--primary-soft); }
.tmsg .att { display: inline-flex; gap: 5px; background: var(--primary-soft); border-radius: 6px; padding: 3px 8px; font-size: 12px; margin: 4px 6px 0 0; }
.tmsg .replies { margin: 8px 0 0 8px; padding-left: 12px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.tmsg .replies .tmsg { grid-template-columns: 26px minmax(0, 1fr); }
.tmsg .replies .av { width: 26px; height: 26px; font-size: 10px; }
.tm-hint { font-size: 11px; color: var(--warn); font-weight: 600; }
.tm-compose { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.tm-compose textarea { flex: 1; min-height: 44px; max-height: 160px; resize: vertical; }
@media (max-width: 860px) {
  .mail { grid-template-columns: 1fr; }
  .mail-side { position: static; max-height: 46vh; }
  .mail-main, .tm-main { min-height: 60vh; height: auto; }
  .tm-msgs { max-height: 60vh; }
}
/* referral checklist + documents */
.ms-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ms-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 5px 8px; border-radius: var(--radius); font-size: 13.5px; }
.ms-list li.done { background: var(--ok-soft); }
.ms-list label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.ms-list .stamp { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.ref-files { display: flex; flex-direction: column; gap: 6px; }
.ref-files .mail-att a { font-weight: 600; }
label.check input[type=radio], label.check input[type=checkbox] { width: auto; margin: 0; }
label.check { white-space: nowrap; }
/* 1.13 */
.ap-filters select, .ap-filters input[type=date] { width: auto; }
.tbl tr.ap-labs-pending td { background: var(--warn-soft); }
.warn-text { color: var(--warn); }
.card.tint-warn { border-color: var(--warn); background: linear-gradient(0deg, #fff, var(--warn-soft)); }
.tm-table td { vertical-align: top; }

/* 1.15 task screenshots (paste / drop / choose) */
.shot-wrap[hidden], [data-shot-more][hidden] { display: none !important; }
.shot-zone { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--muted); background: var(--line-2); cursor: text; font-size: 13px; }
.shot-zone:focus, .shot-zone.over { outline: none; border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); color: var(--ink); }
.shot-zone .link-btn { font-size: inherit; }
.shot-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.shot-list:empty { margin: 0; }
.shot { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card, #fff); overflow: hidden; }
.shot img { display: block; max-width: 220px; max-height: 150px; object-fit: contain; }
.shot .shot-doc { display: block; padding: 14px 16px; font-size: 13px; max-width: 220px; overflow-wrap: anywhere; }
.shot .icon-btn { position: absolute; top: 2px; right: 2px; background: rgba(255,255,255,.9); font-size: 12px; padding: 2px 6px; }
.shot-zone label.link-btn { display: inline; margin: 0; font-weight: inherit; color: var(--primary); }

/* 1.16 Teams: organize chats (folders, pins, hidden) + tasks in conversations */
.tm-item { position: relative; padding-right: 34px; user-select: none; }
.tm-item .tm-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-item.unread .tm-name { font-weight: 700; }
.tm-item.unread::before { content: ''; position: absolute; left: 8px; top: 13px; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.tm-item.dragging { opacity: .45; }
.tm-more { position: absolute; right: 6px; top: 6px; border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 6px; cursor: pointer; opacity: 0; }
.tm-item:hover .tm-more, .tm-item.on .tm-more, .tm-more:focus { opacity: 1; }
.tm-more:hover { background: var(--line-2); color: var(--ink); }
.tm-grp .tm-more { position: static; opacity: .7; font-size: 14px; margin-left: 2px; }
.tm-grp { cursor: pointer; user-select: none; }
.tm-grp.folder { color: var(--ink-2); }
.tm-grp .tm-unread { background: var(--primary); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 10px; }
.tm-pin { font-size: 11px; }
.tm-tcount { font-size: 10.5px; font-weight: 700; color: var(--primary-deep); background: var(--primary-soft); border-radius: 8px; padding: 0 5px; margin-left: 2px; }
.tm-sec { border-radius: 8px; margin: 0 4px; }
.tm-sec.drop-on { background: var(--primary-soft); outline: 2px dashed var(--primary); outline-offset: -2px; }
.tm-empty { font-size: 12px; color: var(--muted); padding: 4px 20px 8px; font-style: italic; }
.tm-hidden-toggle { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; padding: 10px 14px; cursor: pointer; }
.tm-srch .btn { white-space: nowrap; }
.pop-menu { position: fixed; z-index: 1000; width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow), 0 10px 30px rgba(0,0,0,.12); padding: 5px; }
.pop-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; font-size: 13px; padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--ink); }
.pop-menu button:hover { background: var(--surface-2); }
.pop-menu button.on { font-weight: 600; color: var(--primary-deep); }
.pop-menu hr { border: 0; border-top: 1px solid var(--line-2); margin: 4px 0; }
.pop-menu .pm-head { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 10px 2px; }
.tm-tasks { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.tm-task { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--primary); background: #fff; color: var(--ink); border-radius: 8px; padding: 4px 9px; font: inherit; font-size: 12.5px; cursor: pointer; max-width: 100%; text-align: left; }
.tm-task b { color: var(--primary-deep); }
.tm-task:hover { background: var(--primary-soft); }
.tm-task.closed { border-color: var(--line); color: var(--muted); }
.tm-task.hl { box-shadow: 0 0 0 3px var(--accent); }
.tm-task .badge { font-size: 10.5px; }
.tm-taskcards { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.tmsg.task-hl > div > .body, .tmsg.task-hl .tm-taskcards .tm-task.hl { animation: tm-flash 2.4s ease-out 1; }
.tmsg.task-hl > .av { box-shadow: 0 0 0 3px var(--accent); }
@keyframes tm-flash { 0% { background: var(--accent-soft, #fff3c4); } 100% { background: inherit; } }
.tm-attach { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 8px 12px; background: var(--primary-soft); border-top: 1px solid var(--line); font-size: 12.5px; }
.tm-attach[hidden] { display: none; }
.tm-compose .btn-sm { align-self: flex-end; }
.tm-card-preview { border-left: 3px solid var(--primary); background: var(--surface-2); padding: 8px 12px; border-radius: 6px; }
.mt-pick { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
.mt-row { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; border: 0; border-left: 3px solid transparent; background: none; font: inherit; font-size: 13px; padding: 7px 12px; cursor: pointer; }
.mt-row:hover { background: var(--surface-2); }
.mt-row.on { background: var(--primary-soft); border-left-color: var(--primary); font-weight: 600; }
.mt-row .sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.mt-ic { width: 22px; text-align: center; }
.td-tm-links { display: flex; flex-direction: column; gap: 4px; }
.td-tm-link { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.td-thread { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); padding: 10px; max-height: 300px; overflow: auto; }
.td-msg { padding: 6px 10px; border-radius: 8px; background: #fff; border: 1px solid var(--line-2); margin-bottom: 6px; }
.td-msg.me { background: var(--primary-soft); }
.td-msg.about { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.td-msg-body { white-space: pre-wrap; font-size: 13px; margin-top: 2px; }
@media (max-width: 760px) { .tm-more { opacity: 1; } }

/* 1.19 Visit Orders inside the CRM */
.vo-embed{margin:-6px -4px 0}
.vo-embed iframe{display:block;width:100%;height:calc(100dvh - var(--topbar, 56px) - 40px);border:0;background:transparent}
@media (max-width: 760px){ .vo-embed iframe{height:calc(100dvh - var(--topbar, 56px) - 120px)} }
.vo-kv{display:grid;grid-template-columns:110px 1fr;gap:6px 14px;font-size:13.5px}.vo-kv b{color:var(--muted);font-weight:600}.vo-kv .pre{white-space:pre-wrap}
.vo-cl{border:1px solid var(--line);border-radius:10px;overflow:hidden}
.vo-cl-row{display:flex;gap:10px;align-items:center;padding:9px 12px;border-bottom:1px solid var(--line-2);font-size:13.5px}.vo-cl-row:last-child{border-bottom:0}
.vo-cl-row.done{background:var(--ok-soft, #eef7f0)}.vo-cl-row .small{margin-left:auto}
.ok-text{color:var(--ok)}
.vo-events{max-height:280px;overflow:auto}
/* 1.20 e-mail suggestions from Tebra + Tebra demographics on the profile */
.mail-chips{display:flex;flex-wrap:wrap;gap:6px}
.mail-chip{border:1px solid var(--line);background:#fff;border-radius:999px;padding:4px 10px;font:inherit;font-size:12.5px;cursor:pointer;color:var(--ink)}
.mail-chip b{color:var(--primary-deep);font-weight:600}.mail-chip:hover{border-color:var(--primary)}
.mail-chip.on{background:var(--primary);border-color:var(--primary);color:#fff}.mail-chip.on b{color:var(--accent)}
.tp-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(320px,1fr));gap:14px;align-items:start}
.tp-grid>.card.tp-card,.tp-grid>.card.tp-card+.card{margin:0}.tp-card h3{margin:0 0 8px;font-size:15px}
.tp-kv{display:grid;grid-template-columns:minmax(110px,40%) 1fr;gap:5px 12px;font-size:13.5px}
.tp-kv dt{color:var(--muted)}.tp-kv dd{margin:0;word-break:break-word}
.tp-card.alert{border-color:var(--warn);background:var(--warn-soft)}
/* 1.21: medication refill details on the task form and drawer */
.refill-box{border:1px solid var(--line);border-left:3px solid var(--accent);border-radius:8px;padding:10px 12px;background:var(--surface-2,#f7faf9)}
.refill-head{display:flex;gap:8px;align-items:baseline;flex-wrap:wrap;margin-bottom:6px}
.refill-grid{display:grid;grid-template-columns:minmax(160px,220px) 1fr;gap:10px 14px}
.refill-grid .field{margin:0}.refill-grid small{display:block;margin-top:3px;color:var(--muted)}
.refill-grid .mail-chips{margin-top:6px}
@media (max-width:640px){.refill-grid{grid-template-columns:1fr}}
.refill-sum{display:flex;gap:18px;flex-wrap:wrap;align-items:baseline;padding:8px 12px;border-radius:8px;background:var(--surface-2,#f7faf9);border:1px solid var(--line);margin:0 0 10px;font-size:14px}
.refill-sum.missing{border-color:var(--warn);background:var(--warn-soft)}
.refill-box [hidden]{display:none!important}
/* 1.22: signature dialog (saved · by hand · typed), Name/NPI stamp picker, pick-one dialog */
.sig-tabs{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:12px;border-bottom:1px solid var(--line);padding-bottom:8px}
.sig-tab{border:1px solid var(--line);background:#fff;border-radius:999px;padding:6px 14px;font:inherit;font-size:13.5px;cursor:pointer;color:var(--ink)}
.sig-tab.on{background:var(--primary);border-color:var(--primary);color:#fff}
.sig-saved{border:1px dashed var(--line);border-radius:10px;background:#fff;display:flex;align-items:center;justify-content:center;min-height:150px;padding:14px}
.sig-saved img{max-width:100%;max-height:150px}
.sig-fonts{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:8px;margin-top:10px}
.sig-font{border:1px solid var(--line);background:#fff;border-radius:10px;padding:10px 14px;font-size:30px;line-height:1.25;color:#101a3a;cursor:pointer;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-height:64px}
.sig-font.on{border-color:var(--primary);box-shadow:0 0 0 2px var(--primary) inset}
.stamp-grid{display:grid;grid-template-columns:1.1fr 1fr;gap:18px}
@media (max-width:700px){.stamp-grid{grid-template-columns:1fr}}
.stamp-people{display:flex;flex-direction:column;gap:6px;margin-top:4px;max-height:320px;overflow:auto}
.stamp-person{display:flex;flex-direction:column;align-items:flex-start;gap:2px;border:1px solid var(--line);background:#fff;border-radius:8px;padding:8px 12px;font:inherit;cursor:pointer;text-align:left}
.stamp-person.on{border-color:var(--primary);box-shadow:0 0 0 2px var(--primary) inset}
.stamp-lines{display:flex;flex-direction:column;gap:4px;margin-top:4px}
.stamp-preview{font:bold 12.5px/1.25 Helvetica,Arial,sans-serif;background:#fff;border:1px dashed var(--line);border-radius:8px;padding:10px 12px;margin:4px 0 0;white-space:pre-wrap;color:#101a3a;min-height:44px}
.choose-list{display:flex;flex-direction:column;gap:8px}
.choose-opt{display:flex;flex-direction:column;gap:2px;align-items:flex-start;text-align:left;border:1px solid var(--line);background:#fff;border-radius:10px;padding:10px 14px;font:inherit;cursor:pointer}
.choose-opt:hover{border-color:var(--primary)}
.choose-opt.primary{border-color:var(--primary);background:var(--surface-2)}
.btn-primary-soft{border-color:var(--primary);color:var(--primary-deep);background:var(--primary-soft)}
/* 1.22: pharmacy suggestions */
.ph-wrap{position:relative}
.ph-menu{position:absolute;left:0;right:0;top:calc(100% + 4px);z-index:60;background:#fff;border:1px solid var(--line);border-radius:10px;box-shadow:0 10px 28px rgba(16,40,48,.16);max-height:320px;overflow:auto;padding:4px 0}
.ph-grp{font-size:11px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--muted);padding:8px 12px 4px}
.ph-row{display:flex;flex-direction:column;align-items:flex-start;gap:1px;width:100%;border:0;background:none;text-align:left;padding:7px 12px;font:inherit;font-size:13.5px;cursor:pointer;color:var(--ink)}
.ph-row:hover,.ph-row.on{background:var(--primary-soft)}
.ph-note{padding:8px 12px}
