:root {
  color-scheme: light;
  --bg: #f6f8fa;
  --surface: #fff;
  --surface-soft: #f2f5f8;
  --navy: #172536;
  --clinical-heading: #234F78;
  --muted: #56677a;
  --line: #dce3ea;
  --blue: #234F78;
  --blue-soft: #eaf0f6;
  --violet: #8068e8;
  --violet-soft: #f1edff;
  --green: #187a48;
  --green-soft: #e8f8ef;
  --orange: #8a5200;
  --orange-soft: #fff4db;
  --red: #b4233b;
  --red-soft: #feeaed;
  --shadow: 0 4px 16px rgba(27, 43, 86, .06);
  --radius: 18px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --type-caption: .75rem;
  --type-meta: .8125rem;
  --type-ui: .9375rem;
  --type-body: 1rem;
  --type-clinical: 1rem;
  --type-section: 1.25rem;
  --type-title: 1.5rem;
  --type-page: 1.875rem;
  --line-tight: 1.2;
  --line-heading: 1.3;
  --line-ui: 1.4;
  --line-body: 1.55;
  --line-reading: 1.65;
  --weight-medium: 500;
  --weight-semibold: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; min-height: 100%; max-width: 100%; background: var(--bg); color: var(--navy); }
body { min-height: 100dvh; overflow: hidden; font-size: 16px; line-height: 1.5; }
button, input, select { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid rgba(35,79,120,.42); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 5px; color: var(--blue); font-size: var(--type-caption); line-height: var(--line-ui); font-weight: var(--weight-semibold); letter-spacing: .04em; text-transform: uppercase; }
.app { display: grid; grid-template-columns: 232px 370px minmax(0, 1fr); height: 100dvh; }
.sidebar { border-right: 1px solid var(--line); background: #fafbfc; padding: 28px 20px max(24px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; margin: 0 8px 40px; font-size: 21px; }
.brand img { width: 42px; height: 42px; }
.brand span, .mobile-header strong span { color: var(--blue); font-size: 12px; }
.home-brand { padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; text-align: left; touch-action: manipulation; }
.home-brand:hover { opacity: .86; }.home-brand:active { transform: translateY(1px); }
.sidebar nav { display: grid; gap: 8px; }
.nav { min-height: 48px; padding: 0 14px; border: 0; border-radius: 13px; background: transparent; display: flex; align-items: center; gap: 12px; color: var(--muted); cursor: pointer; text-align: left; }
.nav:hover { background: #f2f4fb; color: var(--navy); }
.nav.active { background: var(--blue-soft); color: var(--blue); font-weight: var(--weight-semibold); }
.nav .badge { margin-left: auto; }
.account { margin-top: auto; padding: 16px 6px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; min-width: 0; }
.account div:last-child { min-width: 0; display: grid; }
.account strong { overflow: hidden; text-overflow: ellipsis; font-size: var(--type-caption); }
.account small { color: var(--muted); font-size: var(--type-caption); line-height: var(--line-ui); }
.account small { color: var(--muted); }
.patient-rail { overflow: hidden; background: var(--surface-soft); border-right: 1px solid var(--line); padding: 24px 0 16px; display: flex; flex-direction: column; }
.patient-rail .rail-heading, .patient-rail .search-box { margin-inline: 18px; }
.patient-rail .search-box { flex-shrink: 0; }
.rail-heading { display: flex; justify-content: space-between; align-items: center; padding: 0 0 8px; }
.rail-heading h2 { margin: 0; font-size: var(--type-title); line-height: var(--line-heading); font-weight: var(--weight-semibold); letter-spacing: -.018em; }
.rail-heading #refresh { border: 0; background: transparent; color: var(--muted); }
.rail-heading #refresh .i-refresh { width: 18px; height: 18px; }
.rail-heading #refresh:hover { background: var(--surface); }
.rail-heading #refresh:active { background: var(--surface-soft); }
.patient-overview h2 { margin: 0 0 12px; color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); font-weight: var(--weight-semibold); }
.patient-overview-values { display: flex; flex-wrap: wrap; gap: 24px; }
.patient-overview-values > div { display: grid; gap: 2px; }
.patient-overview-values strong { color: var(--navy); font-size: var(--type-title); line-height: var(--line-heading); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.patient-overview-values span { color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); font-weight: var(--weight-medium); white-space: nowrap; }
.mobile-patient-overview { display: none; }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; display: inline-grid; place-items: center; cursor: pointer; position: relative; }
.icon-button:hover { border-color: #cbd3ea; background: #fbfcff; }
.icon-button:active { background: var(--surface-soft); }
.icon-button:disabled { cursor: default; }
.search-box { height: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); display: flex; align-items: center; gap: 9px; padding: 0 12px; margin-bottom: 12px; }
.search-box input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--navy); font-size: 16px; }
.search-box input::placeholder { color: #9aa2b5; }
.patient-list { display: grid; align-content: start; gap: 14px; overflow-y: auto; overflow-x: hidden; padding: 4px 12px 12px; border: 0; border-radius: 0; background: transparent; scrollbar-width: thin; }
.patient-list .empty-copy { padding: 18px 16px; }
.patient-date-group { display: grid; gap: 8px; }
.patient-date-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 2px; }
.patient-date-heading h3 { margin: 0; color: var(--navy); font-size: var(--type-ui); line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.patient-date-count { flex: 0 0 auto; color: var(--muted); font-size: var(--type-caption); line-height: var(--line-ui); }
.patient-row { display: grid; grid-template-columns: 44px minmax(0,1fr) 12px; align-items: center; gap: 8px; width: 100%; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: none; cursor: pointer; text-align: left; }
.patient-row.active { border-color: #b7c8dd; background: #fbfcfe; }
@media (hover: hover) { .patient-row:hover { border-color: #c8d4e2; background: #fbfcfe; } }
.patient-row:active { background: #f3f6fa; }
.patient-row:focus-visible { outline: 2px solid rgba(36,92,168,.55); outline-offset: 2px; z-index: 1; }
.patient-row .patient-avatar-frame { width: 42px; height: 42px; }
.patient-row-main { min-width: 0; align-self: center; }
.patient-row-heading { min-width: 0; }
.patient-row h3 { margin: 0; color: var(--navy); font-size: var(--type-ui); line-height: var(--line-heading); font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.patient-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin-top: 3px; color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); }
.patient-row-age { overflow-wrap: anywhere; }
.patient-row .diagnosis { min-height: 2.8em; margin: 4px 0 0; color: #43566b; font-size: var(--type-meta); line-height: var(--line-ui); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.patient-row .pill { margin: 0; }
.patient-row-chevron { color: #8297ac; font-size: 22px; line-height: 1; }
.patient-card { width: 100%; min-height: 88px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 2px 10px rgba(26,42,82,.025); margin-bottom: 8px; cursor: pointer; text-align: left; }
.patient-card:hover, .patient-card.active { border-color: #6e89ea; box-shadow: 0 7px 20px rgba(55,85,175,.1); }
.patient-card-head { display: grid; grid-template-columns: 44px minmax(0,1fr); gap: 12px; align-items: center; }
.patient-card h3 { margin: 0 0 3px; font-size: var(--type-body); line-height: var(--line-heading); font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.patient-card-context { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.patient-card-date { color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); white-space: nowrap; }
.patient-card-summary { display: flex; align-items: center; gap: 10px; padding-left: 56px; margin-top: -16px; }
.meta { color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); }
.patient-card .diagnosis { flex: 1; margin: 0; color: var(--muted); font-size: var(--type-ui); font-weight: 400; line-height: 1.45; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.card-foot { display: flex; justify-content: space-between; gap: 6px; align-items: flex-end; }
.latest { margin-top: 9px; color: var(--muted); font-size: var(--type-caption); line-height: var(--line-ui); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pill { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; border-radius: 999px; padding: 4px 8px; font-size: var(--type-caption); font-weight: var(--weight-semibold); line-height: var(--line-ui); }
.pill::before { content: ""; width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: currentColor; }
.pill.ready, .pill.active { color: var(--green); background: var(--green-soft); }
.pill.processing { color: var(--blue); background: var(--blue-soft); }
.pill.review { color: var(--orange); background: var(--orange-soft); }
.workspace { overflow-y: auto; min-width: 0; padding: 28px clamp(22px,3vw,52px) 32px; scroll-behavior: smooth; }
.welcome-state { min-height: 100%; color: var(--navy); }
.dashboard-header { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 28px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.dashboard-intro { max-width: 60ch; }
.dashboard-intro .eyebrow { margin-bottom: 8px; }
.dashboard-intro h1 { margin: 0 0 8px; font-size: var(--type-page); line-height: var(--line-tight); font-weight: var(--weight-semibold); letter-spacing: -.025em; }
.dashboard-intro > p:last-child { max-width: 46ch; margin: 0; color: var(--muted); font-size: var(--type-body); line-height: var(--line-reading); }
.patient-overview { min-width: 280px; }
.dashboard-sections { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 32px; padding-top: 32px; }
.dashboard-section { min-width: 0; }
.dashboard-section-heading { display: flex; align-items: baseline; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.dashboard-section-heading h2 { margin: 0; color: var(--clinical-heading); font-size: var(--type-section); line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.dashboard-count { min-width: 24px; color: var(--muted); font-size: var(--type-meta); font-variant-numeric: tabular-nums; }
.dashboard-patient-list { display: grid; }
.dashboard-patient { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 16px; width: 100%; min-height: 76px; padding: 12px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; cursor: pointer; text-align: left; }
.dashboard-patient:hover .dashboard-patient-main > strong { color: var(--blue); }
.dashboard-patient:focus-visible { outline-offset: -2px; }
.dashboard-patient-main { display: grid; gap: 4px; min-width: 0; }
.dashboard-patient-main > strong { overflow: hidden; color: var(--navy); font-size: var(--type-body); line-height: var(--line-heading); font-weight: var(--weight-semibold); text-overflow: ellipsis; white-space: nowrap; }
.dashboard-patient-context { overflow: hidden; color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); text-overflow: ellipsis; white-space: nowrap; }
.dashboard-patient-meta { display: grid; justify-items: end; gap: 4px; color: var(--muted); font-size: var(--type-caption); line-height: var(--line-ui); white-space: nowrap; }
.dashboard-empty { margin: 0; padding: 18px 0; color: var(--muted); font-size: var(--type-ui); line-height: var(--line-reading); }
.content { max-width: 920px; margin: 0 auto; }
.back-button { min-height: 44px; display: inline-flex; align-items: center; border: 0; background: transparent; color: var(--blue); padding: 0 4px 0 0; cursor: pointer; }
.dossier-back { display: block; min-height: 42px; padding: 8px 2px 10px; }
.dossier-header { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 22px; overflow: hidden; }
.dossier-person { display: grid; grid-template-columns: 64px minmax(0,1fr) auto; gap: 16px; align-items: center; padding: 22px; }
.dossier-person h1 { font-size: var(--type-title); line-height: var(--line-heading); font-weight: var(--weight-semibold); letter-spacing: -.018em; margin: 0 0 7px; }
.person-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); }
.patient-id { border: 0; background: var(--surface-soft); color: var(--blue); border-radius: 8px; padding: 4px 7px; font-size: var(--type-caption); line-height: var(--line-ui); cursor: pointer; max-width: 100%; overflow-wrap: anywhere; }
.header-status { align-self: start; }
.update-strip { display: flex; gap: 30px; flex-wrap: wrap; border-top: 1px solid var(--line); background: #fbfcff; padding: 12px 22px; color: var(--muted); font-size: 12px; }
.update-strip strong { color: var(--navy); margin-left: 5px; }
.patient-header { display: grid; grid-template-columns: 44px minmax(0,1fr) 44px; align-items: center; gap: 16px; padding: 20px 0 22px; border-bottom: 1px solid var(--line); background: var(--bg); }
.patient-header-person { display: flex; align-items: center; gap: 14px; min-width: 0; }
.patient-header-identity { min-width: 0; }
.patient-header .patient-avatar-frame.large { width: 56px; height: 56px; }
.patient-back { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--blue); cursor: pointer; font-size: 30px; line-height: 1; }
.patient-back:hover { background: var(--surface-soft); }
.patient-header-identity h1 { margin: 0; font-size: clamp(22px,1.8vw,28px); line-height: var(--line-tight); font-weight: var(--weight-semibold); letter-spacing: -.022em; overflow-wrap: anywhere; }
.patient-header-identity p { margin: 5px 0 0; color: var(--muted); font-size: var(--type-ui); line-height: var(--line-ui); }
.patient-overflow-menu { display: block; position: relative; }
.patient-header > .patient-overflow-menu { justify-self: end; }
.patient-overflow-menu > summary { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer; font-size: 25px; line-height: 1; list-style: none; }
.patient-overflow-menu > summary::-webkit-details-marker { display: none; }
.patient-overflow-menu[open] > summary { background: var(--surface-soft); color: var(--navy); }
.patient-overflow-menu-items { position: absolute; z-index: 46; top: calc(100% + 6px); right: 0; display: none; min-width: 196px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 12px 28px rgba(20,34,70,.16); }
.patient-overflow-menu[open] > .patient-overflow-menu-items { display: grid; }
.patient-overflow-item { min-height: 44px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--navy); cursor: pointer; font: inherit; text-align: left; }
.patient-overflow-item:hover, .patient-overflow-item:focus-visible { background: var(--surface-soft); }
.patient-header .edit-identity-button { min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--blue); font-size: var(--type-ui); font-weight: var(--weight-semibold); }
.patient-primary-nav { display: flex; gap: clamp(18px,3vw,34px); margin: 18px 0 2px; padding: 0; border-bottom: 1px solid var(--line); background: transparent; }
.patient-primary-nav button { position: relative; min-height: 48px; padding: 0 2px 12px; border: 0; border-radius: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: var(--type-ui); font-weight: var(--weight-medium); line-height: var(--line-ui); white-space: nowrap; }
.patient-primary-nav button.active { color: var(--navy); font-weight: var(--weight-semibold); }
.patient-primary-nav button.active::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--blue); content: ""; }
.patient-clinical-section { padding: 20px 2px; border-bottom: 1px solid var(--line); }
.patient-clinical-section:last-child { border-bottom: 0; }
.clinical-section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.clinical-section-heading h2 { margin: 0; color: var(--clinical-heading); font-size: var(--type-section); line-height: var(--line-heading); font-weight: var(--weight-semibold); letter-spacing: -.012em; }
.section-link { min-height: 44px; margin: -10px -8px -10px 0; padding: 0 8px; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: var(--type-ui); font-weight: var(--weight-semibold); white-space: nowrap; }
.clinical-section-footer { display: flex; justify-content: flex-start; margin-top: 10px; }
.clinical-section-footer .source-link { margin: 0 0 0 -8px; font-size: var(--type-meta); font-weight: var(--weight-medium); }
.clinical-section-body { max-width: 84ch; font-size: var(--type-clinical); line-height: var(--line-reading); }
.clinical-section-body p { margin: 0 0 12px; }
.clinical-section-body p:last-child { margin-bottom: 0; }
.clinical-lead { font-size: var(--type-clinical); line-height: var(--line-reading); font-weight: 550; color: var(--navy); overflow-wrap: anywhere; }
.clinical-context, .clinical-highlight { color: #425166; }
.clinical-context b, .clinical-highlight b { color: var(--navy); font-weight: var(--weight-semibold); }
.patient-clinical-section .event-row { padding: 12px 0; }
.patient-clinical-section .event-row:first-child { padding-top: 0; }
.patient-clinical-section .event-row:last-child { padding-bottom: 0; }
.patient-clinical-section .event-date { margin-bottom: 3px; font-size: var(--type-meta); line-height: var(--line-ui); }
.patient-clinical-section .event-summary { font-size: var(--type-clinical); line-height: var(--line-reading); font-weight: var(--weight-medium); }
.patient-clinical-section .event-context { color: var(--muted); font-size: var(--type-ui); line-height: 1.5; overflow-wrap: anywhere; }
.patient-clinical-section .detail-list { margin-top: 8px; }
.patient-clinical-section.is-warning { margin: 16px 0 0; padding: 16px 0; border: 0; border-top: 1px solid #eed5ab; background: transparent; }
.patient-clinical-section.is-warning h2 { color: #714600; }
.summary-timeline-row { display: grid; grid-template-columns: 112px minmax(0,1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid #edf0f5; }
.summary-timeline-row:last-child { border-bottom: 0; }
.summary-timeline-row time { color: var(--muted); font-size: var(--type-meta); line-height: var(--line-body); }
.summary-timeline-row span { font-size: var(--type-body); line-height: var(--line-reading); }
.patient-loading { padding: 10px 0; }
.skeleton { background: linear-gradient(100deg,#e9ecf3 24%,#f5f6f9 38%,#e9ecf3 52%); background-size: 220% 100%; animation: document-placeholder 1.35s ease-in-out infinite; }
.skeleton-header { height: 72px; margin-bottom: 20px; border-radius: 8px; }
.skeleton-line { width: 72%; height: 18px; margin: 10px 0; border-radius: 6px; }
.skeleton-line.wide { width: 94%; }
.skeleton-section { height: 96px; margin-top: 20px; border-radius: 6px; }
.load-error { max-width: 520px; margin: 60px auto; text-align: center; }
.load-error h1 { margin: 0 0 8px; font-size: var(--type-title); line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.load-error p { margin: 0 0 20px; color: var(--muted); font-size: var(--type-body); line-height: var(--line-reading); }
.load-error-actions { display: flex; justify-content: center; gap: 10px; }
.action-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin: 16px 0; }
.action-card { min-height: 76px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; font-weight: 650; cursor: pointer; }
.action-card:hover { border-color: #c3ccec; transform: translateY(-1px); }
.module-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 0; background: transparent; }
.module-icon img { display: block; width: 32px; height: 32px; }
.clinical-card { margin: 12px 0; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.clinical-card[open] > summary { border-bottom: 1px solid #eff1f7; }
.clinical-card summary { list-style: none; cursor: pointer; padding: 16px 18px; display: flex; align-items: center; gap: 10px; font-size: var(--type-body); line-height: var(--line-heading); font-weight: var(--weight-semibold); color: #17316f; }
.clinical-card summary::-webkit-details-marker { display: none; }
.clinical-card summary::after { content: "⌃"; margin-left: auto; color: #8490aa; }
.clinical-card:not([open]) summary::after { content: "⌄"; }
.section-icon { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; display: grid; place-items: center; }
.section-icon img { width: 30px; height: 30px; display: block; }
.source-page-range { outline: 2px solid rgba(75,111,222,.22); outline-offset: 3px; border-radius: 5px; }
.clinical-body { max-width: 84ch; padding: 16px 18px 18px; line-height: var(--line-reading); font-size: var(--type-body); }
.clinical-body p { margin: 0 0 12px; }
.clinical-body p:last-child { margin-bottom: 0; }
.clinical-body .lead { font-size: var(--type-clinical); font-weight: var(--weight-semibold); line-height: var(--line-reading); overflow-wrap: anywhere; }
.event-row { border-bottom: 1px solid #eff1f7; padding: 12px 0; display: grid; gap: 6px; }
.event-row:last-child { border-bottom: 0; padding-bottom: 0; }
.event-date { display: block; color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); }
.event-summary { display: block; font-size: var(--type-clinical); line-height: var(--line-reading); overflow-wrap: anywhere; }
.detail-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px 18px; margin-top: 7px; }
.detail-list div { display: grid; gap: 3px; font-size: var(--type-meta); line-height: var(--line-ui); }
.detail-list b { color: var(--muted); font-weight: 500; }
.empty-copy { color: var(--muted); font-style: normal; }
.warning-card { border-color: #f4d2a2; }
.warning-card summary { color: #a76a16; }
.recovery-card { margin: 0 0 16px; padding: 16px 18px; border: 1px solid #f4d2a2; border-radius: 16px; background: #fff8ef; box-shadow: var(--shadow); }
.recovery-card h2 { margin: 0 0 8px; color: #a76a16; font-size: var(--type-body); line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.recovery-card p { margin: 0 0 14px; color: #5f4a2a; font-size: var(--type-ui); line-height: var(--line-reading); }
.recovery-block { margin: 0 0 14px; padding: 0; }
.recovery-block:last-of-type { margin-bottom: 10px; }
.recovery-block h3 { margin: 0 0 6px; color: #8a5a14; font-size: 14px; font-weight: 700; }
.recovery-block p { margin: 0 0 10px; }
.recovery-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.recovery-actions-secondary { margin-top: 4px; }
.subpage-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.subpage-head h1 { margin: 0; font-size: var(--type-page); line-height: var(--line-tight); font-weight: var(--weight-semibold); letter-spacing: -.02em; }
.compact-subpage-head { display: grid; grid-template-columns: 44px minmax(0,1fr); align-items: center; gap: 10px; margin-bottom: 0; }
.compact-subpage-head .subpage-back { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--blue); cursor: pointer; font-size: 30px; line-height: 1; }
.compact-subpage-head .subpage-back:hover { background: var(--surface-soft); }
.compact-subpage-head .subpage-identity { min-width: 0; }
.compact-subpage-head h1 { font-size: var(--type-title); line-height: var(--line-heading); font-weight: var(--weight-semibold); letter-spacing: -.018em; }
.compact-subpage-head p { margin: 3px 0 0; color: var(--muted); font-size: var(--type-ui); line-height: var(--line-ui); font-weight: 400; overflow-wrap: anywhere; }
.compact-subpage-head + .patient-primary-nav { margin-top: 14px; margin-bottom: 16px; }
.compact-subpage-head + .patient-primary-nav + .timeline .timeline-year:first-child { margin-top: 14px; }
.timeline { --timeline-rail-x: 4px; position: relative; margin-left: 0; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: var(--timeline-rail-x); top: 8px; bottom: 8px; width: 1px; background: var(--line); }
.timeline-year { position: relative; z-index: 1; width: max-content; margin: 26px 0 10px -20px; padding: 0 8px 0 0; background: var(--bg); font-size: var(--type-body); line-height: var(--line-heading); font-weight: var(--weight-semibold); color: var(--navy); }
.timeline-event { position: relative; background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 12px 0 16px; margin: 0; }
.timeline-marker { position: absolute; left: -19px; top: 19px; width: 9px; height: 9px; border: 2px solid var(--bg); border-radius: 50%; background: #8c9bab; box-shadow: 0 0 0 1px #8c9bab; display: block; }
.timeline-marker img { display: none; }
.timeline-event h3 { margin: 4px 0 6px; font-size: var(--type-clinical); line-height: var(--line-reading); font-weight: var(--weight-semibold); }
.timeline-event .category { color: var(--muted); font-size: var(--type-caption); line-height: var(--line-ui); font-weight: var(--weight-semibold); }
.timeline-event[data-event-type] .timeline-marker { background: #8c9bab; }
.timeline-event[data-event-type] .category { color: var(--muted); }
.meta-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.meta-chip { max-width: 100%; padding: 0; border-radius: 0; background: transparent; color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); overflow-wrap: anywhere; }
.event-more { margin-top: 9px; border-top: 1px solid #eff1f7; padding-top: 8px; }
.event-more summary { color: var(--blue); cursor: pointer; font-size: var(--type-caption); line-height: var(--line-ui); font-weight: var(--weight-semibold); }
.event-more p { font-size: var(--type-meta); line-height: var(--line-reading); }
.timeline-extra { display: grid; gap: 9px; padding-top: 9px; }
.timeline-extra > div { display: grid; gap: 3px; }
.timeline-extra b { color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); font-weight: var(--weight-semibold); }
.timeline-extra span { font-size: var(--type-meta); line-height: var(--line-reading); overflow-wrap: anywhere; }
.radiology-year { margin: 20px 0 9px; color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); font-weight: var(--weight-semibold); }
.report-card { background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 14px 0 22px; box-shadow: none; margin-bottom: 8px; }
.report-card h2 { font-size: var(--type-clinical); margin: 5px 0 8px; line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.radiology-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.radiology-date { color: var(--muted); font-size: 12px; font-weight: 650; }
.radiology-impression { margin: 0; color: var(--navy); font-size: var(--type-clinical); font-weight: 400; line-height: var(--line-reading); overflow-wrap: anywhere; }
.radiology-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 13px; }
.radiology-actions .button { min-height: 44px; }
.radiology-unavailable { color: var(--muted); font-size: 12px; }
.ai-badge { display: inline-flex; width: max-content; padding: 3px 7px; border-radius: 999px; color: #6550c8; background: var(--violet-soft); font-size: var(--type-caption); line-height: var(--line-ui); font-weight: var(--weight-semibold); letter-spacing: .01em; }
.radiology-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.radiology-chip { padding: 4px 8px; border-radius: 999px; background: var(--blue-soft); color: #3559bd; font-size: var(--type-caption); line-height: var(--line-ui); font-weight: var(--weight-semibold); }
.radiology-more { margin-top: 11px; border-top: 1px solid #edf0f6; padding-top: 9px; }
.radiology-more > summary { width: max-content; color: var(--blue); cursor: pointer; list-style: none; font-size: var(--type-caption); line-height: var(--line-ui); font-weight: var(--weight-semibold); }
.radiology-more > summary::-webkit-details-marker { display: none; }
.radiology-more > summary::after { content: " ›"; }
.radiology-more[open] > summary::after { content: " ⌃"; }
.radiology-expanded { display: grid; gap: 12px; padding-top: 11px; }
.ai-compact { border-left: 3px solid #b4a6f2; padding-left: 10px; }
.radiology-detail-row { margin-top: 8px; }
.radiology-detail-row b { color: var(--muted); font-size: var(--type-caption); line-height: var(--line-ui); }
.radiology-detail-row p { margin: 3px 0 0; font-size: var(--type-meta); line-height: var(--line-reading); overflow-wrap: anywhere; }
.source-report { border-top: 1px solid var(--line); padding-top: 11px; }
.source-report summary { color: var(--navy); cursor: pointer; font-size: var(--type-meta); line-height: var(--line-ui); font-weight: var(--weight-semibold); }
.source-report[open] summary { margin-bottom: 10px; }
.source-report pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.55; margin: 0; color: #29344f; }
.radiology-source-link { justify-self: start; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: var(--type-meta); font-weight: var(--weight-semibold); }
.document-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(220px,1fr)); gap: 13px; }
.document-card { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 16px; min-height: 145px; cursor: pointer; text-align: left; }
.document-card:hover { border-color: #adbbe9; }
.document-card.unavailable { cursor: default; opacity: .72; }
.document-card strong, .document-card p { max-width: 100%; overflow-wrap: anywhere; }
.document-icon { width: 45px; height: 54px; display: grid; place-items: center; border-radius: 9px; background: var(--green-soft); color: var(--green); font-weight: 800; margin-bottom: 15px; }
.document-layout { display: grid; grid-template-columns: minmax(0,1fr); align-items: start; gap: 20px; }
.document-layout.has-index { grid-template-columns: minmax(188px,220px) minmax(0,1fr); }
.document-index { position: sticky; top: 16px; display: grid; max-height: calc(100dvh - 150px); overflow-y: auto; padding: 0; scrollbar-width: thin; }
.document-index-item { display: grid; gap: 3px; min-height: 60px; padding: 10px 8px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--navy); cursor: pointer; text-align: left; }
.document-index-item:hover, .document-index-item:focus-visible { background: var(--surface); }
.document-index-item strong { overflow: hidden; color: var(--blue); font-size: var(--type-meta); line-height: var(--line-heading); font-weight: var(--weight-semibold); text-overflow: ellipsis; white-space: nowrap; }
.document-index-item .meta { overflow: hidden; font-size: var(--type-caption); text-overflow: ellipsis; white-space: nowrap; }
.document-reader { display: grid; gap: 18px; }
.document-section { scroll-margin-top: 76px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: none; overflow: clip; }
.document-section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; background: transparent; border-bottom: 1px solid var(--line); }
.document-section-head h2 { margin: 0 0 4px; font-size: var(--type-body); line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.document-section-head p { margin: 0; }
.document-original { color: var(--blue); font-size: var(--type-meta); line-height: var(--line-ui); text-decoration: none; text-align: right; max-width: 210px; }
.document-body { padding: 12px; overflow-x: hidden; }
.document-page { position: relative; width: min(100%, 820px); margin: 0 auto 12px; max-width: 100%; scroll-margin-top: 24px; }
.document-page:last-child { margin-bottom: 0; }
.document-page-open { display: block; width: 100%; padding: 0; border: 0; border-radius: 4px; overflow: hidden; background: linear-gradient(110deg,#e6e9f0 25%,#f2f4f8 38%,#e6e9f0 52%); background-size: 220% 100%; animation: document-placeholder 1.5s ease-in-out infinite; box-shadow: 0 3px 13px rgba(21,34,68,.12); cursor: zoom-in; }
.document-page-open.dimensions-pending { min-height: 180px; }
.document-page-open.loaded, .document-page-open:has(img[src]) { animation: none; background: #fff; }
.document-page img { display: block; width: 100%; height: auto; object-fit: contain; object-position: top center; background: #fff; }
.document-page figcaption { position: absolute; right: 7px; bottom: 7px; padding: 3px 7px; border-radius: 999px; background: rgba(16,29,63,.76); color: #fff; font-size: 12px; line-height: 16px; backdrop-filter: blur(5px); }
.native-pdf-frame { display: block; width: 100%; height: min(70dvh, 820px); max-height: calc(100dvh - 220px); border: 0; background: #fff; transform-origin: center center; transition: transform .16s ease; }
.native-pdf-stage { width: 100%; max-width: 100%; overflow: hidden; display: grid; place-items: center; background: #fff; }
.native-pdf-stage.is-rotated-90 .native-pdf-frame,
.native-pdf-stage.is-rotated-270 .native-pdf-frame { width: min(70dvh, 820px); height: min(100%, 640px); }
.native-pdf-stage.is-rotated-180 .native-pdf-frame { width: 100%; }
.document-fullscreen { margin: 12px 16px 16px; }
.viewer-pdf-stage { width: 100%; height: 100%; min-height: min(78dvh, 900px); display: grid; place-items: center; overflow: hidden; background: #111827; }
.viewer-pdf-frame { width: 100%; height: 100%; min-height: min(78dvh, 900px); border: 0; background: #fff; transform-origin: center center; }
.viewer-pdf-stage.is-rotated-90 .viewer-pdf-frame,
.viewer-pdf-stage.is-rotated-270 .viewer-pdf-frame { width: min(78dvh, 900px); height: min(100%, 720px); }
.document-loading { min-height: 240px; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); font-size: var(--type-caption); line-height: var(--line-reading); text-align: center; }
.loading-pulse { width: 36px; height: 36px; border-radius: 50%; background: var(--blue-soft); box-shadow: 0 0 0 0 rgba(66,105,225,.25); animation: loading-pulse 1.5s infinite; }
.docx-preview-host { width: min(100%,820px); margin: 0 auto; background: #fff; border-radius: 6px; box-shadow: 0 3px 13px rgba(21,34,68,.1); overflow: hidden; }
.docx-preview { padding: clamp(22px,5vw,52px); color: #26324e; font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif; font-size: var(--type-body); line-height: var(--line-reading); overflow-wrap: anywhere; }
.docx-preview h1 { margin: 0 0 22px; color: #1f4e79; font-size: clamp(22px,3vw,28px); line-height: var(--line-tight); font-weight: var(--weight-semibold); letter-spacing: -.018em; text-align: center; }
.docx-preview h2 { margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 1px solid #d6e2ed; color: #1f4e79; font-size: var(--type-section); line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.docx-preview h3 { margin: 20px 0 7px; color: #315f89; font-size: var(--type-body); line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.docx-preview p { margin: 0 0 11px; }
.docx-preview ul { margin: 5px 0 12px; padding-left: 22px; }
.docx-preview li { margin-bottom: 5px; }
.docx-table-wrap { max-width: 100%; overflow-x: auto; margin: 14px 0; }
.docx-preview table { width: 100%; border-collapse: collapse; font-size: var(--type-meta); line-height: var(--line-reading); }
.docx-preview td { min-width: 110px; padding: 8px; border: 1px solid #dce2ef; vertical-align: top; }
@keyframes document-placeholder { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes loading-pulse { 70% { box-shadow: 0 0 0 14px rgba(66,105,225,0); } 100% { box-shadow: 0 0 0 0 rgba(66,105,225,0); } }
.page-title { margin: 0 0 20px; font-size: var(--type-page); line-height: var(--line-tight); font-weight: var(--weight-semibold); letter-spacing: -.02em; }
.notification-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.notification-heading .page-title { margin: 0; }
.notification-read-all { min-height: 44px; font-size: var(--type-meta); }
.notification { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 0; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.notification:last-child { border: 0; }
.notification.read { opacity: 1; }
.notification.unread { border-left: 3px solid var(--blue); padding-left: 13px; }
.notification-read-one { margin-left: 12px; }
.notification-main { display: grid; grid-template-columns: 36px minmax(0,1fr); width: 100%; min-height: 60px; padding: 6px 0; border: 0; background: transparent; color: inherit; gap: 12px; align-items: center; cursor: pointer; text-align: left; }
.notification-dot { width: 34px; height: 34px; border-radius: 50%; background: var(--blue-soft); display: grid; place-items: center; color: var(--blue); }
.notification.ready .notification-dot { background: var(--green-soft); color: var(--green); }
.notification-copy { display: grid; gap: 4px; min-width: 0; }
.notification h3 { font-size: var(--type-ui); line-height: var(--line-heading); font-weight: var(--weight-semibold); margin: 0; }
.notification.read h3 { color: var(--muted); font-weight: var(--weight-medium); }
.notification-context { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); }
.notification-context time { font-variant-numeric: tabular-nums; }
.notification-read-one { min-width: 44px; min-height: 44px; padding: 0 8px; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: var(--type-meta); }
.notification-empty { margin: 0; padding: 22px; color: var(--muted); text-align: center; }
.panel { border: 1px solid var(--line); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.health-panel { margin-bottom: 22px; padding: 16px 20px; overflow: hidden; }
.health-panel h2 { margin: 0; padding: 2px 0 10px; font-size: var(--type-body); line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.health-row { min-height: 56px; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px 18px; padding: 10px 0; border-top: 1px solid var(--line); }
.health-copy { min-width: 0; display: grid; gap: 3px; }
.health-label { min-width: 0; font-weight: 650; }
.health-description { min-width: 0; color: var(--muted); font-size: var(--type-caption); line-height: var(--line-ui); overflow-wrap: anywhere; }
.health-result { min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 8px; color: var(--muted); text-align: right; overflow-wrap: anywhere; }
.health-result .status-dot { flex: 0 0 auto; }
.system-health-actions { display: flex; justify-content: flex-end; margin: -8px 0 22px; }
.system-health-actions .button { min-height: 44px; }
.health-value { font-size: var(--type-title); line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px var(--green-soft); }
.status-dot.unknown { background: var(--muted); box-shadow: 0 0 0 5px #eef0f4; }
.status-dot.status-warning { background: #c18318; box-shadow: 0 0 0 5px #fff1d8; }
.status-dot.status-error { background: var(--red); box-shadow: 0 0 0 5px var(--red-soft); }
.status-dot.status-unknown, .status-dot.status-maintenance { background: var(--muted); box-shadow: 0 0 0 5px #eef0f4; }
.device { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.device:last-child { border: 0; }
.device h3 { margin: 0 0 5px; font-size: var(--type-ui); line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.device p { margin: 0; color: var(--muted); font-size: var(--type-caption); line-height: var(--line-ui); }
.button, button.primary { border: 0; border-radius: 12px; min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; font-size: var(--type-ui); line-height: var(--line-ui); font-weight: var(--weight-semibold); transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease; }
.button { background: var(--surface-soft); color: var(--navy); }
.button.primary, button.primary { background: var(--blue); color: #fff; box-shadow: 0 1px 2px rgba(23, 37, 54, .12); }
button.primary:hover:not(:disabled), .button.primary:hover:not(:disabled) { background: #1d4366; }
.button:active:not(:disabled), button.primary:active:not(:disabled) { transform: translateY(1px); }
button:disabled, .button:disabled { cursor: not-allowed; opacity: .52; box-shadow: none; }
button.primary.wide { min-height: 48px; }
.button.subtle { background: var(--surface-soft); color: var(--navy); }
.button.soft { background: var(--blue-soft); color: var(--blue); }
.button.soft:hover:not(:disabled) { background: #dfeaf3; }
.button.danger { background: var(--red-soft); color: var(--red); }
.button.danger:hover:not(:disabled) { background: #fbdfe4; }
.wide { width: 100%; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 10px; background: var(--red); color: #fff; font-size: var(--type-caption); line-height: var(--line-ui); font-weight: var(--weight-semibold); padding: 0 5px; }
.auth-screen { min-height: 100dvh; overflow-y: auto; display: grid; place-items: center; padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom)); background: radial-gradient(circle at 50% 8%, #eaf2fb, transparent 42%), var(--bg); }
.auth-card { width: min(440px,100%); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 20px; padding: 34px; }
.auth-logo { display: block; width: 74px; height: 74px; border-radius: 0; background: transparent; }
.auth-card h1 { margin: 4px 0 8px; font-size: var(--type-page); line-height: var(--line-tight); font-weight: var(--weight-semibold); letter-spacing: -.02em; }
.auth-card form { display: grid; gap: 15px; margin-top: 25px; }
.auth-card label { display: grid; gap: 7px; font-size: var(--type-ui); line-height: var(--line-ui); font-weight: var(--weight-semibold); }
.auth-card input[type="email"], .auth-card input[type="password"] { width: 100%; height: 48px; border: 1px solid #dfe3ee; border-radius: 12px; padding: 0 13px; outline: 0; font-size: 16px; }
.auth-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.trusted-choice { grid-template-columns: auto 1fr; align-items: start; padding: 12px; background: var(--surface-soft); border-radius: 12px; cursor: pointer; }
.trusted-choice input { width: 20px; height: 20px; margin: 1px 2px 0 0; accent-color: var(--blue); }
.trusted-choice span { display: grid; gap: 4px; }
.trusted-choice small { color: var(--muted); font-weight: 400; line-height: 1.4; }
.form-error { min-height: 18px; color: var(--red); font-size: var(--type-meta); line-height: var(--line-ui); margin: -4px 0; }
.security-note { text-align: center; color: var(--muted); font-size: var(--type-meta); line-height: var(--line-reading); margin: 18px 0 0; }
.viewer-open { overscroll-behavior: none; }
html:has(dialog[open]), body:has(dialog[open]) { overflow: hidden; overscroll-behavior: none; }
html:has(dialog[open]) .workspace,
html:has(dialog[open]) .patient-list { overflow: hidden; }
.viewer { position: fixed; inset: 0; width: min(1200px,100vw); height: min(900px,100dvh); max-width: none; max-height: none; margin: auto; border: 0; padding: 0; border-radius: 20px; overflow: hidden; background: #e8ebf2; grid-template-rows: auto minmax(0,1fr) auto; }
.viewer[open] { display: grid; }
.viewer::backdrop { background: rgba(13,22,45,.55); backdrop-filter: blur(5px); }
.viewer-bar { position: relative; z-index: 2; min-height: 64px; padding: max(8px,env(safe-area-inset-top)) 16px 8px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; overflow: visible; }
.viewer-bar > div:first-child { display: grid; min-width: 0; }
.viewer-bar strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: var(--type-ui); line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.viewer-bar small { color: var(--muted); font-size: var(--type-caption); line-height: var(--line-ui); }
.viewer-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.viewer-rotation-controls { display: flex; align-items: center; gap: 4px; }
.viewer-rotation-controls .viewer-tool { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--navy); cursor: pointer; font-size: 20px; }
.viewer-rotation-controls .viewer-tool:hover { background: var(--surface-soft); }
.viewer-rotation-controls .viewer-menu-panel { top: calc(100% + 8px); right: 0; bottom: auto; }
.viewer-canvas { min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y pinch-zoom; padding: 15px; overscroll-behavior: contain; }
.viewer-canvas iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-pdf-stage { width: 100%; height: 100%; min-height: min(70dvh,720px); display: grid; place-items: center; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.viewer-pdf-stage iframe { width: 100%; height: 100%; border: 0; background: #fff; transform-origin: center center; transition: transform .16s ease; }
.viewer-pdf-stage.is-rotated-90 iframe,
.viewer-pdf-stage.is-rotated-270 iframe { width: min(70dvh,720px); height: min(100%,100%); max-width: 100%; }
.viewer-canvas img { display: block; flex: 0 0 auto; max-width: none; height: auto; object-fit: contain; object-position: top center; box-shadow: var(--shadow); transition: transform .16s ease; transform-origin: center center; }
.viewer-thumbs { position: relative; z-index: 2; min-height: calc(60px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; overflow-x: auto; overflow-y: hidden; overscroll-behavior: contain; padding: 8px 15px max(8px, env(safe-area-inset-bottom)); background: #fff; }
.viewer-thumbs button { min-width: 42px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-soft); }
.viewer-thumbs button.active { color: #fff; border-color: var(--blue); background: var(--blue); }
.viewer-thumbs button:disabled { opacity: .4; }
.viewer-thumbs .viewer-sep { width: 1px; height: 22px; background: var(--line); flex: 0 0 auto; margin: 0 2px; }
.viewer-thumbs .viewer-tool { min-width: 44px; min-height: 44px; height: 44px; display: inline-grid; place-items: center; color: var(--navy); }
.viewer-thumbs .viewer-tool svg { width: 18px; height: 18px; display: block; }
.viewer-menu { position: relative; }
.viewer-menu-panel { position: absolute; right: 0; bottom: calc(100% + 8px); min-width: 180px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); display: grid; gap: 4px; }
.viewer-menu-panel button { min-height: 44px; justify-content: flex-start; padding: 0 12px; width: 100%; }
.dossier-person-main { min-width: 0; display: grid; gap: 8px; }
.dossier-person-top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; }
.edit-identity-button { min-height: 36px; padding: 0 12px; border: 0; border-radius: 11px; background: var(--surface-soft); color: #42527a; display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 650; cursor: pointer; }
.edit-identity-button:hover { background: #e8ecf8; }
.edit-identity-button svg { width: 15px; height: 15px; flex: 0 0 auto; }
.identity-provenance { color: var(--muted); font-size: 12px; }
.identity-sheet { width: min(520px, calc(100vw - 24px)); max-height: min(920px, calc(100dvh - 24px)); border: 0; border-radius: 22px; padding: 0; overflow: hidden; box-shadow: 0 24px 80px rgba(20,34,70,.28); }
.identity-sheet[open] { display: flex; flex-direction: column; }
.identity-sheet::backdrop { background: rgba(20,27,45,.45); }
.identity-sheet-body { overflow-y: auto; padding: 22px 22px 8px; display: grid; gap: 14px; }
.identity-sheet h2 { margin: 0; font-size: var(--type-title); line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.identity-sheet .sheet-lead { margin: 0; color: var(--muted); font-size: var(--type-ui); line-height: var(--line-reading); }
.identity-recognized { padding: 12px 14px; border-radius: 14px; background: var(--surface-soft); color: #42527a; font-size: var(--type-meta); line-height: var(--line-reading); }
.identity-recognized strong { display: block; color: var(--navy); margin-bottom: 4px; }
.identity-form { display: grid; gap: 12px; }
.identity-form label { display: grid; gap: 6px; font-size: var(--type-ui); line-height: var(--line-ui); font-weight: var(--weight-semibold); }
.identity-form input, .identity-form select { width: 100%; min-height: 44px; border: 1px solid #dfe3ee; border-radius: 12px; padding: 0 12px; background: #fff; outline: 0; }
.identity-form input:focus, .identity-form select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.identity-form .field-error { color: var(--red); font-size: 12px; font-weight: 500; min-height: 16px; }
.identity-form-row { display: grid; grid-template-columns: 1.2fr .8fr; gap: 12px; }
.identity-sheet-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px max(16px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fbfcff; }
.identity-diff { display: grid; gap: 10px; }
.identity-diff-row { display: grid; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--surface-soft); }
.identity-diff-row b { font-size: 12px; color: var(--muted); font-weight: 650; }
.identity-conflict { display: grid; gap: 12px; }
.identity-conflict-card { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.identity-conflict-card h3 { margin: 0 0 6px; font-size: var(--type-meta); color: var(--muted); line-height: var(--line-ui); font-weight: var(--weight-semibold); }
.identity-conflict-card p { margin: 0; font-size: var(--type-ui); line-height: var(--line-reading); }
.notification-permission { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; padding: 16px; }
.notification-permission h2, .notification-permission p { margin: 0; }.notification-permission h2 { margin-bottom: 4px; font-size: var(--type-body); line-height: var(--line-heading); font-weight: var(--weight-semibold); }
.toast { position: fixed; z-index: 100; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: #172444; color: #fff; border-radius: 12px; padding: 12px 17px; box-shadow: var(--shadow); font-size: 13px; }
.offline-banner { position: fixed; z-index: 95; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 32px); transform: translateX(-50%); padding: 9px 14px; border: 1px solid #e6c890; border-radius: 999px; background: rgba(255,248,232,.97); color: #714600; box-shadow: 0 8px 28px rgba(50,38,10,.12); font-size: 13px; line-height: 18px; text-align: center; }
.mobile-header, .mobile-menu { display: none; }
.account-mark { display: block; width: 36px; height: 36px; flex: 0 0 auto; border-radius: 0; background: transparent; }
.brand img, .mobile-header .brand-mark { display: block; border-radius: 0; background: transparent; }
.patient-avatar-frame { position: relative; display: block; flex: 0 0 auto; width: 44px; height: 44px; overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; filter: none; }
.patient-avatar-frame.large { width: 56px; height: 56px; }
.patient-avatar-frame.small { width: 34px; height: 34px; }
.patient-avatar { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; object-fit: contain; object-position: center; border-radius: 0; background: transparent; filter: none; box-shadow: none; mix-blend-mode: darken; pointer-events: none; }
.i { width: 20px; height: 20px; display: inline-block; background: currentColor; mask-size: contain; mask-repeat: no-repeat; mask-position: center; }
.i-people { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='9' cy='8' r='3'/%3E%3Cpath d='M3 19c0-4 2-6 6-6s6 2 6 6M16 6a3 3 0 0 1 0 6M17 14c2.7.3 4 2 4 5'/%3E%3C/svg%3E"); }
.i-search { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='m16 16 5 5'/%3E%3C/svg%3E"); }
.i-bell { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M5 17h14l-2-3V9a5 5 0 0 0-10 0v5l-2 3Z'/%3E%3Cpath d='M10 20h4'/%3E%3C/svg%3E"); }
.i-system { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Crect x='3' y='4' width='18' height='14' rx='3'/%3E%3Cpath d='M8 21h8M9 13l2-2 2 2 3-4'/%3E%3C/svg%3E"); }
.i-settings { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19 13.5v-3l-2-.7-.5-1.2.9-1.9-2.1-2.1-1.9.9-1.2-.5-.7-2h-3l-.7 2-1.2.5-1.9-.9-2.1 2.1.9 1.9-.5 1.2-2 .7v3l2 .7.5 1.2-.9 1.9 2.1 2.1 1.9-.9 1.2.5.7 2h3l.7-2 1.2-.5 1.9.9 2.1-2.1-.9-1.9.5-1.2 2-.7Z'/%3E%3C/svg%3E"); }
.i-scan { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8V6a2 2 0 0 1 2-2h2M20 8V6a2 2 0 0 0-2-2h-2M4 16v2a2 2 0 0 0 2 2h2M20 16v2a2 2 0 0 1-2 2h-2'/%3E%3Cpath d='M7 12h10'/%3E%3C/svg%3E"); }
.i-refresh { width: 21px; height: 21px; mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 11a8 8 0 1 0-2.34 5.66'/%3E%3Cpath d='M20 4v7h-7'/%3E%3C/svg%3E"); }
.power-card { display: grid; gap: 18px; margin-bottom: 28px; padding: 22px; overflow: hidden; }
.power-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.power-heading h2, .power-danger h3 { margin: 0; }
.server-running { color: #238653; font-weight: 650; }
.server-running::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #2db66f; }
.power-status { display: grid; grid-template-columns: minmax(150px,1fr) minmax(140px,1fr); gap: 9px 18px; margin: 0; }
.power-status dt { color: var(--muted); }.power-status dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.switch-row { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 12px; }
.switch-row input { width: 48px; height: 28px; accent-color: var(--blue); }
.schedule-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.schedule-form label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.schedule-form input { min-width: 0; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; }
.power-actions { display: grid; gap: 10px; padding-top: 4px; }
.duration-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }.duration-row span { margin-right: auto; }
.power-danger { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }.power-danger h3 { width: 100%; font-size: 15px; }
.power-warning { margin: 0; padding: 11px 13px; border-radius: 10px; background: #fff4df; color: #79510d; font-size: 13px; }.power-warning.hidden { display: none; }
.power-info { display: grid; gap: 3px; margin: 0; padding: 12px 14px; border-radius: 12px; background: #eef5ff; color: #315b88; font-size: 13px; }.power-info strong { color: #244c75; }.power-info span { line-height: 1.4; }
.power-footer, .power-unavailable { margin: 0; color: var(--muted); font-size: 13px; }.power-unavailable { font-size: 16px; font-weight: 650; }
.confirm-dialog { width: min(440px,calc(100vw - 28px)); padding: 24px; border: 0; border-radius: 20px; box-shadow: 0 24px 80px rgba(20,34,70,.28); }.confirm-dialog::backdrop { background: rgba(20,27,45,.45); }.confirm-dialog h2 { margin-top: 0; }.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.gemscan-page { display: grid; gap: 22px; }
.gemscan-section { display: grid; gap: 12px; padding: 18px; }
.gemscan-section > h2 { margin: 0; font-size: 18px; }
.gemscan-section > p.meta { margin: 0; }
.gemscan-enroll-form, .gemscan-recipient-form { display: grid; gap: 12px; }
.gemscan-enroll-form label, .gemscan-recipient-form label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.gemscan-enroll-form input, .gemscan-recipient-form input, .gemscan-recipient-form select, .gemscan-recipient-form textarea {
  min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-soft); color: var(--navy); font: inherit;
}
.gemscan-recipient-form textarea { min-height: 72px; resize: vertical; }
.gemscan-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.gemscan-code-card {
  display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: #eef3ff; border: 1px solid #d7e1fb;
}
.gemscan-code-card.expired { background: #fff4df; border-color: #f0d7a4; }
.gemscan-code-value {
  margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; color: var(--navy); user-select: all;
}
.gemscan-category {
  display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 650;
}
.gemscan-category.a { background: #e8f6ee; color: #1f6b45; }
.gemscan-category.b { background: #eef2ff; color: #3454b4; }
.gemscan-status { color: var(--muted); font-size: 12px; }
.gemscan-status.active { color: #1f6b45; }
.gemscan-status.revoked, .gemscan-status.inactive { color: #9a3b32; }
.gemscan-help { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.gemscan-help strong { color: var(--navy); font-weight: 650; }
.device .gemscan-device-meta, .device .gemscan-recipient-meta { display: grid; gap: 4px; }
.device .gemscan-device-meta p, .device .gemscan-recipient-meta p { margin: 0; }
.device.gemscan-doctor { grid-template-columns: minmax(0,1fr); align-items: stretch; gap: 14px; }
.gemscan-web-access { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.gemscan-web-access.active { color: #1f6b45; }
.gemscan-web-access.invite_pending { color: #79510d; }
.gemscan-web-access.disabled { color: #9a3b32; }
.gemscan-doctor-actions, .gemscan-device-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.gemscan-filter select { min-width: 9.5rem; }
.gemscan-doctor-actions .button, .gemscan-doctor-actions button.primary {
  min-height: 40px; padding: 0 12px; font-size: 14px;
}
.gemscan-invite-form { display: grid; gap: 12px; }
.gemscan-invite-form label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.gemscan-invite-form input {
  min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface-soft); color: var(--navy); font: inherit;
}
.gemscan-invite-link {
  margin: 0; padding: 12px; border-radius: 12px; background: #eef3ff; border: 1px solid #d7e1fb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; color: var(--navy); user-select: all;
}
@media (max-width: 820px) {
  .gemscan-section { padding: 14px; }
  .gemscan-code-value { font-size: 14px; }
  .schedule-form { grid-template-columns: 1fr; }
  .gemscan-doctor-actions .button, .gemscan-doctor-actions button.primary { flex: 1 1 auto; }
}
#refresh[aria-busy="true"] .i-refresh { animation: refresh-spin .8s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .app { grid-template-columns: 82px 320px minmax(0,1fr); }
  .sidebar { padding-inline: 14px; }
  .brand { margin-inline: auto; }
  .brand strong, .nav:not(.active)::after, .nav { font-size: 0; }
  .nav { justify-content: center; padding: 0; }
  .nav .i { width: 22px; height: 22px; }
  .nav .badge { position: absolute; margin: -27px 0 0 25px; }
  .account > div:last-child { display: none; }
  .account { justify-content: center; }
  .dashboard-header { grid-template-columns: 1fr; align-items: start; gap: 24px; }
  .patient-overview { min-width: 0; }
  .dashboard-sections { grid-template-columns: 1fr; gap: 24px; padding-top: 24px; }
}
@media (max-width: 820px) {
  html, body { overflow-x: hidden; }
  body { overflow-y: auto; }
  .app { display: block; height: auto; min-height: 100dvh; padding-top: calc(56px + env(safe-area-inset-top)); padding-bottom: env(safe-area-inset-bottom); }
  .sidebar { display: none; }
  .mobile-header { position: fixed; z-index: 40; left: 0; right: 0; top: 0; height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0 14px; background: rgba(255,255,255,.96); backdrop-filter: blur(18px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
  .mobile-brand { min-height: 44px; display: flex; align-items: center; gap: 7px; font-size: var(--type-body); }
  .mobile-brand strong { white-space: nowrap; }
  .mobile-header .brand-mark { width: 32px; height: 32px; }
  .mobile-menu-button { position: relative; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--navy); cursor: pointer; }
  .mobile-menu-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .mobile-menu-button .badge { position: absolute; top: -4px; right: -4px; }
  .mobile-menu { position: absolute; display: grid; top: calc(100% + 7px); right: 10px; width: min(286px,calc(100vw - 20px)); padding: 7px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.98); box-shadow: 0 18px 50px rgba(20,34,70,.18); }
  .mobile-menu button { width: 100%; min-height: 46px; display: grid; grid-template-columns: 24px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 0 11px; border: 0; border-radius: 11px; background: transparent; color: var(--navy); cursor: pointer; text-align: left; }
  .mobile-menu button.active { background: var(--blue-soft); color: #345dd4; font-weight: 700; }
  .mobile-menu .i { width: 20px; height: 20px; }
  .mobile-menu-section { margin: 5px 10px 2px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--type-caption); line-height: var(--line-ui); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: .04em; }
  .patient-rail { display: block; overflow: visible; border: 0; padding: 12px 16px 40px; min-height: calc(100dvh - 132px); }
  .patient-rail.hidden-mobile { display: none; }
  .patient-rail .rail-heading, .patient-rail .search-box { margin-inline: 0; }
  .rail-heading { padding: 4px 0 4px; }
  .rail-heading h2 { font-size: 26px; line-height: var(--line-tight); letter-spacing: -.025em; }
  .mobile-patient-overview { display: block; margin: 0 0 10px; color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); font-weight: var(--weight-medium); white-space: nowrap; }
  .patient-rail .search-box { margin-bottom: 8px; }
  .patient-list { overflow: visible; padding: 0; }
  .patient-row .patient-avatar-frame { width: 44px; height: 44px; }
  .patient-row { padding: 12px; }
  .workspace { display: none; overflow: visible; padding: 16px 20px 44px; }
  .workspace.mobile-active { display: block; }
  .workspace.mobile-active { scroll-padding-top: calc(62px + env(safe-area-inset-top)); }
  .content { max-width: none; }
  .welcome-state { min-height: 50vh; }
  .patient-header { position: relative; z-index: 1; grid-template-columns: 44px minmax(0,1fr) 44px; gap: 8px; margin: -16px -20px 0; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); }
  .patient-header > .patient-back { grid-column: 1; grid-row: 1; }
  .patient-header-person { grid-column: 2; grid-row: 1; gap: 10px; min-width: 0; }
  .patient-header > .patient-overflow-menu { grid-column: 3; grid-row: 1; }
  .patient-header .patient-avatar-frame.large { width: 50px; height: 50px; }
  .patient-header-identity h1 { font-size: 20px; line-height: var(--line-tight); letter-spacing: -.018em; }
  .patient-header-identity p { margin-top: 3px; font-size: var(--type-meta); line-height: var(--line-ui); }
  .patient-compact-header { position: fixed; z-index: 35; top: calc(56px + env(safe-area-inset-top)); left: 0; right: 0; height: 56px; display: grid; grid-template-columns: 44px 36px minmax(0,1fr) 44px; align-items: center; gap: 7px; padding: 4px 16px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97); backdrop-filter: blur(18px); }
  .patient-compact-header .patient-avatar-frame.small { width: 36px; height: 36px; }
  .patient-compact-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: var(--type-body); font-weight: var(--weight-semibold); }
  .patient-compact-header .patient-overflow-menu { display: block; justify-self: end; }
  .patient-primary-nav { gap: 12px; margin: 8px 0 0; }
  .patient-primary-nav button { flex: 1; min-height: 48px; padding-inline: 0; font-size: var(--type-ui); }
  .patient-clinical-section { padding: 20px 0; }
  .clinical-section-heading { align-items: center; margin-bottom: 10px; }
  .clinical-section-heading h2 { font-size: var(--type-section); line-height: var(--line-heading); }
  .clinical-section-body { font-size: var(--type-clinical); line-height: var(--line-reading); }
  .patient-primary-nav + .patient-clinical-section { padding: 18px 0 20px; }
  .patient-primary-nav + .patient-clinical-section .clinical-section-heading { margin-bottom: 8px; }
  .summary-timeline-row { grid-template-columns: 94px minmax(0,1fr); gap: 10px; }
  .load-error-actions { align-items: stretch; flex-direction: column; }
  .load-error-actions .button { width: 100%; min-height: 48px; }
  .dossier-person { grid-template-columns: 56px minmax(0,1fr); gap: 11px; padding: 13px 14px; }
  .dossier-person .patient-avatar-frame.large { width: 56px; height: 56px; border-radius: 14px; }
  .header-status { grid-column: 1 / -1; margin-top: -2px; }
  .edit-identity-button { min-height: 44px; }
  .identity-sheet { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border-radius: 0; }
  .identity-form-row { grid-template-columns: 1fr; }
  .identity-sheet-footer { flex-direction: column-reverse; }
  .identity-sheet-footer .button { width: 100%; min-height: 44px; }
  .dossier-person h1 { font-size: var(--type-title); }
  .person-meta { gap: 5px 7px; font-size: var(--type-caption); }
  .update-strip { display: grid; gap: 5px; padding: 9px 14px; }
  .action-grid { gap: 8px; }
  .action-card { min-height: 64px; display: grid; justify-items: center; text-align: center; gap: 3px; padding: 6px 3px; font-size: 12px; line-height: 16px; }
  .module-icon { width: 34px; height: 34px; }
  .module-icon img { width: 28px; height: 28px; }
  .clinical-card { border-radius: 16px; }
  .clinical-card summary { padding: 15px 14px; }
  .clinical-body { padding: 14px; }
  .clinical-body .lead { font-size: var(--type-clinical); }
  .detail-list { grid-template-columns: 1fr; }
  .document-layout, .document-layout.has-index { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .document-index { position: static; display: flex; max-height: none; overflow-x: auto; overflow-y: hidden; gap: 8px; margin: 0; padding: 1px 0 5px; }
  .document-index-item { flex: 0 0 min(70vw,240px); min-height: 58px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
  .document-reader { gap: 14px; }
  .document-section { scroll-margin-top: calc(62px + env(safe-area-inset-top)); border-radius: 15px; margin-inline: -4px; }
  .document-section-head { align-items: flex-start; padding: 12px; }
  .document-section-head h2 { font-size: var(--type-body); }
  .document-original { max-width: 44%; min-height: 44px; display: flex; align-items: center; justify-content: flex-end; font-size: var(--type-caption); }
  .document-body { padding: 6px; }
  .document-page { margin-bottom: 7px; scroll-margin-top: calc(74px + env(safe-area-inset-top)); }
  .document-page-open { border-radius: 2px; }
  .docx-preview { padding: 22px 16px 28px; font-size: var(--type-ui); line-height: var(--line-reading); }
  .docx-preview h1 { margin-bottom: 20px; font-size: var(--type-title); }
  .docx-preview h2 { margin-top: 23px; font-size: var(--type-body); }
  .docx-preview td { min-width: 96px; padding: 7px; }
  .dossier-back { margin-top: 2px; min-height: 46px; padding-top: 10px; }
  .health-panel { padding: 16px 18px; }
  .health-row { align-items: start; gap: 8px 12px; }
  .health-result { padding-top: 2px; }
  .power-card { padding: 17px 14px; }.power-heading { align-items: flex-start; flex-direction: column; }.power-status { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }.schedule-form { grid-template-columns: 1fr; }.schedule-form .button, .power-actions > .button, .power-danger .button { width: 100%; min-height: 44px; }.duration-row .button { flex: 1; min-width: 62px; min-height: 44px; }.dialog-actions { flex-direction: column-reverse; }.dialog-actions .button { width: 100%; min-height: 44px; }
  .notification-heading { align-items: flex-start; }
  .notification-heading { flex-direction: column; }
  .notification-read-all { width: 100%; }
  .report-card { padding: 14px 0 22px; border-radius: 0; }
  .radiology-impression { font-size: 16px; }
  .page-title, .subpage-head h1 { font-size: var(--type-title); }
  .viewer { width: 100vw; height: 100dvh; border-radius: 0; }
  .viewer-canvas { padding: 6px; }
  .viewer-canvas img { width: 100%; min-height: min-content; }
  .viewer-bar { min-height: calc(64px + env(safe-area-inset-top)); padding-top: max(8px,env(safe-area-inset-top)); }
  .viewer-actions .button { display: none; }
  .viewer-bar { padding-inline: 10px; gap: 6px; }
  .viewer-bar > div:first-child { flex: 1 1 auto; }
  .viewer-actions { gap: 4px; }
  .viewer-rotation-controls { gap: 2px; }
  .viewer-rotation-controls .viewer-tool, #viewer-close { width: 44px; height: 44px; border-radius: 12px; }
  .viewer-thumbs button { min-width: 44px; height: 44px; }
  .notification-permission { align-items: stretch; flex-direction: column; }.notification-permission .button { width: 100%; min-height: 44px; }
  .auth-card { padding: 27px 22px; border-radius: 18px; }
  .auth-card h1 { font-size: var(--type-title); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
@media (max-width: 390px) {
  .workspace { padding-inline: 16px; }
  .patient-header { margin-inline: -16px; }
  .report-card { padding: 14px 0 22px; }
  .timeline { --timeline-rail-x: 4px; margin-left: 0; padding-left: 20px; }
  .timeline-marker { left: -19px; width: 9px; height: 9px; }
  .timeline-marker img { display: none; }
  .timeline-year { margin-left: -20px; }
}
@media (min-width: 821px) and (max-width: 1050px) {
  .app { grid-template-columns: 290px minmax(0,1fr); }
  .sidebar { display: none; }
}

@media (max-width: 820px) {
  .patient-rail #refresh { color: var(--muted); }
  .patient-rail .search-box { border-color: #e0e7f0; }
  .patient-rail .search-box > .i { color: #50708d; }
  .patient-rail .search-box:focus-within { border-color: #a9bdd2; box-shadow: 0 0 0 2px rgba(35,79,120,.08); }

  .patient-rail .patient-row-chevron { color: #8297ac; }
  .patient-rail .patient-row:active { background: #f0f5fa; }
}

.demo-badge{display:inline-flex;align-items:center;min-height:22px;padding:0 8px;border-radius:8px;background:#fff4df;color:#79510d;font-size:var(--type-caption);line-height:var(--line-ui);font-weight:var(--weight-semibold);letter-spacing:.02em;margin-top:4px}
.ai-provider-settings{display:grid;gap:12px;margin-bottom:20px}.ai-provider-options{display:grid;gap:8px;border:0;padding:0;margin:0}.ai-provider-options legend{font-weight:var(--weight-semibold);font-size:var(--type-section);margin-bottom:8px}.ai-provider-options label{display:flex;align-items:center;gap:8px;min-height:40px}.ai-provider-stats p{margin:4px 0;color:var(--muted);font-size:var(--type-meta)}.ai-provider-waiting{display:grid;gap:8px;border-top:1px solid var(--line);padding-top:12px}.ai-provider-waiting h3{margin:0;font-size:var(--type-ui)}.ai-provider-waiting-row{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap}.ai-provider-waiting-row span{font-size:var(--type-meta);color:var(--muted)}
.ai-provider-badge,.ai-provider-review{display:inline-flex;align-items:center;width:max-content;max-width:100%;margin-top:4px;padding:2px 8px;border-radius:8px;background:var(--blue-soft);color:var(--blue);font-size:var(--type-caption);line-height:var(--line-ui);font-weight:var(--weight-medium)}.ai-provider-review{background:var(--orange-soft);color:var(--orange)}
.patient-row.demo-patient{border-color:#f0d7a4}
.demo-banner{display:grid;gap:2px;margin-top:8px;padding:10px 12px;border-radius:12px;background:#fff4df;border:1px solid #f0d7a4;color:#79510d}
.demo-banner strong{font-size:var(--type-meta);line-height:var(--line-ui);font-weight:var(--weight-semibold);overflow-wrap:anywhere}
.demo-banner span{font-size:var(--type-caption);line-height:var(--line-ui);opacity:.92}


.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.admin-patients-toolbar { display: grid; gap: 10px; margin-bottom: 12px; }
.admin-patients-filters { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; }
.admin-patients-filters input, .admin-patients-filters select {
  min-height: 44px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-soft); color: var(--navy); font: inherit;
}
.admin-patients-list { display: grid; gap: 8px; }
.admin-patient-card {
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden;
}
.admin-patient-card.archived { opacity: .92; }
.admin-patient-toggle {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; padding: 12px 14px; border: 0; background: transparent;
  color: inherit; font: inherit; cursor: pointer;
}
.admin-patient-main { display: grid; gap: 4px; min-width: 0; }
.admin-patient-main strong { font-size: var(--type-clinical); line-height: var(--line-heading); font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.admin-patient-meta { color: var(--muted); font-size: var(--type-meta); line-height: var(--line-ui); }
.admin-archive-mark { display: inline-flex; width: fit-content; margin-top: 2px; padding: 2px 8px; border-radius: 8px; background: #eef2f7; color: #5b6b7c; font-size: var(--type-caption); line-height: var(--line-ui); font-weight: var(--weight-semibold); }
.admin-patient-chevron { color: var(--muted); font-size: 16px; line-height: 1.4; flex: 0 0 auto; }
.admin-patient-expand { display: grid; gap: 6px; padding: 0 14px 14px; border-top: 1px solid var(--line); }
.admin-patient-expand > p { margin: 10px 0 0; font-size: var(--type-ui); line-height: var(--line-reading); }
.admin-patients-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.admin-delete-preview { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 4px; }
.admin-delete-preview li { font-size: var(--type-ui); line-height: var(--line-reading); }
.admin-delete-dialog { width: min(440px, calc(100vw - 28px)); }
@media (max-width: 720px) {
  .admin-patients-filters { grid-template-columns: 1fr; }
  .admin-patient-toggle { padding: 12px; }
}

/* Focused visual refinements: keep clinical surfaces flat and controls predictable. */
.viewer-rotation-controls .viewer-tool { font-size: 22px; font-weight: var(--weight-semibold); }
.viewer-thumbs button { min-width: 44px; height: 44px; border-radius: 10px; font-size: var(--type-meta); font-weight: var(--weight-medium); scroll-snap-align: center; }
.viewer-menu-panel button { min-height: 44px; width: 100%; justify-content: flex-start; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--navy); font: inherit; text-align: left; cursor: pointer; }
.viewer-menu-panel button:hover:not(:disabled), .viewer-menu-panel button:focus-visible { background: var(--surface-soft); }
.viewer-menu-panel button:disabled { color: var(--muted); }
.event-more summary { display: inline-flex; min-height: 44px; align-items: center; }
.gemscan-page { gap: 18px; }
.gemscan-section { gap: 10px; padding: 16px; }
.gemscan-filter select { min-width: 9.5rem; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--navy); font: inherit; }
.notification-read-one { min-height: 44px; margin-left: 8px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: var(--blue); font: inherit; font-size: var(--type-caption); font-weight: var(--weight-semibold); cursor: pointer; }
.notification-read-one:hover { background: var(--blue-soft); }

@media (max-width: 820px) {
  .dashboard-header { gap: 18px; padding-bottom: 20px; }
  .dashboard-sections { gap: 20px; padding-top: 20px; }
  .mobile-menu { border-radius: 16px; background: #fff; box-shadow: 0 12px 34px rgba(23,37,54,.14); }
  .mobile-menu button.active { color: var(--blue); font-weight: var(--weight-semibold); }
}

@media (prefers-reduced-motion: reduce) {
  .button, button.primary { transition-duration: .01ms !important; }
}

@media (max-width: 720px) {
 .patient-row .patient-avatar-frame { width: 56px; height: 56px; justify-self: center; }
}
