:root {
  --ink: #183247;
  --ink-deep: #0d2435;
  --blue: #2168d5;
  --blue-dark: #174fa8;
  --blue-soft: #edf4ff;
  --teal: #0d9488;
  --teal-soft: #e9f8f5;
  --paper: #ffffff;
  --canvas: #f4f7f9;
  --surface-subtle: #f8fafb;
  --line: #dfe7ec;
  --line-strong: #cad6de;
  --muted: #647784;
  --muted-light: #8a9aa5;
  --danger: #b74438;
  --danger-soft: #fff1ef;
  --shadow-sm: 0 1px 2px rgba(13, 36, 53, .04), 0 5px 18px rgba(13, 36, 53, .04);
  --shadow: 0 16px 45px rgba(13, 36, 53, .09);
  --radius: 18px;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);
  --duration-press: 140ms;
  --duration-fast: 160ms;
  --duration-ui: 220ms;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; overflow-x: hidden; }
body { min-height: 100vh; margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
svg { display: block; }
:focus-visible { outline: 3px solid rgba(33, 104, 213, .25); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 14px; border-radius: 10px; background: var(--ink-deep); color: white; transform: translateY(-150%); transition: transform var(--duration-fast) var(--ease-out); }
.skip-link:focus { transform: translateY(0); }

.app-shell { padding-top: calc(68px + env(safe-area-inset-top)); }
.app-main { width: 100%; }
.topbar { position: fixed; z-index: 30; inset: 0 0 auto; height: calc(68px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); background: rgba(255, 255, 255, .94); border-bottom: 1px solid rgba(13, 36, 53, .09); backdrop-filter: blur(18px); }
.topbar-inner { width: min(1200px, calc(100% - 40px)); height: 100%; margin: 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; width: max-content; text-decoration: none; font-size: 19px; font-weight: 790; letter-spacing: -.035em; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 11px 4px 11px 11px; background: var(--ink-deep); color: white; font-weight: 820; letter-spacing: -.08em; box-shadow: 0 6px 15px rgba(13, 36, 53, .16); }
.brand-mark span { color: #56d9cf; margin-left: 1px; }
.brand-mark.large { width: 52px; height: 52px; border-radius: 16px 5px 16px 16px; font-size: 21px; }
.main-nav { display: flex; align-items: center; justify-content: center; }
.nav-link { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 13px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 720; transition: color var(--duration-fast) ease, background-color var(--duration-fast) ease, transform var(--duration-press) var(--ease-out); }
.nav-link svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-link:hover, .nav-link.active { background: var(--blue-soft); color: var(--blue); }
.doctor-menu { justify-self: end; display: flex; align-items: center; gap: 7px; }
.mobile-app-menu { display: none; }
.doctor-profile-link { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 12px; text-decoration: none; transition: color var(--duration-fast) ease, background-color var(--duration-fast) ease, transform var(--duration-press) var(--ease-out); }
.doctor-profile-link:hover { background: var(--surface-subtle); }
.doctor-profile-link.active { background: var(--blue-soft); color: var(--blue); }
.profile-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--teal-soft); color: var(--teal); font-size: 11px; font-weight: 800; }
.doctor-copy { display: grid; line-height: 1.2; }
.doctor-copy strong { font-size: 13px; }
.doctor-copy small { display: flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--muted); font-size: 11px; }
.presence-dot { width: 6px; height: 6px; border-radius: 50%; background: #27ad78; box-shadow: 0 0 0 3px #e2f6ed; }
.profile-edit-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.sign-out-button { width: 38px !important; height: 38px !important; }

.flash-stack { position: fixed; z-index: 50; top: calc(80px + env(safe-area-inset-top)); right: max(20px, env(safe-area-inset-right)); display: grid; gap: 10px; max-width: min(420px, calc(100vw - 40px)); pointer-events: none; }
.flash { padding: 13px 16px; border: 1px solid #b9ead4; border-radius: 12px; background: #edfbf4; color: #176a48; box-shadow: var(--shadow); font-size: 14px; font-weight: 650; }
.flash.alert { background: var(--danger-soft); border-color: #f1c1bb; color: var(--danger); }

.dashboard-page, .patient-page, .prescription-view-page { width: min(1200px, calc(100% - 40px)); margin: 0 auto; padding: 38px 0 calc(64px + env(safe-area-inset-bottom)); }
.dashboard-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.dashboard-heading h1, .patient-profile-header h1, .prescription-view-header h1 { margin: 5px 0 5px; color: var(--ink-deep); font-size: clamp(30px, 3.5vw, 40px); line-height: 1.1; letter-spacing: -.043em; }
.dashboard-heading > div > p:last-child, .patient-profile-main p, .prescription-view-header p { margin: 0; color: var(--muted); font-size: 15px; }
.eyebrow { margin: 0; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .115em; text-transform: uppercase; }
.primary-button, .secondary-button, .write-button, .search-button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 8px; border-radius: 11px; padding: 0 17px; text-decoration: none; cursor: pointer; font-weight: 730; transition: transform var(--duration-press) var(--ease-out), box-shadow var(--duration-fast) ease, background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, color var(--duration-fast) ease; }
.primary-button svg, .secondary-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.primary-button { border: 1px solid var(--blue); background: var(--blue); color: white; box-shadow: 0 6px 16px rgba(33, 104, 213, .18); }
.primary-button:hover { border-color: var(--blue-dark); background: var(--blue-dark); transform: translateY(-1px); box-shadow: 0 9px 22px rgba(33, 104, 213, .22); }
.primary-button.full { width: 100%; }
.secondary-button { border: 1px solid var(--line-strong); background: white; color: var(--ink); }
.secondary-button:hover { border-color: #aebdc7; background: var(--surface-subtle); }

.search-panel { display: grid; grid-template-columns: minmax(220px, .6fr) minmax(420px, 1.4fr); align-items: center; gap: 28px; margin-bottom: 24px; padding: 22px 24px; border: 1px solid #dbe5ec; border-radius: var(--radius); background: linear-gradient(135deg, #eef6ff 0%, #f8fbfd 72%); }
.search-copy h2 { margin: 0 0 5px; color: var(--ink-deep); font-size: 18px; letter-spacing: -.02em; }
.search-copy p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.patient-search { height: 54px; display: flex; align-items: center; gap: 11px; padding: 6px 6px 6px 16px; background: white; border: 1px solid var(--line-strong); border-radius: 13px; box-shadow: var(--shadow-sm); }
.patient-search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(33, 104, 213, .1); }
.patient-search svg { flex: 0 0 auto; width: 20px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.patient-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; color: var(--ink); font-size: 15px; background: transparent; }
.patient-search input::placeholder { color: var(--muted-light); }
.search-button { align-self: stretch; min-width: 94px; border: 0; background: var(--ink-deep); color: white; }
.search-button:hover { background: #173b54; }
.clear-search { color: var(--blue); text-decoration: none; font-size: 12px; font-weight: 700; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(310px, .75fr); gap: 22px; align-items: start; }
.content-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.patient-list-card, .quick-add-card, .timeline-card, .patient-facts { padding: 24px; }
.quick-add-card { position: sticky; top: 88px; scroll-margin-top: 90px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 17px; }
.section-heading h2 { margin: 4px 0 0; color: var(--ink-deep); font-size: 20px; letter-spacing: -.025em; }
.compact-heading { margin-bottom: 8px; }
.count-pill, .time-badge { padding: 6px 10px; border-radius: 99px; background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 760; }
.time-badge { background: var(--teal-soft); color: var(--teal); }
.card-intro { margin: -5px 0 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }

.patient-list { display: grid; }
.patient-row { display: grid; grid-template-columns: minmax(210px, 1.35fr) minmax(145px, .75fr) auto; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid #edf1f3; }
.patient-identity { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; }
.patient-identity > span:last-child { min-width: 0; display: grid; }
.patient-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.patient-identity:hover strong { color: var(--blue); }
.patient-identity small, .patient-last-visit small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.avatar { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 13px; background: #eef3f7; color: var(--ink); font-size: 12px; font-weight: 800; }
.avatar.large { width: 64px; height: 64px; border-radius: 19px; font-size: 17px; }
.patient-last-visit { display: grid; font-size: 13px; }
.write-button { min-height: 38px; padding: 0 13px; border: 1px solid #cbd9e4; background: white; color: var(--blue); font-size: 13px; }
.write-button:hover { border-color: var(--blue); background: var(--blue-soft); }
.write-button.has-draft { border-color: #e2a329; background: #fff8e7; color: #8a5a00; }
.patient-actions { display: grid; justify-items: stretch; gap: 3px; }
.discard-draft { padding: 2px; border: 0; background: transparent; color: var(--danger); cursor: pointer; font-size: 10px; }
.discard-draft:hover { text-decoration: underline; }

.stack-form { display: grid; gap: 17px; }
.stack-form.compact { gap: 13px; }
.stack-form label, .visit-label { display: grid; gap: 7px; color: var(--ink); font-size: 12px; font-weight: 720; }
.stack-form label span, .visit-label span { display: flex; justify-content: space-between; }
.stack-form label em, .visit-label em { color: var(--muted-light); font-style: normal; font-size: 10px; font-weight: 600; }
.stack-form input, .stack-form select, .stack-form textarea, .visit-label input { width: 100%; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; outline: 0; background: white; color: var(--ink); font-size: 14px; transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease, background-color var(--duration-fast) ease; }
.stack-form input, .stack-form select, .visit-label input { height: 44px; padding-block: 0; }
.stack-form textarea { resize: vertical; }
.stack-form input:focus, .stack-form select:focus, .stack-form textarea:focus, .visit-label input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(33, 104, 213, .1); }
.form-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.form-errors { padding: 11px 13px; border: 1px solid #f0cbc6; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.duplicate-warning { display: grid; gap: 5px; padding: 10px 12px; border: 1px solid #eed596; border-radius: 10px; background: #fff9e9; color: #73520a; font-size: 11px; }
.duplicate-warning[hidden] { display: none; }
.duplicate-warning a { color: var(--blue); font-weight: 700; text-decoration: none; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 13px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pagination .secondary-button { min-height: 36px; padding-inline: 12px; }
.follow-up-strip { display: flex; align-items: center; gap: 20px; margin-bottom: 22px; padding: 14px 18px; border: 1px solid #eed596; border-radius: 14px; background: #fffaf0; }
.follow-up-strip > div:first-child { flex: 0 0 auto; display: grid; gap: 3px; }
.follow-up-strip > div:first-child strong { font-size: 13px; }
.follow-up-list { display: flex; gap: 8px; min-width: 0; overflow-x: auto; }
.follow-up-chip { flex: 0 0 auto; display: grid; gap: 2px; padding: 8px 11px; border: 1px solid #edddb4; border-radius: 9px; background: white; text-decoration: none; }
.follow-up-chip span { font-size: 12px; font-weight: 720; }
.follow-up-chip small, .follow-up-label { color: #9a6300; font-size: 10px; }
.empty-state { display: grid; justify-items: center; padding: 42px 20px; text-align: center; color: var(--muted); }
.empty-state > span { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px; background: #edf3f7; color: var(--ink); font-size: 18px; font-weight: 750; }
.empty-state h3 { margin: 14px 0 5px; color: var(--ink); }
.empty-state p { max-width: 390px; margin: 0 0 18px; }

.auth-shell { display: grid; place-items: center; padding: 24px; background: #102b3e; }
.auth-shell::before { content: ""; position: fixed; width: 480px; height: 480px; right: -190px; top: -190px; border: 88px solid rgba(86, 217, 207, .09); border-radius: 50%; }
.auth-shell::after { content: "Rx"; position: fixed; left: 4vw; bottom: -9vw; color: rgba(255, 255, 255, .035); font-family: Georgia, serif; font-size: min(43vw, 500px); line-height: .8; }
.auth-shell .app-main { position: relative; z-index: 1; display: grid; place-items: center; }
.auth-card { width: min(430px, 100%); padding: 36px; border-radius: 24px 8px 24px 24px; background: white; box-shadow: 0 28px 85px rgba(0, 0, 0, .23); }
.auth-brand { display: flex; gap: 15px; align-items: center; }
.auth-brand h1 { margin: 2px 0 0; color: var(--ink-deep); font-size: 31px; letter-spacing: -.045em; }
.auth-intro { margin: 22px 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.demo-credentials { display: grid; gap: 4px; margin-top: 20px; padding: 13px; border-radius: 11px; background: #f1f5f7; color: var(--muted); font-size: 11px; }
.demo-credentials span { margin-bottom: 3px; color: var(--ink); font-weight: 750; }
.demo-credentials code { font-size: 11px; }
.auth-footer { margin: 19px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.auth-footer a { color: var(--blue); font-weight: 750; text-decoration: none; }
.signup-card { width: min(470px, 100%); }

.onboarding-page { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 40px 0 70px; }
.onboarding-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.onboarding-heading h1 { margin: 5px 0 6px; color: var(--ink-deep); font-size: clamp(30px, 4vw, 42px); line-height: 1.08; letter-spacing: -.045em; }
.onboarding-heading p:last-child { margin: 0; color: var(--muted); font-size: 14px; }
.onboarding-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(330px, .85fr); gap: 24px; align-items: start; }
.onboarding-form-card { padding: clamp(22px, 4vw, 32px); }
.setup-form { display: grid; gap: 30px; }
.setup-form fieldset { display: grid; gap: 16px; margin: 0; padding: 0; border: 0; }
.setup-form fieldset + fieldset { padding-top: 27px; border-top: 1px solid var(--line); }
.setup-form legend { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; color: var(--ink-deep); font-size: 17px; font-weight: 780; }
.setup-form legend span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--ink-deep); color: #56d9cf; font-size: 10px; }
.setup-form label { display: grid; gap: 7px; color: var(--ink); font-size: 12px; font-weight: 720; }
.setup-form input, .setup-form textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; padding: 11px 12px; outline: 0; background: white; color: var(--ink); font-size: 14px; resize: vertical; transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease, background-color var(--duration-fast) ease; }
.setup-form input { height: 46px; }
.setup-form input:focus, .setup-form textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(33, 104, 213, .1); }
.setup-submit { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 23px; border-top: 1px solid var(--line); }
.setup-submit p { max-width: 260px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.header-preview-wrap { position: sticky; top: 92px; }
.header-preview-wrap > .eyebrow { margin: 0 0 9px 4px; }
.header-preview { min-height: 175px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 27px; border-radius: 16px 16px 0 0; background: white; border-bottom: 3px solid var(--ink); box-shadow: var(--shadow); }
.header-preview > div:first-child { display: flex; align-items: center; gap: 12px; }
.header-preview h2 { margin: 0 0 5px; color: var(--ink-deep); font-family: Georgia, serif; font-size: 19px; }
.header-preview p { margin: 0; color: var(--muted); font-size: 9px; }
.preview-brand { display: grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px 4px 12px 12px; background: var(--ink-deep); color: white; font-weight: 800; }
.preview-brand span { color: #56d9cf; }
.preview-clinic { display: grid; max-width: 145px; gap: 4px; color: var(--muted); font-size: 9px; text-align: right; }
.preview-clinic strong { color: var(--ink); font-size: 11px; }
.preview-patient-lines { display: grid; grid-template-columns: auto 1fr auto 1fr; align-items: center; gap: 8px; padding: 16px 19px; background: white; color: var(--muted-light); font-size: 8px; text-transform: uppercase; letter-spacing: .07em; box-shadow: 0 14px 32px rgba(13, 36, 53, .08); }
.preview-patient-lines i { border-bottom: 1px solid var(--line); }
.preview-note { margin: 15px 5px 0; color: var(--muted); font-size: 11px; line-height: 1.55; }

.profile-edit-page { width: min(1040px, calc(100% - 40px)); margin: 0 auto; padding: 40px 0 70px; }
.profile-edit-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.profile-edit-heading h1 { margin: 5px 0 6px; color: var(--ink-deep); font-size: clamp(30px, 4vw, 42px); line-height: 1.08; letter-spacing: -.045em; }
.profile-edit-heading p:last-child { margin: 0; color: var(--muted); font-size: 14px; }
.profile-edit-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(330px, .9fr); gap: 24px; align-items: start; }
.profile-form-card { padding: clamp(22px, 4vw, 32px); }
.profile-identity { display: flex; align-items: center; gap: 16px; margin-bottom: 30px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.profile-avatar-large { flex: 0 0 auto; width: 58px; height: 58px; border-radius: 17px; font-size: 17px; }
.profile-identity h2 { margin: 4px 0 3px; color: var(--ink-deep); font-size: 21px; letter-spacing: -.025em; }
.profile-identity p:last-child { margin: 0; color: var(--muted); font-size: 12px; }
.profile-form { gap: 24px; }
.profile-form legend { display: block; margin-bottom: 14px; font-size: 18px; }
.profile-account-note { display: grid; gap: 5px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-subtle); }
.profile-account-note span { color: var(--muted); font-size: 11px; font-weight: 700; }
.profile-account-note strong { color: var(--ink-deep); font-size: 14px; }
.profile-account-note small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.profile-form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 22px; border-top: 1px solid var(--line); }
.profile-preview-card { position: sticky; top: 92px; }
.profile-preview-footer { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px; background: white; }
.profile-preview-footer div { display: grid; gap: 4px; }
.profile-preview-footer strong { color: var(--ink-deep); font-size: 13px; }
.profile-preview-footer span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.profile-preview-footer a { color: var(--blue); font-size: 12px; font-weight: 750; text-decoration: none; }

.breadcrumb { display: inline-block; margin-bottom: 20px; color: var(--blue); text-decoration: none; font-size: 13px; font-weight: 720; }
.breadcrumb a { text-decoration: none; }
.patient-profile-header, .prescription-view-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.profile-actions, .form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.narrow-page { max-width: 720px; }
.edit-patient-card { padding: clamp(22px, 4vw, 34px); }
.edit-patient-card h1 { margin: 4px 0 0; color: var(--ink-deep); font-size: 30px; letter-spacing: -.035em; }
.patient-profile-main { display: flex; align-items: center; gap: 17px; }
.patient-detail-grid { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 22px; align-items: start; }
.patient-facts dl, .patient-rail dl { display: grid; gap: 0; margin: 12px 0 0; }
.patient-facts dl div, .patient-rail dl div { display: grid; gap: 4px; padding: 14px 0; border-top: 1px solid #edf1f3; }
dt { color: var(--muted); font-size: 11px; font-weight: 650; }
dd { margin: 0; font-size: 13px; font-weight: 720; }
.warning-text { color: var(--danger); }
.timeline { display: grid; }
.timeline-item { display: grid; grid-template-columns: 80px minmax(0, 1fr) auto; align-items: center; gap: 17px; padding: 17px 0; border-top: 1px solid #edf1f3; }
.timeline-date { display: grid; place-items: center; padding: 9px; border-radius: 12px; background: var(--blue-soft); }
.timeline-date strong { color: var(--ink-deep); font-size: 21px; line-height: 1; }
.timeline-date span { margin-top: 4px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.timeline-copy h3 { margin: 0 0 5px; font-size: 15px; }
.timeline-copy p { margin: 0; color: var(--muted); font-size: 12px; }
.text-link { color: var(--blue); font-size: 12px; font-weight: 730; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

.prescription-form { width: 100%; height: calc(100vh - 68px - env(safe-area-inset-top)); height: calc(100dvh - 68px - env(safe-area-inset-top)); min-width: 0; min-height: 600px; display: grid; grid-template-rows: 68px minmax(0, 1fr); overflow: hidden; }
.prescription-topline { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px clamp(14px, 3vw, 32px); border-bottom: 1px solid var(--line); background: white; }
.prescription-topline > div { display: flex; align-items: center; gap: 11px; }
.prescription-titlebar, .save-cluster { min-width: 0; }
.save-cluster { flex: 0 0 auto; }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--ink); text-decoration: none; cursor: pointer; }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover, .icon-button.ghost:hover { background: var(--surface-subtle); border-color: var(--line-strong); }
.icon-button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.rx-doctor { display: grid; line-height: 1.25; }
.rx-doctor strong { color: var(--ink-deep); font-size: 14px; }
.rx-doctor small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.save-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 650; }
.save-state i { width: 7px; height: 7px; border-radius: 50%; background: #28a873; box-shadow: 0 0 0 3px #e4f5ed; }
.save-state.unsaved i { background: #dc9a22; box-shadow: 0 0 0 3px #fdf2d9; }
.save-state.error { color: var(--danger); }
.save-state.error i { background: var(--danger); box-shadow: 0 0 0 3px #fde7e4; }
.save-label-short { display: none; }
.mobile-save-menu { position: relative; display: none; }
.mobile-save-menu summary { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line-strong); border-radius: 10px; background: white; color: var(--ink); cursor: pointer; font-weight: 800; list-style: none; }
.mobile-save-menu summary::-webkit-details-marker { display: none; }
.mobile-save-menu > div { position: absolute; z-index: 80; top: 46px; right: 0; width: 190px; display: grid !important; gap: 5px !important; padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: var(--shadow); }
.mobile-save-action { min-height: 42px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; text-align: left; font-size: 12px; font-weight: 720; }
.mobile-save-action:hover { background: var(--blue-soft); color: var(--blue); }
.page-error { position: fixed; z-index: 30; left: 50%; top: 80px; transform: translateX(-50%); }
.prescription-workspace { min-height: 0; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.patient-rail { padding: 24px 21px; overflow: auto; background: var(--surface-subtle); border-right: 1px solid var(--line); }
.patient-rail-mobile-heading, .patient-rail-backdrop { display: none; }
.rail-patient-header { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.rail-patient-header > div { min-width: 0; }
.patient-rail h1 { overflow: hidden; margin: 3px 0; font-size: 19px; letter-spacing: -.03em; text-overflow: ellipsis; white-space: nowrap; }
.patient-demographics { margin: 0; color: var(--muted); font-size: 12px; }
.allergy-alert { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 8px; padding: 11px; border: 1px solid #f0cbc6; border-radius: 11px; background: var(--danger-soft); color: var(--danger); }
.allergy-alert svg { flex: 0 0 auto; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.allergy-alert span { display: grid; gap: 2px; }
.allergy-alert small { font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.allergy-alert strong { font-size: 12px; }
.visit-label { margin-top: 25px; }
.follow-up-field { margin-top: 12px; }
.clinical-note { margin: 15px 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--ink); font-size: 11px; line-height: 1.45; }
.clinical-note small { display: block; margin-bottom: 4px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.clinical-note p { margin: 0; }
.previous-rx { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.previous-rx summary { display: grid; grid-template-columns: 1fr auto; gap: 6px; cursor: pointer; color: var(--ink); font-size: 12px; font-weight: 730; }
.previous-rx summary span, .previous-rx > p { color: var(--muted); font-size: 10px; font-weight: 500; }
.previous-rx-paper { position: relative; height: 270px; margin: 9px 0; overflow: hidden; border: 1px solid var(--line); background: white; }
.previous-rx-paper canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.previous-rx-text { padding: 14px; overflow-y: auto; color: var(--ink); font-size: 11px; line-height: 1.55; }
.previous-rx-text p { margin: 0 0 8px; white-space: pre-wrap; }
.mobile-patient-context { display: none; }
.patient-context-button { min-height: 36px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: white; color: var(--blue); cursor: pointer; font-size: 11px; font-weight: 750; white-space: nowrap; }
.paper-stage { position: relative; min-width: 0; min-height: 0; padding: 18px 20px; overflow: auto; overscroll-behavior: contain; background: #e6edf1; }
.paper { position: relative; width: min(800px, 100%); margin: 0 auto; overflow: hidden; background: white; box-shadow: 0 7px 26px rgba(13, 36, 53, .13); }
.paper::before, .readonly-paper::before { content: ""; position: absolute; z-index: 0; top: 0; bottom: 0; left: 64px; width: 1px; background: #f1cbc6; }
.paper-guide { position: absolute; z-index: 0; inset: 38px 42px; display: grid; grid-template-rows: 22% 53% 25%; color: #a0adb6; font-family: Georgia, serif; font-size: 12px; font-style: italic; pointer-events: none; }
.paper-guide span { padding-left: 38px; border-bottom: 1px solid #edf1f3; }
.paper-guide .rx-symbol { padding-top: 16px; color: #97a9b5; font-size: 29px; font-style: normal; }
.readonly-paper canvas { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.prescription-sections { position: relative; z-index: 1; display: grid; padding: 38px 42px; }
.prescription-section { position: relative; min-height: 0; border-bottom: 1px solid #edf1f3; }
.prescription-section:last-child { border-bottom: 0; }
.section-overlay { position: absolute; z-index: 2; top: 8px; left: 38px; right: 18px; display: flex; align-items: baseline; gap: 10px; color: #8a9ca8; font: italic 12px/1.2 Georgia, serif; pointer-events: none; }
.section-overlay strong { color: #7f96a5; font-size: 29px; font-style: normal; font-weight: 500; }
.section-overlay small { color: #9aabb5; font: italic 11px/1.2 Georgia, serif; }
.prescription-section-input { width: 100%; min-height: 132px; padding: 36px 20px 18px 38px; border: 0; border-radius: 5px; outline: 0; resize: none; overflow: hidden; background: transparent; color: var(--ink-deep); caret-color: var(--blue); font: 20px/1.55 Inter, ui-sans-serif, system-ui, sans-serif; touch-action: auto; }
.prescription-section-input::placeholder { color: #b0bbc2; opacity: .68; }
.prescription-section-input:focus { background: rgb(237 244 255 / 32%); box-shadow: inset 0 0 0 2px rgb(37 99 235 / 18%); }
.medicines-section { padding: 54px 10px 14px 38px; }
.medication-entry-table { overflow-x: auto; overscroll-behavior: contain; border: 1px solid #dfe7ec; border-radius: 8px; background: white; }
.medication-table-header, .medication-entry-row { min-width: 570px; display: grid; grid-template-columns: minmax(175px, 2fr) minmax(100px, 1fr) minmax(120px, 1.15fr) minmax(90px, .9fr) 36px; }
.medication-table-header { position: sticky; z-index: 2; top: 0; background: #f5f8fa; color: #6d7f8b; font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.medication-table-header span { padding: 8px 9px; border-right: 1px solid #dfe7ec; }
.medication-table-header span:last-child { border-right: 0; }
.medication-entry-row { border-top: 1px solid #dfe7ec; }
.medication-entry-row textarea { min-height: 58px; padding: 10px 9px; border: 0; border-right: 1px solid #dfe7ec; border-radius: 0; outline: 0; resize: none; overflow-y: auto; background: white; color: var(--ink-deep); caret-color: var(--blue); font-size: 16px; line-height: 1.35; touch-action: auto; }
.medication-entry-row textarea::placeholder { color: #aeb9c0; }
.medication-entry-row textarea:focus { position: relative; z-index: 1; background: var(--blue-soft); box-shadow: inset 0 0 0 2px rgb(37 99 235 / 24%); }
.remove-medication { min-width: 36px; border: 0; background: white; color: #91a0a9; cursor: pointer; font-size: 20px; touch-action: manipulation; }
.remove-medication:active { background: var(--danger-soft); color: var(--danger); }
.add-medication { min-height: 38px; margin: 9px; padding: 0 12px; border: 1px dashed #aebdc7; border-radius: 7px; background: white; color: var(--blue); cursor: pointer; font-size: 12px; font-weight: 750; touch-action: manipulation; }
.input-mode-badge { min-height: 38px; display: inline-flex; align-items: center; padding: 7px 11px; border: 1px solid #cce3de; border-radius: 999px; background: var(--teal-soft); color: #177b72; font-size: 11px; font-weight: 750; white-space: nowrap; }
.prescription-view-header { align-items: flex-end; }
.prescription-view-header h1 { font-size: clamp(28px, 4vw, 38px); }
.view-actions { display: flex; gap: 9px; }
.print-sheet { width: min(860px, 100%); margin: 0 auto; padding: 40px 46px 28px; background: white; box-shadow: var(--shadow); }
.print-clinic-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; padding-bottom: 22px; border-bottom: 3px solid var(--ink); }
.print-clinic-header h2 { margin: 5px 0; color: var(--ink-deep); font-size: 26px; letter-spacing: -.035em; }
.print-clinic-header p { margin: 0; color: var(--muted); }
.clinic-address { display: grid; gap: 4px; text-align: right; color: var(--muted); font-size: 12px; }
.clinic-address, .patient-profile-main, .timeline-copy, .print-patient-bar span { overflow-wrap: anywhere; }
.clinic-address strong { color: var(--ink); font-size: 14px; }
.print-patient-bar { display: grid; grid-template-columns: 1.4fr 1fr .7fr; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.print-patient-bar span { display: grid; gap: 4px; font-size: 13px; }
.print-patient-bar strong { color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.print-follow-up, .print-allergy { padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 12px; }
.print-follow-up strong, .print-allergy strong { margin-right: 7px; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.print-allergy { color: var(--danger); }
.secondary-button:disabled { opacity: .55; cursor: wait; }
turbo-frame.patient-list-card { display: block; }
.readonly-paper { position: relative; height: 830px; overflow: hidden; background: white; }
.readonly-prescription-text, .review-prescription-text { position: relative; z-index: 1; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-deep); font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-weight: 450; }
.readonly-prescription-text { height: 100%; padding: 48px 72px; font-size: 18px; line-height: 1.7; }
.structured-prescription { position: relative; z-index: 1; height: 100%; padding: 42px 68px; overflow: auto; color: var(--ink-deep); font-size: 15px; line-height: 1.5; }
.structured-section { margin-bottom: 25px; }
.structured-section h3 { margin: 0 0 9px; color: #718590; font: italic 13px/1.2 Georgia, serif; }
.structured-section p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.structured-medicines h3 { color: #526d7e; font-size: 20px; font-style: normal; }
.medication-output-table { overflow: hidden; border: 1px solid #cfd9df; border-radius: 6px; }
.medication-output-header, .medication-output-row { display: grid; grid-template-columns: 2fr 1fr 1.15fr .9fr; }
.medication-output-header { background: #f2f6f8; color: #607581; font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.medication-output-header span, .medication-output-row span { min-width: 0; padding: 8px 10px; overflow-wrap: anywhere; border-right: 1px solid #cfd9df; }
.medication-output-header span:last-child, .medication-output-row span:last-child { border-right: 0; }
.medication-output-row { border-top: 1px solid #cfd9df; font-size: 13px; }
.medication-output-row span:first-child { font-weight: 700; }
.print-footer { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; padding-top: 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.doctor-signature { display: grid; min-width: 200px; padding-top: 15px; border-top: 1px solid var(--ink); text-align: center; }
.doctor-signature strong { color: var(--ink); font-size: 12px; }

@media (max-width: 1100px) {
  .prescription-workspace { grid-template-columns: 230px minmax(0, 1fr); }
  .patient-rail { padding: 20px 17px; }
  .save-cluster .primary-button, .save-cluster .secondary-button { min-height: 40px; padding-inline: 12px; font-size: 12px; }
}

@media (max-width: 820px) {
  .save-state { display: none; }
}

@media (max-width: 960px) {
  .prescription-workspace { position: relative; display: block; }
  .patient-rail { position: fixed; z-index: 60; top: calc(68px + env(safe-area-inset-top)); bottom: 0; left: 0; width: min(360px, calc(100vw - 24px)); padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); visibility: hidden; border-right: 1px solid var(--line); box-shadow: var(--shadow); transform: translateX(-105%); transition: transform var(--duration-ui) var(--ease-drawer), visibility 0s linear var(--duration-ui); }
  .patient-rail.open { visibility: visible; transform: translateX(0); transition-delay: 0s; }
  .patient-rail-mobile-heading { position: sticky; z-index: 2; top: -18px; display: flex; align-items: center; justify-content: space-between; margin: -18px -18px 16px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px); }
  .patient-rail-mobile-heading strong { font-size: 14px; }
  .patient-rail-mobile-heading .icon-button { width: 38px; height: 38px; font-size: 22px; }
  .patient-rail-backdrop { position: fixed; z-index: 50; inset: calc(68px + env(safe-area-inset-top)) 0 0; display: block; width: 100%; border: 0; background: rgba(13, 36, 53, .36); cursor: pointer; }
  .patient-rail-backdrop[hidden] { display: none; }
  .rail-patient-header .avatar { display: inline-flex; }
  .paper-stage { height: 100%; padding: 12px 18px 20px; }
  .mobile-patient-context { position: sticky; z-index: 5; top: 0; width: min(800px, 100%); min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 auto 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255, 255, 255, .96); box-shadow: var(--shadow-sm); backdrop-filter: blur(12px); }
  .mobile-patient-context > span:first-child { min-width: 0; display: grid; }
  .mobile-patient-context > span:first-child strong, .mobile-patient-context > span:first-child small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-patient-context strong { font-size: 12px; }
  .mobile-patient-context small { margin-top: 2px; color: var(--muted); font-size: 10px; }
  .mobile-allergy { margin-left: auto; color: var(--danger); font-size: 10px; text-align: right; }
  .paper { width: min(800px, 100%); min-width: 0; min-height: max(900px, calc(100dvh - 170px)); }
}

@media (max-width: 900px) {
  .topbar-inner { grid-template-columns: 1fr auto; }
  .main-nav { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .quick-add-card { position: static; }
  .patient-row { grid-template-columns: minmax(0, 1fr) auto; }
  .patient-last-visit { display: none; }
  .patient-detail-grid { grid-template-columns: 1fr; }
  .patient-facts { order: 2; }
  .onboarding-grid { grid-template-columns: 1fr; }
  .header-preview-wrap { position: static; }
}

@media (max-width: 680px) {
  .app-shell { padding-top: calc(60px + env(safe-area-inset-top)); }
  .topbar { height: calc(60px + env(safe-area-inset-top)); }
  .topbar-inner { width: calc(100% - 28px); }
  .brand { font-size: 17px; }
  .brand-mark { width: 34px; height: 34px; }
  .doctor-copy { display: none; }
  .doctor-profile-link { padding: 3px; }
  .dashboard-page, .patient-page, .prescription-view-page { width: min(100% - 28px, 1200px); padding-top: 26px; }
  .dashboard-heading, .patient-profile-header, .prescription-view-header { align-items: stretch; flex-direction: column; }
  .profile-actions { width: 100%; }
  .profile-actions > * { flex: 1; }
  .profile-actions .primary-button, .profile-actions .secondary-button { padding-inline: 12px; font-size: 13px; white-space: nowrap; }
  .dashboard-heading .primary-button, .patient-profile-header .primary-button { width: 100%; }
  .dashboard-heading h1 { font-size: 30px; }
  .search-panel { grid-template-columns: 1fr; gap: 15px; padding: 18px; }
  .patient-search { height: auto; min-height: 52px; flex-wrap: wrap; }
  .search-button { min-width: auto; padding: 0 14px; }
  .patient-list-card, .quick-add-card, .timeline-card, .patient-facts { padding: 18px; }
  .patient-row { gap: 9px; }
  .patient-actions { min-width: 68px; }
  .write-button { width: 100%; min-width: 68px; padding: 0 8px; font-size: 0; }
  .write-button [data-draft-label] { font-size: 11px; }
  .write-button > span[aria-hidden] { font-size: 14px; }
  .form-pair { grid-template-columns: 1fr; }
  .timeline-item { grid-template-columns: 68px minmax(0, 1fr); }
  .timeline-item .text-link { grid-column: 2; }
  .prescription-form { height: calc(100vh - 60px - env(safe-area-inset-top)); height: calc(100dvh - 60px - env(safe-area-inset-top)); min-height: 0; grid-template-rows: 64px minmax(0, 1fr); }
  .prescription-topline { width: 100vw; min-width: 0; padding: 8px 10px; }
  .rx-doctor small { display: none; }
  .prescription-titlebar { gap: 7px !important; }
  .save-option { display: none !important; }
  .mobile-save-menu { display: block; }
  .save-cluster .primary-button { min-height: 40px; padding: 0 11px; font-size: 12px; }
  .save-label-full { display: none; }
  .save-label-short { display: inline; }
  .patient-rail { top: calc(60px + env(safe-area-inset-top)); }
  .patient-rail-backdrop { inset-block-start: calc(60px + env(safe-area-inset-top)); }
  .paper-stage { padding: 10px 10px calc(18px + env(safe-area-inset-bottom)); }
  .paper { min-width: 0; min-height: max(760px, calc(100dvh - 170px)); }
  .paper::before { left: 38px; }
  .paper-guide { inset: 30px 20px; }
  .paper-guide span { padding-left: 28px; }
  .print-sheet { padding: 25px 20px; }
  .print-clinic-header { flex-direction: column; }
  .clinic-address { text-align: left; }
  .print-patient-bar { grid-template-columns: 1fr 1fr; }
  .print-patient-bar span:last-child { grid-column: 1 / -1; }
  .view-actions > * { flex: 1; }
  .view-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .view-actions > :last-child { grid-column: 1 / -1; }
  .follow-up-strip { align-items: flex-start; flex-direction: column; }
  .onboarding-page { width: min(100% - 28px, 1120px); padding-top: 26px; }
  .onboarding-heading { align-items: stretch; flex-direction: column; }
  .onboarding-form-card { padding: 19px; }
  .setup-submit { align-items: stretch; flex-direction: column; }
  .setup-submit .primary-button { width: 100%; }
  .header-preview { flex-direction: column; }
  .preview-clinic { max-width: none; text-align: left; }
  .auth-card { padding: 28px 24px; }
}

@media (max-width: 420px) {
  .topbar-inner { width: calc(100% - 20px); }
  .brand { gap: 7px; font-size: 15px; }
  .brand-mark { width: 32px; height: 32px; }
  .doctor-menu { gap: 2px; }
  .prescription-titlebar .icon-button { width: 38px; height: 38px; }
  .rx-doctor strong { font-size: 13px; }
  .mobile-patient-context { gap: 7px; }
  .patient-context-button { padding-inline: 9px; font-size: 0; }
  .patient-context-button::after { content: "Details"; font-size: 10px; }
  .mobile-allergy { max-width: 105px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .patient-profile-main .avatar { display: none; }
  .dashboard-heading h1 { font-size: 27px; }
  .patient-search { padding-left: 11px; }
  .search-button { min-width: 72px; }
  .print-sheet { padding-inline: 16px; }
  .print-clinic-header h2 { font-size: 22px; }
}

@media (max-height: 600px) {
  .prescription-form { min-height: 0; }
  .paper { min-height: 680px; }
}

@media print {
  @page { size: A4; margin: 10mm; }
  body { background: white; padding: 0; }
  .topbar, .flash-stack, .prescription-view-header, .skip-link { display: none !important; }
  .prescription-view-page { width: 100%; padding: 0; }
  .print-sheet { width: 100%; padding: 0; box-shadow: none; }
  .readonly-paper { height: 225mm; }
}

/* Shared workspace rhythm and guided workflows. */
[hidden] { display: none !important; }
button, input[type=submit] { touch-action: manipulation; }
.primary-button:disabled { opacity: .6; cursor: wait; transform: none; }
.field-hint { margin: -4px 0 4px; color: var(--muted); font-size: 13px; line-height: 1.6; font-weight: 400; }
.flash { display: flex; align-items: center; gap: 14px; pointer-events: auto; opacity: 1; transform: translateY(0); transition: opacity var(--duration-fast) ease, transform var(--duration-ui) var(--ease-out); }
.flash > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.flash.is-leaving { opacity: 0; transform: translateY(-8px); pointer-events: none; transition-duration: var(--duration-fast); }
.flash button { flex: 0 0 44px; height: 44px; border: 0; border-radius: 8px; background: transparent; color: inherit; cursor: pointer; font-size: 23px; transition: background .15s ease; }
.flash button:hover { background: rgba(0, 0, 0, .06); }
@starting-style {
  .flash { opacity: 0; transform: translateY(-8px); }
}
.clear-search { min-height: 40px; border: 0; background: transparent; cursor: pointer; }
.workspace-overview { display: grid; grid-template-columns: 1fr 1fr 1.3fr; margin-bottom: 26px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.workspace-overview > * { display: flex; align-items: center; gap: 14px; padding: 22px; text-decoration: none; }
.workspace-overview > * + * { border-left: 1px solid var(--line); }
.workspace-overview strong { display: block; color: var(--ink-deep); font-size: 24px; letter-spacing: -.03em; }
.workspace-overview small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.overview-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 auto; background: var(--teal-soft); color: #177b72; border-radius: 12px; font-size: 25px; }
.workspace-overview .setup-shortcut strong { font-size: 15px; letter-spacing: -.015em; }
.setup-shortcut:hover { background: var(--surface-subtle); border-radius: 0 16px 16px 0; }
.welcome-guide { margin-bottom: 24px; padding: 24px; background: #eaf4f2; border: 1px solid #cce3de; border-radius: 16px; }
.welcome-guide h2 { font-size: 22px; margin: 8px 0 24px; letter-spacing: -.025em; }
.welcome-guide ol { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; list-style: none; padding: 0; margin: 0; }
.welcome-guide li { display: flex; gap: 12px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.welcome-guide li b { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: white; color: var(--teal); flex: 0 0 auto; }
.welcome-guide li strong { display: block; color: var(--ink); font-size: 14px; }
.patient-row { grid-template-columns: minmax(0, 1.3fr) minmax(110px, .7fr) auto; }
.patient-list-card[busy] .patient-list { opacity: .5; }
.patient-list { transition: opacity .15s; }
.setup-progress { display: flex; gap: 8px; margin-bottom: 24px; padding: 8px; background: #e9eef2; border: 1px solid var(--line); border-radius: 14px; }
.setup-progress button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; border: 0; padding: 12px; border-radius: 9px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 700; cursor: pointer; transition: color var(--duration-fast) ease, background-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease, transform var(--duration-press) var(--ease-out); }
.setup-progress button.current { background: white; box-shadow: var(--shadow-sm); color: var(--ink-deep); }
.setup-progress .setup-step-number { display: grid; place-items: center; width: 24px; height: 24px; flex: 0 0 24px; border: 1px solid var(--line-strong); border-radius: 50%; font-size: 11px; }
.setup-progress button.current .setup-step-number { background: var(--ink-deep); color: white; border-color: var(--ink-deep); }
.setup-progress button.complete .setup-step-number { background: var(--teal-soft); color: #136b62; border-color: #b5dcd4; }
.onboarding-page { scroll-margin-top: 88px; }
.setup-form fieldset + fieldset { padding-top: 0; border-top: 0; }
.setup-navigation { display: flex; align-items: center; gap: 14px; padding-top: 22px; border-top: 1px solid var(--line); }
.setup-navigation > span { margin-right: auto; color: var(--muted); font-size: 12px; }
.setup-review h2 { margin: 10px 0; font-size: 28px; letter-spacing: -.035em; }
.setup-review > p { color: var(--muted); font-size: 14px; line-height: 1.65; }
.setup-assurance { padding: 18px; margin: 24px 0; border: 1px solid #cbe7df; border-radius: 12px; background: var(--teal-soft); }
.setup-assurance p { margin: 8px 0 0; font-size: 13px; line-height: 1.6; }
.setup-submit { flex-wrap: wrap; }
.setup-submit .primary-button { width: auto; height: auto; min-height: 46px; white-space: normal; }
.preview-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.live-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: #177b72; }
.live-badge i { width: 6px; height: 6px; background: var(--teal); border-radius: 50%; }
.header-preview { padding: 24px; gap: 16px; box-shadow: none; border: 1px solid var(--line); border-bottom: 3px solid var(--ink); }
.header-preview > div, .header-preview h2, .preview-clinic { min-width: 0; overflow-wrap: anywhere; }
.header-preview > div:first-child { align-items: flex-start; }
.preview-brand { display: none; }
.header-preview h2 { font-family: inherit; }
.preview-clinic { max-width: 42%; }
.preview-patient-lines { box-shadow: none; border-inline: 1px solid var(--line); }
.preview-writing { display: grid; grid-template-rows: 70px 140px 45px; padding: 20px 28px; background: white; border-inline: 1px solid var(--line); color: var(--muted-light); font: italic 12px Georgia, serif; }
.preview-writing strong { border-top: 1px solid #edf1f3; padding-top: 18px; font-size: 30px; font-weight: 400; }
.preview-footer { display: flex; justify-content: space-between; padding: 16px 24px; border: 1px solid var(--line); border-radius: 0 0 10px 10px; background: white; color: var(--muted); font-size: 9px; }
.auth-layout { display: grid; grid-template-columns: 1fr minmax(350px, 440px); align-items: center; gap: 100px; width: min(1020px, 100%); padding-block: 35px; }
.auth-story { color: #d1e1e9; }
.auth-story .brand { color: white; margin-bottom: 60px; }
.auth-story .eyebrow { color: #69d8ca; }
.auth-story h2 { color: white; font-size: clamp(38px, 4vw, 54px); line-height: 1.12; letter-spacing: -.045em; margin: 18px 0 22px; }
.auth-story > p:not(.eyebrow) { max-width: 400px; line-height: 1.7; font-size: 15px; }
.auth-story ol { display: grid; gap: 18px; list-style: none; margin: 30px 0 55px; padding: 0; font-size: 14px; }
.auth-story li span { margin-right: 14px; color: #69d8ca; font-size: 11px; }
.auth-story small { font-size: 12px; color: #9ab7c9; }
.auth-layout .auth-card { width: 100%; border-radius: 22px; }
.auth-layout .auth-brand > .brand-mark { display: none; }
.auth-layout .auth-brand h1 { font-size: 30px; }
.password-toggle { justify-self: start; border: 0; padding: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 12px; min-height: 28px; }
.forgot-password { text-align: right; font-size: 12px; }
.forgot-password a { color: var(--blue); text-decoration: none; }
.writing-guidance { width: min(800px, 100%); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin: 0 auto 12px; color: #536a79; font-size: 11px; line-height: 1.5; }
.draft-device-note { color: var(--muted); }
.ink-feedback { width: min(800px, 100%); margin: 0 auto 12px; }
.review-dialog { width: min(760px, calc(100% - 28px)); max-height: calc(100dvh - 32px); padding: 26px; border: 1px solid var(--line); border-radius: 20px; color: var(--ink); box-shadow: var(--shadow); overflow: auto; opacity: 0; transform: scale(.97); transform-origin: center; transition: opacity var(--duration-fast) ease, transform var(--duration-ui) var(--ease-out), display var(--duration-ui) allow-discrete, overlay var(--duration-ui) allow-discrete; }
.review-dialog[open] { opacity: 1; transform: scale(1); }
.review-dialog::backdrop { background: rgba(13, 36, 53, 0); backdrop-filter: blur(0); transition: background-color var(--duration-ui) ease, backdrop-filter var(--duration-ui) ease, display var(--duration-ui) allow-discrete, overlay var(--duration-ui) allow-discrete; }
.review-dialog[open]::backdrop { background: rgba(13, 36, 53, .6); backdrop-filter: blur(3px); }
@starting-style {
  .review-dialog[open] { opacity: 0; transform: scale(.97); }
  .review-dialog[open]::backdrop { background: rgba(13, 36, 53, 0); backdrop-filter: blur(0); }
}
.review-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.review-heading h2 { margin: 6px 0 20px; font-size: 26px; letter-spacing: -.03em; }
.review-heading button { font-size: 24px; }
.review-patient { display: grid; gap: 5px; padding: 15px; background: var(--surface-subtle); border-radius: 10px; }
.review-patient span { color: var(--muted); font-size: 12px; }
.review-details { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.review-details dd { margin-top: 6px; overflow-wrap: anywhere; }
.review-ink { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: white; }
.review-ink img { display: block; width: 100%; height: auto; }
.review-notice { color: var(--muted); font-size: 13px; line-height: 1.6; }
.saved-transcript { margin-bottom: 24px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.saved-transcript summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 16px; cursor: pointer; }
.saved-transcript summary > span:first-child { display: grid; gap: 3px; }
.saved-transcript summary small { color: var(--muted); font-size: 11px; }
.saved-transcript pre { margin: 0; padding: 0 16px 16px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); font: 13px/1.6 Inter, ui-sans-serif, sans-serif; }
.saved-prescription-bar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; margin-bottom: 24px; border: 1px solid #c8e5dd; border-radius: 14px; background: var(--teal-soft); }
.saved-prescription-bar > div { display: flex; align-items: center; gap: 12px; }
.saved-prescription-bar strong, .saved-prescription-bar small { display: block; }
.saved-prescription-bar strong { font-size: 14px; }
.saved-prescription-bar small { margin-top: 4px; font-size: 12px; color: var(--muted); }
.saved-check { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: white; color: #157e63; }
.export-feedback { color: var(--muted); font-size: 13px; }
.export-feedback:empty { display: none; }
@media (max-width: 960px) {
  .patient-row { grid-template-columns: minmax(0, 1fr) auto; }
  .patient-last-visit { display: none; }
  .auth-layout { gap: 40px; }
  .search-panel { grid-template-columns: 1fr; gap: 16px; }
  .setup-review { min-height: 0; }
}
@media (max-width: 900px) {
  .main-nav { display: flex; }
  .topbar-inner { grid-template-columns: auto 1fr auto; gap: 8px; }
  .doctor-copy { display: none; }
  .header-preview-wrap { max-width: 620px; width: 100%; margin-inline: auto; }
}
@media (max-width: 680px) {
  .main-nav { gap: 2px; }
  .nav-link { font-size: 11px; padding-inline: 8px; min-height: 44px; }
  .nav-link svg { display: none; }
  .workspace-overview { grid-template-columns: 1fr 1fr; }
  .workspace-overview > * { padding: 16px; gap: 10px; }
  .workspace-overview > :last-child { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .overview-icon { width: 34px; height: 34px; font-size: 21px; }
  .workspace-overview small { font-size: 11px; }
  .workspace-overview strong { font-size: 21px; }
  .welcome-guide ol { grid-template-columns: 1fr; }
  .auth-layout { display: block; padding-block: 0; max-width: 440px; }
  .auth-story { display: none; }
  .auth-layout .auth-brand > .brand-mark { display: inline-flex; }
  .setup-progress { gap: 2px; padding: 5px; }
  .setup-progress button { flex-direction: column; padding: 10px 5px; font-size: 11px; text-align: center; }
  .setup-navigation { flex-wrap: wrap; gap: 10px; }
  .setup-navigation .primary-button { font-size: 13px; padding-inline: 12px; }
  .header-preview { flex-direction: row; padding: 18px; }
  .header-preview h2 { font-size: 16px; }
  .preview-clinic { max-width: 42%; text-align: right; }
  .preview-writing { grid-template-rows: 55px 95px 30px; }
  .saved-prescription-bar { align-items: stretch; flex-direction: column; gap: 15px; }
  .review-dialog { padding: 20px; }
  .review-dialog .form-actions { flex-wrap: wrap; }
  .review-dialog .form-actions > * { flex: 1; white-space: nowrap; padding-inline: 12px; font-size: 13px; }
  .review-details { grid-template-columns: 1fr 1fr; }
  .writing-guidance { font-size: 11px; }
  .draft-device-note { display: none; }
  .save-state { display: block; position: absolute; top: 100%; right: 12px; padding: 6px 9px; border-radius: 0 0 8px 8px; background: white; font-size: 10px; pointer-events: none; box-shadow: var(--shadow-sm); }
  .prescription-topline { position: relative; z-index: 10; }
  .paper-stage { padding-top: 30px; }
  .stack-form input, .stack-form select, .stack-form textarea, .setup-form input, .setup-form textarea, .visit-label input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; }
  .flash, .review-dialog, .review-dialog::backdrop,
  .patient-rail, .quick-add-card, .landing-button,
  .primary-button, .secondary-button, .write-button, .search-button,
  .nav-link, .doctor-profile-link, .icon-button,
  .setup-progress button, .template-option-card, .story-image img {
    animation: none !important;
    transform: none !important;
    transition-duration: 0ms !important;
  }
}
@media print {
  .saved-prescription-bar, .saved-transcript, .export-feedback, .review-dialog { display: none !important; }
}
/* Submit controls retain their action hierarchy inside field layouts. */
.stack-form input.primary-button, .setup-form input.primary-button { background: var(--blue); color: white; border-color: var(--blue); cursor: pointer; }
.stack-form input.primary-button:hover, .setup-form input.primary-button:hover { background: var(--blue-dark); }
.patient-search input.search-button { flex: 0 0 auto; height: auto; background: var(--ink-deep); color: white; }
.nav-link { white-space: nowrap; }
.review-pad-header { display: grid; gap: 5px; padding: 18px; border-bottom: 2px solid var(--ink); }
.review-pad-header span { font-size: 11px; color: var(--muted); }
.prescription-form > .page-error { position: fixed; z-index: 25; top: 140px; left: 50%; transform: translateX(-50%); width: min(600px, calc(100% - 30px)); }
@media (max-width: 900px) {
  .onboarding-page.reviewing .header-preview-wrap { order: -1; }
}
@media (max-width: 380px) {
  .doctor-menu .profile-avatar { display: none; }
  .doctor-profile-link { padding: 0; }
  .review-heading h2 { font-size: 23px; }
}
.ink-feedback { padding: 11px 13px; border: 1px solid #c4d8e9; border-radius: 10px; background: #f0f6fc; color: #315d7f; font-size: 12px; line-height: 1.5; }
.ink-feedback.error { background: var(--danger-soft); border-color: #f0cbc6; color: var(--danger); }
@media print {
  .print-sheet { height: 276mm; display: flex; flex-direction: column; break-inside: avoid; }
  .print-clinic-header, .print-patient-bar, .print-allergy, .print-follow-up, .print-footer { flex: 0 0 auto; }
  .readonly-paper { height: auto; min-height: 0; flex: 1 1 auto; }
  .print-clinic-header { flex-direction: row; }
  .clinic-address { text-align: right; }
  .print-patient-bar { grid-template-columns: 1.4fr 1fr .7fr; }
  .print-patient-bar span:last-child { grid-column: auto; }
}
.draft-time { max-width: 135px; color: #8a5a00; font-size: 10px; text-align: center; line-height: 1.5; }
.draft-feedback { color: var(--danger); font-size: 13px; }
.draft-feedback:empty { display: none; }
.dashboard-grid > .draft-feedback { grid-column: 1 / -1; }
.profile-actions { flex-wrap: wrap; }
.profile-actions .discard-draft { min-height: 36px; padding: 8px; font-size: 12px; }

/* Tablet-first workspace -------------------------------------------------- */
.quick-add-mobile-heading, .quick-add-backdrop { display: none; }

.prescription-shell {
  height: 100vh;
  height: 100dvh;
  padding-top: 0;
  overflow: hidden;
}
.prescription-shell > .topbar { display: none; }
.prescription-shell .prescription-form {
  height: 100vh;
  height: 100dvh;
  grid-template-rows: 66px minmax(0, 1fr);
}
.prescription-shell .prescription-topline { padding-inline: clamp(14px, 2.5vw, 28px); }
.paper { aspect-ratio: 210 / 297; min-height: 0; }

@media (max-width: 1180px) {
  .topbar-inner { width: min(100% - 32px, 1120px); }
  .nav-link { min-height: 44px; padding-inline: 12px; }
  .dashboard-page, .patient-page, .prescription-view-page { width: min(100% - 32px, 1120px); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid > .draft-feedback { grid-column: 1; }
  .quick-add-card {
    position: fixed;
    z-index: 65;
    top: calc(68px + env(safe-area-inset-top));
    right: 0;
    bottom: 0;
    width: min(430px, calc(100vw - 32px));
    max-height: none;
    padding: 0 24px calc(24px + env(safe-area-inset-bottom));
    overflow-y: auto;
    visibility: hidden;
    border-radius: 0;
    border-width: 0 0 0 1px;
    box-shadow: -18px 0 55px rgba(13, 36, 53, .2);
    transform: translateX(105%);
    transition: transform var(--duration-ui) var(--ease-drawer), visibility 0s linear var(--duration-ui);
  }
  .quick-add-card.open { visibility: visible; transform: translateX(0); transition-delay: 0s; }
  .quick-add-mobile-heading {
    position: sticky;
    z-index: 2;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 -24px 21px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .97);
    backdrop-filter: blur(14px);
  }
  .quick-add-mobile-heading h2 { margin: 3px 0 0; color: var(--ink-deep); font-size: 22px; letter-spacing: -.03em; }
  .quick-add-mobile-heading .icon-button { font-size: 22px; }
  .quick-add-card > .section-heading { display: none; }
  .quick-add-backdrop {
    position: fixed;
    z-index: 60;
    inset: calc(68px + env(safe-area-inset-top)) 0 0;
    display: block;
    width: 100%;
    border: 0;
    background: rgba(13, 36, 53, .38);
    cursor: pointer;
  }
  .quick-add-backdrop[hidden] { display: none; }
  body.quick-add-open { overflow: hidden; }
  .quick-add-card .stack-form input,
  .quick-add-card .stack-form select { min-height: 48px; height: 48px; font-size: 16px; }
  .quick-add-card .primary-button { min-height: 50px; }
}

@media (min-width: 961px) and (max-width: 1180px) {
  .prescription-workspace { grid-template-columns: 250px minmax(0, 1fr); }
  .patient-rail { padding: 20px 18px; }
  .paper-stage { padding-inline: 18px; }
}

@media (max-width: 1050px) {
  .doctor-copy { display: none; }
  .topbar-inner { grid-template-columns: auto 1fr auto; gap: 10px; }
}

@media (max-width: 960px) {
  .prescription-shell .patient-rail { top: 66px; }
  .prescription-shell .patient-rail-backdrop { inset-block-start: 66px; }
  .paper { width: min(760px, 100%); min-height: 0; }
  .mobile-patient-context { min-height: 54px; }
  .patient-context-button { min-height: 44px; }
  .onboarding-page { width: min(100% - 32px, 1120px); }
}

@media (orientation: portrait) and (max-width: 960px) {
  .quick-add-card { width: 100vw; }
  .prescription-shell .save-option { display: none !important; }
  .prescription-shell .mobile-save-menu { display: block; }
}

@media (max-width: 900px) {
  .main-nav { display: flex; }
  .onboarding-grid { grid-template-columns: 1fr; }
  .header-preview-wrap { position: static; max-width: 640px; width: 100%; margin-inline: auto; }
  .profile-edit-grid { grid-template-columns: 1fr; }
  .profile-preview-card { position: static; max-width: 640px; width: 100%; margin-inline: auto; }
}

@media (max-width: 680px) {
  .quick-add-card { top: calc(60px + env(safe-area-inset-top)); width: 100vw; }
  .quick-add-backdrop { inset-block-start: calc(60px + env(safe-area-inset-top)); }
  .prescription-shell .prescription-form { grid-template-rows: 64px minmax(0, 1fr); }
  .prescription-shell .patient-rail { top: 64px; }
  .prescription-shell .patient-rail-backdrop { inset-block-start: 64px; }
  .paper { aspect-ratio: 210 / 297; min-height: 0; }
  .mobile-patient-context { min-height: 52px; }
  .profile-edit-page { width: min(100% - 28px, 1040px); padding-top: 26px; }
  .profile-edit-heading { align-items: stretch; flex-direction: column; }
  .profile-form-actions { align-items: stretch; flex-direction: column-reverse; }
  .profile-form-actions > * { width: 100%; }
}

@media (pointer: coarse) {
  .primary-button, .secondary-button, .nav-link, .write-button, .search-button,
  .icon-button, .patient-context-button, .mobile-save-action,
  .setup-progress button, .setup-navigation button { min-height: 48px; }
  .icon-button { width: 48px; height: 48px; }
}

@media print {
  .quick-add-backdrop { display: none !important; }
}

/* Prescription template setup and printable variants ------------------- */
.style-setup-panel { min-width: 0; }
.template-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.template-option { min-width: 0; cursor: pointer; }
.template-option > input, .accent-options input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.template-option-card { position: relative; height: 100%; display: grid; grid-template-rows: 112px auto; gap: 13px; padding: 10px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 13px; background: white; transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease, transform var(--duration-press) var(--ease-out); }
.template-option > input:focus-visible + .template-option-card { outline: 3px solid rgba(33, 104, 213, .18); outline-offset: 2px; }
.template-option-card::after { content: "✓"; position: absolute; top: 8px; right: 8px; display: none; width: 25px; height: 25px; place-items: center; border-radius: 50%; background: var(--blue); color: white; font-size: 13px; font-weight: 850; box-shadow: 0 2px 8px rgba(33, 104, 213, .25); }
.template-option > input:checked + .template-option-card { border-color: var(--blue); background: #f7fbff; box-shadow: 0 0 0 2px rgba(33, 104, 213, .18); }
.template-option > input:checked + .template-option-card::after { display: grid; }
.template-thumbnail { position: relative; display: block; overflow: hidden; border: 1px solid #dce4e9; border-radius: 7px; background: #fbfcfd; }
.template-thumbnail::after { content: ""; position: absolute; inset: 48px 10px 10px; background: repeating-linear-gradient(to bottom, transparent 0 12px, #e8edf0 12px 13px); }
.template-thumbnail i, .template-thumbnail b, .template-thumbnail em, .template-thumbnail small { position: absolute; z-index: 1; display: block; background: #9aabb5; border-radius: 10px; }
.template-thumbnail i { width: 44%; height: 5px; left: 10px; top: 13px; background: var(--ink-deep); }
.template-thumbnail b { width: 34%; height: 4px; left: 10px; top: 24px; }
.template-thumbnail em { width: 30%; height: 5px; right: 10px; top: 13px; }
.template-thumbnail small { width: 24%; height: 4px; right: 10px; top: 24px; }
.template-thumbnail--classic { border-bottom: 3px solid #183247; }
.template-thumbnail--clinic i { width: 54%; left: 23%; top: 10px; background: #183247; }
.template-thumbnail--clinic b { width: 38%; left: 31%; top: 21px; }
.template-thumbnail--clinic em { width: 46%; left: 27%; right: auto; top: 30px; height: 3px; }
.template-thumbnail--clinic small { display: none; }
.template-thumbnail--compact { border-left: 5px solid #183247; }
.template-thumbnail--compact i { width: 38%; }
.template-thumbnail--compact b { width: 48%; }
.template-thumbnail--compact em { width: 26%; }
.template-option-copy { display: grid; gap: 7px; padding: 0 2px 3px; color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.45; }
.template-option-copy > span { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.template-option-copy strong { color: var(--ink-deep); font-size: 14px; }
.template-option-copy small { padding: 3px 6px; border-radius: 20px; background: var(--surface-subtle); color: var(--muted); font-size: 9px; }
.style-choice-heading, .style-customization-heading { display: grid; gap: 4px; }
.style-choice-heading strong, .style-customization-heading strong, .style-control-label { color: var(--ink-deep); font-size: 13px; }
.style-choice-heading span, .style-customization-heading span { color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.45; }
.style-customization { display: grid; gap: 13px; margin-top: 6px; padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-subtle); }
.style-customization strong, .guide-toggle strong { color: var(--ink-deep); font-size: 13px; }
.style-customization-heading span, .guide-toggle small { color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.45; }
.style-control-label { margin-top: 2px; }
.accent-options { display: flex; flex-wrap: wrap; gap: 9px; }
.accent-options label { cursor: pointer; }
.accent-options label > span { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 9px; border: 1px solid var(--line-strong); border-radius: 9px; background: white; color: var(--muted); font-size: 10px; }
.accent-options label i { width: 15px; height: 15px; border-radius: 50%; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.accent-options input:checked + span { border-color: var(--swatch); background: color-mix(in srgb, var(--swatch) 7%, white); box-shadow: 0 0 0 2px color-mix(in srgb, var(--swatch) 22%, transparent); color: var(--ink-deep); font-weight: 750; }
.accent-options input:checked + span::after { content: "✓"; color: var(--swatch); font-size: 13px; font-weight: 900; }
.accent-options input:focus-visible + span { outline: 3px solid rgba(33, 104, 213, .18); outline-offset: 2px; }
.guide-toggle { grid-template-columns: auto 1fr !important; align-items: flex-start; gap: 11px !important; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: white; cursor: pointer; }
.guide-toggle input[type="checkbox"] { width: 19px; height: 19px; margin: 1px 0 0; accent-color: var(--blue); }
.guide-toggle > span { display: grid; gap: 4px; }

.prescription-preview-sheet { --rx-accent: #183247; }
.prescription-preview-sheet .header-preview { border-bottom-color: var(--rx-accent); }
.prescription-preview-sheet[data-template="clinic"] .header-preview { align-items: center; flex-direction: column; gap: 7px; min-height: 175px; text-align: center; }
.prescription-preview-sheet[data-template="clinic"] .preview-clinic { order: -1; max-width: 100%; text-align: center; }
.prescription-preview-sheet[data-template="clinic"] .preview-clinic strong { color: var(--rx-accent); font-size: 15px; }
.prescription-preview-sheet[data-template="clinic"] .preview-doctor { justify-content: center; }
.prescription-preview-sheet[data-template="compact"] .header-preview { min-height: 130px; padding-block: 20px; border-bottom-width: 1px; border-left: 6px solid var(--rx-accent); }
.prescription-preview-sheet[data-template="compact"] .preview-clinic { order: -1; max-width: 48%; text-align: left; }
.prescription-preview-sheet[data-template="compact"] .preview-doctor { text-align: right; }
.prescription-preview-sheet[data-guides="hidden"] .preview-writing span, .prescription-preview-sheet[data-guides="hidden"] .preview-writing strong { visibility: hidden; }

.print-sheet { --rx-accent: #183247; }
.print-clinic-header { border-bottom-color: var(--rx-accent); }
.template-clinic .print-clinic-header { align-items: center; flex-direction: column; gap: 8px; text-align: center; }
.template-clinic .print-clinic-block { order: -1; text-align: center; }
.template-clinic .print-clinic-block strong { color: var(--rx-accent); font-size: 22px; }
.template-clinic .print-doctor-block .eyebrow { display: none; }
.template-clinic .print-doctor-block h2 { margin-block: 0 3px; font-size: 22px; }
.template-compact .print-clinic-header { align-items: stretch; padding: 13px 0 13px 18px; border-bottom-width: 1px; border-left: 7px solid var(--rx-accent); }
.template-compact .print-clinic-block { order: -1; text-align: left; }
.template-compact .print-clinic-block strong { color: var(--rx-accent); font-size: 18px; }
.template-compact .print-doctor-block { text-align: right; }
.template-compact .print-doctor-block .eyebrow { display: none; }
.template-compact .print-doctor-block h2 { margin-top: 0; font-size: 20px; }
.review-pad-header { border-bottom-color: var(--rx-accent, var(--ink)); }
.review-pad-header.template-clinic { text-align: center; }
.review-pad-header.template-compact { border-bottom-width: 1px; border-left: 5px solid var(--rx-accent); }

.review-dialog { width: min(980px, calc(100% - 28px)); padding: 24px; }
.review-heading { align-items: flex-start; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.review-heading h2 { margin-bottom: 5px; }
.review-heading p:last-child { margin: 0; color: var(--muted); font-size: 13px; }
.review-content { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 22px; align-items: start; padding-top: 20px; }
.review-preview-panel { min-width: 0; }
.review-preview-label { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 9px; }
.review-preview-label strong { color: var(--ink-deep); font-size: 13px; }
.review-preview-label span { color: #177b72; font-size: 11px; font-weight: 700; }
.review-document { width: 100%; aspect-ratio: 210 / 297; display: flex; flex-direction: column; overflow: hidden; padding: 25px 29px 18px; border: 1px solid #cad5dc; border-radius: 8px; background: white; box-shadow: 0 12px 32px rgba(13, 36, 53, .09); }
.review-document .print-clinic-header { flex: 0 0 auto; gap: 18px; padding-bottom: 13px; }
.review-document .print-clinic-header h2 { margin: 3px 0; font-size: 18px; }
.review-document .print-clinic-header p { font-size: 8px; }
.review-document .clinic-address { gap: 3px; font-size: 8px; }
.review-document .clinic-address strong { font-size: 10px; }
.review-document .print-patient-bar { flex: 0 0 auto; gap: 12px; padding: 10px 0; }
.review-document .print-patient-bar span { gap: 2px; font-size: 9px; }
.review-document .print-patient-bar strong { font-size: 7px; }
.review-document .print-allergy, .review-document .print-follow-up { flex: 0 0 auto; padding: 6px 0; font-size: 8px; }
.review-document .print-allergy strong, .review-document .print-follow-up strong { font-size: 7px; }
.review-document-paper { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: white; }
.review-document-paper::before { content: ""; position: absolute; z-index: 0; inset-block: 0; left: 25px; width: 1px; background: #f1cbc6; }
.review-document-paper .paper-guide { inset: 20px 24px; font-size: 8px; }
.review-document-paper .paper-guide .rx-symbol { font-size: 22px; }
.review-document-paper img { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.review-prescription-text { height: 100%; padding: 24px 32px; overflow: hidden; font-size: 10px; line-height: 1.6; }
.review-structured-prescription { padding: 20px 28px; overflow: hidden; font-size: 8px; line-height: 1.35; }
.review-structured-prescription .structured-section { margin-bottom: 11px; }
.review-structured-prescription .structured-section h3 { margin-bottom: 5px; font-size: 8px; }
.review-structured-prescription .structured-medicines h3 { font-size: 11px; }
.review-structured-prescription .medication-output-header { font-size: 5px; }
.review-structured-prescription .medication-output-header span,
.review-structured-prescription .medication-output-row span { padding: 4px 5px; }
.review-structured-prescription .medication-output-row { font-size: 7px; }
.prescription-review-dialog .review-summary { gap: 16px; }
.review-document .print-footer { flex: 0 0 auto; gap: 12px; padding-top: 9px; font-size: 7px; }
.review-document .doctor-signature { min-width: 130px; padding-top: 8px; }
.review-document .doctor-signature strong { font-size: 8px; }
.review-document .doctor-signature small { font-size: 6px; }
.review-document.template-clinic .print-clinic-header { gap: 4px; padding-bottom: 9px; }
.review-document.template-clinic .print-clinic-block strong { font-size: 14px; }
.review-document.template-clinic .print-doctor-block h2 { font-size: 14px; }
.review-document.template-compact .print-clinic-header { gap: 12px; padding: 8px 0 8px 11px; border-left-width: 4px; }
.review-document.template-compact .print-clinic-block strong { font-size: 12px; }
.review-document.template-compact .print-doctor-block h2 { font-size: 13px; }
.review-summary { position: sticky; top: 0; display: grid; gap: 18px; }
.review-summary .review-details { grid-template-columns: 1fr; gap: 0; margin: 0; border-block: 1px solid var(--line); }
.review-summary .review-details > div { padding: 12px 2px; }
.review-summary .review-details > div + div { border-top: 1px solid var(--line); }
.review-summary .review-details dt { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.review-summary .review-details dd { color: var(--ink-deep); font-size: 13px; }
.review-summary .review-notice { margin: 0; }

@media (max-width: 680px) {
  .setup-progress { overflow-x: auto; justify-content: flex-start; }
  .setup-progress button { min-width: 132px; }
  .template-options { grid-template-columns: 1fr; }
  .template-option-card { grid-template-columns: 120px minmax(0, 1fr); grid-template-rows: 94px; align-items: center; }
  .review-dialog { padding: 18px; }
  .review-content { grid-template-columns: 1fr; }
  .review-summary { position: static; }
  .review-summary .review-details { grid-template-columns: repeat(3, 1fr); }
  .review-summary .review-details > div + div { border-top: 0; border-left: 1px solid var(--line); padding-left: 12px; }
}

@media print {
  .template-clinic .print-clinic-header { flex-direction: column; }
  .template-compact .print-clinic-header { flex-direction: row; }
}

/* Public homepage ------------------------------------------------------- */
.landing-shell { background: #071f30; }
.landing-shell .app-main { min-height: 100vh; }
.landing-page {
  --landing-navy: #071f30;
  --landing-navy-soft: #0e3044;
  --landing-cyan: #40d5cf;
  --landing-cyan-dark: #0aa9a5;
  --landing-blue: #2568df;
  --landing-cloud: #f3f7f9;
  --landing-line: #d9e5eb;
  min-height: 100vh;
  overflow: hidden;
  background: white;
  color: var(--landing-navy);
}
.landing-container { width: min(1180px, calc(100% - 48px)); margin-inline: auto; }
.landing-nav { position: absolute; z-index: 20; inset: 0 0 auto; border-bottom: 1px solid rgba(255, 255, 255, .1); color: white; }
.landing-nav-inner { min-height: 78px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 28px; }
.landing-brand { display: inline-flex; width: max-content; align-items: center; gap: 11px; color: inherit; font-size: 21px; font-weight: 800; letter-spacing: -.04em; text-decoration: none; }
.landing-nav .brand-mark, .landing-footer .brand-mark { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .1); box-shadow: none; }
.landing-links { display: flex; align-items: center; gap: 30px; }
.landing-links a, .landing-text-link { color: rgba(255, 255, 255, .72); font-size: 14px; font-weight: 650; text-decoration: none; }
.landing-links a:hover, .landing-text-link:hover { color: white; }
.landing-actions { justify-self: end; display: flex; align-items: center; gap: 20px; }
.landing-button { min-height: 54px; display: inline-flex; align-items: center; justify-content: center; gap: 11px; padding: 0 23px; border: 1px solid var(--landing-cyan); border-radius: 12px 4px 12px 12px; background: var(--landing-cyan); color: var(--landing-navy); box-shadow: 0 10px 30px rgba(64, 213, 207, .18); font-size: 15px; font-weight: 800; text-decoration: none; transition: transform var(--duration-press) var(--ease-out), background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease; }
.landing-button:hover { transform: translateY(-2px); background: #63e1dc; border-color: #63e1dc; box-shadow: 0 15px 36px rgba(64, 213, 207, .25); }
.landing-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.landing-button-small { min-height: 42px; padding-inline: 17px; border-radius: 10px 3px 10px 10px; font-size: 14px; }

.landing-hero { position: relative; min-height: 760px; display: grid; align-items: center; padding: 145px 0 90px; overflow: hidden; background: var(--landing-navy); color: white; }
.landing-hero::before { content: ""; position: absolute; inset: 0; opacity: .13; background-image: linear-gradient(rgba(125, 211, 225, .35) 1px, transparent 1px), linear-gradient(90deg, rgba(125, 211, 225, .35) 1px, transparent 1px); background-size: 80px 80px; mask-image: linear-gradient(90deg, #000, transparent 72%); }
.landing-hero::after { content: "Rx"; position: absolute; right: -28px; bottom: -70px; color: rgba(255, 255, 255, .025); font-family: Georgia, serif; font-size: 360px; line-height: .8; pointer-events: none; }
.hero-grid { position: relative; z-index: 1; display: grid; grid-template-columns: .9fr 1.1fr; align-items: center; gap: clamp(54px, 7vw, 100px); }
.landing-kicker { display: flex; align-items: center; gap: 9px; margin: 0 0 22px; color: var(--landing-cyan); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.landing-kicker > span { width: 22px; height: 2px; background: currentColor; }
.hero-copy h1 { max-width: 670px; margin: 0; font-size: clamp(52px, 5.8vw, 78px); line-height: .98; letter-spacing: -.058em; }
.hero-copy h1 em, .final-cta h2 em { color: var(--landing-cyan); font-style: normal; }
.hero-lede { max-width: 600px; margin: 30px 0 32px; color: #bad0dc; font-size: clamp(17px, 1.7vw, 20px); line-height: 1.65; }
.hero-actions { display: flex; align-items: center; gap: 24px; }
.landing-video-link { display: inline-flex; align-items: center; gap: 10px; color: white; font-size: 15px; font-weight: 750; text-decoration: none; }
.landing-video-link > span { display: grid; place-items: center; width: 39px; height: 39px; border: 1px solid rgba(255, 255, 255, .28); border-radius: 50%; }
.landing-video-link svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.hero-proof { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 29px; color: #8eabb9; font-size: 13px; }
.hero-proof span { display: flex; align-items: center; gap: 7px; }
.hero-proof svg { width: 15px; fill: none; stroke: var(--landing-cyan); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.hero-product { position: relative; }
.hero-product-glow { position: absolute; inset: 5% -14% -14% 7%; border-radius: 50%; background: radial-gradient(circle, rgba(46, 206, 202, .22), transparent 68%); filter: blur(14px); }
.hero-clinic-photo { position: relative; overflow: hidden; aspect-ratio: 3 / 2; border: 1px solid rgba(170, 229, 232, .34); border-radius: 26px 9px 26px 26px; background: #0c3043; box-shadow: 0 35px 90px rgba(0, 0, 0, .36); transform: perspective(1200px) rotateY(-4deg) rotateX(1deg); }
.hero-clinic-photo::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(180deg, transparent 60%, rgba(7, 31, 48, .18)); box-shadow: inset 0 0 0 8px rgba(255, 255, 255, .04); pointer-events: none; }
.hero-clinic-photo img { width: 100%; height: 100%; display: block; object-fit: cover; }
.consultation-note { position: absolute; right: -20px; bottom: -38px; display: flex; align-items: center; gap: 12px; padding: 15px 18px; border: 1px solid rgba(255, 255, 255, .35); border-radius: 15px 5px 15px 15px; background: rgba(255, 255, 255, .96); color: var(--landing-navy); box-shadow: 0 16px 35px rgba(0, 0, 0, .24); }
.consultation-pulse { position: relative; width: 13px; height: 13px; flex: 0 0 auto; border: 3px solid white; border-radius: 50%; background: #11a99e; box-shadow: 0 0 0 5px #d9f6f3; }
.consultation-note > span:last-child { display: grid; gap: 3px; }
.consultation-note strong { font-size: 13px; }
.consultation-note small { color: #607682; font-size: 11px; }
.hero-video-frame { position: relative; overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid rgba(170, 229, 232, .34); border-radius: 26px 9px 26px 26px; background: #0c3043; box-shadow: 0 35px 90px rgba(0, 0, 0, .36); transform: perspective(1200px) rotateY(-4deg) rotateX(1deg); }
.hero-video-frame::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 8px rgba(255, 255, 255, .04); pointer-events: none; }
.hero-video-frame video { width: 100%; height: 100%; display: block; object-fit: cover; }
.hero-play { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; border: 0; background: rgba(7, 31, 48, .05); color: white; cursor: pointer; font-weight: 760; }
.hero-play[hidden] { display: none; }
.hero-play svg { width: 58px; height: 58px; padding: 16px; border-radius: 50%; background: rgba(7, 31, 48, .86); fill: none; stroke: white; stroke-width: 1.8; stroke-linejoin: round; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.memory-note { position: absolute; right: -20px; bottom: -38px; display: flex; align-items: center; gap: 12px; padding: 14px 17px; border: 1px solid rgba(255, 255, 255, .35); border-radius: 15px 5px 15px 15px; background: rgba(255, 255, 255, .96); color: var(--landing-navy); box-shadow: 0 16px 35px rgba(0, 0, 0, .24); }
.memory-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px 3px 11px 11px; background: #ddf8f5; color: #078c87; }
.memory-icon svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.memory-note > span:last-child { display: grid; gap: 3px; }
.memory-note strong { font-size: 13px; }
.memory-note small { color: #607682; font-size: 11px; }

.positioning-strip { background: var(--landing-cyan); }
.strip-grid { min-height: 108px; display: grid; grid-template-columns: 1fr auto 1.25fr auto .75fr; align-items: center; gap: 28px; }
.strip-grid p { margin: 0; font-size: clamp(18px, 2.2vw, 27px); letter-spacing: -.035em; }
.strip-grid p strong { font-weight: 850; }
.strip-plus, .strip-equals { color: rgba(7, 31, 48, .35); font-size: 28px; font-weight: 300; }
.strip-result { display: flex; align-items: center; gap: 11px; }
.strip-result .brand-mark { width: 40px; height: 40px; background: var(--landing-navy); }

.clinic-story { background: #f6f9fa; }
.story-heading { display: grid; grid-template-columns: 1.15fr .85fr; align-items: end; gap: clamp(55px, 9vw, 120px); margin-bottom: 58px; }
.story-heading h2 { margin: 0; color: var(--landing-navy); font-size: clamp(40px, 5vw, 62px); line-height: 1.03; letter-spacing: -.055em; }
.story-heading > p { max-width: 520px; margin: 0 0 4px; color: #607682; font-size: 17px; line-height: 1.7; }
.story-heading .landing-kicker { color: var(--landing-cyan-dark); }
.story-grid { display: grid; grid-template-columns: 1.08fr .92fr; gap: 28px; align-items: start; }
.story-card { margin: 0; }
.story-card-review { margin-top: 92px; }
.story-image { position: relative; overflow: hidden; aspect-ratio: 4 / 3; border-radius: 24px 7px 24px 24px; background: #dfe8eb; box-shadow: 0 24px 55px rgba(7, 31, 48, .13); }
.story-image::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 70%, rgba(7, 31, 48, .5)); pointer-events: none; }
.story-image img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .6s var(--ease-in-out); }
.story-card:hover .story-image img { transform: scale(1.018); }
.story-step { position: absolute; z-index: 1; left: 22px; bottom: 19px; padding: 8px 11px; border: 1px solid rgba(255, 255, 255, .26); border-radius: 99px; background: rgba(7, 31, 48, .72); color: white; backdrop-filter: blur(10px); font-size: 11px; font-weight: 800; letter-spacing: .055em; text-transform: uppercase; }
.story-card figcaption { padding: 27px 8px 0; }
.story-card h3 { margin: 0 0 11px; color: var(--landing-navy); font-size: clamp(24px, 2.6vw, 32px); line-height: 1.15; letter-spacing: -.04em; }
.story-card p { max-width: 520px; margin: 0; color: #607682; font-size: 15px; line-height: 1.7; }
.story-disclosure { margin: 46px 0 0; color: #91a1a9; font-size: 11px; text-align: center; }

.landing-section { padding: 120px 0; }
.section-intro { max-width: 650px; margin-bottom: 56px; }
.section-intro.centered { margin-inline: auto; text-align: center; }
.section-intro.centered .landing-kicker { justify-content: center; }
.section-intro h2, .demo-copy h2 { margin: 0; color: var(--landing-navy); font-size: clamp(40px, 5vw, 62px); line-height: 1.03; letter-spacing: -.055em; }
.section-intro > p:last-child, .demo-copy > p { margin: 24px 0 0; color: #607682; font-size: 17px; line-height: 1.65; }
.section-intro .landing-kicker, .demo-copy .landing-kicker { color: var(--landing-cyan-dark); }

.comparison-section { background: white; }
.comparison-table { overflow: hidden; border: 1px solid var(--landing-line); border-radius: 22px 7px 22px 22px; box-shadow: 0 25px 65px rgba(7, 31, 48, .08); }
.comparison-row { display: grid; grid-template-columns: 1.55fr repeat(3, 1fr); }
.comparison-row > div { min-width: 0; display: flex; align-items: center; gap: 8px; padding: 20px 22px; border-top: 1px solid var(--landing-line); color: #526b78; font-size: 14px; }
.comparison-row > div + div { border-left: 1px solid var(--landing-line); }
.comparison-header > div { border-top: 0; background: #f7fafb; color: #718590; font-size: 12px; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
.comparison-header .curepad-column { color: white; background: var(--landing-navy); }
.comparison-row > div:first-child { display: grid; gap: 5px; }
.comparison-row strong { color: var(--landing-navy); font-size: 15px; }
.comparison-row small { color: #7b8e98; font-size: 12px; line-height: 1.45; }
.comparison-row .curepad-column { background: #eafafa; color: #0b6665; font-weight: 760; }
.comparison-check { display: grid; place-items: center; width: 24px; height: 24px; flex: 0 0 auto; border-radius: 50%; background: #d9f6f3; color: #0a8a85; font-weight: 900; }
.comparison-no { color: #9caab1; font-weight: 700; }
.mini-logo { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 9px 3px 9px 9px; background: var(--landing-cyan); color: var(--landing-navy); font-size: 11px; letter-spacing: -.06em; }

.workflow-section { background: var(--landing-cloud); }
.workflow-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid #cad9e1; }
.workflow-grid article { position: relative; min-height: 330px; padding: 34px 38px 38px 0; }
.workflow-grid article + article { padding-left: 38px; border-left: 1px solid #cad9e1; }
.step-number { position: absolute; top: -13px; left: 0; padding-right: 12px; background: var(--landing-cloud); color: #7a909b; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.workflow-grid article + article .step-number { left: 38px; }
.feature-icon { width: 62px; height: 62px; display: grid; place-items: center; margin: 22px 0 34px; border-radius: 18px 5px 18px 18px; background: white; color: var(--landing-blue); box-shadow: 0 12px 28px rgba(7, 31, 48, .08); }
.feature-icon svg { width: 28px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.workflow-grid h3 { margin: 0 0 13px; font-size: 24px; letter-spacing: -.035em; }
.workflow-grid p { max-width: 310px; margin: 0; color: #607682; font-size: 16px; line-height: 1.65; }

.demo-section { background: white; }
.demo-grid { display: grid; grid-template-columns: .72fr 1.28fr; align-items: center; gap: 70px; }
.demo-copy h2 { font-size: clamp(38px, 4.5vw, 56px); }
.demo-copy ul { display: grid; gap: 12px; margin: 27px 0 0; padding: 0; list-style: none; color: #385362; }
.demo-copy li { display: flex; align-items: center; gap: 10px; }
.demo-copy li span { color: var(--landing-cyan-dark); font-weight: 900; }
.demo-video-wrap { overflow: hidden; aspect-ratio: 16 / 9; border: 10px solid var(--landing-navy); border-radius: 26px 8px 26px 26px; background: var(--landing-navy); box-shadow: 0 30px 75px rgba(7, 31, 48, .2); }
.demo-video-wrap video { width: 100%; height: 100%; display: block; object-fit: cover; }

.final-cta { padding: 105px 0; overflow: hidden; background: var(--landing-navy); color: white; }
.final-cta-inner { display: grid; grid-template-columns: 1.15fr .85fr; align-items: end; gap: 90px; }
.final-cta h2 { margin: 0; font-size: clamp(48px, 6vw, 76px); line-height: .98; letter-spacing: -.06em; }
.final-cta-inner > div:last-child > p { margin: 0 0 28px; color: #a9c2ce; font-size: 17px; line-height: 1.65; }
.landing-button-light { background: white; border-color: white; box-shadow: none; }
.landing-button-light:hover { background: var(--landing-cyan); border-color: var(--landing-cyan); }

.landing-footer { padding: 38px 0; border-top: 1px solid rgba(255, 255, 255, .09); background: var(--landing-navy); color: white; }
.footer-inner { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 25px; }
.footer-inner p { margin: 0; color: #7f9dab; font-size: 13px; }
.footer-inner > div { justify-self: end; display: flex; gap: 24px; }
.footer-inner > div a { color: #aac0ca; font-size: 13px; font-weight: 700; text-decoration: none; }
.footer-inner > div a:hover { color: white; }

@media (min-width: 1021px) and (max-width: 1300px) {
  .landing-hero { min-height: 720px; padding-block: 125px 72px; }
  .hero-grid { grid-template-columns: .92fr 1.08fr; gap: 54px; }
  .hero-copy h1 { font-size: clamp(54px, 5.2vw, 66px); }
  .hero-lede { margin-block: 24px 27px; font-size: 17px; }
}

@media (max-width: 1020px) {
  .landing-links { display: none; }
  .landing-nav-inner { grid-template-columns: 1fr auto; }
  .hero-grid { grid-template-columns: 1fr; }
  .landing-hero { padding-top: 150px; }
  .hero-copy { max-width: 760px; }
  .hero-product { width: min(820px, 94%); margin: 12px auto 20px; }
  .story-heading { grid-template-columns: 1fr; gap: 24px; }
  .strip-grid { grid-template-columns: 1fr auto 1.25fr; }
  .strip-equals, .strip-result { display: none; }
  .demo-grid { grid-template-columns: 1fr; gap: 42px; }
  .demo-copy { max-width: 650px; }
}

@media (max-width: 760px) {
  .landing-container { width: min(100% - 32px, 1180px); }
  .landing-nav-inner { min-height: 70px; }
  .landing-actions .landing-text-link { display: none; }
  .landing-button-small { min-height: 40px; padding-inline: 14px; }
  .landing-hero { min-height: 0; padding: 125px 0 76px; }
  .hero-grid { gap: 54px; }
  .hero-copy h1 { font-size: clamp(46px, 14vw, 64px); }
  .hero-lede { margin-top: 24px; font-size: 17px; }
  .hero-actions { align-items: flex-start; flex-direction: column; gap: 19px; }
  .hero-actions .landing-button { width: 100%; }
  .hero-proof { gap: 12px 18px; }
  .hero-product { width: 100%; margin-bottom: 0; }
  .hero-clinic-photo { border-radius: 18px 6px 18px 18px; transform: none; }
  .consultation-note { position: relative; right: auto; bottom: auto; width: calc(100% - 24px); margin: -12px auto 0; }
  .hero-video-frame { border-radius: 18px 6px 18px 18px; transform: none; }
  .hero-play span { display: none; }
  .hero-play svg { width: 50px; height: 50px; padding: 14px; }
  .memory-note { position: relative; right: auto; bottom: auto; width: calc(100% - 24px); margin: -12px auto 0; }
  .positioning-strip { padding: 23px 0; }
  .strip-grid { min-height: 0; grid-template-columns: 1fr auto 1.15fr; gap: 14px; }
  .strip-grid p { font-size: 17px; }
  .strip-plus { font-size: 22px; }
  .landing-section { padding: 82px 0; }
  .story-heading { margin-bottom: 38px; }
  .story-grid { grid-template-columns: 1fr; gap: 48px; }
  .story-card-review { margin-top: 0; }
  .story-image { border-radius: 18px 6px 18px 18px; }
  .story-card figcaption { padding: 22px 2px 0; }
  .story-disclosure { margin-top: 36px; }
  .section-intro { margin-bottom: 38px; }
  .section-intro h2, .demo-copy h2 { font-size: clamp(38px, 11vw, 52px); }
  .comparison-table { overflow-x: auto; border-radius: 17px 5px 17px 17px; }
  .comparison-row { min-width: 740px; grid-template-columns: 1.45fr repeat(3, 1fr); }
  .comparison-row > div { padding: 17px 16px; }
  .workflow-grid { grid-template-columns: 1fr; border-top: 0; }
  .workflow-grid article, .workflow-grid article + article { min-height: 0; padding: 29px 0 42px 78px; border-top: 1px solid #cad9e1; border-left: 0; }
  .workflow-grid article + article .step-number, .step-number { top: -11px; left: 0; }
  .feature-icon { position: absolute; top: 24px; left: 0; width: 55px; height: 55px; margin: 0; }
  .workflow-grid h3 { margin-top: 7px; }
  .demo-video-wrap { border-width: 6px; border-radius: 18px 6px 18px 18px; }
  .final-cta { padding: 82px 0; }
  .final-cta-inner { grid-template-columns: 1fr; gap: 35px; }
  .footer-inner { grid-template-columns: 1fr auto; }
  .footer-inner p { display: none; }
}

@media (max-width: 430px) {
  .landing-brand { font-size: 19px; }
  .landing-brand .brand-mark { width: 34px; height: 34px; }
  .landing-button-small { font-size: 13px; }
  .landing-kicker { line-height: 1.45; }
  .hero-copy h1 { font-size: 44px; }
  .hero-proof { display: grid; }
  .memory-note { width: calc(100% - 16px); padding-inline: 13px; }
  .memory-note small { font-size: 10px; }
  .strip-grid { gap: 9px; }
  .strip-grid p { font-size: 15px; }
  .footer-inner > div { gap: 15px; }
}

/* Interaction polish ---------------------------------------------------- */
::selection { background: rgba(33, 104, 213, .18); color: var(--ink-deep); }

.icon-button,
.patient-context-button,
.mobile-save-action,
.clear-search,
.password-toggle,
.landing-video-link,
.hero-play,
.accent-options label > span,
.guide-toggle,
.avatar,
.follow-up-chip,
.timeline-date,
.landing-video-link > span,
.hero-play svg {
  transition: transform var(--duration-press) var(--ease-out),
              color var(--duration-fast) ease,
              background-color var(--duration-fast) ease,
              border-color var(--duration-fast) ease,
              box-shadow var(--duration-fast) ease,
              opacity var(--duration-fast) ease;
}

.patient-identity strong,
.text-link,
.breadcrumb,
.profile-preview-footer a,
.landing-links a,
.landing-text-link,
.footer-inner > div a {
  transition: color var(--duration-fast) ease, text-decoration-color var(--duration-fast) ease;
}

.stack-form input::placeholder,
.stack-form textarea::placeholder,
.setup-form input::placeholder,
.setup-form textarea::placeholder,
.visit-label input::placeholder { color: var(--muted-light); opacity: .88; }

.stack-form input:user-invalid,
.stack-form select:user-invalid,
.stack-form textarea:user-invalid,
.setup-form input:user-invalid,
.setup-form textarea:user-invalid,
.visit-label input:user-invalid {
  border-color: #d77b70;
  background: #fffafa;
}

.template-option > input:checked + .template-option-card,
.accent-options input:checked + span { transform: translateY(-1px); }

.quick-add-card[data-instant-motion],
.patient-rail[data-instant-motion] { transition: none !important; }

@media (hover: hover) and (pointer: fine) {
  .follow-up-chip:hover { border-color: #ddb95f; box-shadow: var(--shadow-sm); }
  .timeline-item:hover .timeline-date { box-shadow: inset 0 0 0 1px rgba(33, 104, 213, .12); }
  .landing-video-link:hover > span { transform: scale(1.06); border-color: rgba(255, 255, 255, .5); }
  .hero-play:hover svg { transform: scale(1.06); }
  .accent-options label:hover > span,
  .guide-toggle:hover { border-color: #aebdc7; }
  .template-option:hover .template-option-card { transform: translateY(-1px); border-color: #a9bac5; }
}

@media (hover: none) {
  .primary-button:hover { border-color: var(--blue); background: var(--blue); transform: none; box-shadow: 0 6px 16px rgba(33, 104, 213, .18); }
  .secondary-button:hover { border-color: var(--line-strong); background: white; }
  .search-button:hover, .patient-search input.search-button:hover { background: var(--ink-deep); }
  .nav-link:hover:not(.active) { background: transparent; color: var(--muted); }
  .doctor-profile-link:hover:not(.active), .icon-button:hover { background: transparent; border-color: var(--line); }
  .icon-button.ghost:hover { background: transparent; border-color: transparent; }
  .patient-identity:hover strong { color: inherit; }
  .write-button:hover { border-color: #cbd9e4; background: white; }
  .template-option:hover .template-option-card { transform: none; border-color: var(--line-strong); }
  .template-option > input:checked + .template-option-card { transform: translateY(-1px); border-color: var(--blue); }
  .landing-button:hover { transform: none; background: var(--landing-cyan); border-color: var(--landing-cyan); box-shadow: 0 10px 30px rgba(64, 213, 207, .18); }
  .landing-button-light:hover { background: white; border-color: white; }
  .story-card:hover .story-image img { transform: none; }
}

:is(.primary-button, .secondary-button, .write-button, .search-button, .landing-button,
    .icon-button, .patient-context-button, .hero-play, .setup-progress button,
    .template-option, .accent-options label, .guide-toggle):active:not(:disabled) {
  transform: scale(.97);
}

:is(.mobile-save-action, .clear-search, .password-toggle):active:not(:disabled) {
  transform: scale(.98);
}

.patient-identity:active .avatar,
.landing-video-link:active > span { transform: scale(.96); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 680px) {
  .input-mode-badge { display: none; }
  .prescription-sections { padding: 28px 24px; }
  .section-overlay { left: 22px; }
  .prescription-section-input { padding-right: 12px; padding-left: 22px; font-size: 18px; }
  .medicines-section { padding-right: 0; padding-left: 22px; }
  .medication-table-header, .medication-entry-row { min-width: 540px; }
  .readonly-prescription-text { padding: 36px 42px; font-size: 16px; }
  .structured-prescription { padding: 32px 38px; }
}

/* Keep the editor focused on the amount of clinical content, rather than a fixed A4 split. */
.prescription-shell .paper { aspect-ratio: auto; min-height: 0; }

.review-content { grid-template-columns: minmax(0, 1fr) 310px; }

.review-medication-checklist {
  align-self: start;
  padding: 20px;
  border: 1px solid #c7d8e7;
  border-radius: 14px;
  background: #f7fbff;
}

.review-medication-checklist[hidden] { display: none; }

.review-medication-checklist h3 { margin: 2px 0 14px; color: var(--ink-deep); font-size: 18px; }

.review-medication-checklist ol { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }

.review-medication-checklist li {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid #dae6ef;
  border-radius: 10px;
  background: white;
}

.review-medication-checklist strong { color: var(--ink-deep); font-size: 16px; line-height: 1.25; }
.review-medication-checklist span { color: var(--muted); font-size: 14px; line-height: 1.45; }

.review-save-actions { display: grid; gap: 9px; padding-top: 16px; border-top: 1px solid var(--line); }
.review-save-actions > button:not(.review-edit-button) { width: 100%; min-height: 46px; }
.review-save-actions p { margin: 0 2px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.review-edit-button { justify-self: center; min-height: 40px; padding: 0 12px; border: 0; background: transparent; color: var(--blue); font: inherit; font-size: 12px; font-weight: 750; cursor: pointer; }
.patient-share-prompt { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; padding: 18px 20px; border: 1px solid #c7d8e7; border-radius: 14px; background: #f2f8ff; }
.patient-share-prompt > div { display: grid; gap: 4px; }
.patient-share-prompt strong { color: var(--ink-deep); font-size: 14px; }
.patient-share-prompt span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.patient-share-prompt button { flex: 0 0 auto; }
.export-feedback a { color: var(--blue); font-weight: 750; }

@media (max-width: 680px) {
  .topbar-inner { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .main-nav, .doctor-menu { display: none; }

  .mobile-app-menu { position: relative; display: block; justify-self: end; }
  .mobile-app-menu summary {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    background: white;
    color: var(--ink-deep);
    cursor: pointer;
    list-style: none;
  }
  .mobile-app-menu summary::-webkit-details-marker { display: none; }
  .mobile-app-menu summary svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.9; }
  .mobile-app-menu:not([open]) .mobile-app-menu-panel { display: none; }
  .mobile-app-menu-panel {
    position: absolute;
    z-index: 30;
    top: calc(100% + 8px);
    right: 0;
    width: min(320px, calc(100vw - 28px));
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: white;
    box-shadow: 0 18px 42px rgba(29, 54, 74, .2);
  }
  .mobile-app-menu-panel nav { display: grid; padding: 8px; }
  .mobile-app-menu-link { display: grid; gap: 2px; padding: 12px; border-radius: 10px; color: var(--ink-deep); text-decoration: none; }
  .mobile-app-menu-link.active { background: #edf6fd; color: var(--blue); }
  .mobile-app-menu-link span { font-weight: 750; }
  .mobile-app-menu-link small, .mobile-app-menu-profile small { color: var(--muted); font-size: 12px; }
  .mobile-app-menu-account { display: grid; gap: 10px; padding: 12px; border-top: 1px solid var(--line); background: #f8fbfd; }
  .mobile-app-menu-profile { display: flex; gap: 10px; align-items: center; color: var(--ink-deep); text-decoration: none; }
  .mobile-app-menu-profile > span:last-child { display: grid; gap: 2px; min-width: 0; }
  .mobile-app-menu-profile strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-sign-out, .mobile-sign-out button { width: 100%; min-height: 42px; border: 1px solid #d9b6b1; border-radius: 9px; background: white; color: #a5453d; font: inherit; font-weight: 700; }

  .prescription-shell .paper { aspect-ratio: auto; min-height: 0; }
  .review-content { grid-template-columns: 1fr; }
  .review-medication-checklist { order: -1; }
  .patient-share-prompt { align-items: stretch; flex-direction: column; }
}

/* Tablet-first pad setup: keep the current decision and its outcome together. */
@media (max-width: 900px) {
  .setup-progress { align-items: center; overflow: visible; }
  .setup-progress button { position: relative; flex: 0 0 48px; min-width: 48px; padding: 9px; }
  .setup-progress button.current { flex: 1 1 auto; }
  .setup-progress button:not(.current) .setup-step-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .setup-progress button.current .setup-step-label { display: inline; }

  .template-options { grid-template-columns: 1fr; }
  .template-option-card { grid-template-columns: 140px minmax(0, 1fr); grid-template-rows: minmax(108px, auto); align-items: center; gap: 16px; padding: 12px; }
  .template-thumbnail { min-height: 108px; }
  .template-option-copy { gap: 8px; font-size: 13px; }
  .template-option-copy strong { font-size: 16px; }
  .template-option-copy small { font-size: 10px; }

  .onboarding-page.styling .header-preview-wrap {
    position: sticky;
    z-index: 12;
    top: calc(76px + env(safe-area-inset-top, 0px));
    order: -1;
    width: 100%;
    max-width: 680px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: rgba(246, 249, 251, .96);
    box-shadow: 0 10px 30px rgba(13, 36, 53, .1);
    backdrop-filter: blur(14px);
  }
  .onboarding-page.styling .preview-heading { margin: 0 4px 8px; }
  .onboarding-page.styling .prescription-preview-sheet .header-preview { min-height: 118px; padding: 16px; border-radius: 11px; box-shadow: none; }
  .onboarding-page.styling .preview-patient-lines,
  .onboarding-page.styling .preview-writing,
  .onboarding-page.styling .preview-footer,
  .onboarding-page.styling .preview-note { display: none; }
}

@media (pointer: coarse) {
  .setup-progress button,
  .template-option,
  .accent-options label,
  .guide-toggle {
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  .setup-form input,
  .setup-form textarea,
  .setup-form select { font-size: 16px; }
  .accent-options label > span { min-height: 48px; padding: 9px 12px; font-size: 13px; }
  .accent-options label i { width: 19px; height: 19px; }
  .guide-toggle { min-height: 64px; padding: 14px; }
  .guide-toggle input[type="checkbox"] { width: 24px; height: 24px; }
}

@media (pointer: coarse) and (max-width: 1050px) {
  .setup-navigation,
  .setup-submit {
    position: sticky;
    z-index: 10;
    bottom: 0;
    margin: 4px -8px -8px;
    padding: 14px 8px calc(14px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 -10px 24px rgba(13, 36, 53, .08);
    backdrop-filter: blur(14px);
  }
}

/* Direct-on-pad setup -------------------------------------------------- */
.pad-builder-page { width: min(1240px, calc(100% - 40px)); }
.pad-builder-form { display: grid; gap: 18px; }
.pad-builder-errors { margin: 0; }
.pad-builder-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.pad-builder-stage { min-width: 0; }
.pad-builder-stage-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0 4px 12px; }
.pad-builder-stage-heading h2, .pad-builder-controls h2 { margin: 3px 0 0; color: var(--ink-deep); font-size: 20px; letter-spacing: -.025em; }
.pad-builder-stage-heading > span { display: inline-flex; align-items: center; gap: 6px; color: #177b72; font-size: 11px; font-weight: 750; }
.pad-builder-stage-heading > span i { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); }

.pad-builder-sheet { min-height: 790px; display: flex; flex-direction: column; overflow: hidden; border: 1px solid #cbd6dd; border-radius: 15px; background: white; box-shadow: 0 18px 46px rgba(13, 36, 53, .13); }
.pad-builder-sheet .pad-builder-header { min-height: 215px; border-radius: 0; box-shadow: none; }
.pad-builder-sheet .pad-builder-doctor { min-width: 0; flex: 1 1 56%; display: grid; align-content: start; gap: 12px; }
.pad-builder-sheet .pad-builder-clinic { min-width: 220px; max-width: 42%; display: grid; align-content: start; gap: 9px; }
.pad-inline-pair { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 9px; }
.pad-inline-field { position: relative; display: grid; gap: 3px; min-width: 0; color: #718590; font-size: 9px; font-weight: 800; letter-spacing: .045em; text-align: left; text-transform: uppercase; }
.pad-inline-field input, .pad-inline-field textarea { width: 100%; min-width: 0; padding: 8px 9px; border: 1px dashed #aabdc9; border-radius: 8px; outline: 0; resize: none; background: #f8fbfd; color: var(--ink-deep); font: 650 14px/1.3 Inter, ui-sans-serif, system-ui, sans-serif; letter-spacing: normal; text-align: inherit; text-transform: none; transition: border-color var(--duration-fast) ease, background-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease; }
.pad-doctor-name input { font-size: 20px; font-weight: 790; }
.pad-clinic-name input { color: var(--rx-accent); font-size: 15px; font-weight: 790; }
.pad-inline-field textarea { min-height: 55px; }
.pad-inline-field input:focus, .pad-inline-field textarea:focus { border-style: solid; border-color: var(--blue); background: white; box-shadow: 0 0 0 3px rgba(33, 104, 213, .12); }
.pad-inline-field input:user-invalid, .pad-inline-field textarea:user-invalid { border-color: #d77b70; background: #fffafa; }
.pad-builder-writing { flex: 1 1 auto; grid-template-rows: minmax(110px, .8fr) minmax(260px, 2fr) minmax(90px, .7fr); box-shadow: none; }
.pad-builder-footer { display: flex; align-items: end; justify-content: space-between; gap: 24px; min-height: 104px; padding: 13px 24px 17px; border: 1px solid var(--line); border-top: 0; color: var(--muted); font-size: 9px; }
.signature-preview-button { position: relative; width: 230px; min-height: 72px; display: grid; place-items: center; padding: 5px 12px 18px; border: 1px dashed #9fb2bf; border-radius: 9px; background: #f9fbfc; color: var(--blue); cursor: pointer; touch-action: manipulation; }
.signature-preview-button canvas { width: 100%; height: 45px; }
.signature-preview-button canvas[hidden] { display: none; }
.signature-preview-button > span { font-size: 12px; font-weight: 750; }
.signature-preview-button small { position: absolute; right: 12px; bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 650; }
.pad-builder-help { margin: 12px 4px 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.prescription-preview-sheet[data-template="clinic"] .pad-builder-header { min-height: 270px; }
.prescription-preview-sheet[data-template="clinic"] .pad-builder-doctor,
.prescription-preview-sheet[data-template="clinic"] .pad-builder-clinic { width: min(620px, 100%); max-width: 100%; }
.prescription-preview-sheet[data-template="clinic"] .pad-builder-doctor { flex: none; }
.prescription-preview-sheet[data-template="clinic"] .pad-inline-field { text-align: center; }
.prescription-preview-sheet[data-template="compact"] .pad-builder-header { min-height: 205px; }
.prescription-preview-sheet[data-template="compact"] .pad-builder-doctor { text-align: right; }
.prescription-preview-sheet[data-template="compact"] .pad-builder-doctor .pad-inline-field { text-align: right; }
.prescription-preview-sheet[data-template="compact"] .pad-builder-clinic { max-width: 48%; }

.pad-builder-controls { position: sticky; top: 88px; display: grid; gap: 20px; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: var(--shadow-sm); }
.pad-builder-controls > div:first-child > p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.pad-builder-controls fieldset { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
.pad-builder-controls fieldset + fieldset { padding-top: 17px; border-top: 1px solid var(--line); }
.pad-builder-controls legend { margin-bottom: 10px; color: var(--ink-deep); font-size: 13px; font-weight: 780; }
.pad-template-options { grid-template-columns: 1fr; gap: 8px; }
.pad-template-options .template-option-card { grid-template-columns: 72px minmax(0, 1fr); grid-template-rows: 58px; align-items: center; gap: 10px; padding: 8px; }
.pad-template-options .template-thumbnail { height: 58px; min-height: 0; }
.pad-template-options .template-thumbnail::after { inset: 34px 7px 7px; background-size: auto 8px; }
.pad-template-options .template-thumbnail i { top: 8px; left: 7px; }
.pad-template-options .template-thumbnail b { top: 18px; left: 7px; }
.pad-template-options .template-thumbnail em { top: 8px; right: 7px; }
.pad-template-options .template-thumbnail small { top: 18px; right: 7px; }
.pad-template-options .template-option-copy { gap: 2px; font-size: 11px; }
.pad-template-options .template-option-copy strong { font-size: 13px; }
.signature-requirement { display: grid; gap: 4px; padding: 13px; border: 1px solid #d9c789; border-radius: 11px; background: #fffaf0; }
.signature-requirement strong { color: var(--ink-deep); font-size: 12px; }
.signature-requirement span { color: var(--muted); font-size: 11px; line-height: 1.45; }
.signature-requirement.complete { border-color: #b9dfd5; background: var(--teal-soft); }
.signature-requirement.complete strong { color: #136b62; }
.pad-builder-actions { display: grid; gap: 12px; padding-top: 17px; border-top: 1px solid var(--line); }
.pad-builder-actions > span { color: var(--muted); font-size: 10px; line-height: 1.45; }
.pad-builder-actions .primary-button { width: 100%; min-height: 48px; }

.signature-dialog { width: min(760px, calc(100% - 28px)); padding: 22px; border: 0; border-radius: 18px; box-shadow: 0 24px 80px rgba(13, 36, 53, .3); }
.signature-dialog::backdrop { background: rgba(13, 36, 53, .52); backdrop-filter: blur(3px); }
.signature-dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.signature-dialog-heading h2 { margin: 4px 0 5px; color: var(--ink-deep); font-size: 24px; }
.signature-dialog-heading p:last-child { max-width: 560px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.signature-canvas-wrap { position: relative; height: 260px; overflow: hidden; border: 2px solid #bfd0dc; border-radius: 13px; background: #fbfdfe; }
.signature-canvas-wrap canvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.signature-canvas-wrap::after { content: ""; position: absolute; left: 9%; right: 9%; bottom: 48px; border-bottom: 1px solid #aebdc7; pointer-events: none; }
.signature-canvas-wrap > span { position: absolute; right: 9%; bottom: 28px; color: var(--muted-light); font-size: 9px; pointer-events: none; }
.signature-feedback { min-height: 20px; margin: 8px 2px 0; color: var(--danger); font-size: 12px; }
.signature-dialog-actions { display: grid; grid-template-columns: auto auto 1fr auto auto; gap: 9px; align-items: center; }
.signature-dialog-actions button { min-height: 46px; }

.doctor-signature.has-drawn-signature { min-width: 210px; padding-top: 0; border-top: 0; }
.doctor-signature-canvas { width: 180px; height: 52px; margin: 0 auto 2px; display: block; border-bottom: 1px solid #718590; }

@media (max-width: 1000px) {
  .pad-builder-grid { grid-template-columns: 1fr; }
  .pad-builder-controls { position: static; }
  .pad-builder-stage { max-width: 760px; width: 100%; margin-inline: auto; }
  .pad-builder-controls { max-width: 760px; width: 100%; margin-inline: auto; }
  .pad-builder-sheet .pad-builder-header,
  .prescription-preview-sheet[data-template="clinic"] .pad-builder-header,
  .prescription-preview-sheet[data-template="compact"] .pad-builder-header { min-height: 0; align-items: stretch; flex-direction: column; }
  .pad-builder-sheet .pad-builder-doctor,
  .pad-builder-sheet .pad-builder-clinic,
  .prescription-preview-sheet[data-template="clinic"] .pad-builder-doctor,
  .prescription-preview-sheet[data-template="clinic"] .pad-builder-clinic,
  .prescription-preview-sheet[data-template="compact"] .pad-builder-clinic { width: 100%; max-width: 100%; }
  .pad-builder-sheet .pad-builder-clinic { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, .9fr); align-items: end; }
  .prescription-preview-sheet[data-template="clinic"] .pad-inline-field,
  .prescription-preview-sheet[data-template="compact"] .pad-builder-doctor .pad-inline-field { text-align: left; }
  .pad-builder-actions { position: sticky; z-index: 12; bottom: 0; margin: 0 -10px -10px; padding: 13px 10px calc(13px + env(safe-area-inset-bottom, 0px)); background: rgba(255, 255, 255, .96); box-shadow: 0 -10px 24px rgba(13, 36, 53, .08); backdrop-filter: blur(14px); }
}

@media (max-width: 680px) {
  .pad-builder-page { width: min(100% - 20px, 1240px); }
  .pad-builder-page .onboarding-heading { gap: 14px; }
  .pad-builder-sheet { min-height: 720px; border-radius: 12px; }
  .pad-builder-sheet .pad-builder-header,
  .prescription-preview-sheet[data-template="clinic"] .pad-builder-header,
  .prescription-preview-sheet[data-template="compact"] .pad-builder-header { min-height: 0; align-items: stretch; flex-direction: column; padding: 18px; }
  .pad-builder-sheet .pad-builder-doctor,
  .pad-builder-sheet .pad-builder-clinic,
  .prescription-preview-sheet[data-template="compact"] .pad-builder-clinic { width: 100%; max-width: 100%; text-align: left; }
  .pad-builder-sheet .pad-builder-clinic { grid-template-columns: 1fr; }
  .prescription-preview-sheet[data-template="clinic"] .pad-inline-field,
  .prescription-preview-sheet[data-template="compact"] .pad-builder-doctor .pad-inline-field { text-align: left; }
  .pad-inline-pair { grid-template-columns: 1fr; }
  .pad-builder-writing { grid-template-rows: 85px minmax(190px, 1fr) 70px; padding-inline: 20px; }
  .pad-builder-footer { align-items: stretch; flex-direction: column-reverse; padding: 14px 18px; }
  .signature-preview-button { width: 100%; }
  .signature-dialog { width: calc(100% - 12px); max-height: calc(100dvh - 12px); padding: 16px; }
  .signature-canvas-wrap { height: min(300px, 42dvh); }
  .signature-dialog-actions { grid-template-columns: 1fr 1fr; }
  .signature-dialog-actions > span { display: none; }
  .signature-dialog-actions button:nth-last-child(-n + 2) { grid-row: 2; }
}

/* Pad setup customization and final preview --------------------------- */
.pad-builder-statusbar {
  position: sticky;
  z-index: 25;
  top: calc(76px + env(safe-area-inset-top, 0px));
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 11px 9px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 9px 26px rgba(13, 36, 53, .09);
  backdrop-filter: blur(16px);
}
.pad-builder-status-summary { min-width: 0; display: flex; align-items: center; gap: 0; overflow-x: auto; scrollbar-width: none; }
.pad-builder-status-summary::-webkit-scrollbar { display: none; }
.pad-builder-status-summary > span { min-width: 98px; display: grid; gap: 2px; padding: 2px 16px; border-left: 1px solid var(--line); }
.pad-builder-status-summary > span:first-child { padding-left: 0; border-left: 0; }
.pad-builder-status-summary small { color: var(--muted); font-size: 9px; font-weight: 720; letter-spacing: .055em; text-transform: uppercase; }
.pad-builder-status-summary strong { overflow: hidden; color: var(--ink-deep); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.pad-builder-status-actions { flex: 0 0 auto; display: flex; gap: 8px; }
.pad-builder-status-actions > * { min-height: 42px; }
.pad-preview-feedback { min-height: 0; margin: -7px 4px 0; color: var(--danger); font-size: 12px; font-weight: 680; }
.pad-preview-feedback:empty { display: none; }

.pad-controls-mobile-heading, .pad-customization-dock { display: none; }
.pad-controls-backdrop { display: none; }
.pad-signature-panel { display: grid; gap: 10px; }
.pad-signature-panel > .secondary-button { width: 100%; }

.pad-preview-dialog {
  width: min(1040px, calc(100% - 28px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  background: #f0f4f6;
  box-shadow: 0 24px 80px rgba(13, 36, 53, .34);
}
.pad-preview-dialog::backdrop { background: rgba(13, 36, 53, .58); backdrop-filter: blur(3px); }
.pad-preview-dialog-heading {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: white;
}
.pad-preview-dialog-heading h2 { margin: 3px 0 4px; color: var(--ink-deep); font-size: 22px; letter-spacing: -.025em; }
.pad-preview-dialog-heading p:last-child { margin: 0; color: var(--muted); font-size: 11px; }
.pad-preview-dialog-heading > div:last-child { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.pad-final-preview-viewport { height: calc(100dvh - 190px); min-height: 420px; padding: 24px; overflow: auto; overscroll-behavior: contain; }
.pad-final-sheet { width: min(794px, 100%); min-height: 1123px; display: flex; flex-direction: column; margin: 0 auto; }
.pad-final-sheet .pad-final-writing-space { flex: 1 1 auto; height: auto; min-height: 690px; }
.pad-final-sheet .print-patient-bar { grid-template-columns: 1.4fr 1fr .7fr; }
.pad-final-sheet .print-patient-bar span:last-child { grid-column: auto; }
.pad-final-sheet.guides-hidden .paper-guide { display: none; }
.pad-final-preview-viewport.is-actual-size .pad-final-sheet { width: 794px; max-width: none; }
.pad-preview-dialog-actions {
  min-height: 80px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: white;
}
.pad-preview-dialog-actions > span { color: var(--muted); font-size: 11px; line-height: 1.45; }
.pad-preview-dialog-actions button, .pad-preview-dialog-actions input { min-height: 48px; }

@media (max-width: 1000px) {
  .pad-builder-page { padding-bottom: calc(98px + env(safe-area-inset-bottom, 0px)); }
  .pad-builder-statusbar { top: calc(68px + env(safe-area-inset-top, 0px)); }
  .pad-builder-status-summary > span { min-width: 90px; padding-inline: 12px; }
  .pad-builder-status-summary > span:nth-last-child(-n + 2) { display: none; }

  .pad-builder-sheet .pad-builder-header,
  .prescription-preview-sheet[data-template="clinic"] .pad-builder-header,
  .prescription-preview-sheet[data-template="compact"] .pad-builder-header {
    min-height: 0;
    display: grid;
    align-items: start;
    gap: 18px;
  }
  .pad-builder-sheet[data-template="classic"] .pad-builder-header { grid-template-columns: minmax(0, 1.15fr) minmax(250px, .85fr); }
  .pad-builder-sheet[data-template="clinic"] .pad-builder-header { grid-template-columns: 1fr; }
  .pad-builder-sheet[data-template="compact"] .pad-builder-header { grid-template-columns: minmax(250px, .9fr) minmax(0, 1.1fr); }
  .pad-builder-sheet .pad-builder-header > .pad-builder-doctor,
  .pad-builder-sheet .pad-builder-header > .pad-builder-clinic { width: 100%; max-width: 100%; display: grid; }
  .pad-builder-sheet .pad-builder-clinic { grid-template-columns: 1fr; }
  .pad-builder-sheet[data-template="classic"] .pad-builder-clinic { text-align: right; }
  .pad-builder-sheet[data-template="classic"] .pad-builder-clinic .pad-inline-field { text-align: right; }
  .pad-builder-sheet[data-template="clinic"] .pad-builder-header > * { width: min(620px, 100%); margin-inline: auto; }
  .pad-builder-sheet[data-template="clinic"] .pad-inline-field { text-align: center; }
  .pad-builder-sheet[data-template="compact"] .pad-builder-doctor .pad-inline-field { text-align: right; }

  .pad-builder-controls {
    position: fixed;
    z-index: 90;
    top: auto;
    bottom: 0;
    left: 50%;
    width: min(700px, calc(100% - 16px));
    max-width: none;
    max-height: min(72dvh, 650px);
    margin: 0;
    padding: 0 20px calc(20px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
    visibility: hidden;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -18px 54px rgba(13, 36, 53, .24);
    transform: translate(-50%, 105%);
    transition: transform var(--duration-ui) var(--ease-drawer), visibility 0s linear var(--duration-ui);
  }
  .pad-builder-controls.is-open { visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
  .pad-controls-mobile-heading {
    position: sticky;
    z-index: 2;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 -20px 18px;
    padding: 15px 20px 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .97);
    backdrop-filter: blur(14px);
  }
  .pad-controls-mobile-heading h2 { margin-top: 2px; }
  .pad-controls-intro, .pad-builder-actions { display: none; }
  .pad-builder-controls .pad-control-panel { display: none; }
  .pad-builder-controls[data-active-panel="layout"] [data-control-panel="layout"],
  .pad-builder-controls[data-active-panel="colour"] [data-control-panel="colour"],
  .pad-builder-controls[data-active-panel="guides"] [data-control-panel="guides"],
  .pad-builder-controls[data-active-panel="signature"] [data-control-panel="signature"] { display: grid; }
  .pad-builder-controls fieldset + fieldset { padding-top: 0; border-top: 0; }
  .pad-controls-backdrop { position: fixed; z-index: 80; inset: 0; display: block; width: 100%; border: 0; background: rgba(13, 36, 53, .46); }
  .pad-controls-backdrop[hidden] { display: none; }
  body.pad-controls-open { overflow: hidden; }

  .pad-customization-dock {
    position: fixed;
    z-index: 60;
    right: 8px;
    bottom: 0;
    left: 8px;
    min-height: 72px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 7px 7px calc(7px + env(safe-area-inset-bottom, 0px));
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 -10px 30px rgba(13, 36, 53, .13);
    backdrop-filter: blur(16px);
  }
  .pad-customization-dock button {
    min-width: 0;
    min-height: 54px;
    display: grid;
    place-content: center;
    gap: 3px;
    padding: 5px 7px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink-deep);
    cursor: pointer;
    text-align: center;
  }
  .pad-customization-dock button + button { border-left: 1px solid var(--line); border-radius: 0; }
  .pad-customization-dock small { color: var(--muted); font-size: 9px; font-weight: 700; }
  .pad-customization-dock strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
  .pad-customization-dock .dock-preview-action { border-left: 0; border-radius: 10px; background: var(--blue); color: white; }
  .pad-customization-dock .dock-preview-action small { color: rgba(255, 255, 255, .78); }
}

@media (max-width: 680px) {
  .pad-builder-statusbar { top: calc(60px + env(safe-area-inset-top, 0px)); padding-left: 11px; }
  .pad-builder-status-summary > span { min-width: 82px; padding-inline: 10px; }
  .pad-builder-status-actions .pad-customize-button { display: none; }
  .pad-builder-status-actions .primary-button { min-height: 44px; padding-inline: 12px; font-size: 12px; }

  .pad-builder-sheet[data-template="classic"] .pad-builder-header,
  .pad-builder-sheet[data-template="clinic"] .pad-builder-header,
  .pad-builder-sheet[data-template="compact"] .pad-builder-header { grid-template-columns: 1fr; }
  .pad-builder-sheet[data-template="classic"] .pad-builder-clinic,
  .pad-builder-sheet[data-template="classic"] .pad-builder-clinic .pad-inline-field,
  .pad-builder-sheet[data-template="clinic"] .pad-inline-field,
  .pad-builder-sheet[data-template="compact"] .pad-builder-doctor .pad-inline-field { text-align: left; }

  .pad-customization-dock { right: 4px; left: 4px; }
  .pad-customization-dock button { padding-inline: 3px; }
  .pad-customization-dock strong { font-size: 10px; }
  .pad-preview-dialog { width: calc(100% - 8px); max-height: calc(100dvh - 8px); border-radius: 15px; }
  .pad-preview-dialog-heading { align-items: flex-start; padding: 13px 14px; }
  .pad-preview-dialog-heading p:last-child { display: none; }
  .pad-preview-dialog-heading h2 { font-size: 18px; }
  .pad-preview-dialog-heading .pad-preview-zoom { min-height: 44px; padding-inline: 10px; font-size: 11px; }
  .pad-final-preview-viewport { height: calc(100dvh - 196px); padding: 12px; }
  .pad-final-sheet { min-height: 1123px; }
  .pad-preview-dialog-actions { grid-template-columns: 1fr 1fr; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .pad-preview-dialog-actions > span { display: none; }
}

@media (pointer: coarse) {
  .pad-inline-field input, .pad-inline-field textarea { min-height: 48px; font-size: 16px; }
  .pad-doctor-name input { font-size: 20px; }
  .pad-customization-dock button, .pad-customize-button, .pad-preview-zoom { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
}

@media (prefers-reduced-motion: reduce) {
  :is(.primary-button, .secondary-button, .write-button, .search-button, .landing-button,
      .icon-button, .patient-context-button, .hero-play, .setup-progress button,
      .template-option, .accent-options label, .guide-toggle,
      .mobile-save-action, .clear-search, .password-toggle):active:not(:disabled),
  .patient-identity:active .avatar,
  .landing-video-link:active > span,
  .template-option > input:checked + .template-option-card,
  .accent-options input:checked + span { transform: none; }
  .pad-builder-controls { transition: none; }
}
