:root {
  color-scheme: light;
  font: 100%/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --bg: #FAF8F4; --surface: #fff; --surface-alt: #f7f8fa;
  --ink: #352F25; --muted: #676b73; --faint: #878b93; --line: #e4e5e9;
  --accent: #805D2E; --accent-hover: #664A24; --accent-soft: #F7F2E9;
  --primary: #805D2E; --primary-hover: #664A24;
  --chrome: rgba(250,250,252,.88); --field: #fff; --focus: #805D2E;
  --green: #28764f; --green-bg: #edf6ef; --blue: #3e65a0; --blue-bg: #edf2fa;
  --error: #b32f3f; --error-bg: #fff0f1; --shadow: 0 24px 80px rgba(20,28,40,.18);
  --radius: 1rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark; --bg:#111214; --surface:#1b1c20; --surface-alt:#23252a;
    --ink:#f1f2f5; --muted:#a9adb6; --faint:#838893; --line:#34373e;
    --accent:#D9BD8D; --accent-hover:#E6CEAB; --accent-soft:#3C3222;
    --chrome:rgba(24,25,29,.9); --field:#222429; --focus:#D9BD8D;
    --green:#9ed7b5; --green-bg:#263b2e; --blue:#b0c9f4; --blue-bg:#28354b;
    --error:#ffb1bc; --error-bg:#44272e; --shadow:0 24px 80px rgba(0,0,0,.45);
  }
}
:root[data-theme="dark"] {
  color-scheme:dark; --bg:#111214; --surface:#1b1c20; --surface-alt:#23252a;
  --ink:#f1f2f5; --muted:#a9adb6; --faint:#838893; --line:#34373e;
  --accent:#D9BD8D; --accent-hover:#E6CEAB; --accent-soft:#3C3222;
  --chrome:rgba(24,25,29,.9); --field:#222429; --focus:#D9BD8D;
  --green:#9ed7b5; --green-bg:#263b2e; --blue:#b0c9f4; --blue-bg:#28354b;
  --error:#ffb1bc; --error-bg:#44272e; --shadow:0 24px 80px rgba(0,0,0,.45);
}
* { box-sizing:border-box; }
body { margin:0; min-width:20rem; background:var(--bg); color:var(--ink); font-size:.9375rem; -webkit-font-smoothing:antialiased; }
body:has(dialog[open]) { overflow:hidden; }
button,input,select,textarea { font:inherit; color:inherit; }
button,a,input,select,textarea { -webkit-tap-highlight-color:transparent; }
button { cursor:pointer; }
button:disabled { cursor:default; opacity:.45; }
button,a { touch-action:manipulation; }
button:not(:disabled),a.button { transition:background-color 120ms, color 120ms, transform 100ms; }
button:not(:disabled):active,a.button:active { transform:scale(.975); transition-duration:0ms; }
a { color:var(--accent); text-decoration:none; }
h1,h2,h3,p { margin:0; }
h1,h2,h3 { font-weight:600; }
h1 { font-size:2rem; letter-spacing:-.035em; line-height:1.18; }
h2 { letter-spacing:-.02em; }
:focus-visible { outline:3px solid var(--focus); outline-offset:3px; }
bdi { overflow-wrap:anywhere; }
[hidden] { display:none !important; }
.icon { width:1.2rem; height:1.2rem; flex:none; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.icon-small { width:1rem; height:1rem; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.skip-link { position:fixed; top:-5rem; left:1rem; z-index:100; padding:.75rem 1rem; border-radius:.5rem; background:var(--surface); color:var(--ink); }
.skip-link:focus { top:1rem; }
.button { display:inline-flex; align-items:center; justify-content:center; gap:.5rem; min-height:2.75rem; padding:.625rem 1rem; border:1px solid var(--line); border-radius:.65rem; background:var(--surface); color:var(--ink); font-size:.875rem; font-weight:550; line-height:1.35; white-space:nowrap; }
.button:hover:not(:disabled) { background:var(--surface-alt); }
.button.primary { border-color:transparent; background:var(--primary); color:#fff; }
.button.primary:hover:not(:disabled) { background:var(--primary-hover); }
.button.quiet { color:var(--accent); border-color:transparent; background:transparent; }
.button.quiet:hover:not(:disabled) { background:var(--accent-soft); }
.button.block { width:100%; }
.icon-button,.password-toggle { display:inline-flex; align-items:center; justify-content:center; flex:none; min-width:2.75rem; min-height:2.75rem; border:0; border-radius:.7rem; background:transparent; color:var(--muted); }
.icon-button:hover,.password-toggle:hover { background:var(--surface-alt); color:var(--ink); }
.brand { display:flex; align-items:center; gap:.7rem; min-width:0; }
.brand-logo { display:block; flex:none; width:3rem; height:3rem; object-fit:contain; }
.brand-name { font-size:1rem; font-weight:600; letter-spacing:-.02em; line-height:1.2; }
.topbar { background:var(--surface); }
.topbar-inner { display:flex; align-items:center; justify-content:space-between; gap:1rem; max-width:94rem; margin:auto; padding:1rem 2.25rem; min-height:5rem; }
.account-area,.account-person { display:flex; align-items:center; gap:.65rem; min-width:0; }
.account-area { gap:.25rem; }
.account-person { margin-right:.65rem; }
.account-name { font-size:.8125rem; max-width:12rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.avatar { display:flex; align-items:center; justify-content:center; width:2.125rem; height:2.125rem; flex:none; background:var(--surface-alt); border:1px solid var(--line); color:var(--muted); border-radius:50%; font-size:.6875rem; font-weight:600; }
.topnav { position:sticky; top:0; z-index:10; background:var(--chrome); border-bottom:1px solid var(--line); backdrop-filter:blur(20px); -webkit-backdrop-filter:blur(20px); }
.nav-inner { display:flex; gap:.35rem; max-width:94rem; margin:auto; padding:.35rem 2.25rem; overflow-x:auto; scrollbar-width:none; }
.nav-inner::-webkit-scrollbar { display:none; }
.nav-button { display:inline-flex; align-items:center; justify-content:center; gap:.55rem; flex:none; min-height:2.75rem; padding:.65rem .9rem; border:0; border-radius:.65rem; background:transparent; color:var(--muted); font-size:.875rem; font-weight:500; white-space:nowrap; }
.nav-button:hover { color:var(--ink); background:var(--surface-alt); }
.nav-button.active { color:var(--accent); background:var(--accent-soft); }
.nav-label-mobile { display:none; }
.nav-count { font-size:.75rem; font-variant-numeric:tabular-nums; opacity:.85; }
.workspace { max-width:94rem; margin:auto; padding:2rem 2.25rem 4rem; scroll-margin-top:4.5rem; }
.page-heading { display:flex; align-items:center; justify-content:space-between; gap:1.5rem; margin-bottom:1.75rem; }
.heading-actions { display:flex; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:.65rem; min-width:0; }
.heading-actions select { max-width:23rem; }
.notice { display:flex; align-items:center; gap:.8rem; margin:0 0 1.5rem; padding:.75rem 1rem; border:1px solid var(--line); background:var(--surface); border-radius:.8rem; color:var(--muted); font-size:.875rem; }
.notice p { flex:1; }
.notice.info { background:var(--accent-soft); color:var(--accent); border-color:transparent; }
.pool-controls { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:1rem; margin-bottom:1.25rem; }
.status-tabs { display:flex; flex-wrap:wrap; gap:.35rem; }
.status-tab { display:flex; align-items:center; justify-content:center; gap:.55rem; min-height:2.75rem; padding:.625rem .8rem; background:transparent; border:1px solid transparent; border-radius:.7rem; color:var(--muted); font-size:.875rem; }
.status-tab span { font-size:.75rem; font-variant-numeric:tabular-nums; }
.status-tab:hover { color:var(--ink); background:var(--surface); }
.status-tab.active { background:var(--surface); border-color:var(--line); color:var(--ink); font-weight:550; }
.search-wrap { position:relative; width:18rem; max-width:100%; }
.search-wrap>.icon { position:absolute; left:.9rem; top:50%; transform:translateY(-50%); color:var(--muted); pointer-events:none; width:1rem; height:1rem; }
.search-input { width:100%; min-height:2.75rem; padding:.65rem .85rem .65rem 2.5rem; background:var(--field); border:1px solid var(--line); border-radius:.7rem; font-size:.875rem; }
input::placeholder,textarea::placeholder { color:var(--muted); opacity:1; }
.workspace-grid { display:grid; grid-template-columns:minmax(0,1fr) 21rem; gap:1.5rem; align-items:start; }
.panel,.patients-card { min-width:0; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; }
.table-scroll { max-width:100%; }
table { width:100%; border-collapse:collapse; text-align:left; }
th { padding:.9rem 1.15rem; border-bottom:1px solid var(--line); color:var(--muted); font-size:.75rem; font-weight:550; line-height:1.4; }
td { padding:1.1rem 1.15rem; border-bottom:1px solid var(--line); font-size:.8125rem; vertical-align:middle; }
tbody tr:last-child td { border-bottom:0; }
.patient-table { table-layout:fixed; }
.patient-table th:first-child { width:24%; }
.patient-table th:nth-child(2) { width:24%; }
.patient-table th:nth-child(3) { width:10%; }
.patient-table th:last-child { width:7.5rem; }
.patient-table .action-column { text-align:right; }
.patient-table td,.patient-table th { padding-left:.9rem; padding-right:.9rem; }
.patient-name { color:var(--ink); font-weight:550; line-height:1.5; overflow-wrap:anywhere; }
.patient-number,.patient-detail-number { margin-top:.2rem; color:var(--muted); font-size:.75rem; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.case-name { line-height:1.45; overflow-wrap:anywhere; }
.case-code,.category-code { margin-top:.25rem; color:var(--muted); font-size:.6875rem; letter-spacing:.035em; }
.hospital-column { font-variant-numeric:tabular-nums; }
.mobile-label { display:none; }
.resident-cell { font-size:.75rem; color:var(--muted); overflow-wrap:anywhere; }
.status-pill { display:inline-flex; align-items:center; padding:.2rem .5rem; border-radius:.4rem; font-size:.6875rem; font-weight:550; white-space:nowrap; }
.status-pill.available { color:var(--green); background:var(--green-bg); }
.status-pill.assigned { color:var(--blue); background:var(--blue-bg); }
.status-pill.completed { color:var(--muted); background:var(--surface-alt); }
.view-button { display:inline-flex; align-items:center; justify-content:center; min-width:5.6rem; min-height:2.75rem; gap:.35rem; padding:.6rem .75rem; border:1px solid transparent; border-radius:.6rem; background:var(--accent-soft); color:var(--accent); font-size:.8125rem; font-weight:550; white-space:nowrap; }
.view-button .icon { width:1rem; height:1rem; }
.view-button:hover { border-color:var(--accent); color:var(--accent-hover); }
.table-bottom { display:flex; align-items:center; justify-content:space-between; gap:1rem; min-height:3.75rem; padding:.5rem 1.15rem; border-top:1px solid var(--line); color:var(--muted); font-size:.75rem; }
.empty-state { display:flex; align-items:center; justify-content:center; flex-direction:column; gap:1rem; min-height:20rem; padding:2rem; text-align:center; color:var(--muted); }
.empty-state>.icon { width:1.8rem; height:1.8rem; color:var(--faint); }
.empty-state h2 { color:var(--muted); font-size:1rem; }
.priority-panel { padding:1.4rem 1.15rem .65rem; }
.panel-title { font-size:1rem; font-weight:600; margin-bottom:1rem; }
.priority-select,.filter-select,.field-select,.field-input { width:100%; max-width:100%; min-width:0; min-height:2.75rem; padding:.65rem .75rem; border:1px solid var(--line); border-radius:.65rem; background:var(--field); color:var(--ink); font-size:.875rem; line-height:1.4; }
select { cursor:pointer; }
.filter-select { width:auto; max-width:100%; }
.priority-select { font-size:.8125rem; }
.priority-column-labels { display:flex; justify-content:space-between; gap:.5rem; margin-top:1.5rem; padding-bottom:.5rem; color:var(--muted); font-size:.6875rem; letter-spacing:.01em; }
.rank-item { display:flex; align-items:center; gap:.6rem; min-height:4.1rem; padding:.75rem 0; border-top:1px solid var(--line); }
.rank-number { flex:none; min-width:1rem; color:var(--muted); font-size:.75rem; font-variant-numeric:tabular-nums; }
.rank-name { flex:1; min-width:0; font-size:.8125rem; font-weight:500; line-height:1.5; }
.rank-you { display:inline-block; margin-left:.35rem; color:var(--accent); font-size:.6875rem; font-weight:500; }
.rank-count { flex:none; font-size:.75rem; font-variant-numeric:tabular-nums; color:var(--muted); }
.rank-count strong { color:var(--ink); font-weight:600; }
.rank-missing { font-size:.6875rem; }
.is-you .rank-number { color:var(--accent); }
.priority-ranking-table th:not(:nth-child(2)),.priority-ranking-table td:not(:nth-child(2)) { text-align:center; }
.priority-ranking-table td { font-size:.875rem; }
.rank-cell { font-variant-numeric:tabular-nums; color:var(--muted); }
.count-emphasis { font-weight:650; }
.you-row { background:var(--accent-soft); }
.resident-identity { display:flex; align-items:center; gap:.75rem; min-width:0; }
.resident-identity>div { min-width:0; }
.resident-name { font-weight:550; overflow-wrap:anywhere; }
.resident-username { font-size:.75rem; color:var(--muted); margin-top:.15rem; overflow-wrap:anywhere; }
.login-status { color:var(--muted); font-size:.75rem; }
.login-status.enabled { color:var(--green); }
.resident-number { font-variant-numeric:tabular-nums; }
.row-actions { display:flex; flex-wrap:wrap; gap:.5rem; justify-content:flex-end; }
.progress-summary { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:1rem; margin-bottom:1.5rem; }
.summary-card { padding:1.35rem 1.5rem; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); }
.summary-label { color:var(--muted); font-size:.8125rem; }
.summary-number { margin-top:.4rem; font-size:2rem; font-weight:600; letter-spacing:-.03em; font-variant-numeric:tabular-nums; }
.progress-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:1rem; }
.progress-card { padding:1.5rem; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); }
.progress-card h2 { margin-top:.35rem; min-height:3rem; font-size:1rem; line-height:1.45; }
.progress-numbers { display:flex; align-items:baseline; gap:.4rem; margin:1.25rem 0 .7rem; }
.progress-numbers strong { font-size:1.75rem; font-weight:600; letter-spacing:-.035em; }
.progress-numbers span { color:var(--muted); font-size:.8125rem; }
progress { display:block; appearance:none; width:100%; height:.3rem; margin-bottom:1.1rem; border:0; border-radius:1rem; overflow:hidden; background:var(--surface-alt); accent-color:var(--accent); }
progress::-webkit-progress-bar { background:var(--surface-alt); border-radius:1rem; }
progress::-webkit-progress-value { background:var(--accent); border-radius:1rem; }
progress::-moz-progress-bar { background:var(--accent); }
.progress-detail { display:flex; justify-content:space-between; gap:1rem; padding:.4rem 0; font-size:.8125rem; }
.progress-detail>span:first-child { color:var(--muted); }
.progress-detail strong { font-weight:550; font-variant-numeric:tabular-nums; }
.additional-cases { margin-top:1.5rem; padding:1.5rem; max-width:42rem; }
.requirements-panel { max-width:50rem; padding:1.5rem; }
.history-table { table-layout:fixed; }
.history-table th:first-child,.history-table td:first-child { width:60%; padding-left:0; }
.history-table th,.history-table td { padding:1rem .75rem; }
.history-table th:not(:first-child) { text-align:right; }
.history-table td:not(:first-child) { text-align:right; }
.history-table .field-input { width:5.5rem; text-align:center; }
.category-title { font-size:.875rem; font-weight:500; line-height:1.45; }
.history-current { color:var(--muted); font-variant-numeric:tabular-nums; }
.panel-actions { display:flex; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:.75rem; padding-top:1.5rem; }
.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1.25rem; }
.form-field { display:flex; flex-direction:column; gap:.45rem; min-width:0; }
.form-field.full { grid-column:1/-1; }
.field-label,.credential-label { display:flex; align-items:baseline; flex-wrap:wrap; column-gap:.5rem; font-size:.8125rem; font-weight:550; line-height:1.4; }
.optional { color:var(--muted); font-size:.75rem; font-weight:400; }
textarea.field-input { min-height:7rem; resize:vertical; line-height:1.65; }
.field-input[readonly] { color:var(--muted); }
.field-input[aria-invalid="true"] { border-color:var(--error); }
.password-wrap { position:relative; }
.password-wrap input { width:100%; padding-right:3rem; }
.password-toggle { position:absolute; top:0; right:.15rem; height:100%; }
.form-error { padding:.8rem 1rem; border-radius:.65rem; background:var(--error-bg); color:var(--error); font-size:.8125rem; line-height:1.5; margin-bottom:1rem; overflow-wrap:anywhere; }
.form-error:empty { display:none; }
.login-layout { display:flex; align-items:center; justify-content:center; min-height:100vh; min-height:100dvh; padding:3rem 1.5rem; }
.login-appearance { position:absolute; top:1rem; right:1rem; }
.login-card { width:100%; max-width:23rem; }
.login-card>.brand-logo { margin:0 auto 1.5rem; width:6.875rem; height:6.875rem; }
.initial-loading>.brand-logo { width:4.5rem; height:4.5rem; }
.login-card h1 { font-size:2.2rem; line-height:1.14; letter-spacing:-.04em; margin-bottom:2.5rem; text-align:center; }
.login-form { display:flex; flex-direction:column; gap:1.25rem; }
.login-form .form-error { margin-bottom:0; }
.login-form .button { margin-top:.5rem; }
.login-form .field-input { min-height:3.1rem; }
.initial-loading { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:1.25rem; min-height:100vh; color:var(--muted); font-size:.875rem; }
dialog { width:calc(100% - 2rem); max-width:37rem; max-height:calc(100vh - 3rem); max-height:calc(100dvh - 3rem); margin:auto; padding:0; border:1px solid var(--line); border-radius:1.2rem; background:var(--surface); color:var(--ink); box-shadow:var(--shadow); overflow:auto; overscroll-behavior:contain; }
dialog.wide-dialog { max-width:43rem; }
dialog::backdrop { background:rgba(16,20,27,.38); }
.dialog-header { display:flex; align-items:flex-start; justify-content:space-between; gap:1rem; padding:1.4rem 1.5rem 1rem; border-bottom:1px solid var(--line); }
.dialog-header h2 { padding-top:.45rem; font-size:1.2rem; line-height:1.35; }
.dialog-header p { color:var(--muted); font-size:.8125rem; margin-top:.4rem; }
.dialog-header .icon-button { margin-right:-.35rem; }
.dialog-body { padding:1.5rem; }
.dialog-footer { display:flex; align-items:center; justify-content:flex-end; gap:.75rem; padding:1rem 1.5rem; border-top:1px solid var(--line); background:var(--surface); }
.dialog-footer.split { justify-content:space-between; }
.patient-detail-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:1rem; margin-bottom:1.75rem; }
.patient-detail-name { font-size:1.35rem; font-weight:600; letter-spacing:-.025em; line-height:1.4; overflow-wrap:anywhere; }
.patient-detail-heading .status-pill { margin-top:.3rem; }
.detail-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1.25rem; }
.detail-wide { grid-column:1/-1; }
.detail-label { color:var(--muted); font-size:.75rem; margin-bottom:.35rem; }
.detail-value { font-size:.875rem; overflow-wrap:anywhere; }
.notes-section { margin-top:1.75rem; padding:1rem; border:1px solid var(--line); border-radius:.85rem; background:var(--surface-alt); }
.notes-heading { display:flex; align-items:center; justify-content:space-between; gap:.65rem; margin-bottom:.5rem; }
.section-label { color:var(--ink); font-size:.8125rem; font-weight:600; }
.notes-input { background:var(--surface); }
.notes-content { margin-top:.65rem; font-size:.875rem; line-height:1.7; white-space:pre-wrap; overflow-wrap:anywhere; }
.assign-row { display:flex; align-items:flex-end; gap:.75rem; padding-top:1.5rem; }
.assign-row>.form-field { flex:1; }
.patient-timeline { margin-top:1.75rem; border-top:1px solid var(--line); padding-top:1.25rem; }
.patient-timeline .section-label { margin-bottom:1rem; }
.timeline-entry { display:flex; align-items:baseline; justify-content:space-between; gap:1rem; padding:.5rem 0; }
.timeline-text { color:var(--muted); font-size:.75rem; }
.timeline-time { flex:none; color:var(--muted); font-size:.6875rem; }
.credentials-box { display:flex; flex-direction:column; gap:1.5rem; }
.credential-row { display:flex; align-items:flex-end; justify-content:space-between; gap:1rem; }
.credential-row>div { flex:1; min-width:0; }
.credential-value { margin-top:.35rem; font-family:ui-monospace,SFMono-Regular,Consolas,monospace; font-size:.875rem; overflow-wrap:anywhere; }
.credentials-note { margin-top:1.5rem; color:var(--muted); font-size:.8125rem; }
.toast-region { position:fixed; bottom:1.5rem; left:50%; transform:translateX(-50%); width:max-content; max-width:calc(100% - 2rem); z-index:100; pointer-events:none; }
.toast { display:flex; align-items:center; gap:.75rem; padding:.65rem .75rem .65rem 1rem; border:1px solid var(--line); border-radius:.85rem; background:var(--surface); color:var(--ink); box-shadow:0 8px 30px rgba(0,0,0,.12); pointer-events:auto; }
.toast>.icon { color:var(--accent); }
.toast.error>.icon { color:var(--error); }
.toast-message { font-size:.8125rem; line-height:1.5; }
.toast button { display:flex; align-items:center; justify-content:center; min-width:2.75rem; min-height:2.75rem; padding:.5rem; border:0; border-radius:.5rem; background:transparent; color:var(--muted); }
@media (max-width:1250px) {
  .workspace-grid { grid-template-columns:minmax(0,1fr) 19.5rem; gap:1rem; }
  .topbar-inner,.nav-inner { padding-left:1.5rem; padding-right:1.5rem; }
  .workspace { padding-left:1.5rem; padding-right:1.5rem; }
  .patient-table th,.patient-table td { padding-left:.7rem; padding-right:.7rem; }
  .patient-table .owner-column { display:none; }
  .patient-table th:first-child { width:29%; }
  .patient-table th:nth-child(2) { width:29%; }
}
@media (max-width:1000px) {
  .workspace-grid { grid-template-columns:minmax(0,1fr); }
  .priority-panel { max-width:none; }
  .rank-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); column-gap:2rem; }
  .priority-panel .priority-select { max-width:25rem; }
  .priority-column-labels { display:none; }
  .rank-list { margin-top:1rem; }
  .patient-table .owner-column { display:table-cell; }
  .patient-table th:first-child { width:24%; }
  .patient-table th:nth-child(2) { width:24%; }
  .progress-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .heading-actions { max-width:65%; }
}
@media (max-width:700px) {
  .topbar-inner { padding:.75rem 1rem; min-height:4.5rem; gap:.65rem; }
  .brand { gap:.6rem; }
  .brand-name { max-width:12.5rem; font-size:.9375rem; }
  .account-person { display:none; }
  .account-area { gap:0; }
  .nav-inner { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); padding:.3rem .5rem; gap:.15rem; overflow:visible; }
  .nav-button { flex-direction:column; min-width:0; min-height:3.25rem; padding:.4rem .15rem; gap:.2rem; font-size:.75rem; line-height:1.25; }
  .nav-label-full,.nav-button .nav-count { display:none; }
  .nav-label-mobile { display:inline; }
  .nav-button .icon { width:1.05rem; height:1.05rem; }
  .workspace { padding:1.5rem 1rem 2.5rem; }
  .page-heading { align-items:flex-start; gap:1rem; flex-direction:column; margin-bottom:1.25rem; }
  h1 { font-size:1.75rem; }
  .heading-actions { width:100%; max-width:none; justify-content:flex-start; }
  .heading-actions .filter-select { flex:1; width:100%; max-width:100%; }
  .pool-controls { gap:1rem; }
  .search-wrap { width:100%; order:2; }
  .status-tabs { display:grid; grid-auto-flow:column; grid-auto-columns:minmax(0,1fr); width:100%; }
  .status-tab { flex-direction:column; min-width:0; min-height:3rem; gap:.1rem; padding:.4rem .2rem; font-size:.75rem; }
  .patient-table,.patient-table tbody { display:block; }
  .patient-table thead { display:none; }
  .patient-table tr { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:.35rem 1rem; padding:.9rem 1.1rem; border-bottom:1px solid var(--line); }
  .patient-table tr:last-child { border-bottom:0; }
  .patient-table td,.patient-table .owner-column { display:block; width:auto; min-width:0; padding:0; border:0; }
  .patient-table .patient-column { grid-column:1; grid-row:1; align-self:center; }
  .patient-table .status-column { grid-column:2; grid-row:1; text-align:right; align-self:start; padding-top:.1rem; }
  .patient-table .category-column { grid-column:1/-1; grid-row:2; }
  .patient-table .hospital-column { grid-column:1; grid-row:3; align-self:center; color:var(--muted); font-size:.75rem; }
  .patient-table .action-column { grid-column:2; grid-row:3; text-align:right; }
  .patient-table .owner-column { grid-column:1/-1; grid-row:4; font-size:.75rem; }
  .mobile-label { display:inline; color:var(--muted); margin-right:.5rem; }
  .patient-name { font-size:.9375rem; }
  .case-name { font-size:.8125rem; color:var(--muted); }
  .case-code { font-size:.6875rem; }
  .patient-table .case-name { display:inline; }
  .patient-table .case-code { display:inline-block; margin:0 0 0 .5rem; }
  .view-button { min-width:5.6rem; padding:.6rem .75rem; }
  .rank-list { grid-template-columns:1fr; }
  .priority-column-labels { display:flex; }
  .priority-panel { padding:1.25rem 1.1rem .65rem; }
  .rank-list { margin-top:0; }
  .priority-panel .priority-select { max-width:none; }
  .rank-item { min-height:4.25rem; }
  .rank-name { font-size:.875rem; }
  .rank-count { font-size:.8125rem; }
  .notice { flex-wrap:wrap; align-items:flex-start; padding:1rem; gap:.65rem; }
  .notice p { min-width:60%; }
  .notice .button { margin-left:auto; }
  .progress-summary { gap:.6rem; }
  .summary-card { padding:1rem .8rem; }
  .summary-label { font-size:.75rem; line-height:1.4; }
  .summary-number { font-size:1.6rem; }
  .progress-grid { gap:1rem; grid-template-columns:minmax(0,1fr); }
  .progress-card { padding:1.25rem; }
  .progress-card h2 { min-height:0; }
  .requirements-panel { padding:1rem; }
  .history-table th,.history-table td { padding:.9rem .4rem; }
  .history-table th:first-child,.history-table td:first-child { width:55%; }
  .history-table th { font-size:.6875rem; }
  .history-table .field-input { width:4rem; padding:.6rem .35rem; }
  .category-title { font-size:.8125rem; }
  .priority-ranking-table,.priority-ranking-table tbody { display:block; }
  .priority-ranking-table thead { display:none; }
  .priority-ranking-table tr { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:.9rem .5rem; padding:1.1rem; border-bottom:1px solid var(--line); }
  .priority-ranking-table tr:last-child { border-bottom:0; }
  .priority-ranking-table td { display:block; padding:0; border:0; }
  .priority-ranking-table .rank-cell { grid-column:4; grid-row:1; text-align:right; }
  .priority-ranking-table .rank-cell::before { content:'#'; }
  .priority-ranking-table .priority-resident { grid-column:1/4; grid-row:1; }
  .priority-ranking-table .avatar { display:none; }
  .priority-ranking-table td[data-label] { text-align:left; font-variant-numeric:tabular-nums; }
  .priority-ranking-table td[data-label]::before { content:attr(data-label); display:block; margin-bottom:.3rem; font-size:.6875rem; font-weight:400; color:var(--muted); }
  .resident-table,.resident-table tbody { display:block; }
  .resident-table thead { display:none; }
  .resident-table tr { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.8rem; padding:1.1rem; border-bottom:1px solid var(--line); }
  .resident-table tr:last-child { border-bottom:0; }
  .resident-table td { display:block; padding:0; border:0; }
  .resident-table .resident-person { grid-column:1/-1; }
  .resident-table .login-column { grid-column:1/-1; }
  .resident-table .resident-number { font-size:1.1rem; }
  .resident-table .resident-number::before { content:attr(data-label); display:block; color:var(--muted); font-size:.75rem; margin-bottom:.2rem; }
  .resident-table .resident-actions { grid-column:1/-1; }
  .row-actions { justify-content:flex-start; }
  dialog { width:calc(100% - 1.25rem); max-height:calc(100vh - 1.25rem); max-height:calc(100dvh - 1.25rem); border-radius:1rem; }
  .dialog-header { padding:1rem 1rem .75rem; }
  .dialog-header h2 { font-size:1.125rem; }
  .dialog-body { padding:1.1rem; }
  .dialog-footer { padding:1rem 1.1rem; }
  .form-grid { grid-template-columns:minmax(0,1fr); gap:1rem; }
  .field-input,.field-select,.filter-select,.priority-select,.search-input { font-size:1rem; }
  .field-label { font-size:.8125rem; }
  .patient-detail-heading { gap:.75rem; }
  .patient-detail-name { font-size:1.2rem; }
  .detail-grid { gap:1.15rem 1rem; }
  .notes-section { padding:.8rem; }
  .notes-heading { gap:.25rem; }
  .notes-heading .button { padding:.6rem .65rem; }
  .notes-input { min-height:8.5rem; }
  .assign-row { flex-direction:column; align-items:stretch; }
  .assign-row .button { align-self:flex-end; }
  .dialog-actions { align-items:stretch; flex-direction:column; }
  .timeline-entry { flex-direction:column; gap:.2rem; padding:.6rem 0; }
  .credential-row { gap:.5rem; }
  .credential-row .button { padding:.6rem .7rem; }
  .credential-row .button .icon { display:none; }
  .toast-region { bottom:calc(.75rem + env(safe-area-inset-bottom)); max-width:calc(100% - 1.25rem); }
  .toast { gap:.6rem; padding:.5rem .5rem .5rem .8rem; }
  .toast-message { font-size:.8125rem; }
}
@media (max-width:380px) {
  .topbar-inner { padding:.65rem .75rem; }
  .brand-name { max-width:11rem; }
  .workspace { padding-left:.75rem; padding-right:.75rem; }
  .heading-actions { gap:.5rem; }
  .heading-actions .button { padding:.625rem .75rem; }
  .progress-summary { grid-template-columns:1fr; }
  .summary-card { display:flex; align-items:center; justify-content:space-between; }
  .summary-number { margin:0; }
  .detail-grid { grid-template-columns:minmax(0,1fr); }
  .patient-detail-heading { flex-direction:column; gap:.65rem; }
  .notes-heading { flex-wrap:wrap; }
  .notes-heading .button { margin-left:auto; }
  .history-table th:first-child,.history-table td:first-child { width:49%; }
  .history-table .field-input { width:3.5rem; }
}
@media (prefers-reduced-motion:reduce) {
  *,*::before,*::after { scroll-behavior:auto !important; transition:none !important; animation:none !important; }
  button:not(:disabled):active,a.button:active { transform:none; }
}
@media (prefers-reduced-transparency:reduce) {
  .topnav { background:var(--surface); backdrop-filter:none; -webkit-backdrop-filter:none; }
}
@media (prefers-contrast:more) {
  :root { --line:#737780; --muted:#454951; }
  :root[data-theme="dark"] { --line:#979ca6; --muted:#d1d4db; }
  .topnav { background:var(--surface); backdrop-filter:none; -webkit-backdrop-filter:none; }
  .status-pill { border:1px solid currentColor; }
}
@media (prefers-contrast:more) and (prefers-color-scheme:dark) {
  :root:not([data-theme="light"]) { --line:#979ca6; --muted:#d1d4db; }
}
