:root {
  color-scheme: light;
  --bg-a: #d7e2ef;
  --bg-b: #ffe0ad;
  --surface: rgba(255, 252, 246, .84);
  --surface-strong: #fffdf9;
  --inset: #f0ece7;
  --ink: #261d18;
  --muted: #766b63;
  --border: rgba(80, 60, 46, .14);
  --teal: #0b7772;
  --teal-soft: #d9eeeb;
  --amber: #d58d38;
  --amber-ink: #2d1b0a;
  --red: #b54640;
  --green: #268562;
  --green-dark: #1d6c4e;
  --shadow: 0 22px 60px rgba(49, 39, 33, .12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg-a: #263447;
    --bg-b: #81501e;
    --surface: rgba(43, 33, 27, .86);
    --surface-strong: #31251f;
    --inset: #211914;
    --ink: #fff8ef;
    --muted: #c3b5a9;
    --border: rgba(255, 238, 220, .14);
    --teal: #73d0c5;
    --teal-soft: #173e3b;
    --amber: #e4a358;
    --amber-ink: #281708;
    --red: #f2837d;
    --green: #3aa77f;
    --green-dark: #2d8968;
    --shadow: 0 24px 70px rgba(0, 0, 0, .28);
  }
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: linear-gradient(135deg, var(--bg-a), var(--bg-b)) fixed; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px; }
.login-card { width: min(440px, 100%); display: grid; gap: 26px; padding: 30px; border: 1px solid var(--border); border-radius: 26px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(22px); }
.product-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 9px; color: var(--muted); font-size: 11px; text-align: center; }
.product-footer a { color: var(--teal); font-weight: 750; text-decoration: none; }
.product-footer a:hover, .product-footer a:focus-visible { text-decoration: underline; }
.app-footer { width: min(1460px, calc(100% - 32px)); margin: -34px auto 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 300; white-space: nowrap; }
.brand b { font-weight: 800; }
.brand-copy { display: grid; gap: 0; line-height: 1; }
.brand-copy small { margin-top: 3px; color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: .08em; }
.brand-mark { position: relative; width: 38px; height: 38px; display: inline-block; border-radius: 50%; background: #075d64; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.brand-mark i { position: absolute; width: 8px; height: 8px; background: white; border-radius: 50%; }
.brand-mark i:nth-child(1) { left: 8px; top: 7px; }
.brand-mark i:nth-child(2) { right: 7px; top: 15px; }
.brand-mark i:nth-child(3) { left: 9px; bottom: 6px; }
.brand-mark::after { content: ""; position: absolute; inset: 7px 10px 7px 8px; border: 2px solid white; border-right-color: transparent; border-radius: 50%; }
h1, h2, p { margin: 0; }
h1 { margin-bottom: 7px; font-size: 28px; }
h2 { font-size: 19px; }
p, small { color: var(--muted); line-height: 1.45; }
.stack, .dialog-card { display: grid; gap: 15px; }
label { min-width: 0; display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 650; }
input, select, textarea { min-width: 0; width: 100%; min-height: 42px; padding: 9px 11px; color: var(--ink); background: var(--surface-strong); border: 1px solid var(--border); border-radius: 11px; outline: none; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber), transparent 76%); }
.primary, .quiet { min-height: 42px; padding: 9px 15px; border-radius: 11px; border: 1px solid transparent; font-weight: 750; }
.primary { color: white; background: var(--amber); }
.primary:hover { filter: brightness(1.05); }
.quiet { color: var(--ink); background: var(--surface-strong); border-color: var(--border); }
.close-case-button { min-height: 42px; padding: 9px 15px; color: white; border: 1px solid #2868d7; border-radius: 11px; background: #2868d7; font-weight: 750; }
.close-case-button:hover { background: #1f56ba; }
.compact { min-height: 38px; white-space: nowrap; }
.form-error { min-height: 18px; color: var(--red); font-size: 13px; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; z-index: 20; top: 0; display: grid; grid-template-columns: minmax(max-content, 1fr) minmax(280px, 540px) minmax(max-content, 1fr); align-items: center; gap: 20px; min-height: 68px; padding: 10px clamp(16px, 4vw, 54px); background: color-mix(in srgb, var(--surface-strong), transparent 7%); border-bottom: 1px solid var(--border); backdrop-filter: blur(20px); }
.account { position: relative; display: flex; align-items: center; color: var(--muted); font-size: 13px; }
.topbar .account { justify-self: end; }
.topbar-actions { position: relative; justify-self: end; display: flex; align-items: center; gap: 7px; }
.notification-menu { position: relative; }
.notification-button { position: relative; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; color: var(--ink); border: 1px solid var(--border); border-radius: 50%; background: var(--surface-strong); font-size: 17px; }
.notification-button:hover, .notification-button[aria-expanded="true"] { border-color: color-mix(in srgb, var(--teal), var(--border) 45%); background: var(--teal-soft); }
.notification-button b { position: absolute; top: -4px; right: -4px; min-width: 19px; height: 19px; padding: 2px 5px; color: white; border: 2px solid var(--surface-strong); border-radius: 999px; background: var(--red); font-size: 10px; line-height: 11px; }
.notification-dropdown { position: absolute; z-index: 42; top: calc(100% + 10px); right: 0; width: min(390px, calc(100vw - 24px)); overflow: hidden; border: 1px solid var(--border); border-radius: 18px; background: var(--surface-strong); box-shadow: var(--shadow); }
.notification-dropdown header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 15px; border-bottom: 1px solid var(--border); }
.notification-dropdown header > div { display: grid; gap: 2px; }
.notification-dropdown header small { font-size: 11px; }
.notification-dropdown header button { padding: 5px 7px; color: var(--teal); border: 0; background: transparent; font-size: 11px; font-weight: 800; }
.notification-list { max-height: min(520px, calc(100vh - 110px)); overflow-y: auto; }
.notification-item { position: relative; display: grid; gap: 5px; width: 100%; padding: 13px 15px 13px 30px; color: var(--ink); border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; }
.notification-item:hover { background: var(--inset); }
.notification-item.unread { background: color-mix(in srgb, var(--teal-soft), transparent 35%); }
.notification-item.unread::before { content: ""; position: absolute; top: 18px; left: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.notification-item strong { font-size: 13px; }
.notification-item p { overflow: hidden; font-size: 12px; line-height: 1.35; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.notification-item footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 10px; }
.notification-empty { padding: 28px 18px; text-align: center; font-size: 12px; }
.content { flex: 1; width: min(1460px, calc(100% - 32px)); margin: 28px auto 60px; }
.overview { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.overview article { display: grid; gap: 7px; padding: 18px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); backdrop-filter: blur(16px); }
.overview span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.overview strong { font-size: 27px; }
.workspace-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.tabs { display: flex; gap: 5px; padding: 4px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); }
.tab { min-height: 35px; padding: 7px 13px; color: var(--muted); border: 0; border-radius: 9px; background: transparent; font-weight: 700; }
.tab.active { color: var(--amber-ink); background: var(--amber); }
.workspace-actions { display: flex; align-items: center; gap: 8px; }
.search { display: flex; align-items: center; gap: 7px; min-width: 260px; padding-left: 11px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-strong); }
.search span { font-size: 21px; color: var(--muted); }
.search input { min-width: 0; width: 100%; border: 0; background: transparent; box-shadow: none; }
.topbar-search { justify-self: center; width: 100%; }
.panel { overflow: hidden; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.panel-heading-actions { display: flex; align-items: center; gap: 8px; }
.panel-heading p { margin-top: 3px; font-size: 13px; }
.panel-heading select { min-width: 150px; min-height: 36px; }
.filter-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--inset), transparent 54%); }
.filter-groups { min-width: 0; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; }
.filter-group { min-width: 0; display: grid; gap: 6px; }
.filter-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .055em; text-transform: uppercase; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip, .clear-filters { min-height: 30px; padding: 5px 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; background: var(--surface-strong); font-size: 12px; font-weight: 750; white-space: nowrap; }
.filter-select { min-width: 172px; min-height: 30px; padding: 5px 28px 5px 10px; color: var(--ink); border: 1px solid var(--border); border-radius: 8px; background: var(--surface-strong); font-size: 12px; font-weight: 750; }
.filter-chip:hover, .clear-filters:hover { color: var(--ink); border-color: color-mix(in srgb, var(--amber), var(--border) 55%); }
.filter-chip.active { color: var(--amber-ink); border-color: color-mix(in srgb, var(--amber), transparent 25%); background: var(--amber); }
.clear-filters { flex: none; color: var(--red); background: transparent; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1040px; }
th, td { padding: 13px 15px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); background: color-mix(in srgb, var(--inset), transparent 24%); font-size: 11px; text-transform: uppercase; letter-spacing: .045em; }
td { font-size: 13px; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-strong), transparent 45%); }
.identity { display: grid; gap: 2px; }
.identity strong { font-size: 14px; }
.identity small { color: var(--muted); }
.status { display: inline-flex; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status.waiting { color: #75460d; background: #ffe3b7; }
.status.answered { color: #075d57; background: #cfebe7; }
.status.closed { color: var(--muted); background: var(--inset); }
.status.completed { color: var(--teal); background: color-mix(in srgb, #268562, transparent 82%); }
.role { text-transform: capitalize; }
.active-dot, .inactive-dot { display: inline-flex; align-items: center; gap: 6px; }
.active-dot::before, .inactive-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.active-dot::before { background: #27966e; }
.inactive-dot::before { background: var(--muted); }
.row-action { min-height: 31px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 8px; color: var(--ink); background: var(--surface-strong); font-size: 12px; font-weight: 700; }
.row-action.danger { color: var(--red); }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.doctor-select { min-width: 165px; min-height: 34px; padding: 5px 8px; font-size: 12px; }
.empty { padding: 34px; text-align: center; }
.version-settings { display: grid; grid-template-columns: minmax(240px, .75fr) minmax(320px, 1.25fr); gap: 18px; padding: 20px; }
.version-release-card, .version-policy-form { display: grid; align-content: start; gap: 14px; padding: 20px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface-strong); }
.version-release-card strong { font-size: clamp(32px, 5vw, 54px); line-height: 1; }
.version-release-card .quiet { width: fit-content; text-decoration: none; }
.version-policy-form label { gap: 8px; }
.version-policy-form input { max-width: 240px; font-size: 20px; font-weight: 750; }
.version-policy-form small { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.45; }
.version-policy-note { display: grid; gap: 5px; padding: 13px; border-radius: 13px; background: var(--inset); }
.version-policy-note p { font-size: 12px; }

dialog { width: min(470px, calc(100% - 30px)); padding: 0; color: var(--ink); border: 1px solid var(--border); border-radius: 22px; background: var(--surface-strong); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(14, 12, 10, .58); backdrop-filter: blur(5px); }
.dialog-card { padding: 22px; }
.dialog-heading, .dialog-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-heading p { margin-top: 3px; font-size: 13px; }
.dialog-actions { justify-content: flex-end; margin-top: 4px; }
.mcp-settings { display: grid; gap: 12px; padding: 15px; border: 1px solid var(--border); border-radius: 15px; background: var(--inset); }
.mcp-settings p { margin-top: 3px; font-size: 13px; }
.one-time-token { display: grid; gap: 9px; padding: 12px; border: 1px solid color-mix(in srgb, var(--amber), transparent 48%); border-radius: 12px; background: color-mix(in srgb, var(--amber), transparent 88%); }
.one-time-token code { overflow-wrap: anywhere; user-select: all; font-size: 12px; }
.icon-button { width: 34px; height: 34px; padding: 0; color: var(--muted); border: 1px solid var(--border); border-radius: 50%; background: var(--inset); font-size: 22px; }
.toast { position: fixed; z-index: 50; right: 20px; bottom: 20px; max-width: 380px; padding: 12px 15px; color: var(--ink); border: 1px solid var(--border); border-radius: 12px; background: var(--surface-strong); box-shadow: var(--shadow); }

.brand-large { font-size: 28px; }
.brand-large .brand-mark { width: 48px; height: 48px; }
.eyebrow { display: block; margin-bottom: 5px; color: var(--teal); font-size: 11px; font-weight: 850; letter-spacing: .075em; text-transform: uppercase; }
.login-copy { display: grid; gap: 5px; }
.remember { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.remember input { width: 18px; min-height: 18px; accent-color: var(--teal); }
.login-button { min-height: 48px; }
.account-button { display: flex; align-items: center; gap: 9px; padding: 5px 8px; color: var(--ink); border: 0; border-radius: 12px; background: transparent; text-align: left; }
.account-button:hover { background: var(--inset); }
.account-copy { display: grid; gap: 1px; }
.account-button small { font-size: 11px; text-transform: capitalize; }
.account-chevron { margin-left: 2px; color: var(--muted); font-size: 17px; transition: transform .18s ease; }
.account-button[aria-expanded="true"] .account-chevron { transform: rotate(180deg); }
#accountAvatar { display: grid; place-items: center; width: 36px; height: 36px; color: white; border-radius: 50%; background: var(--teal); font-size: 12px; font-weight: 850; }
.account-dropdown { position: absolute; z-index: 40; top: calc(100% + 10px); right: 0; width: 230px; padding: 7px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-strong); box-shadow: var(--shadow); }
.account-menu-item { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 7px; width: 100%; padding: 10px; color: var(--ink); border: 0; border-radius: 10px; background: transparent; text-align: left; }
.account-menu-item:hover, .account-menu-item:focus-visible { background: var(--inset); outline: none; }
.account-menu-item > span:first-child { color: var(--teal); font-size: 20px; }
.account-menu-item > span:last-child { display: grid; gap: 1px; }
.account-menu-item small { color: var(--muted); font-size: 10px; font-weight: 500; text-transform: none; }
.account-menu-item.danger strong, .account-menu-item.danger > span:first-child { color: var(--red); }
.overview article { cursor: pointer; transition: transform .16s ease, border-color .16s ease; }
.overview article:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--amber), var(--border) 55%); }

.case-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); gap: 14px; padding: 18px; }
.case-card { overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; width: 100%; padding: 0; color: var(--ink); border: 1px solid var(--border); border-radius: 19px; background: var(--surface-strong); text-align: left; box-shadow: 0 10px 26px rgba(49,39,33,.06); transition: transform .16s ease, box-shadow .16s ease; }
.case-card:hover { transform: translateY(-2px); box-shadow: 0 15px 34px rgba(49,39,33,.11); }
.case-card-body { overflow: hidden; display: grid; min-width: 0; width: 100%; max-width: 100%; gap: 10px; padding: 15px; }
.case-title-row, .case-meta, .latest-row { display: flex; align-items: center; gap: 8px; }
.case-title-row strong { min-width: 0; overflow: hidden; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.case-title-row .status { margin-left: auto; }
.case-title-row .case-age { flex: none; color: var(--muted); white-space: nowrap; }
.case-notification-badge { flex: none; display: inline-flex; align-items: center; gap: 3px; padding: 3px 7px; color: white; border-radius: 999px; background: var(--red); font-size: 10px; font-weight: 850; line-height: 1.2; white-space: nowrap; }
.case-patient-row { display: flex; align-items: center; gap: 7px; min-width: 0; }
.case-patient-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-meta { color: var(--muted); font-size: 12px; }
.case-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-meta .push { margin-left: auto; }
.case-summary { min-height: 39px; overflow: hidden; color: color-mix(in srgb, var(--ink), transparent 18%); font-size: 14px; line-height: 1.42; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.case-metrics { overflow: hidden; display: flex; align-items: stretch; gap: 8px; min-width: 0; width: 100%; max-width: 100%; }
.case-card .case-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); contain: inline-size; }
.case-card .case-metrics > .metric { flex: none; width: 100%; max-width: 100%; }
.metric { overflow: hidden; flex: 1; min-width: 0; display: grid; gap: 2px; padding: 9px; border-radius: 11px; background: var(--inset); }
.metric small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; text-transform: uppercase; }
.metric strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.latest-row { overflow: hidden; min-width: 0; width: 100%; padding-top: 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.latest-row strong { flex: 0 1 auto; min-width: 0; max-width: 34%; overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.latest-row .message-preview { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.latest-row time { flex: 0 0 auto; margin-left: auto; white-space: nowrap; }
.status-band { padding: 9px 14px; color: white; font-size: 12px; font-weight: 850; }
.status-band.needs-action { background: #c92725; }
.status-band.waiting-on-other { background: #d58d38; }
.status-band.closed { background: #268562; }
.status-band.completed { background: #268562; }

.wide-dialog { width: min(1160px, calc(100% - 24px)); max-height: calc(100vh - 24px); }
.case-dialog-shell { max-height: calc(100vh - 30px); overflow: auto; }
.sticky-dialog-heading { position: sticky; z-index: 6; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 20px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface-strong), transparent 3%); backdrop-filter: blur(18px); }
.case-dialog-content { display: grid; grid-template-columns: minmax(280px, .82fr) minmax(380px, 1.18fr); align-items: start; gap: 16px; padding: 18px 20px 28px; }
.case-hero { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .65fr); align-items: end; gap: 20px; padding: 18px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); }
.case-hero h3 { margin: 9px 0 5px; font-size: clamp(22px, 2.5vw, 32px); }
.case-hero .case-metrics { justify-content: flex-end; }
.detail-section { min-width: 0; display: grid; gap: 13px; padding: 17px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); }
.detail-section h3 { margin: 0; font-size: 17px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading span { color: var(--muted); font-size: 12px; }
#conversationSection { grid-column: 2; grid-row: 2 / span 4; }
.confirmation-section { grid-column: 1 / -1; grid-row: 2; padding: 14px 16px; border-color: color-mix(in srgb, var(--green), transparent 58%); background: color-mix(in srgb, var(--green), var(--surface) 91%); }
.confirmation-section ~ #conversationSection { grid-row: 3 / span 4; }
.confirmation-form { display: grid; grid-template-columns: minmax(180px, 1.35fr) repeat(2, minmax(110px, .72fr)) minmax(145px, .9fr) minmax(95px, .58fr) auto; align-items: end; gap: 10px; }
.confirmation-copy { align-self: center; min-width: 0; }
.confirmation-copy h3 { color: var(--green-dark); }
.confirmation-copy p { margin-top: 3px; font-size: 11px; }
.confirmation-form label { min-width: 0; }
.confirmation-form input { min-height: 40px; }
.confirmation-submit { min-height: 40px; padding: 9px 16px; color: white; border: 1px solid var(--green); border-radius: 11px; background: var(--green); font-weight: 800; white-space: nowrap; }
.confirmation-submit:hover { background: var(--green-dark); border-color: var(--green-dark); }
.unconfirm-section { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.unconfirm-button { min-height: 40px; padding: 9px 16px; color: var(--red); border: 1px solid color-mix(in srgb, var(--red), transparent 35%); border-radius: 11px; background: var(--surface-strong); font-weight: 800; white-space: nowrap; }
.unconfirm-button:hover { color: white; background: var(--red); }
.patient-details { display: grid; grid-template-columns: minmax(95px, auto) 1fr; gap: 8px 14px; margin: 0; font-size: 13px; }
.patient-details dt { color: var(--muted); font-weight: 650; }
.patient-details dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.patient-flip-card { perspective: 1400px; }
.patient-flipper { position: relative; min-height: 70px; transform-style: preserve-3d; transition: height .42s ease, transform .58s cubic-bezier(.2,.75,.2,1); }
.patient-face { position: absolute; inset: 0 0 auto; display: grid; align-content: start; gap: 13px; width: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.patient-view-face { transform: rotateY(0deg); }
.patient-edit-face { pointer-events: none; transform: rotateY(180deg); }
.patient-flipper.is-editing { transform: rotateY(180deg); }
.patient-flipper.is-editing .patient-view-face { pointer-events: none; }
.patient-flipper.is-editing .patient-edit-face { pointer-events: auto; }
.edit-case-form { padding-bottom: 2px; }
@media (prefers-reduced-motion: reduce) {
  .patient-flipper { transition: none; }
}
.case-header-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
.detail-card { display: grid; gap: 11px; padding: 15px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.detail-card h3 { margin: 0; font-size: 15px; }
.patient-lines { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 14px; }
.patient-line { display: grid; grid-template-columns: 95px 1fr; gap: 8px; font-size: 13px; }
.patient-line span:first-child { color: var(--muted); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 10px; }
.photo-tile { position: relative; overflow: hidden; min-height: 116px; padding: 0; border: 1px solid var(--border); border-radius: 13px; background: var(--inset); }
.photo-tile img { width: 100%; height: 100%; min-height: 116px; object-fit: cover; }
.photo-number { position: absolute; top: 7px; left: 7px; padding: 4px 7px; color: white; border-radius: 7px; background: rgba(0,0,0,.62); font-size: 11px; font-weight: 800; }
.image-placeholder, .no-photos { display: grid; place-items: center; min-height: 116px; color: var(--muted); background: var(--inset); font-size: 12px; }
.photo-tile:not(.deleted-photo) { cursor: zoom-in; }
.upload-button { display: inline-flex; align-items: center; justify-content: center; justify-self: start; min-height: 40px; padding: 8px 13px; color: white; border-radius: 11px; background: var(--teal); cursor: pointer; }
.photo-index { position: absolute; top: 7px; left: 7px; padding: 4px 7px; color: white; border-radius: 7px; background: rgba(0,0,0,.62); font-size: 11px; font-weight: 800; }
.photo-delete { position: absolute; top: 7px; right: 7px; width: 32px; height: 32px; padding: 0; color: white; border: 0; border-radius: 50%; background: #f04444; font-weight: 850; }
.deleted-overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 10px; color: white; background: rgba(0,0,0,.62); font-size: 12px; font-weight: 800; text-align: center; }
.conversation { display: grid; gap: 9px; }
.completion-panel { display: grid; gap: 6px; padding: 12px; border: 1px solid color-mix(in srgb, #268562, transparent 62%); border-radius: 13px; background: color-mix(in srgb, #268562, transparent 88%); }
.completion-panel > div, .completion-action { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.completion-panel strong { color: var(--teal); }
.completion-panel small { white-space: nowrap; }
.completion-panel p, .completion-action span { font-size: 12px; }
.completion-action { padding-top: 11px; border-top: 1px solid var(--border); }
.message { display: grid; gap: 7px; padding: 12px; border-radius: 13px; background: var(--inset); }
.message-head { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.message-head time { margin-left: auto; color: var(--muted); }
.message p { color: var(--ink); white-space: pre-wrap; }
.message img { width: min(100%, 420px); max-height: 360px; object-fit: contain; border-radius: 10px; background: black; }
.message-photo-button { position: relative; justify-self: start; overflow: hidden; max-width: min(100%, 420px); padding: 0; border: 0; border-radius: 10px; background: black; cursor: zoom-in; }
.message-photo-button img { display: block; width: 100%; }
.message-photo-button > span { position: absolute; right: 9px; bottom: 9px; display: grid; place-items: center; width: 34px; height: 34px; color: white; border-radius: 50%; background: rgba(0,0,0,.66); font-size: 18px; }
.message-photo-button:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
.message.deleted { opacity: .68; border: 1px dashed var(--red); }
.message-photo { min-height: 180px; border-radius: 10px; }
.inline-form { display: grid; gap: 10px; }
.inline-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.section-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.form-dialog { width: min(780px, calc(100% - 24px)); max-height: calc(100vh - 24px); overflow: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.span-2 { grid-column: 1 / -1; }
.field-hint { min-height: 15px; color: var(--muted); font-size: 11px; font-weight: 500; }
.field-hint.warning { color: var(--red); }
.match-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.pending-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.pending-photo { position: relative; overflow: hidden; height: 120px; border-radius: 12px; background: var(--inset); }
.pending-photo img { width: 100%; height: 100%; object-fit: cover; }
.pending-photo button { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; padding: 0; color: white; border: 0; border-radius: 50%; background: #f04444; }

.photo-dialog { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; background: #050505; }
.photo-viewer { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; height: 100%; color: white; }
.photo-toolbar { position: relative; z-index: 4; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: #111; }
.photo-toolbar > div { display: flex; align-items: center; gap: 8px; }
.photo-zoom-controls { color: white; }
.photo-zoom-controls button { min-width: 36px; color: white; border-color: #555; background: #252525; }
.photo-zoom-controls button:disabled { opacity: .35; }
.photo-zoom-controls span { min-width: 48px; font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; }
.photo-stage { display: grid; place-items: center; overflow: auto; min-height: 0; }
.photo-stage > img { width: 100%; height: 100%; min-height: 0; object-fit: contain; transition: transform .18s ease; transform-origin: center; }
.photo-arrow { position: absolute; z-index: 3; top: 50%; width: 46px; height: 58px; color: white; border: 0; border-radius: 13px; background: rgba(0,0,0,.52); font-size: 38px; }
.photo-arrow.previous { left: 14px; }.photo-arrow.next { right: 14px; }
.photo-thumbnails { position: relative; z-index: 4; display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px; background: #111; }
.photo-thumbnails button { flex: none; overflow: hidden; width: 70px; height: 54px; padding: 0; border: 2px solid transparent; border-radius: 8px; background: #222; }
.photo-thumbnails button.active { border-color: var(--amber); }
.photo-thumbnails img { width: 100%; height: 100%; object-fit: cover; }

.editor-dialog { width: 100%; max-width: 100%; height: 100vh; max-height: 100vh; border: 0; border-radius: 0; background: black; }
.editor-shell { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; color: white; }
.editor-toolbar, .editor-send { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: #111; }
.editor-tools, .pen-controls { display: flex; align-items: center; gap: 8px; }
.pen-controls label { display: flex; align-items: center; gap: 6px; color: #ddd; }
.pen-controls input[type=color] { width: 40px; min-height: 34px; padding: 2px; }
.pen-controls input[type=range] { width: 120px; }
.canvas-stage { position: relative; display: grid; place-items: center; overflow: hidden; min-height: 0; touch-action: none; }
#markupCanvas { display: block; max-width: 100%; max-height: 100%; touch-action: none; }
.text-layer { position: absolute; pointer-events: none; }
.markup-text { position: absolute; min-width: 90px; padding: 8px 28px 8px 10px; color: white; border: 2px solid #ff8a00; border-radius: 9px; background: rgba(0,0,0,.58); font-weight: 700; line-height: 1.1; white-space: nowrap; pointer-events: auto; user-select: none; touch-action: none; }
.markup-text[contenteditable=true] { user-select: text; }
.text-resize { position: absolute; right: 3px; bottom: 3px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #ff8a00; font-size: 11px; cursor: nwse-resize; }
.editor-send input { flex: 1; color: white; border-color: #444; background: #222; }
hr { width: 100%; border: 0; border-top: 1px solid var(--border); }
.loading { display: grid; place-items: center; min-height: 180px; color: var(--muted); }

@media (max-width: 800px) {
  .photo-toolbar { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; }
  .photo-zoom-controls { justify-self: center; }
  #resetPhotoZoom { display: none; }
  .topbar { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .topbar-search { grid-column: 1 / -1; grid-row: 2; }
  .content { width: min(100% - 20px, 1460px); margin-top: 16px; }
  .overview { grid-template-columns: repeat(2, 1fr); }
  .workspace-bar { align-items: stretch; flex-direction: column; }
  .workspace-actions, .search { width: 100%; }
  .search { min-width: 0; }
  .workspace-actions .primary { flex: none; }
  .tabs { width: 100%; }
  .tab { flex: 1; }
  .account-copy { display: none; }
  .topbar-actions { grid-column: 2; grid-row: 1; }
  .notification-dropdown { position: fixed; top: 66px; right: 10px; }
  .filter-bar { align-items: stretch; flex-direction: column; padding-inline: 14px; }
  .filter-groups { display: grid; gap: 12px; }
  .filter-group { overflow: hidden; }
  .filter-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
  .filter-select { width: 100%; }
  .filter-chips::-webkit-scrollbar { display: none; }
  .clear-filters { align-self: flex-start; }
  .case-grid { grid-template-columns: 1fr; padding: 12px; }
  .version-settings { grid-template-columns: 1fr; padding: 14px; }
  .wide-dialog { width: 100%; max-width: 100%; max-height: 100vh; border-radius: 0; }
  .case-dialog-shell { max-height: 100vh; }
  .case-dialog-content { grid-template-columns: 1fr; padding: 13px; }
  .case-hero { grid-column: auto; grid-template-columns: 1fr; }
  .confirmation-section { grid-column: auto; grid-row: auto; }
  .confirmation-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .confirmation-copy, .confirmation-submit { grid-column: 1 / -1; }
  .confirmation-submit { width: 100%; }
  #conversationSection { grid-column: auto; grid-row: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-toolbar { align-items: flex-start; flex-direction: column; }
  .editor-tools, .pen-controls { width: 100%; }
  .editor-send { align-items: stretch; flex-direction: column; }
}

@media (max-width: 470px) {
  .unconfirm-section { align-items: stretch; flex-direction: column; }
  .unconfirm-button { width: 100%; }
}

@media (max-width: 470px) {
  .topbar { padding-inline: 12px; }
  .brand { font-size: 18px; }
  .brand-mark { width: 34px; height: 34px; }
  .overview article { padding: 14px; }
  .overview strong { font-size: 23px; }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .panel-heading-actions { justify-content: flex-end; }
  .panel-heading select { width: 100%; }
  .case-title-row { align-items: flex-start; }
  .case-title-row strong { white-space: normal; }
  .case-card .case-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .case-hero .case-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: 8px 6px; }
  .message-head { flex-wrap: wrap; }
  .message-head time { margin-left: 0; }
  .inline-fields { grid-template-columns: 1fr; }
  .confirmation-form { grid-template-columns: 1fr; }
  .confirmation-copy, .confirmation-submit { grid-column: auto; }
}
