:root {
  --navy: #10213f;
  --navy-deep: #071832;
  --blue: #0b63ce;
  --blue-dark: #084f9f;
  --teal: #008c8c;
  --green: #14764c;
  --amber: #a56500;
  --red: #a83228;
  --muted: #5d6b82;
  --line: #d8e3f0;
  --line-strong: #b8cae0;
  --surface: #ffffff;
  --soft: #f6f9fd;
  --blue-soft: #edf6ff;
  --warm: #fff9ec;
  --shadow: 0 18px 44px rgba(16, 33, 63, .1);
  --shadow-soft: 0 8px 22px rgba(16, 33, 63, .07);
  --radius: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: #edf3f9; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; color: var(--navy); background: linear-gradient(180deg, #fbfdff 0, #f3f8fd 42%, #edf3f9 100%); font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif; -webkit-font-smoothing: antialiased; overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); }
h1, h2, h3, p { margin-top: 0; }
h1 { color: var(--navy-deep); font-size: clamp(1.9rem, 3vw, 2.65rem); line-height: 1.08; margin-bottom: .65rem; }
h2 { color: #123477; font-size: 1.28rem; margin-bottom: .5rem; }
h3 { color: var(--navy); }
p { color: var(--muted); line-height: 1.6; }
[hidden] { display: none !important; }

.skip-link { position: fixed; z-index: 50; top: .75rem; left: .75rem; transform: translateY(-180%); background: var(--navy-deep); color: white; padding: .7rem 1rem; border-radius: 8px; }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.portal-header { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: env(safe-area-inset-top, 0) max(clamp(1rem, 4vw, 3.5rem), env(safe-area-inset-right, 0)) 0 max(clamp(1rem, 4vw, 3.5rem), env(safe-area-inset-left, 0)); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); box-shadow: 0 1px 8px rgba(16,33,63,.04); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px); }
.brand { display: inline-flex; align-items: center; gap: .8rem; text-decoration: none; color: var(--navy); }
.brand img { width: 58px; height: 48px; object-fit: contain; border-radius: 8px; }
.brand span { display: grid; line-height: 1.05; }
.brand strong { font-size: 1rem; }
.brand small { margin-top: .3rem; color: var(--muted); font-size: .76rem; letter-spacing: .05em; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; gap: 1rem; }
.quiet-link, .text-button, .back-button { min-height: 44px; border: 0; background: transparent; color: var(--blue); font-weight: 700; text-decoration: none; cursor: pointer; padding: .55rem .35rem; display: inline-flex; align-items: center; justify-content: center; }
.quiet-link:hover, .text-button:hover, .back-button:hover { color: var(--blue-dark); text-decoration: underline; }

