:root {
  --ink: #183238;
  --muted: #61777b;
  --paper: #ffffff;
  --ground: #edf2ef;
  --line: #d8e2de;
  --teal: #176b66;
  --teal-dark: #0f504e;
  --teal-soft: #dcecea;
  --blue: #486f9b;
  --blue-soft: #e2eaf4;
  --green: #3f7a5c;
  --green-soft: #dfeee5;
  --amber: #a96c25;
  --amber-soft: #f4e8d4;
  --danger: #9d5045;
  --shadow: 0 18px 50px rgba(24, 50, 56, .09);
  color-scheme: light;
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--ground); }
body { margin: 0; color: var(--ink); background: var(--ground); font-size: 16px; line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
h1, h2, h3, p, dl, dd { margin-top: 0; }
h1 { margin-bottom: .25rem; font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.02; letter-spacing: -.045em; }
h2 { margin-bottom: .15rem; font-size: 1.2rem; line-height: 1.2; letter-spacing: -.02em; }
small { display: block; color: var(--muted); font-size: .82rem; }

.message-stack { position: fixed; z-index: 90; top: 18px; right: 18px; width: min(420px, calc(100vw - 36px)); }
.message { margin: 0 0 8px; padding: 13px 16px; border-left: 4px solid var(--teal); background: white; box-shadow: var(--shadow); }
.message-error { border-left-color: var(--danger); }

.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 14px; color: white; background: var(--ink); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid #f2b84b; outline-offset: 3px; }
.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; }
.demo-banner { min-height: 32px; display: grid; place-items: center; padding: 5px 16px; color: #f6fbfa; background: var(--ink); font-size: .8rem; font-weight: 650; text-align: center; letter-spacing: .01em; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 18px; border: 1px solid transparent; border-radius: 8px; font-weight: 700; text-decoration: none; }
.button-primary { color: white; background: var(--teal); }
.button-primary:hover { background: var(--teal-dark); }
.button-quiet { border-color: var(--line); background: var(--paper); }
.button-full { width: 100%; }
.positive { color: var(--green) !important; }

/* Accounts and access */
.auth-body { min-height: 100vh; background: linear-gradient(130deg, #e5eeea 0 55%, #d5e3de 55%); }
.auth-layout { min-height: 100vh; display: grid; place-items: center; padding: 48px 20px; }
.auth-card { width: min(100%, 560px); padding: clamp(28px, 5vw, 52px); border-top: 5px solid var(--teal); background: var(--paper); box-shadow: var(--shadow); }
.auth-brand { display: inline-block; margin-bottom: 42px; color: var(--ink); font-weight: 850; text-decoration: none; }
.eyebrow { margin-bottom: 10px; color: var(--teal); font-size: .76rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.auth-card h1 { margin-bottom: 18px; font-size: clamp(2rem, 6vw, 3rem); }
.auth-intro, .account-lead { color: var(--muted); }
.stack-form { display: grid; gap: 18px; margin: 28px 0 20px; }
.stack-form > div { display: grid; gap: 6px; }
.stack-form label { font-weight: 750; }
.stack-form input, .stack-form select { width: 100%; min-height: 46px; padding: 9px 11px; border: 1px solid #aebfba; border-radius: 4px; background: white; }
.stack-form input[type="checkbox"] { width: 22px; min-height: 22px; }
.stack-form ul { margin: 5px 0 0; padding-left: 20px; color: var(--muted); font-size: .82rem; }
.stack-form .errorlist, .form-alert { padding: 10px 12px; color: #7a3028; background: #f8e6e2; }
.auth-foot, .auth-links { padding-top: 18px; border-top: 1px solid var(--line); }
.auth-links { display: flex; justify-content: space-between; gap: 16px; }
.auth-card a, .back-link, .prototype-link { color: var(--teal-dark); }
.invitation-context { display: grid; gap: 3px; padding: 18px; border-left: 3px solid var(--teal); background: var(--teal-soft); }

.account-shell { min-height: 100vh; background: var(--ground); }
.account-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 clamp(20px, 5vw, 72px); color: white; background: var(--ink); }
.account-header .auth-brand { margin: 0; color: white; }
.account-header nav { display: flex; align-items: center; gap: 22px; }
.account-header nav a, .link-button { color: #d8e8e5; font: inherit; text-decoration: none; }
.link-button { padding: 0; border: 0; background: transparent; cursor: pointer; }
.account-main { width: min(1120px, calc(100% - 40px)); margin: auto; padding: 58px 0 80px; }
.account-main > h1 { max-width: 800px; }
.account-lead { max-width: 700px; margin: 14px 0 38px; font-size: 1.08rem; }
.secure-panel { margin-top: 32px; border-top: 4px solid var(--ink); background: white; box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 26px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; }
.panel-heading > span:not(.access-badge) { min-width: 32px; padding: 4px 9px; border-radius: 999px; color: white; background: var(--teal); text-align: center; font-weight: 800; }
.secure-list a { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 76px; padding: 14px 26px; border-bottom: 1px solid var(--line); text-decoration: none; }
.secure-list a:last-child { border-bottom: 0; }
.secure-list a:hover { background: var(--teal-soft); }
.secure-list strong, .secure-list small { display: block; }
.secure-list b { color: var(--teal); }
.empty-state, .access-summary, .scope-note { padding: 28px 26px; }
.prototype-link { display: inline-block; margin-top: 28px; font-weight: 750; }
.record-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-top: 32px; }
.record-heading h1 { margin-bottom: 8px; }
.record-heading p { color: var(--muted); }
.access-badge { display: inline-flex; padding: 6px 10px; border-radius: 999px; color: #315f47; background: var(--green-soft); font-size: .8rem; font-weight: 800; }
.invite-list article { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; align-items: center; gap: 22px; padding: 17px 26px; border-bottom: 1px solid var(--line); }
.invite-list article:last-child { border-bottom: 0; }
.danger-link { color: var(--danger); }
.scope-note { margin-top: 22px; border-left: 3px solid var(--amber); background: var(--amber-soft); }
.patient-search { display: grid; grid-template-columns: 90px minmax(260px, 520px) auto; align-items: center; gap: 14px; padding: 18px 26px; border-bottom: 1px solid var(--line); }
.patient-search label { font-weight: 800; }
.patient-search > div { display: flex; gap: 8px; }
.patient-search input { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid #aebfba; }
.wide-form-layout { align-items: start; }
.clinical-form-card { width: min(100%, 760px); }
.clinical-form-card .back-link, .auth-card .back-link { display: inline-block; margin-bottom: 32px; }
.patient-facts { display: grid; grid-template-columns: repeat(3, 1fr); margin: 32px 0 24px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.55); }
.patient-facts div { padding: 19px 22px; border-left: 1px solid var(--line); }
.patient-facts div:first-child { border-left: 0; }
.patient-facts strong { display: block; margin-top: 5px; overflow-wrap: anywhere; }
.open-note { margin: 0 0 24px; padding: 22px 26px; border-left: 4px solid var(--blue); background: var(--blue-soft); }
.open-note > span { color: #36577a; font-size: .77rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.open-note p { margin: 10px 0 4px; }
.clinical-section { margin-top: 24px; }
.examination-card { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 24px; padding: 26px; border-bottom: 1px solid var(--line); }
.examination-card:last-child { border-bottom: 0; }
.exam-date { text-align: center; }
.exam-date span { display: block; color: var(--teal); font-size: 2rem; font-weight: 850; line-height: 1; }
.examination-card h3 { margin: 0 0 5px; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
.examination-card p { margin: 0 0 20px; }
.examination-card p:last-child { margin-bottom: 0; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.panel-action { padding: 18px 26px; border-top: 1px solid var(--line); }
.permanent-link { display: grid; gap: 8px; margin-top: 24px; }
.permanent-link label { font-weight: 750; }
.permanent-link small, .access-state { color: var(--muted); }
.copy-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.copy-row input { width: 100%; min-width: 0; min-height: 46px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.68); }
.invite-actions { display: flex !important; flex-wrap: wrap; gap: 10px !important; }
.clinical-history { margin: 0; padding: 0 26px; list-style: none; }
.clinical-history li { display: grid; grid-template-columns: 110px 1fr; gap: 18px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.clinical-history li:last-child { border-bottom: 0; }
.clinical-history time { color: var(--muted); font-size: .8rem; }
.clinical-history p { margin: 5px 0; }
.clinical-history summary { margin-top: 8px; color: var(--teal-dark); cursor: pointer; }
.change-details { display: grid; gap: 6px; margin-top: 10px; }
.change-details div { padding: 9px; background: var(--ground); }
.change-details dt { color: var(--muted); font-size: .75rem; }
.change-details dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.archive-action { margin-top: 32px; text-align: right; }
.archive-action a { color: var(--danger); }
.technical-badge { padding: 7px 11px; border: 1px solid var(--amber); color: #764b1c; background: var(--amber-soft); font-size: .8rem; font-weight: 800; }
.orientation-note { display: flex; justify-content: space-between; gap: 24px; margin: 28px 0 18px; padding: 13px 18px; border-left: 4px solid var(--blue); background: var(--blue-soft); }
.orientation-note span { color: #36577a; }
.dental-editor { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .45fr); align-items: start; gap: 24px; }
.dental-map, .dental-controls { border-top: 4px solid var(--ink); background: white; box-shadow: var(--shadow); }
.dental-map .panel-heading > strong { color: var(--teal); }
.patient-sides { display: flex; justify-content: space-between; padding: 12px 22px 5px; color: var(--muted); font-size: .76rem; font-weight: 750; }
.arch-label { color: var(--muted); font-size: .76rem; font-weight: 750; text-align: center; text-transform: uppercase; letter-spacing: .08em; }
.tooth-selector-row { display: grid; grid-template-columns: repeat(16, minmax(42px, 1fr)); gap: 5px; min-width: 760px; padding: 12px 20px; }
.dental-map { overflow-x: auto; }
.tooth-select { min-height: 105px; display: grid; grid-template-rows: 54px auto auto; place-items: center; gap: 2px; padding: 7px 2px; border: 1px solid var(--line); background: #fbfcfb; cursor: pointer; }
.tooth-select:hover { border-color: var(--teal); }
.tooth-select .tooth-shape { width: 30px; height: 45px; border: 2px solid #9eb4ae; border-radius: 44% 44% 34% 34%; background: white; }
.lower-row .tooth-shape { transform: scaleX(var(--tooth-scale-x, 1)); }
.tooth-select strong { font-size: .83rem; }
.tooth-select small { font-size: .62rem; text-align: center; }
.tooth-checkbox:focus-visible + .tooth-select { outline: 3px solid #f2b84b; outline-offset: 2px; }
.tooth-checkbox:checked + .tooth-select, .tooth-select.is-selected { border-color: var(--blue); background: var(--blue-soft); }
.tooth-select.has-finding { border-color: var(--green); background: var(--green-soft); }
.tooth-select.is-missing { border-color: var(--danger); background: #f6e4e1; }
.tooth-select.is-missing .tooth-shape { position: relative; opacity: .45; }
.tooth-select.is-missing .tooth-shape::after { content: "×"; position: absolute; inset: -10px; display: grid; place-items: center; color: var(--danger); font-size: 2rem; font-weight: 800; }
.tooth-checkbox:checked + .tooth-select { box-shadow: inset 0 -4px 0 var(--blue); }
.midline { position: relative; height: 22px; margin: 0 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; }
.midline span { position: relative; top: -9px; padding: 0 8px; color: var(--muted); background: white; font-size: .65rem; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; min-width: 620px; padding: 17px 22px 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: .76rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 14px; height: 14px; border: 1px solid; }
.legend-recorded { border-color: var(--green) !important; background: var(--green-soft); }
.legend-missing { border-color: var(--danger) !important; background: #f6e4e1; }
.legend-selected { border-color: var(--blue) !important; background: var(--blue-soft); }
.dental-map.is-mouth-scope .tooth-selector-row { opacity: .38; pointer-events: none; }
.dental-controls { position: sticky; top: 16px; }
.control-section { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.control-section h2 { margin-bottom: 12px; font-size: .92rem; }
.control-section ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.control-section label { cursor: pointer; }
.toggle-line, .surface-options label { display: flex; align-items: center; gap: 9px; min-height: 34px; }
.missing-toggle { color: var(--danger); }
.surface-options { margin: 14px 0 0; padding: 12px 0 0; border: 0; border-top: 1px solid var(--line); }
.surface-options legend { padding: 0 8px 0 0; color: var(--muted); font-size: .78rem; }
.control-section textarea { width: 100%; padding: 9px; border: 1px solid #aebfba; resize: vertical; }
.dental-controls > .button { margin: 20px 22px 10px; width: calc(100% - 44px); }
.control-disclaimer { margin: 0; padding: 8px 22px 22px; color: var(--muted); font-size: .78rem; }
.chart-error { margin-top: 8px; padding: 9px; color: #7a3028; background: #f8e6e2; }
.chart-error ul { margin: 0; }
.saved-findings { margin-top: 24px; }
.saved-findings article { display: grid; grid-template-columns: 150px minmax(160px, .6fr) 1fr; gap: 18px; padding: 15px 24px; border-bottom: 1px solid var(--line); }
.saved-findings article:last-child { border-bottom: 0; }
.saved-findings article p { margin: 0; }
.exam-actions { display: grid; align-content: start; gap: 8px; min-width: 105px; }
.exam-findings { display: flex; flex-wrap: wrap; gap: 6px; }
.exam-findings span, .patient-finding-list strong { display: inline-flex; padding: 4px 8px; color: #315f47; background: var(--green-soft); font-size: .75rem; }
.patient-finding-list { display: grid; gap: 10px; }
.patient-finding-list > div { padding: 10px 12px; border-left: 3px solid var(--green); background: #f7faf8; }
.patient-finding-list p { margin: 6px 0 0; }

@media (max-width: 640px) {
  .auth-links, .record-heading { align-items: stretch; flex-direction: column; }
  .account-header { align-items: flex-start; padding-top: 18px; padding-bottom: 18px; }
  .account-header nav { align-items: flex-end; flex-direction: column; gap: 8px; }
  .account-main { width: min(100% - 28px, 1120px); padding-top: 38px; }
  .invite-list article { grid-template-columns: 1fr; gap: 8px; }
  .copy-row { grid-template-columns: 1fr; }
  .patient-search { grid-template-columns: 1fr; }
  .patient-search > div { align-items: stretch; flex-direction: column; }
  .patient-facts { grid-template-columns: 1fr; }
  .patient-facts div, .patient-facts div:first-child { border-left: 0; border-top: 1px solid var(--line); }
  .patient-facts div:first-child { border-top: 0; }
  .examination-card { grid-template-columns: 54px minmax(0, 1fr); gap: 14px; padding: 20px 16px; }
  .examination-card .exam-actions { grid-column: 2; }
  .detail-grid { grid-template-columns: 1fr; }
  .clinical-history li { grid-template-columns: 1fr; gap: 5px; }
  .orientation-note { flex-direction: column; gap: 4px; }
  .dental-editor { grid-template-columns: 1fr; }
  .dental-controls { position: static; }
  .saved-findings article { grid-template-columns: 1fr; gap: 5px; }
}

/* Landing */
.landing-body { min-height: 100vh; background: #e8efec; }
.landing { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(420px, .95fr); align-items: center; gap: 7vw; max-width: 1320px; margin: auto; padding: 8vw 6vw; }
.landing-copy { max-width: 700px; }
.stage-pill { display: inline-flex; margin-bottom: 28px; padding: 7px 11px; border: 1px solid #b8cbc5; border-radius: 999px; color: var(--teal-dark); font-size: .82rem; font-weight: 700; }
.landing h1 { max-width: 760px; font-size: clamp(3rem, 6vw, 5.7rem); }
.landing-copy > p { max-width: 620px; margin: 26px 0 32px; color: #4d666b; font-size: 1.2rem; }
.landing-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.landing-chart { position: relative; padding: 30px; border: 1px solid #cbd9d4; background: rgba(255,255,255,.7); box-shadow: var(--shadow); }
.landing-chart::before { content: ""; position: absolute; top: -12px; right: 24px; width: 72px; height: 24px; border: 1px solid #9db8af; background: #dce9e4; }
.landing-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.landing-chart-head small { margin-bottom: 3px; }
.landing-chart-head span { display: block; font-size: 1.2rem; font-weight: 750; }
.landing-chart-head strong { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .82rem; }
.landing-chart-head strong b { color: var(--ink); font-size: 1rem; }
.landing-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; padding-top: 20px; color: var(--muted); font-size: .72rem; }
.landing-legend span { display: inline-flex; align-items: center; gap: 6px; }
.landing-legend i { width: 9px; height: 9px; border: 1px solid #aac0bb; border-radius: 50%; background: white; }
.landing-legend i.planned { border-color: var(--amber); background: var(--amber-soft); }
.landing-legend i.progress { border-color: var(--blue); background: var(--blue-soft); }
.landing-legend i.done { border-color: var(--green); background: var(--green-soft); }
.landing-teeth { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; padding: 32px 0 28px; }
.landing-tooth { min-width: 0; text-align: center; }
.landing-teeth .landing-tooth > i { aspect-ratio: .72; display: block; border: 2px solid #aac0bb; border-radius: 45% 45% 38% 38%; background: white; }
.landing-tooth small { margin-top: 7px; font-size: .68rem; }
.landing-teeth i.planned { border-color: var(--amber); background: var(--amber-soft); }
.landing-teeth i.progress { border-color: var(--blue); background: var(--blue-soft); }
.landing-teeth i.done { border-color: var(--green); background: var(--green-soft); }
.landing-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; padding-top: 18px; border-top: 1px solid var(--line); }
.landing-totals div { min-width: 0; padding: 14px; border-radius: 12px; background: rgba(255,255,255,.52); }
.landing-totals dt { color: var(--muted); font-size: .8rem; }
.landing-totals dd { margin: 4px 0 0; font-weight: 800; }
.landing-totals small { margin-top: 5px; font-size: .68rem; line-height: 1.3; }

/* Doctor shell */
.doctor-shell { min-height: calc(100vh - 32px); display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.doctor-nav { position: sticky; top: 0; height: calc(100vh - 32px); display: flex; flex-direction: column; padding: 26px 18px 20px; color: #eff8f6; background: var(--ink); }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--teal); font-weight: 850; letter-spacing: -.08em; }
.brand strong, .brand small { display: block; }
.brand small { color: #aac2c3; }
.primary-nav { display: grid; gap: 4px; margin-top: 56px; }
.primary-nav a { padding: 11px 12px; border-left: 3px solid transparent; color: #c5d7d6; text-decoration: none; }
.primary-nav a:hover, .primary-nav a.is-current { border-left-color: #67b1a9; color: white; background: rgba(255,255,255,.07); }
.doctor-signature { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.14); }
.doctor-signature strong { display: block; font-size: .86rem; }
.doctor-signature small { color: #aac2c3; }
.workspace { width: 100%; max-width: 1360px; margin: 0 auto; padding: 48px clamp(28px, 5vw, 72px) 70px; }
.workspace-header, .patient-header, .plan-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 42px; }
.context-line { margin-bottom: 8px; color: var(--muted); }
.day-note { padding: 8px 12px; border-bottom: 2px solid var(--teal); font-weight: 750; }
.patient-register, .record-section, .odontogram, .selected-treatment { border-top: 4px solid var(--ink); background: var(--paper); box-shadow: var(--shadow); }
.register-tools, .section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 24px 28px; }
.register-tools p, .section-heading p { margin: 3px 0 0; color: var(--muted); font-size: .9rem; }
.search-field { text-align: right; }
.search-field input { width: 250px; padding: 9px 12px; border: 1px solid var(--line); background: #f8faf9; }
.search-field small { margin-top: 4px; }
.patient-list { border-top: 1px solid var(--line); }
.patient-row { min-height: 86px; display: grid; grid-template-columns: 46px minmax(210px, 1fr) 120px 140px 70px; align-items: center; gap: 18px; padding: 14px 28px; border-bottom: 1px solid var(--line); text-decoration: none; }
.patient-row:last-child { border-bottom: 0; }
.patient-row.is-priority { background: #f7fbfa; }
a.patient-row:hover { background: var(--teal-soft); }
.avatar { width: 42px; height: 42px; display: grid; place-items: center; flex: none; border-radius: 50%; color: var(--teal-dark); background: var(--teal-soft); font-size: .82rem; font-weight: 850; }
.avatar-blue { color: #36577a; background: var(--blue-soft); }
.avatar-sand { color: #81531f; background: var(--amber-soft); }
.avatar-small { width: 34px; height: 34px; font-size: .72rem; }
.avatar-large { width: 62px; height: 62px; font-size: 1rem; }
.patient-identity strong, .patient-identity small, .progress-copy strong, .progress-copy small, .money-copy strong, .money-copy small { display: block; }
.row-action { color: var(--teal); font-weight: 750; }
.row-action.muted { color: var(--muted); font-weight: 500; }
.dashboard-lower { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .5fr); gap: 24px; margin-top: 26px; }
.today-line { background: var(--paper); }
.appointment-list { margin: 0; padding: 0 28px 18px; list-style: none; }
.appointment-list li { display: grid; grid-template-columns: 70px 1fr; gap: 20px; padding: 15px 0; border-top: 1px solid var(--line); }
.appointment-list li.is-next time { color: var(--teal); font-weight: 850; }
.appointment-list strong, .appointment-list small { display: block; }
.practice-ledger { padding: 27px; color: white; background: var(--teal-dark); }
.practice-ledger h2 { font-weight: 500; }
.practice-ledger p { margin-bottom: 0; color: #c7dedb; }
.practice-ledger .ledger-number { margin: 22px 0 -5px; color: white; font-size: 4rem; font-weight: 800; line-height: 1; }
.ledger-rule { height: 1px; margin: 30px 0 20px; background: rgba(255,255,255,.25); }
.practice-ledger > strong { font-size: 1.35rem; }
.practice-ledger > small { margin-top: 5px; color: #c7dedb; }

/* Patient card */
.breadcrumbs { display: flex; gap: 9px; margin-bottom: 24px; color: var(--muted); font-size: .88rem; }
.breadcrumbs a { color: var(--teal); }
.patient-title { display: flex; align-items: center; gap: 18px; }
.patient-title h1 { font-size: clamp(2.1rem, 4vw, 3.3rem); }
.patient-title p { margin-bottom: 0; color: var(--muted); }
.header-actions { display: flex; gap: 9px; }
.clinical-summary { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(420px, 1.2fr); margin-bottom: 26px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.55); }
.progress-panel { display: flex; align-items: center; gap: 18px; padding: 24px 0; }
.progress-panel strong, .progress-panel small { display: block; }
.progress-ring { --progress: 42; width: 72px; height: 72px; display: grid; place-items: center; flex: none; border-radius: 50%; background: conic-gradient(var(--teal) calc(var(--progress) * 1%), #cfded9 0); }
.progress-ring::before { content: ""; grid-area: 1/1; width: 56px; height: 56px; border-radius: 50%; background: var(--ground); }
.progress-ring b { z-index: 1; grid-area: 1/1; font-size: .92rem; }
.money-strip { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; }
.money-strip div { padding: 24px; border-left: 1px solid var(--line); }
.money-strip dt { color: var(--muted); font-size: .82rem; }
.money-strip dd { margin: 8px 0 0; font-size: 1.25rem; font-weight: 800; }
.patient-columns { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 24px; }
.patient-main-column { display: grid; gap: 24px; }
.treatment-list { border-top: 1px solid var(--line); }
.treatment-item { display: grid; grid-template-columns: 84px 1fr auto; gap: 18px; align-items: center; min-height: 78px; padding: 14px 28px; border-bottom: 1px solid var(--line); }
.treatment-item:last-child { border-bottom: 0; }
.treatment-item .status-mark { color: var(--amber); font-size: .8rem; font-weight: 800; }
.treatment-item.is-done .status-mark { color: var(--green); }
.treatment-item.is-active .status-mark { color: var(--blue); }
.treatment-item strong, .treatment-item small { display: block; }
.status-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.status-progress { color: #375d83; background: var(--blue-soft); }
.status-needed { color: #84531c; background: var(--amber-soft); }
.status-done { color: #315f47; background: var(--green-soft); }
.status-none { color: var(--muted); background: #edf1ef; }
.history-list { margin: 0; padding: 0 28px 20px; list-style: none; }
.history-list li { display: grid; grid-template-columns: 110px 1fr; gap: 20px; padding: 14px 0; border-top: 1px solid var(--line); }
.history-list time { color: var(--muted); font-size: .82rem; }
.history-list p { margin: 0; }
.patient-side-column { display: grid; align-content: start; gap: 18px; }
.next-step { padding: 24px; color: white; background: var(--teal); }
.next-step > span, .next-step strong, .next-step small { display: block; }
.next-step > span { margin-bottom: 18px; color: #cbe2df; font-size: .8rem; }
.next-step strong { font-size: 1.3rem; }
.next-step p { margin: 8px 0 2px; }
.next-step small { color: #cbe2df; }
.file-preview { padding-bottom: 20px; background: var(--paper); }
.file-preview .section-heading { padding-bottom: 12px; }
.xray-placeholder { height: 150px; display: flex; align-items: center; justify-content: center; gap: 5px; margin: 0 20px; background: #25363c; overflow: hidden; }
.xray-placeholder i { width: 23px; height: 70px; border: 2px solid #a7bec1; border-radius: 50% 50% 40% 40%; opacity: .75; }
.file-preview > p { margin: 12px 20px 0; }
.file-preview strong, .file-preview small { display: block; }
.text-link { color: var(--teal); font-weight: 750; }

/* Odontogram and plan */
.plan-header { align-items: center; }
.plan-header p { margin: 0; color: var(--muted); }
.prototype-message { max-width: 310px; padding: 10px 14px; border-left: 3px solid var(--amber); background: var(--amber-soft); font-size: .86rem; }
.odontogram { margin-bottom: 24px; padding-bottom: 22px; overflow: hidden; }
.teeth-heading { align-items: center; }
.tooth-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .78rem; color: var(--muted); }
.tooth-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.legend-dot.planned { background: var(--amber); }
.legend-dot.progress { background: var(--blue); }
.legend-dot.done { background: var(--green); }
.patient-sides { display: flex; justify-content: space-between; padding: 0 30px 8px; color: var(--muted); font-size: .72rem; }
.odontogram-scroll { margin: 0 24px; padding: 18px 12px; overflow-x: auto; border: 1px solid var(--line); background: #f7faf8; }
.tooth-row { min-width: 880px; display: grid; grid-template-columns: repeat(16, 1fr); gap: 7px; }
.tooth { min-width: 48px; padding: 5px 3px 7px; border: 1px solid transparent; color: var(--ink); background: transparent; cursor: pointer; }
.tooth-shape { width: 32px; height: 42px; display: block; margin: 0 auto 4px; border: 2px solid #aebfbb; border-radius: 46% 46% 38% 38%; background: white; }
.tooth strong { font-size: .75rem; }
.tooth.is-planned .tooth-shape { border-color: var(--amber); background: var(--amber-soft); }
.tooth.is-progress .tooth-shape { border-color: var(--blue); background: var(--blue-soft); }
.tooth.is-done .tooth-shape { border-color: var(--green); background: var(--green-soft); }
.tooth.is-selected { border-color: var(--ink); background: white; box-shadow: 0 3px 10px rgba(24,50,56,.12); }
.jaw-divider { min-width: 880px; display: grid; grid-template-columns: 1fr 1fr; margin: 10px 0; color: var(--muted); font-size: .7rem; text-align: center; }
.jaw-divider span:first-child { border-right: 1px solid var(--line); }
.selection-note { margin: 14px 28px 0; color: var(--teal-dark); font-weight: 750; }
.plan-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 24px; }
.selected-treatment { align-self: start; }
.surface-line { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 28px 24px; border-bottom: 1px solid var(--line); }
.surface { padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .8rem; }
.surface.is-on { border-color: #9abdb8; color: var(--teal-dark); background: var(--teal-soft); }
.procedure-details { display: grid; grid-template-columns: 1.3fr .8fr .7fr; margin: 0; padding: 24px 28px; }
.procedure-details dt { color: var(--muted); font-size: .78rem; }
.procedure-details dd { margin: 6px 0 0; font-weight: 800; }
.material-preview { margin: 0 28px 28px; padding: 16px; border-left: 3px solid var(--teal); background: #f1f7f5; }
.material-preview span { color: var(--teal-dark); font-size: .78rem; font-weight: 800; }
.material-preview p { margin: 5px 0 0; font-size: .88rem; }
.plan-totals { padding: 26px; color: white; background: var(--ink); }
.plan-totals h2 { margin-bottom: 20px; }
.plan-totals dl { margin: 0 0 24px; }
.plan-totals dl div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; color: #c4d5d5; }
.plan-totals dd { margin: 0; color: white; font-weight: 750; }
.plan-totals .positive { color: #8fd0ad !important; }
.plan-totals .total-line { margin-top: 10px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.22); color: white; }
.plan-totals .total-line dd { font-size: 1.25rem; }
.plan-totals .remaining-line { margin-top: 3px; padding: 15px 12px; color: white; background: rgba(255,255,255,.08); }

/* Patient portal */
.portal-body { min-height: 100vh; background: #f3f6f4; }
.portal-header { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(20px, calc((100vw - 1040px) / 2)); border-bottom: 1px solid var(--line); background: white; }
.portal-header .brand small { color: var(--muted); }
.portal { max-width: 1040px; margin: auto; padding: 48px 0 80px; }
.portal-greeting { margin-bottom: 28px; }
.portal-greeting p { margin-bottom: 4px; color: var(--muted); }
.portal-greeting h1 { font-size: clamp(2.4rem, 5vw, 4rem); }
.portal-greeting span { color: var(--muted); }
.portal-progress { position: relative; padding: 28px 32px 25px; color: white; background: var(--teal-dark); }
.portal-progress h2 { margin: 14px 0 4px; font-size: 1.6rem; }
.portal-progress p { margin-bottom: 20px; color: #c9dfdd; }
.portal-progress .status-chip { color: white; background: rgba(255,255,255,.14); }
.progress-track { height: 8px; margin-right: 80px; background: rgba(255,255,255,.18); }
.progress-track i { height: 100%; display: block; background: #9ad3c8; }
.progress-percent { position: absolute; right: 32px; bottom: 16px; font-size: 1.25rem; }
.portal-money { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 26px; border: 1px solid var(--line); border-top: 0; background: white; }
.portal-money div { padding: 20px 24px; border-right: 1px solid var(--line); }
.portal-money div:last-child { border-right: 0; }
.portal-money span, .portal-money strong { display: block; }
.portal-money span { color: var(--muted); font-size: .8rem; }
.portal-money strong { margin-top: 5px; font-size: 1.35rem; }
.portal-money .money-emphasis { background: var(--amber-soft); }
.portal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.portal-section { min-width: 0; padding: 24px; border-top: 3px solid var(--ink); background: white; }
.portal-section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.portal-section-title a { color: var(--teal); font-size: .86rem; font-weight: 750; }
.portal-section-title span, .portal-section-title time { color: var(--muted); font-size: .8rem; }
.next-visit > strong { font-size: 1.15rem; }
.next-visit > p { margin: 4px 0 18px; color: var(--muted); }
.compact-teeth { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.compact-tooth { min-width: 0; padding: 12px 5px; border: 1px solid var(--line); text-align: center; }
.compact-tooth b, .compact-tooth small { display: block; }
.compact-tooth.done { border-color: #a9c7b5; background: var(--green-soft); }
.compact-tooth.progress { border-color: #acbdd1; background: var(--blue-soft); }
.compact-tooth.planned { border-color: #d6bd9a; background: var(--amber-soft); }
.portal-file { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; padding: 13px 0; border-top: 1px solid var(--line); }
.file-icon { width: 36px; height: 36px; display: grid; place-items: center; color: white; background: var(--ink); font-size: .66rem; font-weight: 850; }
.portal-file strong, .portal-file small { display: block; }
.portal-file > span:last-child { color: var(--green); font-size: .78rem; }
.portal-history p { margin: 0; padding: 12px 0; border-top: 1px solid var(--line); }
.portal-history time { display: block; color: var(--muted); font-size: .78rem; }
.portal-pdf { max-width: 320px; margin: 26px auto 0; }

/* PDF mock */
.pdf-body { background: #dfe5e2; }
.pdf-toolbar { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 28px; color: white; background: var(--ink); font-size: .86rem; }
.pdf-toolbar a { font-weight: 750; }
.pdf-stage { padding: 36px 20px 80px; }
.pdf-sheet { width: min(860px, 100%); min-height: 1110px; margin: auto; padding: 54px 58px 42px; background: white; box-shadow: 0 25px 70px rgba(24,50,56,.18); }
.pdf-sheet-header { display: grid; grid-template-columns: 48px 1fr auto; gap: 14px; align-items: center; padding-bottom: 28px; border-bottom: 2px solid var(--ink); }
.pdf-logo { width: 44px; height: 44px; display: grid; place-items: center; color: white; background: var(--teal); font-weight: 850; }
.pdf-sheet-header strong, .pdf-sheet-header small { display: block; }
.pdf-sheet-header > span { color: var(--muted); font-size: .72rem; }
.pdf-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; padding: 28px 0; }
.pdf-parties div { display: grid; }
.pdf-parties small { margin-bottom: 5px; }
.pdf-parties strong { font-size: 1.2rem; }
.pdf-parties span { color: var(--muted); font-size: .85rem; }
.pdf-summary { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 34px; background: #edf4f2; }
.pdf-summary div { padding: 16px; border-right: 1px solid #d2e0dc; }
.pdf-summary div:last-child { border-right: 0; }
.pdf-summary span, .pdf-summary strong { display: block; }
.pdf-summary span { color: var(--muted); font-size: .72rem; }
.pdf-summary strong { margin-top: 4px; font-size: .95rem; }
.pdf-section { margin-top: 30px; }
.pdf-section h2 { padding-bottom: 8px; border-bottom: 1px solid var(--ink); }
.pdf-section table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.pdf-section th, .pdf-section td { padding: 11px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.pdf-section th { color: var(--muted); font-size: .72rem; font-weight: 650; }
.pdf-section th:last-child, .pdf-section td:last-child { text-align: right; }
.pdf-status { font-weight: 750; }
.pdf-status.done { color: var(--green); }
.pdf-status.progress { color: var(--blue); }
.pdf-status.planned { color: var(--amber); }
.pdf-materials > div { display: grid; grid-template-columns: 1fr 1fr auto; gap: 20px; padding: 8px; border-bottom: 1px solid var(--line); font-size: .82rem; }
.pdf-materials > div span:nth-child(2) { color: var(--muted); }
.pdf-footer { display: flex; justify-content: space-between; gap: 30px; margin-top: 60px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; }

@media (max-width: 960px) {
  .landing { grid-template-columns: 1fr; }
  .doctor-shell { grid-template-columns: 1fr; }
  .doctor-nav { position: static; width: 100%; height: auto; display: grid; grid-template-columns: auto 1fr; align-items: center; padding: 14px 20px; }
  .primary-nav { display: flex; justify-content: flex-end; margin: 0; }
  .primary-nav a { border-left: 0; border-bottom: 3px solid transparent; }
  .doctor-signature { display: none; }
  .patient-columns, .plan-grid { grid-template-columns: 1fr; }
  .clinical-summary { grid-template-columns: 1fr; }
  .money-strip div:first-child { border-left: 0; }
  .patient-side-column { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .demo-banner { font-size: .72rem; }
  .landing { padding: 70px 20px; }
  .landing h1 { font-size: 2.8rem; }
  .landing-chart { padding: 20px; }
  .landing-totals { grid-template-columns: 1fr; }
  .landing-totals div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 14px; }
  .landing-totals dd { grid-column: 2; grid-row: 1 / span 2; }
  .landing-totals small { grid-column: 1; }
  .landing-chart-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .landing-legend { display: grid; grid-template-columns: 1fr 1fr; }
  .doctor-nav { grid-template-columns: 1fr; gap: 12px; }
  .primary-nav { justify-content: flex-start; overflow-x: auto; }
  .primary-nav a { flex: none; padding: 8px; font-size: .84rem; }
  .workspace { padding: 30px 16px 60px; }
  .workspace-header, .patient-header, .plan-header { align-items: flex-start; flex-direction: column; margin-bottom: 28px; }
  .header-actions { width: 100%; }
  .header-actions .button { flex: 1; }
  .register-tools { flex-direction: column; }
  .search-field, .search-field input { width: 100%; text-align: left; }
  .patient-row { grid-template-columns: 42px 1fr auto; gap: 12px; padding: 14px 16px; }
  .patient-row .progress-copy, .patient-row .money-copy { grid-column: 2; }
  .patient-row .row-action { grid-column: 3; grid-row: 1; }
  .dashboard-lower, .patient-side-column { grid-template-columns: 1fr; }
  .clinical-summary { display: block; }
  .progress-panel { padding: 20px; }
  .money-strip { grid-template-columns: 1fr; }
  .money-strip div { border-top: 1px solid var(--line); border-left: 0; }
  .treatment-item { grid-template-columns: 72px 1fr; padding: 14px 18px; }
  .treatment-item > b { grid-column: 2; }
  .history-list li { grid-template-columns: 1fr; gap: 3px; }
  .procedure-details { grid-template-columns: 1fr; gap: 18px; }
  .teeth-heading { flex-direction: column; }
  .patient-sides { font-size: .64rem; }
  .portal-header { padding: 0 16px; }
  .portal { padding: 30px 16px 60px; }
  .portal-progress { padding: 24px 20px; }
  .portal-money { grid-template-columns: 1fr; }
  .portal-money div { border-right: 0; border-bottom: 1px solid var(--line); }
  .portal-money div:last-child { border-bottom: 0; }
  .portal-grid { grid-template-columns: 1fr; }
  .portal-section { padding: 20px; }
  .portal-file { grid-template-columns: 38px 1fr; }
  .portal-file > span:last-child { grid-column: 2; }
  .pdf-toolbar { align-items: flex-start; flex-direction: column; }
  .pdf-stage { padding: 0; }
  .pdf-sheet { min-height: 0; padding: 30px 20px; box-shadow: none; }
  .pdf-sheet-header { grid-template-columns: 44px 1fr; }
  .pdf-sheet-header > span { grid-column: 1 / -1; }
  .pdf-parties, .pdf-summary { grid-template-columns: 1fr 1fr; }
  .pdf-summary div:nth-child(2) { border-right: 0; }
  .pdf-section { overflow-x: auto; }
  .pdf-section table { min-width: 620px; }
}

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

/* Real treatment plan */
.plan-card-list, .patient-plan-list, .treatment-stage-list { display: grid; gap: 14px; }
.plan-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 20px; padding: 18px 22px; border-left: 5px solid var(--line); background: #f7faf8; }
.plan-card-main { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-width: 0; text-decoration: none; }
.plan-card div, .plan-card strong, .plan-card span { display: block; }
.plan-card small, .plan-card span { color: var(--muted); }
.plan-card strong { margin: 3px 0; font-size: 1.06rem; }
.plan-card-actions { grid-column: 1 / -1; display: flex !important; gap: 16px; padding-top: 10px; border-top: 1px solid var(--line); font-size: .82rem; }
.plan-card-actions a { color: var(--teal-dark); font-weight: 750; }
.plan-card-actions .danger-link { color: var(--danger); }
.button-danger { color: white; background: var(--danger); }
.archived-plans { border-top: 1px solid var(--line); }
.archived-plans summary { padding: 17px 22px; color: var(--muted); cursor: pointer; font-weight: 750; }
.archived-plans summary span { display: inline-grid; min-width: 24px; min-height: 24px; margin-left: 7px; place-items: center; border-radius: 999px; background: var(--ground); font-size: .75rem; }
.archived-plan-list { display: grid; padding: 0 22px 18px; }
.archived-plan-list article { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.archived-plan-list strong, .archived-plan-list span { display: block; }
.archived-plan-list .link-button { color: var(--teal-dark); text-decoration: underline; cursor: pointer; }
.progress-gray { border-color: #9aa5a1 !important; }
.progress-yellow { border-color: var(--amber) !important; }
.progress-blue { border-color: var(--blue) !important; }
.progress-green { border-color: var(--green) !important; }
.plan-summary { display: grid; grid-template-columns: 1fr auto; gap: 30px; margin-bottom: 22px; padding: 20px 24px; border-left: 6px solid var(--line); background: white; box-shadow: 0 8px 30px rgba(24,50,56,.06); }
.plan-summary small, .plan-summary strong { display: block; }
.plan-summary small { margin-bottom: 5px; color: var(--muted); }
.plan-summary strong { font-size: 1.15rem; }
.exam-import { display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid rgba(24,50,56,.12); }
.exam-import a { color: var(--teal-dark); font-weight: 800; }
.treatment-stage { overflow: hidden; }
.treatment-stage .panel-heading > span { max-width: 240px; color: var(--muted); text-align: right; }
.stage-note { margin: -6px 28px 20px; color: var(--muted); }
.work-list { border-top: 1px solid var(--line); }
.work-row { display: grid; grid-template-columns: 120px minmax(220px, 1fr) 170px 90px; gap: 18px; align-items: center; padding: 18px 26px; border-bottom: 1px solid var(--line); }
.work-row:last-child { border-bottom: 0; }
.work-row h3, .work-row p { margin: 0; }
.work-row p, .work-row small { color: var(--muted); }
.work-row small { display: block; margin-top: 4px; }
.work-status span { display: inline-block; padding: 5px 8px; border-radius: 999px; font-size: .75rem; font-weight: 800; background: var(--amber-soft); }
.work-in_progress .work-status span { color: #375d83; background: var(--blue-soft); }
.work-done .work-status span { color: #315f47; background: var(--green-soft); }
.work-cancelled { opacity: .62; }
.work-cancelled .work-status span { background: #edf1ef; }
.work-price { text-align: right; }
.work-price strong { display: block; }
.work-actions { display: grid; gap: 6px; justify-items: start; }
.work-actions a, .work-actions button { color: var(--teal-dark); font-size: .8rem; font-weight: 750; }
.treatment-form > div { margin-bottom: 18px; }
.treatment-form label { display: block; margin-bottom: 6px; font-weight: 750; }
.treatment-form input:not([type="checkbox"]):not([type="radio"]), .treatment-form select, .treatment-form textarea { width: 100%; }
.treatment-form #id_teeth_selection, .treatment-form #id_surface_selection { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; padding: 12px; border: 1px solid var(--line); }
.treatment-form #id_teeth_selection label, .treatment-form #id_surface_selection label { margin: 0; padding: 6px; font-size: .8rem; background: #f5f8f7; }
.form-note { padding: 12px; color: var(--muted); background: #f4f7f5; }
.patient-plan { padding: 22px; border-left: 5px solid var(--line); background: #f7faf8; }
.patient-plan-heading { display: flex; justify-content: space-between; gap: 18px; }
.patient-plan-heading h3, .patient-plan-heading p { margin: 3px 0; }
.patient-plan-heading small, .patient-plan-heading p { color: var(--muted); }
.patient-stage { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.patient-stage h4 { margin: 0; }
.patient-stage > small { color: var(--muted); }
.patient-work { display: flex; justify-content: space-between; gap: 14px; margin-top: 10px; padding: 10px 12px; background: white; }
.patient-work small { display: block; color: var(--muted); }
.patient-work.work-cancelled { text-decoration: line-through; }
.catalog-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 22px; }
.catalog-list article, .template-list > article { padding: 18px 24px; border-top: 1px solid var(--line); }
.catalog-list article { display: flex; justify-content: space-between; gap: 18px; }
.catalog-list strong, .catalog-list small, .catalog-list b, .catalog-list a { display: block; }
.catalog-list small, .template-list small { margin-top: 4px; color: var(--muted); }
.catalog-list article > div:last-child { text-align: right; }
.catalog-list a, .template-list a { margin-top: 5px; color: var(--teal-dark); font-size: .8rem; font-weight: 750; }
.template-heading { display: flex; justify-content: space-between; gap: 18px; }
.template-heading strong, .template-heading small { display: block; }
.norm-list { margin-top: 12px; }
.norm-list > div { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: .84rem; }
.material-summary { margin-bottom: 22px; padding: 20px 24px; border: 1px solid #bed3cc; background: #f1f7f5; }
.material-summary h2 { margin-bottom: 10px; }
.material-summary div { display: flex; flex-wrap: wrap; gap: 8px; }
.material-summary span { padding: 7px 9px; background: white; }
.material-summary > small { display: block; margin-top: 12px; color: var(--muted); }
.work-materials { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.work-materials span { padding: 4px 7px; color: var(--teal-dark); background: var(--teal-soft); font-size: .75rem; }
.patient-material-summary { margin-top: 16px; padding: 12px; background: white; }
.patient-material-summary strong, .patient-material-summary span, .patient-material-summary small { display: block; }
.patient-material-summary span { margin-top: 5px; }
.patient-material-summary small { margin-top: 8px; color: var(--muted); }
.payment-panel { margin-bottom: 22px; }
.finance-overview { margin-bottom: 22px; }
.finance-overview .money-summary { padding-top: 4px; }
.money-negative { color: #934f48; }
.finance-groups { display: grid; gap: 18px; padding: 18px 24px; }
.finance-groups > section + section { padding-top: 18px; border-top: 1px solid var(--line); }
.finance-groups h3 { margin: 0 0 10px; font-size: .92rem; }
.finance-groups .money-summary { padding: 0; }
.patient-money > .finance-groups { padding: 12px 0 4px; }
.patient-money .money-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.patient-money .money-summary > div { min-height: 78px; }
.patient-money .money-summary small { white-space: nowrap; }
.money-flow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 16px 24px 0; color: var(--muted); font-size: .8rem; }
.money-flow span { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.55); }
.money-flow i { font-style: normal; }
.money-flow-note { margin: 18px 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.5); }
.money-flow-note strong, .money-flow-note p { display: block; }
.money-flow-note p { margin: 6px 0 0; color: var(--muted); }
.payment-panel .panel-heading { align-items: center; }
.money-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 10px; padding: 18px 24px; }
.money-summary > div { padding: 12px; border-radius: 12px; background: rgba(255,255,255,.68); }
.money-summary small, .money-summary strong, .money-summary b { display: block; }
.money-summary small { margin-bottom: 5px; color: var(--muted); }
.payment-ledger { border-top: 1px solid var(--line); }
.payment-entry { display: grid; grid-template-columns: minmax(220px, 1fr) auto 150px; gap: 18px; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.payment-entry:last-child { border-bottom: 0; }
.payment-entry strong, .payment-entry small, .payment-entry span { display: block; }
.payment-entry small, .payment-entry span, .payment-entry p { color: var(--muted); }
.payment-entry p { margin: 5px 0 0; }
.payment-refund > b, .payment-reversal > b { color: #934f48; }
.payment-reversed { opacity: .55; }
.payment-actions { display: grid; gap: 5px; justify-items: start; }
.payment-actions a { color: var(--teal-dark); font-size: .8rem; font-weight: 750; }
.patient-money { margin-top: 16px; padding: 14px; border-radius: 14px; background: rgba(255,255,255,.62); }
.patient-money > .money-summary { padding: 10px 0; }
.patient-payment { display: flex; justify-content: space-between; gap: 12px; padding: 8px 2px; border-top: 1px solid var(--line); }
.study-list { display: grid; gap: 14px; padding: 20px 24px 24px; }
.study-card { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.66); }
.study-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.study-heading h3, .study-heading p { margin: 3px 0; }
.study-heading small, .study-heading span, .study-links { color: var(--muted); }
.study-links { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.study-links span { padding: 4px 7px; border-radius: 999px; background: var(--teal-soft); font-size: .76rem; }
.study-files { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; margin-top: 14px; }
.study-file { display: grid; grid-template-columns: 82px 1fr; gap: 12px; align-items: center; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.study-file strong, .study-file small, .study-file span { display: block; overflow-wrap: anywhere; }
.study-file small, .study-file span { margin-top: 4px; color: var(--muted); }
.study-thumb, .study-file-icon { width: 82px; height: 68px; border-radius: 10px; overflow: hidden; background: #e7eeeb; }
.study-thumb img { width: 100%; height: 100%; object-fit: cover; }
.study-file-icon { display: grid; place-items: center; color: var(--teal-dark); font-weight: 850; }
.study-file-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 7px; }
.study-file-actions a { color: var(--teal-dark); font-size: .78rem; font-weight: 750; }
.study-file-cancelled { opacity: .62; }

@media (max-width: 700px) {
  .plan-summary { grid-template-columns: 1fr; gap: 14px; }
  .exam-import, .patient-plan-heading, .patient-work { align-items: flex-start; flex-direction: column; }
  .work-row { grid-template-columns: 1fr; gap: 10px; }
  .work-price { text-align: left; }
  .work-actions { display: flex; flex-wrap: wrap; gap: 14px; }
  .treatment-form #id_teeth_selection { grid-template-columns: repeat(4, 1fr); }
  .treatment-form #id_surface_selection { grid-template-columns: repeat(2, 1fr); }
  .catalog-grid { grid-template-columns: 1fr; }
  .catalog-list article, .template-heading { flex-direction: column; }
  .catalog-list article > div:last-child { text-align: left; }
  .norm-list > div { grid-template-columns: 1fr; gap: 3px; }
  .payment-panel .panel-heading, .payment-entry, .patient-payment { align-items: flex-start; grid-template-columns: 1fr; flex-direction: column; }
  .plan-card { grid-template-columns: 1fr; }
  .plan-card-main, .archived-plan-list article { align-items: flex-start; flex-direction: column; }
  .plan-card-actions { flex-wrap: wrap; }
  .patient-money .money-summary { grid-template-columns: 1fr; }
  .patient-money .money-summary > div {
    display: flex;
    min-height: 0;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
  }
  .patient-money .money-summary small { margin-bottom: 0; }
  .money-flow i { transform: rotate(90deg); }
  .study-list { padding: 14px; }
  .study-files { grid-template-columns: 1fr; }
}

@media print {
  .demo-banner, .pdf-toolbar { display: none; }
  .pdf-body, .pdf-stage { background: white; padding: 0; }
  .pdf-sheet { width: 100%; min-height: auto; box-shadow: none; }
}
