/* Brand variables (--brand, --on-brand, --panel, --on-panel, --accent) are set
   per page from the white-label settings; neutral tokens below are fixed. */
:root {
    --text: #0f172a;
    --muted: rgba(15, 23, 42, 0.55);
    --canvas: #f4f6f8;
    --surface: #ffffff;
    --border: rgba(15, 23, 42, 0.12);
    --danger: #a32d2d;
    --danger-bg: #fcebeb;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    color: var(--text);
    background: var(--canvas);
    font-family: var(--font);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ── Logo ─────────────────────────────────────────────────────────────────── */
.logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    flex: none;
    overflow: hidden;
}
.logo svg { width: 60%; height: 60%; }
.logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }

.brand-row { display: flex; align-items: center; gap: 10px; }

/* ── Login (design A: brand panel + form) ─────────────────────────────────── */
.login {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.brand-panel {
    background: var(--panel);
    color: var(--on-panel);
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.brand-name { font-size: 20px; font-weight: 600; }
.tagline { font-size: 34px; line-height: 1.2; font-weight: 600; margin: 0 0 24px; max-width: 460px; }
.features { list-style: none; padding: 0; margin: 0; }
.features li { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-size: 16px; opacity: 0.92; }
.features svg { width: 20px; height: 20px; flex: none; }
.portal-label { margin: 0; font-size: 13px; opacity: 0.75; }

.form-panel {
    background: var(--surface);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 48px 24px 0;
}
.form-wrap { width: 100%; max-width: 380px; margin: auto 0; }
.form-wrap h2 { font-size: 26px; margin: 0 0 4px; }
.compact-brand { display: none; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 28px; }

form { margin-top: 24px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 16px 0 6px; }
input[type=text], input[type=password] {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--canvas);
    color: var(--text);
}
input:focus { outline: 2px solid var(--brand); outline-offset: 1px; background: var(--surface); }

.password { position: relative; }
.password input { padding-right: 64px; }
.reveal {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    border: 0; background: none; color: var(--brand); font-weight: 600; cursor: pointer; padding: 6px;
}
.remember { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--muted); }
.remember input { accent-color: var(--brand); }

button.primary {
    width: 100%;
    margin-top: 22px;
    padding: 13px;
    border: 0;
    border-radius: 10px;
    background: var(--brand);
    color: var(--on-brand);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }

.alert {
    margin-top: 18px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 14px;
}
.notice { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.notice svg { width: 14px; height: 14px; }

.powered-by {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    padding: 18px;
}

/* Narrow screens: hide the brand panel, show a compact brand row */
@media (max-width: 820px) {
    .login { grid-template-columns: 1fr; }
    .brand-panel { display: none; }
    .compact-brand { display: flex; }
    .compact-brand .logo { color: #fff; }
}

/* ── Choose your hospital ─────────────────────────────────────────────────── */
.picker-page { min-height: 100vh; display: flex; flex-direction: column; }
.picker {
    flex: 1;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 72px 24px 24px;
}
.picker-brand { margin-bottom: 40px; font-size: 14px; }
.picker h1 { font-size: 30px; margin: 0 0 8px; }
.picker .lead { font-size: 16px; margin: 0 0 28px; }

.hospital-grid { display: grid; gap: 12px; margin: 0; }
.hospital-card {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 18px 20px;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    font: inherit;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.hospital-card:hover, .hospital-card:focus-visible {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent);
    outline: none;
}
.hospital-card:active { transform: scale(0.995); }
.hospital-card.current { border-color: var(--brand); }

.hospital-tile {
    width: 48px; height: 48px; flex: none;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--brand) 12%, white);
    color: var(--brand);
    font-weight: 700;
    font-size: 17px;
}
.hospital-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.hospital-name { font-size: 17px; font-weight: 600; }
.hospital-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
    font-size: 11px; font-weight: 600;
    padding: 2px 8px; border-radius: 999px;
    background: var(--canvas); color: var(--muted);
    white-space: nowrap;
}
.current-badge { background: color-mix(in srgb, var(--brand) 12%, white); color: var(--brand); }
.chevron { width: 20px; height: 20px; color: var(--muted); flex: none; }
.hospital-card:hover .chevron { color: var(--brand); }

.picker-signout { margin-top: 28px; display: flex; align-items: center; gap: 8px; font-size: 14px; }


/* ── Signed-in shell: top bar + tabs ──────────────────────────────────────── */
.app-page { min-height: 100vh; display: flex; flex-direction: column; }
/* Soft brand glow from the top-left fading to white — same as the iPad app
   (RadialGradient at (-1,-0.9), radius 1.7, stops 0/.2/.6/.95). Built from the
   brand accent so white-label tenants get their own colors. */