main { min-height: calc(100vh - 150px); }
.auth-shell { width: min(1100px, calc(100% - 2rem)); min-height: calc(100vh - 170px); margin: 0 auto; padding: clamp(2.5rem, 8vh, 6rem) 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 440px); gap: clamp(2rem, 7vw, 6rem); align-items: center; }
.auth-shell.compact { grid-template-columns: minmax(320px, 500px); justify-content: center; }
.auth-intro { max-width: 570px; }
.auth-intro h1 { max-width: 540px; }
.auth-intro > p { font-size: 1.08rem; max-width: 530px; }
.eyebrow { color: var(--teal); font-size: .76rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; margin-bottom: .55rem; }
.trust-list { list-style: none; margin: 1.7rem 0 0; padding: 0; display: grid; gap: .8rem; color: #354967; }
.trust-list li { position: relative; padding-left: 1.65rem; }
.trust-list li::before { content: "✓"; position: absolute; left: 0; top: -.1rem; color: var(--teal); font-weight: 900; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--blue); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(1.4rem, 4vw, 2.25rem); }
.auth-card h1, .auth-card h2 { margin-bottom: .45rem; }
.form-lead { margin-bottom: 1.35rem; }
label { display: grid; gap: .38rem; color: #263b5e; font-size: .9rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 46px; padding: .72rem .8rem; color: var(--navy); background: #fbfdff; border: 1px solid var(--line-strong); border-radius: 8px; outline: none; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11,99,206,.14); }
input[readonly] { background: #eef3f8; color: #42536c; cursor: not-allowed; }
.auth-card > label:not(.check-row), .auth-card form > label:not(.check-row) { margin-top: 1rem; }
.check-row { grid-template-columns: 20px minmax(0, 1fr); align-items: start; gap: .7rem; margin-top: 1.25rem; font-weight: 500; line-height: 1.45; }
.check-row input { width: 18px; min-height: 18px; height: 18px; margin: .15rem 0 0; }
.primary-button, .secondary-button, .button-link { min-height: 46px; border-radius: 8px; padding: .72rem 1rem; border: 1px solid transparent; font-weight: 800; cursor: pointer; transition: .15s ease; }
.primary-button { background: var(--blue); color: white; }
.primary-button:hover { background: var(--blue-dark); }
.primary-button.small { min-height: 40px; padding: .55rem .85rem; white-space: nowrap; }
.button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.secondary-button { background: white; color: var(--blue-dark); border-color: var(--line-strong); }
.secondary-button:hover { border-color: var(--blue); background: var(--blue-soft); }
button:disabled { opacity: .58; cursor: not-allowed; }
.auth-card .primary-button { width: 100%; margin-top: 1.35rem; }
.privacy-note { font-size: .78rem; margin: 1.1rem 0 0; text-align: center; }
.field-help { display: block; margin-top: .35rem; color: var(--muted); font-size: .76rem; font-weight: 500; line-height: 1.4; }
.back-button { margin: -.5rem 0 1rem; }
.otp-input { height: 64px; text-align: center; font-size: 2rem; letter-spacing: .45em; padding-left: .45em; font-variant-numeric: tabular-nums; }
.resend-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .86rem; margin-top: 1.2rem; }
.alert { border: 1px solid #efb5b0; border-left: 4px solid var(--red); background: #fff5f4; color: #792820; border-radius: 8px; padding: .8rem 1rem; margin-bottom: 1rem; line-height: 1.45; }
.alert.success { border-color: #a8d5bd; border-left-color: var(--green); background: #f1fbf5; color: #175b3d; }
.alert.info { border-color: #a9caed; border-left-color: var(--blue); background: #f1f7ff; color: #174d87; }

.portal-layout { width: min(1440px, 100%); margin: 0 auto; display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 78px); }
.side-nav { border-right: 1px solid var(--line); background: rgba(248,251,255,.9); padding: 2rem 1.25rem; position: sticky; top: 78px; height: calc(100vh - 78px); display: flex; flex-direction: column; }
.patient-chip { display: flex; align-items: center; gap: .75rem; padding: .75rem; border: 1px solid var(--line); border-radius: 10px; background: white; }
.patient-chip > span { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue-dark); font-weight: 900; }
.patient-chip div { display: grid; min-width: 0; }
.patient-chip small { color: var(--muted); font-size: .7rem; }
.patient-chip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.side-nav nav { display: grid; gap: .35rem; margin-top: 1.5rem; }
.side-nav nav a { color: #3b4f6d; text-decoration: none; font-weight: 700; font-size: .9rem; padding: .75rem .85rem; border-left: 3px solid transparent; border-radius: 6px; }
.side-nav nav a:hover, .side-nav nav a.active { color: var(--blue-dark); background: white; border-left-color: var(--blue); }
.session-note { margin-top: auto; display: grid; gap: .25rem; padding: 1rem .8rem; border-top: 1px solid var(--line); font-size: .74rem; }
.session-note span { color: var(--muted); }
.portal-content { min-width: 0; padding: clamp(1.5rem, 4vw, 3rem); max-width: 1160px; width: 100%; }
.admin-mode-notice { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding: .9rem 1rem; border: 1px solid #e5c58a; border-left: 4px solid var(--amber); border-radius: 9px; background: var(--warm); color: #704b13; }
.admin-mode-notice > div { display: grid; gap: .2rem; }
.admin-mode-notice span { line-height: 1.4; }
.admin-mode-notice a { flex: 0 0 auto; color: #704b13; font-weight: 800; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.3rem; }
.page-heading p:last-child { margin-bottom: 0; }
.edit-notice { border: 1px solid #e5c58a; border-left: 4px solid var(--amber); border-radius: 10px; background: var(--warm); padding: 1rem 1.15rem; display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; margin-bottom: 1rem; }
.edit-notice p { margin: .2rem 0 0; color: #785422; }
.edit-status-notice { border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 10px; background: var(--soft); padding: .9rem 1.15rem; margin-bottom: 1rem; }
.edit-status-notice p { margin: .2rem 0 0; }
.content-card { scroll-margin-top: 96px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow-soft); padding: clamp(1.1rem, 2vw, 1.55rem); margin-bottom: 1rem; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); margin-bottom: .7rem; }
.section-heading h2, .section-heading p { margin-bottom: 0; }
.section-heading > div { min-width: 0; }
.count-pill { border-radius: 999px; padding: .38rem .72rem; background: var(--blue-soft); color: var(--blue-dark); font-size: .76rem; font-weight: 800; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th, td { padding: .9rem .75rem; text-align: left; border-bottom: 1px solid #e6edf5; }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
td { font-size: .9rem; }
td:first-child { color: var(--navy-deep); font-weight: 750; }
.status-pill { display: inline-flex; padding: .32rem .6rem; border-radius: 999px; background: #ecf8f1; color: var(--green); font-size: .74rem; font-weight: 800; }
.billing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; }
.metric { border: 1px solid var(--line); background: var(--soft); border-radius: 9px; padding: 1rem; display: grid; gap: .35rem; }
.metric small { color: var(--muted); font-weight: 700; }
.metric strong { color: var(--navy-deep); font-size: 1.05rem; }
.subheading { font-size: .95rem; margin: 1.4rem 0 .5rem; }
.receipt-list { display: grid; }
.receipt-row, .document-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem; padding: .85rem .2rem; border-bottom: 1px solid #e6edf5; }
.receipt-row:last-child { border-bottom: 0; }
.receipt-row div, .document-row div { display: grid; gap: .2rem; }
.receipt-row small, .document-row small { color: var(--muted); }
.receipt-row a, .document-row a { font-weight: 800; text-decoration: none; }
.receipt-row a:hover, .document-row a:hover { text-decoration: underline; }
.empty-state { color: var(--muted); background: var(--soft); border: 1px dashed var(--line-strong); border-radius: 8px; padding: 1rem; margin-top: .7rem; }
.pending-sync-notice { display: grid; gap: .2rem; margin: .1rem 0 .9rem; padding: .8rem .9rem; border: 1px solid #e5c58a; border-left: 4px solid var(--amber); border-radius: 9px; background: var(--warm); color: #704b13; }
.pending-sync-notice span { line-height: 1.45; }
.status-pill.pending { background: #fff2d7; color: #7a4c00; }

.edit-shell { width: min(1080px, calc(100% - 2rem)); margin: 0 auto; padding: 2rem 0 4rem; }
.edit-header { max-width: 720px; margin-bottom: 1.25rem; }
.edit-form { display: grid; gap: 1rem; }
.form-section { border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow-soft); padding: clamp(1rem, 3vw, 1.5rem); }
.form-section h2 { border-bottom: 1px solid var(--line); padding-bottom: .7rem; margin-bottom: 1rem; }
.section-help { margin: -.35rem 0 1rem; font-size: .9rem; }
.field-note { margin: -.15rem 0 0; padding: .75rem .85rem; border-left: 3px solid var(--amber); border-radius: 6px; background: var(--warm); color: #704b13; font-size: .86rem; }
.form-grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.form-grid:last-child { margin-bottom: 0; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.disposition-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .8rem; margin-bottom: 1rem; }
.disposition-item { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: .85rem; }
.disposition-item label { gap: .55rem; }
.signature-wrap { width: 100%; height: clamp(160px, 24vw, 190px); min-width: 0; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; background: linear-gradient(180deg, #fff, #fafcff); touch-action: none; }
.signature-wrap canvas { display: block; width: 100%; height: 100%; max-width: 100%; cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none; }
.signature-wrap:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11,99,206,.14); }
.signature-wrap canvas:focus { outline: none; }
.signature-alternative { max-width: 560px; margin-top: .65rem; }
.signature-alternative small { color: var(--muted); font-size: .76rem; font-weight: 500; line-height: 1.4; }
.signature-section > .text-button { margin-top: .45rem; }
.additional-signature { margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.additional-signature h3 { margin-bottom: .35rem; font-size: 1rem; }
.additional-signature .text-button { margin-top: .45rem; }
.confirm-row { max-width: 760px; padding: .9rem; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; }
.form-actions button { min-width: 170px; }
footer { min-height: 72px; border-top: 1px solid var(--line); background: white; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem max(clamp(1rem,4vw,3.5rem), env(safe-area-inset-right, 0)) max(1rem, env(safe-area-inset-bottom, 0)) max(clamp(1rem,4vw,3.5rem), env(safe-area-inset-left, 0)); color: var(--muted); font-size: .78rem; }

@media (max-width: 820px) {
  .auth-shell { grid-template-columns: 1fr; padding: 2rem 0 3rem; gap: 1.5rem; }
  .auth-intro { text-align: center; margin: 0 auto; }
  .trust-list { width: fit-content; margin: 1.4rem auto 0; text-align: left; }
  .portal-layout { grid-template-columns: minmax(0, 1fr); min-width: 0; }
  .side-nav { position: static; width: 100%; min-width: 0; max-width: 100vw; height: auto; overflow: hidden; border-right: 0; border-bottom: 1px solid var(--line); padding: 1rem; }
  .side-nav nav { display: flex; width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; margin-top: .8rem; scrollbar-width: none; }
  .side-nav nav::-webkit-scrollbar { display: none; }
  .side-nav nav a { flex: 0 0 auto; text-align: center; border-left: 0; border-bottom: 3px solid transparent; }
  .side-nav nav a.active { border-left-color: transparent; border-bottom-color: var(--blue); }
  .session-note { display: none; }
  .portal-content, .table-wrap { min-width: 0; max-width: 100%; }
  .form-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .portal-header { min-height: 68px; gap: .4rem; padding: env(safe-area-inset-top, 0) max(.65rem, env(safe-area-inset-right, 0)) 0 max(.65rem, env(safe-area-inset-left, 0)); }
  .brand img { width: 46px; height: 40px; }
  .brand strong { font-size: .88rem; }
  .brand small { display: none; }
  .header-actions { gap: .15rem; }
  .quiet-link, .header-actions .text-button { padding-inline: .3rem; font-size: .75rem; white-space: nowrap; }
  .portal-layout { min-height: calc(100vh - 68px); }
  .portal-content { padding: 1rem max(1rem, env(safe-area-inset-right, 0)) 1rem max(1rem, env(safe-area-inset-left, 0)); }
  .edit-shell { width: 100%; padding: 1.25rem max(1rem, env(safe-area-inset-right, 0)) 3rem max(1rem, env(safe-area-inset-left, 0)); }
  .page-heading { align-items: flex-start; }
  .page-heading .secondary-button { min-width: auto; }
  .edit-notice { align-items: stretch; flex-direction: column; }
  .admin-mode-notice { align-items: flex-start; flex-direction: column; }
  .receipt-row, .document-row { grid-template-columns: 1fr; }
  .form-grid.two, .form-grid.three, .disposition-grid { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions button { width: 100%; }
  .resend-row, footer { align-items: flex-start; flex-direction: column; }
  .otp-input { font-size: 1.6rem; }
}

@media (max-width: 360px) {
  .brand { gap: .35rem; }
  .brand img { width: 38px; }
  .brand strong { font-size: .8rem; }
  .quiet-link, .header-actions .text-button { font-size: .7rem; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }

/* ================================================================
   Unified patient portal experience
   Mirrors the registration and admin application design language.
   ================================================================ */

:root {
  --navy: #14263f;
  --navy-deep: #0b1d36;
  --blue: #075ec9;
  --blue-dark: #064b9e;
  --teal: #087e80;
  --green: #16734a;
  --amber: #a56200;
  --red: #b53228;
  --muted: #5b6b80;
  --line: #dce5ef;
  --line-strong: #b9c9dc;
  --surface: #ffffff;
  --soft: #f8fafc;
  --blue-soft: #edf5ff;
  --warm: #fffaf0;
  --shadow: 0 14px 36px rgba(20, 38, 63, .09);
  --shadow-soft: 0 5px 18px rgba(20, 38, 63, .065);
  --radius: 14px;
}

body {
  background: #f3f6fa;
  line-height: 1.5;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

.portal-header {
  min-height: 72px;
  border-bottom-color: var(--line);
  background: rgba(255,255,255,.98);
  box-shadow: 0 2px 12px rgba(20,38,63,.055);
}

.brand img {
  width: 50px;
  height: 44px;
  border: 1px solid #e1e8f0;
  background: white;
  padding: .18rem;
}

.brand strong {
  color: var(--navy-deep);
}

.brand small {
  letter-spacing: .075em;
}

.quiet-link,
.text-button,
.back-button {
  border-radius: 8px;
}

.quiet-link:focus-visible,
.text-button:focus-visible,
.back-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.button-link:focus-visible,
.side-nav nav a:focus-visible,
.receipt-row a:focus-visible,
.document-row a:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(7,94,201,.18);
}

.auth-shell {
  min-height: calc(100vh - 144px);
  min-height: calc(100dvh - 144px);
}

.auth-intro > p {
  color: #4d6078;
}

.eyebrow {
  color: var(--blue);
  letter-spacing: .075em;
}

.trust-list {
  padding: 1.05rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.72);
}

.trust-list li::before {
  content: "\2713";
}

.auth-card {
  border-radius: 16px;
  border-top-width: 3px;
}

input,
select,
textarea {
  border-radius: 9px;
  background: white;
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
  border-color: #8fa9c6;
}

.primary-button,
.secondary-button,
.button-link {
  min-height: 46px;
  border-radius: 9px;
}

.primary-button {
  box-shadow: 0 7px 16px rgba(7,94,201,.17);
}

.alert {
  border-radius: 10px;
}

.portal-layout {
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

.side-nav {
  top: 72px;
  height: calc(100vh - 72px);
  border-right: 0;
  background: #0c2f59;
  padding: 1.35rem 1rem;
}

.patient-chip {
  border-color: rgba(255,255,255,.16);
  background: rgba(255,255,255,.08);
}

.patient-chip > span {
  background: #dcecff;
  color: #064b9e;
}

.patient-chip small {
  color: #b9cce1;
}

.patient-chip strong {
  color: white;
}

.side-nav nav {
  gap: .25rem;
}

.side-nav nav a {
  min-height: 44px;
  display: flex;
  align-items: center;
  border-left: 0;
  border-radius: 8px;
  color: #d9e5f3;
  padding: .72rem .85rem;
}

.side-nav nav a:hover,
.side-nav nav a.active {
  border-left-color: transparent;
  background: #075ec9;
  color: white;
}

.session-note {
  border-top-color: rgba(255,255,255,.14);
  color: white;
}

.session-note span {
  color: #b9cce1;
}

.portal-content {
  max-width: 1240px;
  padding: clamp(1.35rem, 3vw, 2.5rem);
}

.page-heading {
  padding: .35rem 0 .25rem;
}

.page-heading h1 {
  font-size: clamp(1.75rem, 3vw, 2.35rem);
}

.content-card,
.form-section {
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.content-card {
  margin-bottom: 1.15rem;
}

.section-heading {
  margin-bottom: .85rem;
}

.count-pill,
.status-pill {
  border-radius: 999px;
}

th {
  color: #607189;
  background: #f7f9fc;
  font-size: .7rem;
}

th:first-child {
  border-radius: 8px 0 0 8px;
}

th:last-child {
  border-radius: 0 8px 8px 0;
}

tbody tr:hover td {
  background: #f8fbff;
}

.billing-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  min-height: 96px;
  justify-content: center;
  border-radius: 11px;
  background: white;
}

.metric strong {
  font-size: 1.1rem;
}

.receipt-row,
.document-row {
  min-height: 62px;
  padding-inline: .55rem;
  border-radius: 8px;
}

.receipt-row:hover,
.document-row:hover {
  background: #f8fbff;
}

.edit-notice,
.edit-status-notice,
.admin-mode-notice {
  border-radius: 11px;
}

.edit-shell {
  padding-top: 1.5rem;
}

.edit-form {
  gap: 1.15rem;
}

.form-section h2 {
  color: var(--navy-deep);
}

.signature-wrap {
  background: #fff;
}

.form-actions {
  position: sticky;
  bottom: max(.75rem, env(safe-area-inset-bottom));
  z-index: 12;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 10px 26px rgba(20,38,63,.11);
  backdrop-filter: blur(10px);
}

.empty-state {
  border-radius: 10px;
}

@media (max-width: 1020px) {
  .billing-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .portal-layout {
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
    min-height: calc(100vh - 72px);
  }

  .side-nav {
    position: sticky;
    top: 72px;
    z-index: 15;
    width: 100%;
    min-width: 0;
    max-width: 100vw;
    height: auto;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.98);
    padding: .65rem 1rem;
    backdrop-filter: blur(10px);
  }

  .patient-chip {
    display: none;
  }

  .side-nav nav {
    width: 100%;
    min-width: 0;
    margin-top: 0;
  }

  .side-nav nav a {
    min-height: 42px;
    color: #42536a;
  }

  .side-nav nav a:hover,
  .side-nav nav a.active {
    background: #edf5ff;
    color: var(--blue-dark);
    border-bottom-color: var(--blue);
  }
}

@media (max-width: 600px) {
  .portal-header {
    min-height: 64px;
  }

  .brand img {
    width: 42px;
    height: 38px;
  }

  .portal-layout {
    min-height: calc(100vh - 64px);
  }

  .side-nav {
    top: 64px;
    padding-inline: .7rem;
  }

  .side-nav nav a {
    padding-inline: .65rem;
    font-size: .82rem;
  }

  .page-heading h1 {
    font-size: 1.65rem;
  }

  .billing-grid {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 76px;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
  }

  tbody {
    display: grid;
    gap: .75rem;
  }

  tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem 1rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: white;
  }

  tbody td {
    display: grid;
    gap: .2rem;
    min-width: 0;
    padding: 0;
    border: 0;
    font-size: .88rem;
  }

  tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .68rem;
    font-weight: 760;
    letter-spacing: .045em;
    text-transform: uppercase;
  }

  tbody td:first-child {
    grid-column: 1 / -1;
    padding-bottom: .65rem;
    border-bottom: 1px solid var(--line);
    font-size: 1rem;
  }

  .content-card {
    padding: 1rem;
  }

  .form-actions {
    margin-inline: -.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