.app-page, .picker-page {
    background-color: #fff;
    background-image: radial-gradient(170vmin 170vmin at 0% 5%,
        color-mix(in srgb, var(--accent) 58%, white) 0%,
        color-mix(in srgb, var(--accent) 17%, white) 20%,
        color-mix(in srgb, var(--accent) 17%, white) 60%,
        #fff 95%);
    background-attachment: fixed;
}
.app-header {
    background: rgba(255, 255, 255, 0.55); border-bottom: 1px solid rgba(255, 255, 255, 0.7);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    position: sticky; top: 0; z-index: 20;
}
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 24px 8px; }
.topbar-name { font-weight: 700; font-size: 16px; }
.topbar form { margin: 0; display: flex; align-items: center; gap: 14px; }
@media (max-width: 900px) { .lock-btn span { display: none; } }
.tabs { display: flex; gap: 4px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs a {
    padding: 10px 12px 11px; font-size: 14px; font-weight: 600; color: var(--muted);
    text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
button.link, a.link {
    border: 0; background: none; color: var(--brand); font-weight: 600; cursor: pointer; padding: 0;
    font-size: 14px; text-decoration: none; font-family: inherit;
}

.page { flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; }
.page-head p { margin: 0; }
.empty-state { max-width: 560px; margin: 64px auto; text-align: center; }
.loading { padding: 32px; text-align: center; color: var(--muted); font-size: 14px; }
.center { text-align: center; }

/* ── Buttons, pills, tags ─────────────────────────────────────────────────── */
.app-page svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 14px; border: 0; border-radius: 10px; cursor: pointer;
    background: var(--brand); color: var(--on-brand); font: 600 13px/1.2 var(--font); white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
a.btn { text-decoration: none; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.soft { background: color-mix(in srgb, var(--brand) 10%, white); color: var(--brand); }
.btn.amber { background: #b45309; color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.pill-link {
    display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--brand) 25%, white); background: color-mix(in srgb, var(--brand) 7%, white);
    color: var(--brand); font: 600 12px/1.2 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.pill-link svg { width: 13px; height: 13px; }
.pill-link.indigo { background: #e0e7ff; border-color: #c7d2fe; color: #3730a3; }
.pill-link.danger { background: var(--danger-bg); border-color: #f3c7c7; color: var(--danger); }
.icon-btn {
    width: 32px; height: 32px; flex: none; display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 9px; background: var(--canvas); color: var(--muted); cursor: pointer; font-size: 14px;
}
.icon-btn svg { width: 18px; height: 18px; }
.tag {
    display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; vertical-align: middle;
    font-size: 11px; font-weight: 600; background: var(--canvas); color: var(--muted);
}
.tag.ok { background: #dcfce7; color: #15803d; }
.tag.warn { background: #fef3c7; color: #b45309; }
.count {
    display: inline-block; min-width: 20px; padding: 1px 6px; margin-left: 4px; border-radius: 999px;
    font-size: 11px; font-weight: 700; text-align: center;
    background: color-mix(in srgb, var(--brand) 14%, white); color: var(--brand);
}
.count:empty { display: none; }
.avatar {
    width: 36px; height: 36px; flex: none; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--brand) 12%, white); color: var(--brand); font-weight: 700; font-size: 13px;
}
.avatar.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; }
.avatar.lg { width: 56px; height: 56px; border-radius: 14px; font-size: 19px; }

/* ── Segmented control ────────────────────────────────────────────────────── */
.segmented {
    display: flex; gap: 4px; padding: 4px; margin-bottom: 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.segmented button {
    flex: 1; padding: 8px 10px; border: 0; border-radius: 9px; background: none; cursor: pointer;
    font: 600 13px/1.2 var(--font); color: var(--text);
}
.segmented button[aria-selected=true] { background: var(--brand); color: var(--on-brand); }
.segmented button[aria-selected=true] .count { background: rgba(255,255,255,0.25); color: inherit; }
.segmented.small button { padding: 7px 8px; font-size: 12px; }

/* ── Care Queue: list + conversation ──────────────────────────────────────── */
.queue-layout {
    display: grid; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); gap: 20px;
    height: calc(100vh - 210px); min-height: 520px;
}
.queue-list { display: flex; flex-direction: column; min-height: 0; }
.list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 2px 4px 16px 2px; }
.list-empty { padding: 40px 16px; text-align: center; }
.list-empty p { margin: 6px 0 14px; }

.q-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px;
    cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.q-card:hover { border-color: color-mix(in srgb, var(--brand) 45%, white); }
.q-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.q-card.claimed { border-color: #fde68a; }
.q-card.assigned { border-color: #bae6fd; }
.q-card.selected, .h-row.selected { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card-title strong { overflow: hidden; text-overflow: ellipsis; }
.claim-chip {
    display: flex; align-items: center; gap: 6px; margin-top: 10px; padding: 6px 10px; border-radius: 8px;
    font-size: 12px; font-weight: 600;
}
.claim-chip svg { width: 14px; height: 14px; flex: none; }
.claim-chip.ok { background: #f0fdf4; color: #15803d; }
.claim-chip.warn { background: #fef3c7; color: #b45309; }
.claim-chip.info { background: #f0f9ff; color: #0369a1; }
.chip-tag { margin-left: auto; padding: 1px 7px; border-radius: 6px; background: #e0f2fe; font-size: 11px; }
.msg-preview {
    margin: 10px 0 0; padding: 9px 11px; border-radius: 10px; background: var(--canvas); font-size: 13px; line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.msg-preview.one { -webkit-line-clamp: 1; background: none; padding: 0; color: var(--muted); }
.reason { margin: 8px 0 0; font-size: 12px; font-style: italic; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.handled { display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; }
.pulse { animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: 0.35; } to { opacity: 1; } }

.group-head {
    display: flex; align-items: center; gap: 6px; width: 100%; padding: 10px 2px 4px; border: 0; background: none;
    cursor: pointer; font: 700 12px/1 var(--font); letter-spacing: 0.03em; color: var(--muted); text-transform: uppercase;
}
.group-head svg { width: 12px; height: 12px; transition: transform 0.15s; }
.group-head.open svg { transform: rotate(90deg); }
.group-head .count { background: var(--canvas); color: var(--muted); }
.h-row {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--border);
}

.chat-pane {
    min-height: 0; display: flex; flex-direction: column; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
}
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 24px; }
.chat-empty svg { width: 40px; height: 40px; opacity: 0.5; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.chat-head .back { display: none; }
.head-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.status { margin-left: 6px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; vertical-align: middle; }
.status.pending { background: #e0f2fe; color: #0369a1; }
.status.mine { background: #dcfce7; color: #15803d; }
.status.other { background: var(--canvas); color: var(--muted); }
.status.other.warn { background: #fef3c7; color: #b45309; }
.status.done { background: var(--canvas); color: var(--muted); }
.chat-body { flex: 1; overflow-y: auto; padding: 18px 18px 8px; background: #f6f7fb; display: flex; flex-direction: column; gap: 10px; }
.bubble-row { display: flex; flex-direction: column; max-width: 72%; }
.bubble-row.patient { align-self: flex-start; align-items: flex-start; }
.bubble-row.staff { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.patient .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.staff .bubble { background: var(--brand); color: var(--on-brand); border-bottom-right-radius: 4px; }
.bubble-meta { font-size: 11px; color: var(--muted); margin: 3px 4px 0; }
.sys-line { align-self: center; display: flex; align-items: center; gap: 6px; font-size: 12px; font-style: italic; color: var(--muted); }
.sys-line svg { width: 13px; height: 13px; }
.request-note { align-self: center; max-width: 80%; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px dashed var(--border); display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.call-card { align-self: center; width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.call-top { display: flex; align-items: center; gap: 10px; }
.call-icon { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: #e0e7ff; color: #3730a3; flex: none; }
.call-icon svg { width: 16px; height: 16px; }
.call-details { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.players { display: flex; flex-wrap: wrap; gap: 8px; }
.players audio { width: 100%; height: 36px; }
.transcript { margin: 0; max-height: 220px; overflow: auto; padding: 10px; border-radius: 10px; background: var(--canvas); font: 13px/1.5 var(--font); white-space: pre-wrap; }
.chat-foot { border-top: 1px solid var(--border); padding: 12px 14px; background: var(--surface); }
.chat-foot textarea {
    width: 100%; resize: none; padding: 11px 13px; border: 1px solid var(--border); border-radius: 12px;
    font: 14px/1.45 var(--font); color: var(--text); background: var(--canvas); max-height: 180px;
}
.chat-foot textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; background: var(--surface); }
.composer-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.composer-actions .hint { flex: 1; text-align: right; }
.foot-gate { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.foot-note { margin: 0; text-align: center; font-size: 13px; color: var(--muted); }

/* ── Dialogs ──────────────────────────────────────────────────────────────── */
dialog.sheet {
    width: min(480px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 48px)); padding: 0;
    border: 0; border-radius: 18px; box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25); color: var(--text);
}
dialog.sheet.wide { width: min(640px, calc(100vw - 32px)); }
dialog.sheet.narrow { width: min(400px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(15, 23, 42, 0.4); }
dialog[open].sheet { display: flex; flex-direction: column; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.sheet-head h2, .sheet-body h2 { margin: 0 0 2px; font-size: 18px; }
.sheet-head p { margin: 0; }
.sheet-body { padding: 16px 20px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.note { padding: 9px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.note.ok { background: #f0fdf4; color: #15803d; }
.note.warn { background: #fff7ed; color: #c2410c; }
.staff-row {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; font: inherit; color: var(--text);
}
.staff-row:hover { border-color: var(--brand); }
.staff-row.primary { background: #f0fdf4; border-color: #bbf7d0; }
.staff-row .chev { width: 16px; height: 16px; color: var(--muted); }
.day-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.day-chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: 600 12px/1 var(--font); color: var(--text); }
.day-chip.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.hours { display: flex; flex-direction: column; gap: 2px; }
.hour-row { display: grid; grid-template-columns: 56px 1fr 30px 28px 30px; align-items: center; gap: 8px; padding: 4px 2px; font-size: 13px; }
.hour-row .hour { color: var(--muted); font-weight: 600; }
.hour-row.on .hour { color: var(--text); }
.hour-row .bar { height: 8px; border-radius: 99px; background: var(--canvas); overflow: hidden; }
.hour-row .bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.hour-row .value { text-align: center; font-weight: 700; }
.step { width: 30px; height: 28px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 16px; color: var(--text); }
.step:disabled { opacity: 0.4; cursor: default; }

.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
    padding: 11px 18px; border-radius: 12px; background: #0f172a; color: #fff; font-size: 14px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25); max-width: calc(100vw - 32px);
}

/* ── Patient chart ────────────────────────────────────────────────────────── */
.chart-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.chart-banner { display: flex; gap: 16px; align-items: flex-start; padding: 20px; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.chart-banner h1 { margin: 0 0 6px; font-size: 24px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.alerts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 8px; font-size: 13px; color: var(--danger); }
.alert-chip { padding: 2px 9px; border-radius: 999px; background: var(--danger-bg); color: var(--danger); font-weight: 600; font-size: 12px; }
.chart-grid { columns: 2 380px; column-gap: 18px; }
.chart-card { break-inside: avoid; margin: 0 0 18px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.chart-card h2 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 4px; }
.chart-card h3 { margin: 12px 0 4px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.chart-list { list-style: none; margin: 0; padding: 0; }
.chart-list > li { padding: 8px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; }
.chart-list > li:first-child { border-top: 0; padding-top: 0; }
.li-main { font-weight: 600; font-size: 14px; }
.chart-list > li > button.link, .chart-list > li > .chip-row { align-self: flex-start; }
.answer { font-size: 13px; padding: 6px 9px; border-radius: 8px; background: #f0fdf4; }
.meds { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.vitals { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.vital { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 10px; background: var(--canvas); }
.vital strong { font-size: 18px; }
.unit { font-size: 12px; font-weight: 500; color: var(--muted); }
.lab-group { border-top: 1px solid var(--border); padding: 6px 0; }
.lab-group:first-of-type { border-top: 0; }
.lab-group summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 0; }
table.labs { width: 100%; border-collapse: collapse; font-size: 13px; margin: 4px 0; }
table.labs td { padding: 4px 6px; border-top: 1px solid var(--canvas); }
table.labs tr.flag td { color: var(--danger); font-weight: 600; }

/* ── Shared form bits ───────────────────────────────────────────────────── */
input.field, textarea.field, select.field, .field {
    width: 100%; padding: 10px 12px; font: 14px/1.4 var(--font); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
input.field:focus, textarea.field:focus, select.field:focus { outline: 2px solid var(--brand); outline-offset: 0; background: var(--surface); }
.field:disabled { background: var(--canvas); color: var(--muted); }
textarea.field { resize: vertical; }
select.field { appearance: auto; }
.sheet-body label, .form-field label { margin: 4px 0 2px; font-size: 12px; color: var(--muted); }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text); margin: 0; cursor: pointer; }
.check-row input { accent-color: var(--brand); width: 16px; height: 16px; }
.check-row.inline { white-space: nowrap; }
.check-list { display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow-y: auto; }
.check-list .check-row { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.card-row h2 { margin: 0; }
.card-row.end { justify-content: flex-end; margin: 12px 0 0; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); }
.pick-list { display: flex; flex-direction: column; gap: 8px; }
.progress { height: 4px; border-radius: 99px; background: var(--canvas); margin-top: 8px; width: 220px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brand); }
dl.summary { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0 0 12px; font-size: 14px; }
dl.summary dt { color: var(--muted); }
dl.summary dd { margin: 0; font-weight: 600; }
dl.summary.intake dd { font-weight: 500; }
.span-all { grid-column: 1 / -1; margin: 0; }
.tag.info { background: #e0f2fe; color: #0369a1; }
.tag.bad { background: var(--danger-bg); color: var(--danger); }
.tag.good { background: #dcfce7; color: #15803d; }
.btn.blue { background: #2563eb; color: #fff; }
.btn.orange { background: #ea580c; color: #fff; }
.danger-text { color: var(--danger) !important; }
.pre { white-space: pre-wrap; }
.avatar.indigo { background: #e0e7ff; color: #4f46e5; }
.audit { font-weight: 600; color: var(--muted); }
.audit.info { color: #0891b2; }
.audit.good { color: #059669; }
.audit.bad { color: #dc2626; }
.appt-status {
    display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; vertical-align: middle;
    color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); white-space: nowrap;
}
.toolbar { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.toolbar .field { max-width: 420px; }

/* ── Date & slot pickers ──────────────────────────────────────────────────── */
.date-strip, .day-pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.date-pill, .day-pill {
    flex: none; min-width: 54px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px;
    border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: 12px/1.2 var(--font); color: var(--muted);
}
.date-pill strong, .day-pill strong { font-size: 16px; color: var(--text); }
.day-pills { display: grid; grid-template-columns: repeat(7, 1fr); }
.day-pill { min-width: 0; }
.day-pill.has { background: color-mix(in srgb, var(--brand) 8%, white); border-color: color-mix(in srgb, var(--brand) 25%, white); }
.day-pill.today { border: 1.5px solid var(--brand); }
.day-pill.dirty::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #d97706; }
.date-pill.active, .day-pill.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.date-pill.active strong, .day-pill.active strong { color: var(--on-brand); }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.slot {
    padding: 9px 6px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--brand) 30%, white);
    background: color-mix(in srgb, var(--brand) 5%, white); color: var(--brand); font: 600 13px/1.2 var(--font); cursor: pointer;
}
.slot:hover:not(:disabled) { border-color: var(--brand); }
.slot.booked { background: var(--canvas); border-color: var(--border); color: var(--muted); text-decoration: line-through; cursor: default; }
.slot.toggle { background: var(--surface); border-color: var(--border); color: var(--text); }
.slot.toggle.active { background: color-mix(in srgb, var(--brand) 16%, white); border-color: color-mix(in srgb, var(--brand) 45%, white); color: var(--brand); }
.slot.active:not(.toggle) { background: var(--brand); color: var(--on-brand); }

/* ── Staff Schedule ───────────────────────────────────────────────────────── */
.view-switch { max-width: 560px; }
.split { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.split-list .list { overflow: visible; padding: 0; }
.split-list p { margin: 0 0 8px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; min-height: 320px; display: flex; flex-direction: column; gap: 14px; }
.panel > .chat-empty { margin: auto; }
.staff-row.current { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
.editor-head { display: flex; align-items: center; gap: 12px; }
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.editor-info { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.editor-slots { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.editor-foot { display: flex; justify-content: flex-end; position: sticky; bottom: 0; background: var(--surface); padding-top: 6px; }
.date-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.date-label { position: relative; font-size: 17px; font-weight: 700; margin: 0; padding: 6px 10px; border-radius: 10px; cursor: pointer; color: var(--text); }
.date-label:hover { background: var(--canvas); }
.date-label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 14px; }
.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.day-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 9px; border-radius: 8px; font: 600 12px/1.2 var(--font); border: 1px solid transparent; }
.chip.free { background: var(--surface); border-color: color-mix(in srgb, var(--brand) 35%, white); color: var(--brand); cursor: pointer; }
.chip.free:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 8%, white); }
.chip.free:disabled { opacity: 0.5; cursor: default; }
.chip.booked { background: var(--brand); color: var(--on-brand); }
.chip.checked { background: #0891b2; color: #fff; }
.chip.done { background: #059669; color: #fff; }
.segmented.inline { display: inline-flex; margin-bottom: 14px; }
.appt-day h3 { display: flex; align-items: center; gap: 6px; margin: 18px 0 8px; font-size: 14px; color: var(--muted); }
.appt-row, .appt-card {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 8px; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--border);
}
.appt-row.cancelled, .appt-card.cancelled { background: #fef2f2; border-color: #fecaca; }
.appt-row.cancelled strong { text-decoration: line-through; }
.time-box {
    flex: none; min-width: 72px; padding: 8px; border-radius: 10px; text-align: center; font-weight: 700; font-size: 13px;
    background: color-mix(in srgb, var(--brand) 8%, white); color: var(--brand);
}
.staff-pill { align-self: flex-start; margin-top: 2px; padding: 2px 8px; border-radius: 999px; background: var(--canvas); font-size: 12px; font-weight: 600; color: var(--muted); }
.staff-pill.mine { background: color-mix(in srgb, var(--brand) 12%, white); color: var(--brand); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row-actions.wrap { justify-content: flex-start; }

/* ── My Schedule ──────────────────────────────────────────────────────────── */
.queue-layout.single { grid-template-columns: 1fr; height: auto; min-height: 0; }
.queue-layout.single .chat-pane { display: none; }
.queue-layout.single .list { overflow: visible; }
.queue-layout.single .segmented { max-width: 620px; }
.appt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 10px; margin-bottom: 6px; }
.appt-card { flex-direction: column; align-items: stretch; gap: 6px; margin: 0; }
.appt-card .card-head { align-items: center; }

/* ── Visit (SOAP) ─────────────────────────────────────────────────────────── */
.visit-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.visit-head h1 { margin: 0 0 4px; font-size: 24px; }
.visit-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; padding-bottom: 80px; }
.soap { display: flex; flex-direction: column; gap: 14px; }
.soap-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 18px 18px; }
.soap-card summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; margin-bottom: 4px; }
.soap-card summary::-webkit-details-marker { display: none; }
.soap-letter { width: 30px; height: 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand); color: var(--on-brand); font-weight: 800; }
.soap-card h3 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.soap-fields { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.vitals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.soap-field label { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--text); }
.soap-field.compact label { font-size: 12px; }
.field-meta { font-weight: 500; }
.author { padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.author.md { background: color-mix(in srgb, var(--brand) 12%, white); color: var(--brand); }
.author.rn { background: #ede9fe; color: #7c3aed; }
.visit-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 110px; }
.chart-card.side { margin: 0; }
.chart-card.side > summary { cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.visit-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; justify-content: flex-end; align-items: center; gap: 10px;
    padding: 12px 24px; background: var(--surface); border-top: 1px solid var(--border);
}
.visit-bar #save-state { margin-right: auto; }

/* ── Care: patient list + details ─────────────────────────────────────────── */
.patient-table { display: flex; flex-direction: column; gap: 8px; }
.patient-row {
    display: grid; grid-template-columns: 36px minmax(180px, 1.3fr) minmax(140px, 1fr) minmax(200px, 1.4fr) minmax(120px, 0.8fr) 110px;
    align-items: center; gap: 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface);
    border: 1px solid var(--border); text-decoration: none; color: var(--text);
}
.patient-row:hover { border-color: color-mix(in srgb, var(--brand) 45%, white); }
.patient-row.mine { border-color: color-mix(in srgb, var(--brand) 40%, white); }
.p-col { display: flex; flex-direction: column; gap: 2px; font-size: 13px; min-width: 0; }
.p-col .tag { align-self: flex-start; margin: 2px 0 0; }
.banner-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; align-self: flex-start; }
.btn-select { width: auto; font-weight: 600; font-size: 13px; padding: 9px 12px; }
.subtabs { display: flex; gap: 4px; overflow-x: auto; margin: 0 0 16px; border-bottom: 1px solid var(--border); }
.subtabs button {
    padding: 10px 12px; border: 0; background: none; cursor: pointer; font: 600 14px/1 var(--font); color: var(--muted);
    border-bottom: 2px solid transparent; white-space: nowrap;
}
.subtabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.two-col.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); }
.two-col .chart-card { margin: 0; }
.rx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.rx-grid .chart-card { margin: 0; }
.summary-line { margin: 0 0 8px; font-size: 14px; line-height: 1.5; }
.chat-pane.inline { height: 560px; }
.chat-body.dialog-chat { max-height: 55vh; border-radius: 12px; }
.bubble-row.ai .bubble { background: #f5f3ff; border-color: #ddd6fe; }
.bubble .summary-line { margin: 0 0 6px; }
.bubble .summary-line:last-child { margin: 0; }
.ai-intro { margin: auto; text-align: center; max-width: 420px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.link-row {
    display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; padding: 2px 0;
    border: 0; background: none; cursor: pointer; font: inherit; color: var(--text); text-align: left;
}
.link-row:hover .li-main { color: var(--brand); }
.composer { display: flex; flex-direction: column; gap: 8px; }
.composer audio { height: 32px; vertical-align: middle; }
.rx-med { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; }
.rx-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chart-card details > summary.small { cursor: pointer; }

/* ── Add existing patient ─────────────────────────────────────────────────── */
.requests:empty { display: none; }
.requests { margin-bottom: 8px; }
.request-row { grid-template-columns: 36px minmax(0, 1fr) auto; border-style: dashed; border-color: var(--border); }
.request-row.declined { opacity: 0.85; }
.muted-avatar { background: var(--canvas); color: var(--muted); }
.staff-row.static { cursor: default; }
.staff-row.static:hover { border-color: var(--border); }

/* ── Lock button + lock screen ────────────────────────────────────────────── */
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-actions form { margin: 0; }
.lock-btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 13px/1 var(--font);
}
.lock-btn:hover { border-color: var(--brand); color: var(--brand); }
.lock-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.lock-page {
    min-height: 100vh; margin: 0; display: flex; flex-direction: column; overflow: hidden; color: #fff;
    background: linear-gradient(135deg, color-mix(in srgb, var(--panel) 85%, black), color-mix(in srgb, var(--panel) 45%, #0f172a) 60%, #0f172a);
}
.saver { position: fixed; inset: 0; overflow: hidden; cursor: pointer; }
.blob { position: absolute; border-radius: 50%; filter: blur(10px); opacity: 0.55; }
.b1 { width: 520px; height: 520px; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 70%, transparent), transparent 70%);
    top: -120px; left: -80px; animation: drift1 26s ease-in-out infinite alternate; }
.b2 { width: 600px; height: 600px; background: radial-gradient(circle, color-mix(in srgb, var(--brand) 75%, transparent), transparent 70%);
    bottom: -200px; right: -140px; animation: drift2 32s ease-in-out infinite alternate; }
.b3 { width: 420px; height: 420px; background: radial-gradient(circle, rgba(99, 102, 241, 0.55), transparent 70%);
    bottom: -60px; left: 30%; animation: drift3 22s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(28vw, 22vh) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-30vw, -24vh) scale(0.9); } }
@keyframes drift3 { to { transform: translate(-18vw, -40vh) scale(1.2); } }
@media (prefers-reduced-motion: reduce) { .blob { animation: none; } }
.lock-center { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 32px 16px; text-align: center; pointer-events: none; }
.lock-center > * { pointer-events: auto; }
.lock-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.12); font-weight: 700; font-size: 13px; }
.lock-badge svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lock-clock { margin-top: 22px; font-size: clamp(64px, 12vw, 112px); font-weight: 200; line-height: 1; letter-spacing: -0.02em; }
.lock-clock small { font-size: 22px; font-weight: 500; opacity: 0.7; margin-left: 8px; }
.lock-date { margin: 12px 0 2px; font-size: 18px; opacity: 0.85; }
.lock-hospital { margin: 0 0 40px; font-size: 14px; opacity: 0.6; }
.lock-hint { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lock-avatar { width: 68px; height: 68px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.3); font-size: 22px; font-weight: 800; }
.lock-hint strong { font-size: 18px; }
.lock-reveal { margin-top: 16px; border: 0; background: none; color: rgba(255, 255, 255, 0.7); font: 14px var(--font); cursor: pointer; }
.lock-reveal:hover { color: #fff; }
.lock-panel { display: none; width: min(380px, 100%); margin: 0; padding: 22px 22px 12px; border-radius: 20px; background: #fff;
    color: var(--text); text-align: left; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); }
.lock-panel label { margin: 0 0 10px; font-size: 15px; font-weight: 700; color: var(--text); text-align: center; }
.lock-panel .alert { margin-top: 10px; }
.unlock-btn { width: 100%; margin-top: 14px; padding: 12px; font-size: 15px; }
.lock-signout { margin: 10px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.panel-open .lock-hint { display: none; }
.panel-open .lock-panel { display: block; }
.lock-page .powered-by { position: relative; z-index: 1; color: rgba(255, 255, 255, 0.5); }

/* ── Left menu (My Schedule): flush left, full height under the header ──── */
.side-shell { flex: 1; display: flex; min-height: 0; }
.side-shell > .page { flex: 1; min-width: 0; }
.side-shell .queue-layout:not(.single) { grid-template-columns: minmax(240px, 380px) minmax(320px, 1fr); }
.side-nav {
    flex: none; width: 224px; padding: 20px 12px;
    background: rgba(255, 255, 255, 0.6); border-right: 1px solid var(--border);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.side-nav .segmented {
    position: sticky; top: 112px; flex-direction: column; gap: 4px; padding: 0; margin: 0;
    background: none; border: 0; border-radius: 0;
}
.side-nav .segmented button {
    flex: none; display: flex; justify-content: space-between; align-items: center;
    padding: 11px 14px; text-align: left; font-size: 14px; border-radius: 10px;
}
.side-nav .segmented button:hover:not([aria-selected=true]) { background: color-mix(in srgb, var(--brand) 8%, white); }

/* ── Small screens ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .page { padding: 16px; }
    .topbar { padding: 10px 16px 6px; }
    .topbar-who { display: none; }
    .tabs { padding: 0 8px; }
    .queue-layout { grid-template-columns: 1fr; height: auto; min-height: 0; }
    .list { overflow: visible; }
    .chat-pane { display: none; }
    .queue-layout.chat-open .chat-pane {
        display: flex; position: fixed; inset: 0; z-index: 30; border-radius: 0; border: 0;
    }
    .chat-head .back { display: inline-flex; }
    .chat-head .close { display: none; }
    .bubble-row { max-width: 86%; }
    .composer-actions .hint { display: none; }
    .composer-actions { justify-content: space-between; }
    .page-head { align-items: flex-start; flex-direction: column; }
    .split, .two-col, .two-col.wide-left, .visit-layout { grid-template-columns: 1fr; }
    .visit-side { position: static; }
    .patient-row { grid-template-columns: 36px 1fr; }
    .patient-row .p-col, .patient-row > span:last-child:empty { grid-column: 2; }
    .patient-row .p-col.narrow { display: none; }
    .appt-grid, .day-grid { grid-template-columns: 1fr; }
    .chart-banner { flex-wrap: wrap; }
    .banner-actions { margin-left: 0; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .appt-row { flex-wrap: wrap; }
}

/* Left menu on narrow screens: a scrollable strip under the header */
@media (max-width: 900px) {
    .side-shell { flex-direction: column; }
    .side-nav { width: auto; padding: 8px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
    .side-nav .segmented { position: static; flex-direction: row; overflow-x: auto; }
    .side-nav .segmented button { white-space: nowrap; }
}

/* ── Patient list: slide-in panel from the left ───────────────────────────── */
.drawer-backdrop {
    position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, 0.35);
    opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.drawer {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 41; width: 99vw;
    display: flex; flex-direction: column; background: var(--canvas);
    box-shadow: 12px 0 40px rgba(15, 23, 42, 0.2); border-radius: 0 18px 18px 0; overflow: hidden;
    transform: translateX(-104%); transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.drawer-head {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.drawer-title { font-size: 16px; }
.drawer-frame { flex: 1; width: 100%; border: 0; background: transparent; }
body.drawer-open { overflow: hidden; }
body.drawer-open .drawer { transform: translateX(0); }
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { .drawer, .drawer-backdrop { transition: none; } }

/* Patient page inside the drawer: no app chrome, tighter padding */
.app-page.embedded .page { padding: 16px 20px; }

/* ── Care Queue: left menu action + cards grid ────────────────────────────── */
.side-stack { position: sticky; top: 112px; display: flex; flex-direction: column; gap: 4px; }
.side-stack .segmented { position: static; }
.side-link {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 11px 14px; border: 0; border-radius: 10px; background: none; cursor: pointer;
    font: 600 14px/1.2 var(--font); color: var(--text); text-align: left;
}
.side-link svg { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.side-link:hover { background: color-mix(in srgb, var(--brand) 8%, white); }
.side-sep { height: 1px; margin: 4px 6px; background: var(--border); border: 0; }
.q-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; align-items: start; }

/* ── Care Queue: conversation slides up from the bottom ───────────────────── */
.sheet-backdrop {
    position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, 0.35);
    opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.chat-sheet {
    position: fixed; left: 50%; bottom: 0; z-index: 41;
    width: min(1100px, 100vw - 32px); height: min(86vh, 900px);
    display: flex; flex-direction: column;
    transform: translate(-50%, 104%); transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.chat-sheet .chat-pane {
    display: flex; flex: 1; border-radius: 18px 18px 0 0; border-bottom: 0;
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.22);
}
body.chat-open { overflow: hidden; }
body.chat-open .chat-sheet { transform: translate(-50%, 0); }
body.chat-open .sheet-backdrop { opacity: 1; pointer-events: auto; }
@media (max-width: 900px) {
    .side-stack { position: static; flex-direction: row; align-items: center; }
    .side-link { width: auto; white-space: nowrap; }
    .side-sep { width: 1px; height: 24px; margin: 0 4px; }
    .q-grid { grid-template-columns: 1fr; }
    .chat-sheet { width: 100vw; height: 92vh; }
    .chat-sheet .chat-head .close { display: inline-flex; }
    .chat-sheet .chat-head .back { display: none; }
}
@media (prefers-reduced-motion: reduce) { .chat-sheet, .sheet-backdrop { transition: none; } }

/* ── Patient chart: slides up from the bottom, above an open conversation ── */
.chart-backdrop {
    position: fixed; inset: 0; z-index: 44; background: rgba(15, 23, 42, 0.35);
    opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.chart-sheet {
    position: fixed; left: 50%; bottom: 0; z-index: 45;
    width: min(1240px, 100vw - 24px); height: 92vh;
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--canvas); border-radius: 18px 18px 0 0; box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.25);
    transform: translate(-50%, 104%); transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-frame { flex: 1; width: 100%; border: 0; background: transparent; }
body.chart-open { overflow: hidden; }
body.chart-open .chart-sheet { transform: translate(-50%, 0); }
body.chart-open .chart-backdrop { opacity: 1; pointer-events: auto; }
@media (max-width: 900px) { .chart-sheet { width: 100vw; height: 96vh; } }
@media (prefers-reduced-motion: reduce) { .chart-sheet, .chart-backdrop { transition: none; } }

/* Conversation: toggle between this request's messages and the whole thread */
.thread-toggle {
    align-self: center; margin: 0 auto 12px; padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--brand); font: 600 12px var(--font); cursor: pointer;
}
.thread-toggle:hover { background: color-mix(in srgb, var(--brand) 8%, white); }
