/* Clinical glass system — based on the Integrated Biosciences reference. */
:root {
  --ink: #213032;
  --muted: #647273;
  --paper: #ffffff;
  --ground: #eef1ec;
  --line: rgba(34, 47, 48, .14);
  --teal: #334645;
  --teal-dark: #1d2d2e;
  --teal-soft: rgba(206, 247, 158, .22);
  --blue: #55716e;
  --blue-soft: rgba(211, 231, 226, .62);
  --green: #3f6956;
  --green-soft: rgba(219, 239, 221, .7);
  --amber: #9a702e;
  --amber-soft: rgba(244, 232, 201, .72);
  --danger: #a04d48;
  --signal: #cef79e;
  --abyss: #222f30;
  --bone: #f7f7f5;
  --graphite: #4d5757;
  --lichen: #c9cbbe;
  --tissue: #e7e8e1;
  --glass: rgba(255, 255, 255, .66);
  --glass-strong: rgba(255, 255, 255, .84);
  --glass-dark: rgba(24, 39, 40, .78);
  --glass-line: rgba(255, 255, 255, .48);
  --shadow: 0 28px 70px rgba(20, 39, 38, .11), inset 0 1px 0 rgba(255,255,255,.65);
  font-family: "Segoe UI Variable", "Inter Tight", "Aptos", "Segoe UI", sans-serif;
}

html { background: #dfe7e1; scroll-behavior: smooth; }
body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(206,247,158,.34), transparent 31rem),
    radial-gradient(circle at 92% 16%, rgba(154,205,196,.3), transparent 34rem),
    linear-gradient(145deg, #eef2ed 0%, #e4ebe6 45%, #f4f5f1 100%);
  font-size: 16px;
  letter-spacing: -.01em;
}
body::before {
  content: "";
  position: fixed;
  z-index: -1;
  width: 34rem;
  height: 34rem;
  right: -10rem;
  bottom: -13rem;
  border-radius: 50%;
  background: rgba(206, 247, 158, .22);
  filter: blur(30px);
  pointer-events: none;
  animation: ambient-drift 16s ease-in-out infinite alternate;
}

h1, h2, h3, h4, strong, b { font-weight: 560; }
h1 { font-size: clamp(2.35rem, 5vw, 4.6rem); line-height: .98; letter-spacing: -.055em; }
h2 { font-size: clamp(1.2rem, 2vw, 1.6rem); letter-spacing: -.025em; }
.eyebrow {
  color: var(--graphite);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: .76rem;
  font-weight: 500;
  letter-spacing: -.015em;
  text-transform: none;
}
.eyebrow::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 9px 1px 0; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 4px rgba(206,247,158,.2); }
small { color: var(--muted); }
.skip-link { opacity: 0; visibility: hidden; }
.skip-link:focus { opacity: 1; visibility: visible; }

.account-shell, .portal-body, .landing-body, .auth-body, .pdf-body { background: transparent; }
.account-main, .portal, .workspace, .landing, .auth-layout, .pdf-stage { animation: page-arrive .58s cubic-bezier(.22,.8,.25,1) both; }

.account-header {
  position: sticky;
  z-index: 50;
  top: 12px;
  width: min(1200px, calc(100% - 28px));
  min-height: 62px;
  margin: 12px auto 0;
  padding: 0 22px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 18px;
  color: white;
  background: var(--glass-dark);
  box-shadow: 0 16px 44px rgba(16,29,30,.18), inset 0 1px 0 rgba(255,255,255,.12);
  -webkit-backdrop-filter: blur(24px) saturate(145%);
  backdrop-filter: blur(24px) saturate(145%);
}
.account-header .auth-brand { font-size: .96rem; font-weight: 560; letter-spacing: -.02em; }
.account-header nav a, .account-header .link-button {
  padding: 7px 10px;
  border-radius: 9px;
  color: rgba(255,255,255,.72);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: .76rem;
  transition: color .2s ease, background .2s ease;
}
.account-header nav a:hover, .account-header .link-button:hover { color: white; background: rgba(255,255,255,.09); }
.account-main { width: min(1200px, calc(100% - 40px)); padding-top: clamp(48px, 7vw, 88px); }
.account-main > h1,
.record-heading h1 { font-size: clamp(2.65rem, 5vw, 4.25rem); }
.narrow-main { width: min(880px, calc(100% - 40px)); }
.narrow-main > .eyebrow { margin-top: 34px; }
.narrow-main > h1 { margin: 8px 0 30px; }

.secure-panel,
.auth-card,
.landing-chart,
.odontogram,
.selected-treatment,
.portal-section,
.file-preview,
.clinical-summary,
.patient-list,
.schedule-card,
.dental-map,
.dental-controls,
.patient-plan,
.material-summary,
.plan-summary,
.open-note,
.patient-facts {
  border: 1px solid var(--glass-line);
  border-radius: 24px;
  background: var(--glass);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(24px) saturate(145%);
  backdrop-filter: blur(24px) saturate(145%);
}
.secure-panel, .dental-map, .dental-controls { overflow: hidden; border-top: 1px solid var(--glass-line); }
.panel-heading { padding: 24px 28px; border-bottom-color: var(--line); }
.panel-heading > span:not(.access-badge) {
  min-width: 34px;
  color: var(--abyss);
  background: var(--signal);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: .75rem;
  font-weight: 500;
}
.record-heading { align-items: center; }
.record-heading > div:first-child { max-width: 760px; }
.record-heading p { max-width: 660px; }
.back-link, .prototype-link { color: var(--graphite); text-decoration-color: rgba(77,87,87,.35); text-underline-offset: 5px; }

.button {
  min-height: 46px;
  padding: 11px 20px;
  border-radius: 12px;
  font-family: inherit;
  font-size: .92rem;
  font-weight: 650;
  letter-spacing: -.01em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2);
  transition: transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s ease, background .22s ease;
}
.button:hover { transform: translateY(-2px); }
.button:active { transform: translateY(0) scale(.98); }
.button-primary { color: white; background: var(--abyss); box-shadow: 0 10px 24px rgba(34,47,48,.16), inset 0 1px 0 rgba(255,255,255,.12); }
.button-primary:hover { background: #101f20; box-shadow: 0 14px 30px rgba(34,47,48,.23), inset 0 1px 0 rgba(255,255,255,.16); }
.button-quiet { border-color: rgba(34,47,48,.16); background: rgba(255,255,255,.46); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }

.account-form,
.stack-form {
  display: grid;
  gap: 22px;
}
.account-form { padding: clamp(24px, 4vw, 42px); }
.account-form { margin-top: 0; }
.account-form > div,
.stack-form > div { display: grid; gap: 8px; }
.account-form label,
.stack-form label {
  color: var(--abyss);
  font-size: .94rem;
  font-weight: 650;
  letter-spacing: -.01em;
}
.account-form input:not([type="checkbox"]):not([type="radio"]),
.account-form select,
.account-form textarea,
.stack-form input:not([type="checkbox"]):not([type="radio"]),
.stack-form select,
.stack-form textarea,
.patient-search input,
.control-section textarea {
  width: 100%;
  min-height: 52px;
  padding: 13px 15px;
  border: 1px solid rgba(34,47,48,.18);
  border-radius: 13px;
  color: var(--abyss);
  background: rgba(255,255,255,.7);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.85), 0 7px 22px rgba(34,47,48,.035);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease, transform .2s ease;
}
.account-form textarea, .stack-form textarea, .control-section textarea { min-height: 120px; resize: vertical; }
.account-form input:hover, .account-form select:hover, .account-form textarea:hover,
.stack-form input:hover, .stack-form select:hover, .stack-form textarea:hover { border-color: rgba(34,47,48,.32); background: rgba(255,255,255,.84); }
.account-form input:not([type="checkbox"]):not([type="radio"]):focus,
.account-form select:focus, .account-form textarea:focus,
.stack-form input:not([type="checkbox"]):not([type="radio"]):focus,
.stack-form select:focus, .stack-form textarea:focus,
.patient-search input:focus, .control-section textarea:focus {
  outline: 3px solid rgba(168,216,117,.72);
  outline-offset: 2px;
  border-color: #729260;
  background: rgba(255,255,255,.94);
  box-shadow: 0 0 0 4px rgba(206,247,158,.34), 0 14px 34px rgba(34,47,48,.08);
}
.account-form input[type="checkbox"], .account-form input[type="radio"],
.stack-form input[type="checkbox"], .stack-form input[type="radio"] { width: 20px; height: 20px; accent-color: var(--abyss); }
.helptext { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.helptext ul { margin: 7px 0 0; }
.errorlist { margin: 0; padding: 10px 13px; border-radius: 10px; color: #7c302c; background: rgba(255,224,219,.82); list-style-position: inside; }
.form-actions { margin-top: 4px; padding-top: 20px; border-top: 1px solid var(--line); }
.account-form .form-actions { display: flex; justify-content: flex-end; }
.account-form .form-actions .button { min-width: 180px; }
.account-form #id_change_reason { min-height: 96px; }

.auth-body { background: var(--abyss); }
.auth-body::before { width: 52rem; height: 52rem; right: -15rem; bottom: -22rem; background: rgba(206,247,158,.16); filter: blur(55px); }
.auth-layout { padding: 72px 20px; }
.auth-card { width: min(100%, 620px); border-top: 1px solid var(--glass-line); background: rgba(255,255,255,.82); }
.auth-card h1 { font-weight: 520; }
.auth-brand { font-weight: 560; }

.message-stack { top: 24px; right: 24px; }
.message { border: 1px solid var(--glass-line); border-left: 1px solid var(--glass-line); border-radius: 15px; background: rgba(255,255,255,.82); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); animation: toast-in .38s cubic-bezier(.2,.8,.2,1) both; }
.message::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 9px; border-radius: 50%; background: var(--signal); }
.message-error::before { background: #ef8a82; }

.patient-facts { overflow: hidden; border-top: 1px solid var(--glass-line); border-bottom: 1px solid var(--glass-line); background: rgba(255,255,255,.46); }
.patient-facts div { border-left-color: var(--line); }
.open-note { border-left: 1px solid var(--glass-line); background: rgba(225,237,235,.66); }
.open-note > span { color: var(--graphite); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-weight: 500; letter-spacing: -.015em; text-transform: none; }
.secure-list a, .catalog-list article, .template-list > article, .work-row, .patient-work { transition: background .2s ease, transform .2s ease; }
.secure-list a:hover, .catalog-list article:hover, .template-list > article:hover { background: rgba(206,247,158,.15); }
.patient-search { border-bottom-color: var(--line); }
.patient-search input { min-height: 44px; }

.plan-summary { border-left-width: 1px !important; background: rgba(255,255,255,.7); }
.plan-summary.progress-yellow { box-shadow: inset 5px 0 0 #d4a951, var(--shadow); }
.plan-summary.progress-blue { box-shadow: inset 5px 0 0 #7fa3ab, var(--shadow); }
.plan-summary.progress-green { box-shadow: inset 5px 0 0 #74a883, var(--shadow); }
.plan-summary.progress-gray { box-shadow: inset 5px 0 0 #aab1ad, var(--shadow); }
.material-summary { background: rgba(235,246,238,.58); }
.material-summary span, .patient-material-summary, .patient-work { border: 1px solid rgba(255,255,255,.72); border-radius: 13px; background: rgba(255,255,255,.6); box-shadow: inset 0 1px 0 rgba(255,255,255,.74); }
.payment-panel, .patient-money { border: 1px solid var(--glass-line); background: rgba(255,255,255,.54); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(22px) saturate(140%); backdrop-filter: blur(22px) saturate(140%); }
.money-summary > div { border: 1px solid rgba(255,255,255,.72); box-shadow: inset 0 1px 0 rgba(255,255,255,.82); }
.study-card, .study-file { border-color: var(--glass-line); background: rgba(255,255,255,.58); box-shadow: inset 0 1px 0 rgba(255,255,255,.8); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.work-materials span { border: 1px solid rgba(79,110,86,.1); border-radius: 999px; color: #3c5949; background: rgba(206,247,158,.22); }
.work-status span, .status-chip, .access-badge, .technical-badge { border-radius: 999px; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-weight: 500; }

.dental-editor { gap: 20px; }
.dental-controls { top: 94px; }
.tooth-select { border-radius: 14px; background: rgba(255,255,255,.5); transition: transform .2s ease, background .2s ease, border-color .2s ease; }
.tooth-select:hover { transform: translateY(-3px); background: rgba(255,255,255,.9); }
.tooth-select .tooth-shape { background: rgba(255,255,255,.8); }
.midline span { background: rgba(255,255,255,.76); }

.doctor-shell { background: transparent; }
.doctor-nav {
  margin: 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 22px;
  background: var(--glass-dark);
  box-shadow: 0 20px 60px rgba(15,29,29,.2);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}
.primary-nav a { border-left: 0; border-radius: 11px; }
.primary-nav a.active { color: var(--abyss); background: var(--signal); }
.workspace { min-width: 0; max-width: 1280px; }
.patient-row, .treatment-item { border-radius: 14px; }
.patient-row:hover, .treatment-item:hover { background: rgba(206,247,158,.14); }

.plan-workspace { overflow: clip; }
.plan-workspace .breadcrumbs { animation: section-rise .42s .05s cubic-bezier(.2,.8,.2,1) both; }
.plan-workspace .plan-header { display: grid; grid-template-columns: minmax(0, 1fr) minmax(230px, 300px); animation: section-rise .48s .1s cubic-bezier(.2,.8,.2,1) both; }
.plan-workspace .prototype-message {
  max-width: none;
  display: grid;
  gap: 2px;
  padding: 13px 15px;
  border: 1px solid rgba(154,112,46,.24);
  border-left: 1px solid rgba(154,112,46,.24);
  border-radius: 14px;
  background: rgba(244,232,201,.66);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65);
}
.prototype-message strong, .prototype-message span { display: block; }
.prototype-message strong { color: #73501f; font-size: .76rem; }
.prototype-message span { color: var(--graphite); font-size: .78rem; }
.plan-workspace .odontogram { animation: section-rise .54s .17s cubic-bezier(.2,.8,.2,1) both; }
.plan-workspace .plan-grid { animation: section-rise .56s .24s cubic-bezier(.2,.8,.2,1) both; }
.plan-workspace .odontogram-scroll { max-width: calc(100% - 48px); scrollbar-color: rgba(51,70,69,.45) transparent; }
.plan-workspace .tooth-row, .plan-workspace .jaw-divider { min-width: 760px; }
.plan-workspace .tooth { min-width: 38px; transition: color .2s ease, background .22s ease, border-color .22s ease, box-shadow .22s ease, transform .22s cubic-bezier(.2,.8,.2,1); }
.plan-workspace .tooth:hover { z-index: 1; transform: translateY(-4px); }
.plan-workspace .tooth:hover .tooth-shape { box-shadow: 0 8px 18px rgba(34,47,48,.1); }
.plan-workspace .tooth.is-selected { animation: tooth-select .36s cubic-bezier(.2,.9,.25,1); }
.selected-treatment.is-updating { animation: panel-refresh .38s cubic-bezier(.2,.8,.2,1); }

.landing-body { color: white; background: var(--abyss); }
.landing-body::before { background: rgba(206,247,158,.18); }
.landing { max-width: 1400px; }
.landing h1 { color: white; font-weight: 470; letter-spacing: -.06em; }
.landing-copy > p { color: rgba(255,255,255,.62); }
.landing .stage-pill { border-color: rgba(255,255,255,.2); color: var(--signal); background: rgba(255,255,255,.05); }
.landing .button-primary { color: var(--abyss); background: white; }
.landing .button-quiet { color: white; border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.06); }
.landing-chart { border-color: rgba(255,255,255,.14); background: rgba(255,255,255,.08); box-shadow: 0 32px 90px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.13); }
.landing-chart::before { border: 0; border-radius: 999px; background: var(--signal); box-shadow: 0 0 35px rgba(206,247,158,.4); }
.landing-chart-head small, .landing-chart-head strong, .landing-legend, .landing-tooth small, .landing-totals dt, .landing-totals small { color: rgba(255,255,255,.62); }
.landing-chart-head strong b { color: var(--signal); }
.landing-totals div { background: rgba(255,255,255,.065); }
.landing-totals dd { color: white; }

.portal-header { position: sticky; z-index: 40; top: 12px; width: min(1040px, calc(100% - 24px)); margin: 12px auto 0; border: 1px solid rgba(255,255,255,.14); border-radius: 18px; color: white; background: var(--glass-dark); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); }
.portal-header .brand small { color: rgba(255,255,255,.55); }
.portal-progress, .plan-totals, .next-step { border: 1px solid rgba(255,255,255,.12); border-radius: 24px; background: var(--glass-dark); box-shadow: 0 22px 60px rgba(20,39,38,.15); -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px); }
.portal-money { overflow: hidden; margin-top: 12px; border: 1px solid var(--glass-line); border-radius: 22px; background: var(--glass); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }

.pdf-stage { background: linear-gradient(145deg, #d9e1dc, #eef1ed); }
.pdf-sheet { border-radius: 24px; box-shadow: 0 34px 90px rgba(20,39,38,.16); }

details summary { transition: color .2s ease; }
details[open] summary { color: var(--abyss); }
:focus-visible { outline: 3px solid #a8d875; outline-offset: 3px; }

@keyframes page-arrive {
  from { transform: translateY(10px); }
  to { transform: translateY(0); }
}
@keyframes ambient-drift {
  from { transform: translate3d(0,0,0) scale(1); }
  to { transform: translate3d(-5vw,-4vh,0) scale(1.08); }
}
@keyframes toast-in {
  from { transform: translateY(-12px) scale(.98); }
  to { transform: translateY(0) scale(1); }
}
@keyframes section-rise {
  from { transform: translateY(18px); }
  to { transform: translateY(0); }
}
@keyframes tooth-select {
  0% { transform: scale(.94); }
  65% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
@keyframes panel-refresh {
  0% { transform: translateY(0); box-shadow: var(--shadow); }
  45% { transform: translateY(-4px); box-shadow: 0 34px 78px rgba(20,39,38,.16), inset 0 1px 0 rgba(255,255,255,.72); }
  100% { transform: translateY(0); box-shadow: var(--shadow); }
}

@media (max-width: 1180px) {
  .plan-workspace .plan-header { grid-template-columns: minmax(0, 1fr) minmax(210px, 270px); }
  .plan-workspace .odontogram-scroll { max-width: calc(100% - 36px); margin-inline: 18px; }
}

@media (max-width: 700px) {
  body { font-size: 15px; }
  h1 { font-size: clamp(2.3rem, 12vw, 3.7rem); }
  .account-header { top: 8px; width: calc(100% - 16px); margin-top: 8px; padding: 14px 16px; }
  .account-main { width: min(100% - 22px, 1200px); padding-top: 44px; }
  .secure-panel, .auth-card, .patient-plan, .material-summary, .plan-summary, .patient-facts, .open-note { border-radius: 19px; }
  .record-heading { gap: 18px; }
  .header-actions { display: grid; grid-template-columns: 1fr; }
  .account-form { padding: 22px 18px; }
  .account-form .form-actions .button { width: 100%; }
  .panel-heading { padding: 20px; }
  .message-stack { top: 12px; right: 12px; width: calc(100vw - 24px); }
  .doctor-nav { margin: 8px; }
  .portal-header { top: 8px; margin-top: 8px; }
  .plan-workspace { overflow: visible; }
  .plan-workspace .plan-header { display: flex; }
  .plan-workspace .prototype-message { width: 100%; }
  .plan-workspace .odontogram-scroll { max-width: calc(100% - 24px); margin-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body::before, .account-main, .portal, .workspace, .landing, .auth-layout, .pdf-stage, .message, .plan-workspace .breadcrumbs, .plan-workspace .plan-header, .plan-workspace .odontogram, .plan-workspace .plan-grid, .plan-workspace .tooth.is-selected, .selected-treatment.is-updating { animation: none !important; }
  .button, .tooth-select, .tooth, .secure-list a, .patient-row, .treatment-item { transition: none !important; }
}

@media print {
  body, .pdf-body, .pdf-stage { background: white !important; }
  body::before { display: none; }
  .pdf-sheet { border-radius: 0; box-shadow: none; }
}

/* Midnight clinical system — compact, high-contrast and calm. */
@media screen {
  :root {
    --ink: #f4f5f8;
    --muted: #9a9fab;
    --paper: #171922;
    --ground: #101118;
    --line: rgba(255, 255, 255, .1);
    --teal: #716cff;
    --teal-dark: #a9a6ff;
    --teal-soft: rgba(113, 108, 255, .14);
    --blue: #7772ff;
    --blue-soft: rgba(119, 114, 255, .16);
    --green: #55c993;
    --green-soft: rgba(85, 201, 147, .15);
    --amber: #e5ae5b;
    --amber-soft: rgba(229, 174, 91, .15);
    --danger: #ef6b73;
    --signal: #7772ff;
    --abyss: #0d0e14;
    --bone: #f4f5f8;
    --graphite: #b8bcc6;
    --lichen: #343743;
    --tissue: #222530;
    --glass: rgba(24, 26, 35, .9);
    --glass-strong: rgba(29, 31, 42, .96);
    --glass-dark: rgba(14, 15, 22, .92);
    --glass-line: rgba(255, 255, 255, .09);
    --shadow: 0 22px 56px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .045);
    color-scheme: dark;
  }

  html { background: #0a0b10; }
  body {
    color: var(--ink);
    background:
      radial-gradient(circle at 50% -10%, rgba(84, 96, 170, .32), transparent 35rem),
      radial-gradient(circle at 95% 18%, rgba(76, 68, 164, .13), transparent 28rem),
      #0a0b10;
    font-size: 16px;
    line-height: 1.48;
  }
  body::before {
    right: auto;
    bottom: auto;
    top: -20rem;
    left: 12%;
    width: 58rem;
    height: 42rem;
    border-radius: 50%;
    background: rgba(83, 94, 170, .16);
    filter: blur(90px);
    animation: none;
  }

  h1, h2, h3, h4, strong, b { color: var(--ink); font-weight: 620; }
  h1 { font-size: clamp(2.35rem, 4.2vw, 4rem); line-height: 1.01; letter-spacing: -.052em; }
  h2 { font-size: clamp(1.25rem, 2vw, 1.7rem); }
  p, small, dt { color: var(--muted); }
  a { color: #c7c5ff; }
  .eyebrow {
    color: #aeb2bd;
    font-family: inherit;
    font-size: .78rem;
    font-weight: 620;
    letter-spacing: 0;
  }
  .eyebrow::before { background: #7772ff; box-shadow: 0 0 0 4px rgba(119, 114, 255, .13); }
  .back-link, .prototype-link { color: #bfc2cb; text-decoration-color: rgba(191, 194, 203, .38); }
  :focus-visible { outline-color: #8d88ff; }

  .account-header,
  .portal-header {
    top: 16px;
    width: min(1240px, calc(100% - 32px));
    min-height: 60px;
    margin-top: 16px;
    padding: 0 20px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 14px;
    background: rgba(18, 19, 27, .9);
    box-shadow: 0 16px 44px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .04);
    -webkit-backdrop-filter: blur(22px) saturate(120%);
    backdrop-filter: blur(22px) saturate(120%);
  }
  .account-header .auth-brand { font-size: 1rem; font-weight: 680; }
  .account-header nav a, .account-header .link-button {
    padding: 8px 11px;
    border-radius: 9px;
    color: #b8bbc5;
    font-family: inherit;
    font-size: .82rem;
    font-weight: 560;
  }
  .account-header nav a:hover, .account-header .link-button:hover { color: white; background: rgba(255, 255, 255, .065); }

  .account-main { width: min(1200px, calc(100% - 48px)); padding: clamp(54px, 7vw, 86px) 0 88px; }
  .account-main > h1, .record-heading h1 { font-size: clamp(2.55rem, 4.6vw, 4rem); }
  .narrow-main { width: min(820px, calc(100% - 48px)); }
  .narrow-main > .eyebrow { margin-top: 26px; }
  .narrow-main > h1 { margin: 9px 0 28px; }
  .record-heading { margin-bottom: 28px; }
  .header-actions { gap: 10px; }

  .secure-panel,
  .auth-card,
  .landing-chart,
  .odontogram,
  .selected-treatment,
  .portal-section,
  .file-preview,
  .clinical-summary,
  .patient-list,
  .schedule-card,
  .dental-map,
  .dental-controls,
  .patient-plan,
  .material-summary,
  .plan-summary,
  .open-note,
  .patient-facts,
  .payment-panel,
  .patient-money,
  .study-card,
  .study-file {
    border-color: rgba(255, 255, 255, .09);
    border-radius: 16px;
    color: var(--ink);
    background: rgba(23, 25, 34, .93);
    box-shadow: var(--shadow);
    -webkit-backdrop-filter: blur(20px) saturate(115%);
    backdrop-filter: blur(20px) saturate(115%);
  }
  .secure-panel, .dental-map, .dental-controls { border-top-color: rgba(255, 255, 255, .11); }
  .panel-heading { padding: 20px 24px; border-bottom-color: var(--line); }
  .panel-heading > span:not(.access-badge) {
    color: white;
    background: #6762e8;
    font-family: inherit;
    font-weight: 650;
  }

  .button {
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 10px;
    font-size: .9rem;
    font-weight: 650;
    box-shadow: none;
  }
  .button:hover { transform: translateY(-1px); }
  .button-primary {
    color: white;
    border-color: #7772ff;
    background: #6b66ed;
    box-shadow: 0 10px 26px rgba(80, 72, 220, .24), inset 0 1px 0 rgba(255, 255, 255, .18);
  }
  .button-primary:hover { background: #7b76ff; box-shadow: 0 13px 30px rgba(80, 72, 220, .32); }
  .button-quiet { color: #e4e5ea; border-color: rgba(255, 255, 255, .13); background: rgba(255, 255, 255, .045); }
  .button-quiet:hover { background: rgba(255, 255, 255, .08); }
  .button-danger { color: white; border-color: rgba(239, 107, 115, .4); background: rgba(190, 66, 75, .72); }

  .account-form, .stack-form { gap: 18px; }
  .account-form { padding: clamp(24px, 3.2vw, 34px); }
  .account-form > div, .stack-form > div { gap: 7px; }
  .account-form label, .stack-form label { color: #e5e6eb; font-size: .9rem; font-weight: 620; }
  .account-form input:not([type="checkbox"]):not([type="radio"]),
  .account-form select,
  .account-form textarea,
  .stack-form input:not([type="checkbox"]):not([type="radio"]),
  .stack-form select,
  .stack-form textarea,
  .patient-search input,
  .control-section textarea,
  .copy-row input {
    min-height: 48px;
    padding: 11px 14px;
    border-color: rgba(255, 255, 255, .11);
    border-radius: 10px;
    color: #f4f5f8;
    background: #11131a;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
  }
  .account-form input:hover, .account-form select:hover, .account-form textarea:hover,
  .stack-form input:hover, .stack-form select:hover, .stack-form textarea:hover { border-color: rgba(151, 146, 255, .52); background: #141620; }
  .account-form input:not([type="checkbox"]):not([type="radio"]):focus,
  .account-form select:focus, .account-form textarea:focus,
  .stack-form input:not([type="checkbox"]):not([type="radio"]):focus,
  .stack-form select:focus, .stack-form textarea:focus,
  .patient-search input:focus, .control-section textarea:focus {
    outline: 2px solid rgba(141, 136, 255, .72);
    outline-offset: 1px;
    border-color: #8d88ff;
    background: #151721;
    box-shadow: 0 0 0 4px rgba(119, 114, 255, .1);
  }
  .account-form input[type="checkbox"], .account-form input[type="radio"],
  .stack-form input[type="checkbox"], .stack-form input[type="radio"] { accent-color: #7772ff; }
  .helptext { color: #8f94a0; }
  .form-actions { margin-top: 2px; padding-top: 18px; }
  .errorlist { color: #ffb8bc; background: rgba(165, 53, 62, .22); }

  .auth-body { background: #0a0b10; }
  .auth-body::before { background: rgba(92, 84, 210, .2); }
  .auth-layout { padding: 64px 20px; }
  .auth-card { background: rgba(23, 25, 34, .96); }
  .message { color: var(--ink); border-color: rgba(255, 255, 255, .1); background: rgba(27, 29, 39, .96); }
  .message::before { background: #7772ff; }

  .patient-facts, .open-note { background: rgba(25, 27, 37, .9); }
  .patient-facts div { border-left-color: var(--line); }
  .open-note > span { color: #d7d8df; font-family: inherit; font-weight: 650; }
  .secure-list a, .catalog-list article, .template-list > article, .work-row, .patient-work { color: var(--ink); border-color: var(--line); }
  .secure-list a:hover, .catalog-list article:hover, .template-list > article:hover,
  .patient-row:hover, .treatment-item:hover { background: rgba(119, 114, 255, .075); }
  .plan-card, .patient-plan, .plan-summary, .material-summary,
  .material-summary span, .patient-material-summary, .patient-work,
  .money-summary > div, .study-card, .study-file, .patient-money {
    border-color: rgba(255, 255, 255, .085);
    color: var(--ink);
    background: #1b1d27;
    box-shadow: none;
  }
  .plan-card-actions a, .archived-plan-list .link-button,
  .work-actions a, .work-actions button, .catalog-list a, .template-list a,
  .payment-actions a, .study-file-actions a { color: #bcb9ff; }
  .archived-plans, .archived-plan-list article, .work-list, .work-row,
  .payment-ledger, .payment-entry, .finance-groups > section + section,
  .patient-work, .patient-payment { border-color: var(--line); }
  .archived-plans summary, .plan-card small, .plan-card span,
  .work-row p, .work-row small, .catalog-list small, .template-list small,
  .study-heading small, .study-heading span, .study-links { color: var(--muted); }
  details[open] summary { color: white; }

  .money-flow span, .money-flow-note { border-color: var(--line); background: rgba(255, 255, 255, .035); }
  .money-negative, .payment-refund > b, .payment-reversal > b { color: #ff8f96; }
  .work-materials span, .study-links span { color: #c8c6ff; background: rgba(119, 114, 255, .12); }
  .work-status span { color: #efc57f; background: var(--amber-soft); }
  .work-in_progress .work-status span { color: #bcb9ff; background: var(--blue-soft); }
  .work-done .work-status span { color: #7ee0ad; background: var(--green-soft); }

  .doctor-shell { background: #0a0b10; }
  .doctor-nav {
    margin: 14px;
    border-color: rgba(255, 255, 255, .08);
    border-radius: 16px;
    background: rgba(18, 19, 27, .95);
    box-shadow: 0 20px 55px rgba(0, 0, 0, .34);
  }
  .primary-nav a { color: #9ea2ad; }
  .primary-nav a.active { color: white; background: #6762e8; }
  .workspace { max-width: 1260px; padding-top: 58px; }

  .tooth-select { border-color: rgba(255, 255, 255, .11); background: #181a23; }
  .tooth-select:hover { background: #20232e; }
  .tooth-select .tooth-shape, .midline span { background: #f5f6f8; }
  .tooth-checkbox:checked + .tooth-select, .tooth-select.is-selected { border-color: #7772ff; background: rgba(119, 114, 255, .15); }

  .landing-body { background: #0a0b10; }
  .landing-body::before { background: rgba(92, 84, 210, .2); }
  .landing { max-width: 1260px; gap: clamp(36px, 6vw, 86px); }
  .landing-copy > p { color: #9a9fab; }
  .landing .stage-pill { color: #c4c1ff; border-color: rgba(119, 114, 255, .34); background: rgba(119, 114, 255, .09); }
  .landing .button-primary { color: white; background: #6b66ed; }
  .landing .button-quiet { color: white; border-color: rgba(255, 255, 255, .13); background: rgba(255, 255, 255, .045); }
  .landing-chart { border-color: rgba(255, 255, 255, .09); border-radius: 16px; background: #161820; box-shadow: 0 28px 74px rgba(0, 0, 0, .34); }
  .landing-chart::before { background: #7772ff; box-shadow: 0 0 30px rgba(119, 114, 255, .35); }
  .landing-chart-head small, .landing-chart-head strong, .landing-legend,
  .landing-tooth small, .landing-totals dt, .landing-totals small { color: #9398a4; }
  .landing-chart-head strong b { color: #aaa7ff; }
  .landing-totals div { background: #1d202a; }

  .portal-progress, .plan-totals, .next-step { border-color: rgba(255, 255, 255, .09); border-radius: 16px; background: #171922; }
  .portal-money { border-color: rgba(255, 255, 255, .09); border-radius: 16px; background: #171922; }

  .plan-workspace .prototype-message { border-color: rgba(229, 174, 91, .26); background: rgba(125, 87, 31, .18); }
  .prototype-message strong { color: #efc57f; }
  .prototype-message span { color: #b8bbc5; }
}

@media screen and (max-width: 700px) {
  .account-header { width: calc(100% - 16px); min-height: 56px; align-items: center; padding: 0 14px; }
  .account-header nav { align-items: center; flex-direction: row; gap: 2px; }
  .account-header nav a, .account-header .link-button { padding: 7px 8px; font-size: .76rem; }
  .account-main, .narrow-main { width: calc(100% - 24px); padding-top: 42px; }
  .account-main > h1, .record-heading h1 { font-size: clamp(2.25rem, 11vw, 3.25rem); }
  .secure-panel, .auth-card, .patient-plan, .material-summary, .plan-summary, .patient-facts, .open-note { border-radius: 14px; }
  .account-form { padding: 20px 16px; }
  .account-form .form-actions .button { width: auto; min-width: 160px; }
  .panel-heading { padding: 18px; }
  .button { min-height: 44px; }
}

/* Porcelain light system — solid surfaces, no decorative gradients. */
@media screen {
  :root {
    --ink: #172033;
    --muted: #667085;
    --paper: #ffffff;
    --ground: #f4f6fa;
    --line: #dde3ec;
    --teal: #5b61e6;
    --teal-dark: #454bc8;
    --teal-soft: #eef0ff;
    --blue: #6670d9;
    --blue-soft: #edf0ff;
    --green: #24865e;
    --green-soft: #eaf7f1;
    --amber: #ad7428;
    --amber-soft: #fff5e5;
    --danger: #c94f57;
    --signal: #5b61e6;
    --abyss: #172033;
    --bone: #f9fafc;
    --graphite: #475467;
    --lichen: #d6dce6;
    --tissue: #eef1f5;
    --glass: #ffffff;
    --glass-strong: #ffffff;
    --glass-dark: #ffffff;
    --glass-line: #dde3ec;
    --shadow: 0 14px 38px rgba(23, 32, 51, .08);
    color-scheme: light;
  }

  html { background: #f4f6fa; }
  body,
  .landing-body,
  .auth-body,
  .doctor-shell {
    color: var(--ink);
    background: #f4f6fa;
  }
  body::before, .landing-body::before, .auth-body::before { display: none; }
  h1, h2, h3, h4, strong, b { color: var(--ink); }
  p, small, dt { color: var(--muted); }
  a, .back-link, .prototype-link { color: #4f56c9; }
  .eyebrow { color: #667085; }
  .eyebrow::before { background: #5b61e6; box-shadow: 0 0 0 4px #e9ebff; }
  :focus-visible { outline-color: #6970e8; }

  .account-header,
  .portal-header {
    color: var(--ink);
    border-color: #e0e5ed;
    background: #ffffff;
    box-shadow: 0 8px 26px rgba(23, 32, 51, .07);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .account-header .auth-brand { color: var(--ink); }
  .account-header nav a, .account-header .link-button { color: #667085; }
  .account-header nav a:hover, .account-header .link-button:hover { color: var(--ink); background: #f1f3f7; }

  .secure-panel,
  .auth-card,
  .landing-chart,
  .odontogram,
  .selected-treatment,
  .portal-section,
  .file-preview,
  .clinical-summary,
  .patient-list,
  .schedule-card,
  .dental-map,
  .dental-controls,
  .patient-plan,
  .material-summary,
  .plan-summary,
  .open-note,
  .patient-facts,
  .payment-panel,
  .patient-money,
  .study-card,
  .study-file {
    color: var(--ink);
    border-color: #e0e5ed;
    background: #ffffff;
    box-shadow: 0 12px 34px rgba(23, 32, 51, .065);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .panel-heading { border-bottom-color: #e6eaf0; }
  .panel-heading > span:not(.access-badge) { color: #484fad; background: #eef0ff; }

  .message-stack { top: 92px; }
  .message {
    color: #172033;
    border-color: #d8dee8;
    background: #ffffff;
    box-shadow: 0 12px 32px rgba(23, 32, 51, .14);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .message::before { background: #5b61e6; }
  .message-error { color: #8f2d35; border-color: #efc8cb; background: #fff6f7; }
  .message-error::before { background: #c94f57; }

  .button {
    color: #344054;
    border-color: #d8dee8;
    background: #ffffff;
    box-shadow: 0 2px 5px rgba(23, 32, 51, .045);
  }
  .button:hover { color: #172033; border-color: #c5ccd8; background: #f8f9fb; }
  .button-primary {
    color: #ffffff;
    border-color: #5b61e6;
    background: #5b61e6;
    box-shadow: 0 8px 20px rgba(91, 97, 230, .2);
  }
  .button-primary:hover { color: #ffffff; border-color: #4d53d2; background: #4d53d2; box-shadow: 0 10px 24px rgba(91, 97, 230, .26); }
  .button-quiet { color: #344054; border-color: #d8dee8; background: #ffffff; }
  .button-danger { color: #ffffff; border-color: #c94f57; background: #c94f57; }

  .account-form label, .stack-form label { color: #344054; }
  .account-form input:not([type="checkbox"]):not([type="radio"]),
  .account-form select,
  .account-form textarea,
  .stack-form input:not([type="checkbox"]):not([type="radio"]),
  .stack-form select,
  .stack-form textarea,
  .patient-search input,
  .control-section textarea,
  .copy-row input {
    color: #172033;
    border-color: #d8dee8;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(23, 32, 51, .025);
  }
  .account-form input:hover, .account-form select:hover, .account-form textarea:hover,
  .stack-form input:hover, .stack-form select:hover, .stack-form textarea:hover { border-color: #aeb6c4; background: #ffffff; }
  .account-form input:not([type="checkbox"]):not([type="radio"]):focus,
  .account-form select:focus, .account-form textarea:focus,
  .stack-form input:not([type="checkbox"]):not([type="radio"]):focus,
  .stack-form select:focus, .stack-form textarea:focus,
  .patient-search input:focus, .control-section textarea:focus {
    outline: 2px solid rgba(91, 97, 230, .3);
    border-color: #6970e8;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(91, 97, 230, .08);
  }
  .account-form input[type="checkbox"], .account-form input[type="radio"],
  .stack-form input[type="checkbox"], .stack-form input[type="radio"] { accent-color: #5b61e6; }
  .helptext { color: #7a8495; }
  .errorlist { color: #9f343c; background: #fff0f1; }
  .form-note { color: #667085; border: 1px solid #e3e7ee; border-radius: 10px; background: #f8f9fb; }

  .patient-facts, .open-note { background: #ffffff; }
  .open-note > span { color: #475467; }
  .secure-list a, .catalog-list article, .template-list > article,
  .work-row, .patient-work { color: var(--ink); border-color: #e6eaf0; }
  .secure-list a:hover, .catalog-list article:hover, .template-list > article:hover,
  .patient-row:hover, .treatment-item:hover { background: #f7f8fc; }
  .plan-card, .patient-plan, .plan-summary, .material-summary,
  .material-summary span, .patient-material-summary, .patient-work,
  .money-summary > div, .study-card, .study-file, .patient-money {
    color: var(--ink);
    border-color: #e2e6ed;
    background: #f9fafc;
  }
  .plan-card-actions a, .archived-plan-list .link-button,
  .work-actions a, .work-actions button, .catalog-list a, .template-list a,
  .payment-actions a, .study-file-actions a { color: #4f56c9; }
  .archived-plans, .archived-plan-list article, .work-list, .work-row,
  .payment-ledger, .payment-entry, .finance-groups > section + section,
  .patient-work, .patient-payment { border-color: #e3e7ee; }
  .money-flow span, .money-flow-note { border-color: #e0e5ed; background: #f8f9fb; }
  .work-materials span, .study-links span { color: #4c52b8; background: #eef0ff; }
  details[open] summary { color: #344054; }
  .money-negative, .payment-refund > b, .payment-reversal > b { color: #a23842; }
  .work-status span { color: #82551b; background: #fff5e5; }
  .work-in_progress .work-status span { color: #4147b4; background: #edf0ff; }
  .work-done .work-status span { color: #176b49; background: #eaf7f1; }
  .work-cancelled, .payment-reversed, .study-file-cancelled { opacity: 1; }
  .work-cancelled, .payment-reversed { background: #f5f6f8; }
  .study-file-cancelled { border-color: #e7c5c8; background: #fff7f7; }
  .study-file-cancelled span { color: #9f343c; }
  .dental-map.is-mouth-scope .tooth-selector-row { opacity: 1; }

  .doctor-shell { background: #f4f6fa; }
  .doctor-nav { border-color: #e0e5ed; background: #ffffff; box-shadow: 0 12px 34px rgba(23, 32, 51, .08); }
  .doctor-nav .brand strong, .doctor-signature strong { color: #172033; }
  .doctor-nav .brand small, .doctor-signature small { color: #667085; }
  .primary-nav a { color: #667085; }
  .primary-nav a:hover, .primary-nav a:focus-visible { color: #343aa1; background: #eef0ff; }
  .primary-nav a.is-current, .primary-nav a.is-current:hover, .primary-nav a.is-current:focus-visible { color: #ffffff; background: #5b61e6; }
  .primary-nav .demo-nav-exit { margin-top: 24px; border-top: 1px solid #e0e5ed; border-radius: 0 0 11px 11px; }
  .demo-banner a { margin-left: 10px; color: #ffffff; font-weight: 750; text-underline-offset: 3px; }
  @media (max-width: 960px) {
    .doctor-nav { grid-template-columns: auto minmax(0, 1fr); gap: 12px; }
    .primary-nav { flex-wrap: wrap; gap: 4px; }
    .primary-nav a { padding: 8px 10px; border: 0; white-space: nowrap; }
    .primary-nav .demo-nav-exit { margin-top: 0; border: 0; border-radius: 11px; }
    .patient-row { grid-template-columns: 42px minmax(150px, 1fr) 80px 100px 65px; gap: 10px; padding-inline: 18px; }
  }
  @media (max-width: 700px) {
    .doctor-nav { grid-template-columns: 1fr; }
    .primary-nav { flex-wrap: nowrap; justify-content: flex-start; }
    .patient-row { grid-template-columns: 42px minmax(0, 1fr) auto; }
  }

  .landing h1 { color: var(--ink); }
  .landing-copy > p { color: #667085; }
  .landing .stage-pill { color: #4f56c9; border-color: #d8dcff; background: #f0f1ff; }
  .landing .button-primary { color: #ffffff; background: #5b61e6; }
  .landing .button-quiet { color: #344054; border-color: #d8dee8; background: #ffffff; }
  .landing-chart { border-color: #e0e5ed; background: #ffffff; box-shadow: 0 16px 44px rgba(23, 32, 51, .08); }
  .landing-chart::before { background: #5b61e6; box-shadow: none; }
  .landing-chart-head small, .landing-chart-head strong, .landing-legend,
  .landing-tooth small, .landing-totals dt, .landing-totals small { color: #667085; }
  .landing-chart-head strong b { color: #4f56c9; }
  .landing-totals div { background: #f7f8fb; }
  .landing-totals dd { color: #172033; }

  .practice-ledger { color: var(--ink); border: 1px solid #e0e5ed; background: #ffffff; box-shadow: 0 12px 34px rgba(23, 32, 51, .065); }
  .practice-ledger p, .practice-ledger .ledger-number, .practice-ledger > small { color: #667085; }
  .practice-ledger .ledger-number, .practice-ledger strong { color: #172033; }
  .ledger-rule { background: #e0e5ed; }

  .portal-header .brand small { color: #667085; }
  .portal-progress, .plan-totals, .next-step, .portal-money { color: var(--ink); border-color: #e0e5ed; background: #ffffff; box-shadow: 0 12px 34px rgba(23, 32, 51, .065); }
  .portal-progress p, .next-step > span, .next-step small { color: #667085; }
  .portal-progress .status-chip { color: #4147b4; background: #edf0ff; }
  .progress-track { background: #e3e7ee; }
  .progress-track i { background: #5b61e6; }
  .plan-totals dl div, .plan-totals dd, .plan-totals .total-line, .plan-totals .remaining-line { color: #344054; }
  .plan-totals .total-line { border-top-color: #e0e5ed; }
  .plan-totals .remaining-line { background: #f3f4ff; }
  .plan-totals .positive { color: #176b49 !important; }
  .plan-workspace .prototype-message { border-color: #ead6ae; background: #fff8e9; }
  .prototype-message strong { color: #8e6225; }
  .prototype-message span { color: #667085; }

  .tooth-choice-grid {
    display: grid !important;
    grid-template-columns: repeat(8, minmax(66px, 1fr)) !important;
    gap: 10px !important;
    padding: 14px !important;
    border: 1px solid #e0e5ed !important;
    border-radius: 14px;
    background: #f8f9fc;
  }
  .jaw-picker { display: grid; gap: 18px; }
  .jaw-section {
    overflow: visible;
    padding: 14px;
    border: 1px solid #e0e5ed;
    border-radius: 14px;
    background: #f8f9fc;
  }
  .jaw-title,
  .jaw-axis,
  .jaw-halves { min-width: 0; }
  .jaw-title { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
  .jaw-title strong { color: #172033; font-size: 1rem; }
  .jaw-title span { color: #7a8495; font-size: .8rem; }
  .jaw-axis { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 8px; color: #667085; font-size: .76rem; }
  .jaw-axis span:last-child { text-align: right; }
  .jaw-axis i { position: relative; padding: 0 12px; color: #4f56c9; font-style: normal; font-weight: 700; }
  .jaw-axis i::before { content: ""; position: absolute; top: 22px; bottom: -102px; left: 50%; width: 1px; background: #cdd2f4; }
  .jaw-halves { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .tooth-quadrant { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
  .tooth-quadrant::before { display: none; content: attr(data-side); }
  .field-intro { margin: -1px 0 10px; color: #7a8495; font-size: .84rem; }
  .tooth-choice {
    position: relative;
    min-width: 0;
    min-height: 112px;
    display: grid !important;
    grid-template-rows: 74px auto;
    place-items: center;
    gap: 3px;
    margin: 0 !important;
    padding: 8px 5px 7px !important;
    border: 1px solid #dce2ea;
    border-radius: 12px;
    color: #657084;
    background: #ffffff !important;
    box-shadow: 0 3px 10px rgba(23, 32, 51, .045);
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease, background .18s ease;
  }
  .tooth-choice:hover { z-index: 1; border-color: #aeb5ea; box-shadow: 0 8px 18px rgba(49, 57, 115, .1); transform: translateY(-2px); }
  .tooth-choice input { position: absolute; width: 1px !important; height: 1px !important; opacity: 0; pointer-events: none; }
  .tooth-model { width: 50px; height: 70px; overflow: visible; color: #fcfcfd; filter: drop-shadow(0 4px 5px rgba(23, 32, 51, .14)); transition: transform .18s ease, color .18s ease; }
  .tooth-model-body { fill: currentColor; stroke: #aeb7c5; stroke-width: 1.7; stroke-linejoin: round; }
  .tooth-model-detail { fill: none; stroke: #d1d7e0; stroke-width: 1.4; stroke-linecap: round; }
  .tooth-model-shine { fill: none; stroke: #ffffff; stroke-width: 2.4; stroke-linecap: round; opacity: .95; }
  .tooth-choice[data-tooth$="1"] .tooth-model,
  .tooth-choice[data-tooth$="2"] .tooth-model { transform: scaleX(.74); }
  .tooth-choice[data-tooth$="3"] .tooth-model { transform: scaleX(.82); }
  .tooth-choice[data-tooth$="4"] .tooth-model,
  .tooth-choice[data-tooth$="5"] .tooth-model { transform: scaleX(.9); }
  .tooth-choice strong { color: #475467; font-size: .84rem; font-weight: 680; }
  .tooth-check { position: absolute; top: 7px; right: 7px; width: 21px; height: 21px; display: grid; place-items: center; border-radius: 50%; color: transparent; background: transparent; font-size: .72rem; }
  .tooth-choice:has(input:focus-visible) { outline: 3px solid rgba(91, 97, 230, .28); outline-offset: 2px; }
  .tooth-choice:has(input:checked) { border-color: #5b61e6; background: #eef0ff !important; box-shadow: 0 0 0 2px rgba(91, 97, 230, .12); }
  .tooth-choice:has(input:checked) .tooth-model { color: #ffffff; filter: drop-shadow(0 5px 6px rgba(63, 69, 177, .22)); }
  .tooth-choice:has(input:checked) .tooth-model-body { stroke: #5b61e6; fill: #cfd3ff; }
  .tooth-choice:has(input:checked) strong { color: #4248b5; }
  .tooth-choice:has(input:checked) .tooth-check { color: #ffffff; background: #5b61e6; }

  .jaw-picker .tooth-choice { min-height: 92px; grid-template-rows: 58px auto; padding: 6px 3px !important; }
  .jaw-picker .tooth-model { width: min(40px, 88%); height: 56px; }
  .tooth-choice.is-missing .tooth-model { opacity: .34; filter: grayscale(1); }
  .tooth-choice.is-missing .missing-mark,
  .plan-tooth.is-missing .plan-tooth-icon::before,
  .plan-tooth.is-missing .plan-tooth-icon::after {
    position: absolute;
    z-index: 2;
    width: 3px;
    border-radius: 3px;
    background: #c94f57;
    content: "";
    transform: rotate(42deg);
  }
  .tooth-choice.is-missing .missing-mark { top: 14px; left: 50%; height: 48px; }
  .tooth-choice.is-missing .missing-mark::after {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: inherit;
    content: "";
    transform: rotate(96deg);
  }

  .payment-target { margin-top: 5px; color: #4147b4 !important; font-weight: 650; }
  .payment-state { margin-top: 5px; color: #9f343c !important; font-weight: 700; }
  .payment-actions .payment-cancel { color: #a23842; }
  .work-payment { display: block; margin-top: 7px !important; color: #4f56c9 !important; font-size: .82rem; }
  .work-payment strong { color: #344054; }
  .work-price span { display: block; margin-top: 6px; color: #4f56c9; font-size: .76rem; font-weight: 700; }

  .tooth-svg {
    --tooth-scale-x: 1;
    width: 34px !important;
    height: 50px !important;
    overflow: visible;
    border: 0 !important;
    border-radius: 0 !important;
    color: #ffffff;
    background: transparent !important;
    filter: drop-shadow(0 3px 4px rgba(23, 32, 51, .13));
    transform: scaleX(var(--tooth-scale-x));
  }
  .tooth-svg .tooth-model-body { fill: currentColor; stroke: #aeb7c5; stroke-width: 1.8; stroke-linejoin: round; }
  .tooth-svg .tooth-model-detail { fill: none; stroke: #d1d7e0; stroke-width: 1.5; stroke-linecap: round; }
  .tooth-svg .tooth-model-shine { fill: none; stroke: #ffffff; stroke-width: 2.5; stroke-linecap: round; }
  .tooth-select[data-tooth-label$="1"] .tooth-svg,
  .tooth-select[data-tooth-label$="2"] .tooth-svg,
  .tooth[data-tooth$="1"] .tooth-svg,
  .tooth[data-tooth$="2"] .tooth-svg { --tooth-scale-x: .74; }
  .tooth-select[data-tooth-label$="3"] .tooth-svg,
  .tooth[data-tooth$="3"] .tooth-svg { --tooth-scale-x: .82; }
  .tooth-select[data-tooth-label$="4"] .tooth-svg,
  .tooth-select[data-tooth-label$="5"] .tooth-svg,
  .tooth[data-tooth$="4"] .tooth-svg,
  .tooth[data-tooth$="5"] .tooth-svg { --tooth-scale-x: .9; }
  .lower-row .tooth-svg,
  .lower-jaw .tooth-svg { transform: scaleX(var(--tooth-scale-x)); }
  .tooth-select { border-color: #dce2ea; background: #ffffff; }
  .tooth-select:hover { border-color: #aeb5ea; background: #f8f9fc; }
  .tooth-checkbox:checked + .tooth-select,
  .tooth-select.is-selected,
  .tooth.is-selected { border-color: #5b61e6; background: #eef0ff; }
  .tooth-checkbox:checked + .tooth-select .tooth-model-body,
  .tooth-select.is-selected .tooth-model-body,
  .tooth.is-selected .tooth-model-body { fill: #cfd3ff; stroke: #5b61e6; }
  .tooth-select.has-finding .tooth-model-body { fill: #eaf7f1; stroke: #24865e; }
  .tooth-select.is-missing .tooth-svg { opacity: .58; }
  .tooth-select.is-missing { position: relative; }
  .tooth-select.is-missing::after { content: "×"; position: absolute; inset: 5px 0 auto; color: #c94f57; font-size: 2rem; line-height: 1; }
  .tooth.is-planned .tooth-model-body { fill: #fff1d8; stroke: #ad7428; }
  .tooth.is-progress .tooth-model-body { fill: #e7ebff; stroke: #6670d9; }
  .tooth.is-done .tooth-model-body { fill: #dff3e9; stroke: #24865e; }

  .surface-picker-field { margin: 0; padding: 0; border: 0; }
  .surface-picker-field legend { margin-bottom: 10px; color: #344054; font-size: .9rem; font-weight: 650; }
  .surface-choice-grid { display: flex !important; flex-wrap: wrap; gap: 8px !important; padding: 0 !important; border: 0 !important; }
  .surface-choice { position: relative; margin: 0 !important; cursor: pointer; }
  .surface-choice input { position: absolute; width: 1px !important; height: 1px !important; opacity: 0; }
  .surface-choice span { display: block; padding: 9px 12px; border: 1px solid #d8dee8; border-radius: 9px; color: #475467; background: #ffffff; font-size: .84rem; font-weight: 600; }
  .surface-choice:has(input:checked) span { color: #4147b4; border-color: #777ce9; background: #eef0ff; box-shadow: 0 0 0 2px rgba(91, 97, 230, .09); }

  .treatment-odontogram { margin-top: 22px; overflow: visible; }
  .odontogram-heading { align-items: center; }
  .odontogram-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 14px 22px 0; color: #667085; font-size: .78rem; }
  .odontogram-legend span { display: inline-flex; align-items: center; gap: 7px; }
  .odontogram-legend i { width: 10px; height: 10px; border: 2px solid #cfd5df; border-radius: 50%; background: #ffffff; }
  .odontogram-legend .legend-planned { border-color: #ad7428; background: #fff1d8; }
  .odontogram-legend .legend-progress { border-color: #6670d9; background: #e7ebff; }
  .odontogram-legend .legend-done { border-color: #24865e; background: #dff3e9; }
  .odontogram-legend .legend-mixed { border-color: #777ce9; background: #f0f0ff; }
  .odontogram-legend .legend-missing { border-color: #c94f57; background: #f7dfe1; }
  .plan-jaws { display: grid; gap: 14px; padding: 16px 22px; }
  .plan-jaw { min-width: 0; padding: 12px; border: 1px solid #e1e6ee; border-radius: 14px; background: #f8f9fc; }
  .plan-jaw-heading { display: grid; grid-template-columns: auto 1fr auto 1fr; align-items: center; gap: 12px; margin-bottom: 9px; color: #667085; font-size: .75rem; }
  .plan-jaw-heading strong { color: #172033; font-size: .92rem; }
  .plan-jaw-heading span:first-of-type { text-align: right; }
  .plan-jaw-heading span:last-child { text-align: left; }
  .plan-jaw-heading i { color: #4f56c9; font-style: normal; font-weight: 700; }
  .plan-jaw-halves { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; }
  .plan-tooth-quadrant { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; min-width: 0; }
  .plan-tooth-quadrant::before { display: none; content: attr(data-side); }
  .plan-tooth {
    position: relative;
    min-width: 0;
    min-height: 82px;
    display: grid;
    grid-template-rows: 54px auto;
    place-items: center;
    gap: 2px;
    padding: 5px 2px 6px;
    border: 1px solid #dce2ea;
    border-radius: 10px;
    color: #667085;
    background: #ffffff;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
  }
  .plan-tooth:hover, .plan-tooth:focus-visible, .plan-tooth.is-active { z-index: 2; border-color: #7177df; outline: 0; box-shadow: 0 7px 18px rgba(50, 57, 117, .14); transform: translateY(-2px); }
  .plan-tooth-icon { position: relative; width: 34px; height: 50px; display: grid; place-items: center; }
  .plan-tooth .tooth-svg { width: 34px !important; height: 50px !important; }
  .plan-tooth strong { color: #475467; font-size: .76rem; }
  .plan-tooth.is-planned { border-color: #e1b573; background: #fff9ef; }
  .plan-tooth.is-progress { border-color: #8d93eb; background: #f2f3ff; }
  .plan-tooth.is-done { border-color: #82bba3; background: #f0faf5; }
  .plan-tooth.is-mixed { border-color: #a5a9e7; background: #f7f7ff; }
  .plan-tooth.is-planned .tooth-model-body { fill: #fff1d8; stroke: #ad7428; }
  .plan-tooth.is-progress .tooth-model-body { fill: #e7ebff; stroke: #6670d9; }
  .plan-tooth.is-done .tooth-model-body { fill: #dff3e9; stroke: #24865e; }
  .plan-tooth.is-mixed .tooth-model-body { fill: #efeffc; stroke: #676dcc; }
  .plan-tooth.is-missing { border-color: #e3b8bc; background: #fbf3f4; }
  .plan-tooth.is-missing .plan-tooth-icon .tooth-svg { opacity: .48; filter: grayscale(1); }
  .plan-tooth.is-missing .plan-tooth-icon::before,
  .plan-tooth.is-missing .plan-tooth-icon::after { top: 2px; left: 16px; height: 46px; }
  .plan-tooth.is-missing .plan-tooth-icon::after { transform: rotate(-42deg); }
  .tooth-work-count { position: absolute; top: 5px; right: 5px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; border-radius: 9px; color: #ffffff; background: #5b61e6; font-size: .65rem; font-weight: 750; }
  .tooth-state-dots { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 3px; }
  .tooth-state-dots i { width: 6px; height: 6px; border-radius: 50%; background: #cfd5df; }
  .tooth-state-dots .is-planned { background: #ad7428; }
  .tooth-state-dots .is-progress { background: #6670d9; }
  .tooth-state-dots .is-done { background: #24865e; }
  .tooth-treatment-preview { min-height: 82px; display: grid; grid-template-columns: minmax(150px, .35fr) 1fr; gap: 20px; margin: 0 22px 18px; padding: 15px 17px; border: 1px solid #dfe4ec; border-radius: 13px; background: #ffffff; }
  .tooth-treatment-preview > div, .tooth-treatment-preview > p { display: grid; align-content: start; gap: 4px; margin: 0; }
  .tooth-treatment-preview span, .tooth-treatment-preview small, .tooth-treatment-preview em { color: #667085; font-size: .78rem; font-style: normal; }
  .tooth-treatment-preview strong { color: #172033; }
  .tooth-treatment-preview b { display: block; color: #344054; }
  .tooth-treatment-preview b + small { display: block; margin: 2px 0 7px; }
  .mouth-wide-works { display: flex; flex-wrap: wrap; gap: 7px 14px; margin: 0 22px 20px; padding: 13px 16px; border-radius: 12px; color: #667085; background: #f5f6fa; font-size: .82rem; }
  .mouth-wide-works strong { width: 100%; color: #344054; }
}

@media screen and (max-width: 900px) {
  .jaw-axis { display: none; }
  .jaw-halves, .plan-jaw-halves { grid-template-columns: 1fr; }
  .tooth-quadrant::before, .plan-tooth-quadrant::before { display: block; grid-column: 1 / -1; color: #667085; font-size: .78rem; font-weight: 650; }
  .plan-jaw-heading { grid-template-columns: 1fr; }
  .plan-jaw-heading span, .plan-jaw-heading i { display: none; }
}

@media screen and (max-width: 760px) {
  .tooth-choice-grid { grid-template-columns: repeat(4, minmax(62px, 1fr)) !important; gap: 8px !important; padding: 10px !important; }
  .tooth-choice { min-height: 104px; }
  .tooth-model { width: 46px; height: 64px; }
  .jaw-section { overflow: visible; padding: 12px; }
  .jaw-title,
  .jaw-halves { min-width: 0; }
  .jaw-halves { grid-template-columns: 1fr; gap: 12px; }
  .tooth-quadrant { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .jaw-picker .tooth-choice { min-height: 96px; grid-template-rows: 60px auto; }
  .odontogram-heading { align-items: flex-start; }
  .plan-jaws, .odontogram-legend { padding-inline: 14px; }
  .tooth-treatment-preview { grid-template-columns: 1fr; gap: 8px; margin-inline: 14px; }
  .mouth-wide-works { margin-inline: 14px; }
}

@media screen and (max-width: 430px) {
  .tooth-choice-grid { grid-template-columns: repeat(4, minmax(54px, 1fr)) !important; gap: 6px !important; padding: 8px !important; }
  .tooth-choice { min-height: 96px; padding-inline: 2px !important; }
  .tooth-model { width: 40px; height: 58px; }
  .tooth-quadrant, .plan-tooth-quadrant { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .plan-tooth { min-height: 86px; }
}

@media screen and (max-width: 700px) {
  .message-stack { top: 78px; }
}

/* Finance analytics, protected removal and compact history. */
.filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid #e0e5ed;
  border-radius: 14px;
  background: #ffffff;
}
.filter-strip a {
  padding: 9px 13px;
  border-radius: 9px;
  color: #667085;
  font-size: .84rem;
  font-weight: 650;
  text-decoration: none;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}
.filter-strip a:hover { color: #344054; background: #f3f4f8; transform: translateY(-1px); }
.filter-strip a.is-active { color: #ffffff; background: #5b61e6; box-shadow: 0 7px 18px rgba(91, 97, 230, .22); }
.dashboard-finance-filter { margin: 16px 22px 0; }
.finance-cards { align-items: stretch; }
.finance-cards > a {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 118px;
  padding: 17px;
  border: 1px solid #e0e5ed;
  border-radius: 14px;
  color: #172033;
  background: #f9fafc;
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.finance-cards > a:hover { transform: translateY(-2px); border-color: #bfc4ef; box-shadow: 0 10px 24px rgba(36, 44, 74, .08); }
.finance-cards > a span { color: #7a8495; font-size: .78rem; }

.history-heading-actions, .archived-plan-actions { display: flex; align-items: center; gap: 12px; }
.history-panel .history-scroll {
  max-height: 430px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
}
.history-panel.is-expanded .history-scroll { max-height: none; overflow: visible; }
.history-scroll::-webkit-scrollbar { width: 10px; }
.history-scroll::-webkit-scrollbar-thumb { border: 3px solid #ffffff; border-radius: 10px; background: #c4cad5; }
.history-toggle { min-width: 104px; padding: 9px 12px; }
.archived-plan-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid #e3e7ee;
  background: #f9fafc;
}
.archived-plan-toolbar .danger-link, .archived-plan-actions .danger-link { color: #ad3842; font-weight: 650; }

.analytics-page { padding-bottom: 80px; }
.analytics-heading { align-items: end; }
.analytics-page > .filter-strip { width: fit-content; margin: 0 0 22px; }
.analytics-balance {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  padding: clamp(24px, 4vw, 42px);
  border-radius: 24px;
  color: #ffffff;
  background: linear-gradient(135deg, #252d5a, #5b61e6 72%, #777ce9);
  box-shadow: 0 20px 46px rgba(41, 47, 110, .2);
}
.analytics-balance::after { content: ""; position: absolute; width: 240px; height: 240px; right: -80px; top: -110px; border-radius: 50%; background: rgba(255,255,255,.12); }
.analytics-balance > * { position: relative; z-index: 1; }
.analytics-balance span, .analytics-balance small { color: rgba(255,255,255,.72); }
.analytics-balance strong { color: #ffffff; font-size: clamp(2.2rem, 6vw, 4.4rem); letter-spacing: -.055em; }
.analytics-balance .money-negative { color: #ffd1d4; }
.analytics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.analytics-grid article {
  display: grid;
  gap: 8px;
  min-height: 142px;
  padding: 20px;
  border: 1px solid #e0e5ed;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(23, 32, 51, .055);
}
.analytics-grid article strong { align-self: end; color: #172033; font-size: 1.45rem; }
.analytics-grid article span { color: #7a8495; font-size: .8rem; }
.analytics-ledger .ledger-filters { margin: 18px 22px 0; }
.bank-ledger { padding: 8px 24px 24px; }
.bank-operation {
  display: grid;
  grid-template-columns: 92px 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 18px 0;
  border-bottom: 1px solid #e8ebf0;
}
.bank-operation:last-child { border-bottom: 0; }
.bank-operation time { color: #7a8495; font-size: .8rem; }
.operation-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: #176b49; background: #eaf7f1; font-size: 1.15rem; }
.operation-refunds .operation-icon, .operation-materials .operation-icon { color: #a23842; background: #fff0f0; }
.bank-operation > div { display: grid; gap: 4px; min-width: 0; }
.bank-operation > div span { overflow: hidden; color: #667085; font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.bank-operation > b { font-size: 1rem; white-space: nowrap; }

.remove-confirmation { max-width: 720px; }
.preservation-note { display: grid; gap: 5px; margin: 24px 0; padding: 18px; border: 1px solid #dfe3eb; border-radius: 14px; background: #f7f8fb; }
.preservation-note span { color: #667085; }
.confirmation-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media screen and (max-width: 900px) {
  .analytics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media screen and (max-width: 620px) {
  .dashboard-finance-filter, .analytics-ledger .ledger-filters { margin-inline: 12px; }
  .history-heading-actions { align-items: flex-end; flex-direction: column; }
  .bank-operation { grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; }
  .bank-operation time { grid-column: 2 / 4; grid-row: 1; }
  .operation-icon { grid-column: 1; grid-row: 1 / 3; }
  .bank-operation > div { grid-column: 2; }
  .bank-operation > b { grid-column: 3; }
  .analytics-grid { grid-template-columns: 1fr; }
  .archived-plan-toolbar, .confirmation-actions { align-items: stretch; flex-direction: column; }
}

/* Catalog workflow and aligned landing/dashboard spacing. */
#materials, #service-templates, [id^="service-"], #practice-finance { scroll-margin-top: 92px; }
.catalog-page .record-heading { margin-top: 24px; margin-bottom: 28px; }
.catalog-section { align-self: start; }
.template-heading { align-items: flex-start; }
.template-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 14px; }
.template-actions a { margin-top: 0; white-space: nowrap; }
.template-actions .danger-link { color: #ad3842; }
.template-list > article { scroll-margin-top: 92px; }
.catalog-actions { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 12px; }
.catalog-actions .danger-link { color: #ad3842; }
.catalog-archive { margin-top: 22px; scroll-margin-top: 92px; }
.catalog-archive > summary,
.catalog-archive-inline > summary { color: #4f56c9; font-weight: 750; cursor: pointer; }
.catalog-archive > summary { padding: 20px 22px; }
.catalog-archive-note { margin: 0; padding: 0 22px 12px; font-size: .84rem; }
.catalog-archive-inline { margin-top: 14px; border-top: 1px solid #e5e8ee; }
.catalog-archive-inline > summary { padding: 13px 0 3px; font-size: .84rem; }
.catalog-archive-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; padding: 0 22px 22px; }
.catalog-archive-columns h2 { margin: 0 0 10px; font-size: 1rem; }
.catalog-archive-list { display: grid; gap: 8px; margin-top: 10px; }
.catalog-archive-list > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 12px; border: 1px solid #e3e7ee; border-radius: 11px; background: #f9fafc; }
.catalog-archive-list form { margin: 0; }
.catalog-archive-list .link-button { color: #4f56c9; font-weight: 700; }
.catalog-archive-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 14px; }
.catalog-archive-actions .danger-link { color: #a23842; font-weight: 650; }
.catalog-archive-list small { text-align: right; }

.finance-overview .panel-heading { padding: 20px 22px; }

.latest-examination-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 26px 0;
  color: #344054;
}
.latest-examination-label span,
.all-examinations summary span {
  padding: 4px 9px;
  border-radius: 999px;
  color: #4f56c9;
  background: #eef0ff;
  font-size: .78rem;
  font-weight: 700;
}
.examination-card { background: #fff; }
.exam-actions .button { min-width: 168px; padding: 10px 13px; }
.all-examinations { border-top: 1px solid #e1e6ee; }
.all-examinations summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px;
  color: #4046ad;
  font-weight: 750;
  cursor: pointer;
  list-style: none;
}
.all-examinations summary::-webkit-details-marker { display: none; }
.all-examinations summary::after { content: "Раскрыть"; color: #667085; font-size: .8rem; font-weight: 600; }
.all-examinations[open] summary::after { content: "Свернуть"; }
.all-examinations[open] summary { border-bottom: 1px solid #e1e6ee; }
.examination-editor-page { scroll-behavior: smooth; }
.examination-teeth-section,
.examination-conclusion { scroll-margin-top: 96px; }
.examination-teeth-section { margin-top: 26px; }
.examination-conclusion { margin-top: 28px; }
.examination-conclusion .account-form { max-width: none; }
.examination-conclusion .account-form textarea { min-height: 150px; }

@media (max-width: 720px) {
  .latest-examination-label { padding: 15px 18px 0; }
  .all-examinations summary { padding: 16px 18px; }
  .exam-actions .button { width: 100%; min-width: 0; }
}
.finance-overview .dashboard-finance-filter { margin: 14px 20px 0; }
.finance-overview .finance-cards { gap: 10px; padding: 10px 20px 20px; }
.finance-overview .finance-cards > a { min-height: 110px; padding: 15px; }

.landing {
  min-height: 100svh;
  width: min(1240px, calc(100% - 64px));
  grid-template-columns: minmax(0, 1.06fr) minmax(430px, .94fr);
  gap: clamp(48px, 6vw, 82px);
  padding: clamp(56px, 9vh, 92px) 0;
}
.landing h1 { max-width: 680px; font-size: clamp(3rem, 5.4vw, 4.9rem); line-height: .98; }
.landing-copy > p { max-width: 600px; margin: 24px 0 30px; line-height: 1.55; }
.landing-chart { padding: 28px; }
.landing-teeth { gap: 5px; padding: 27px 0 24px; }
.landing-tooth { display: grid; justify-items: center; gap: 4px; }
.landing-tooth .tooth-svg {
  width: 44px !important;
  height: 60px !important;
  color: #ffffff;
  transform-origin: center;
  filter: drop-shadow(0 4px 5px rgba(23, 32, 51, .12));
}
.landing-tooth .tooth-model-body { fill: #ffffff; stroke: #aeb7c5; stroke-width: 1.8; }
.landing-tooth .tooth-model-detail { stroke: #d1d7e0; }
.landing-tooth.is-planned .tooth-model-body { fill: #fff1d8; stroke: #ad7428; }
.landing-tooth.is-progress .tooth-model-body { fill: #e7ebff; stroke: #6670d9; }
.landing-tooth.is-done .tooth-model-body { fill: #dff3e9; stroke: #24865e; }
.landing-tooth[data-tooth-label$="1"] .tooth-svg,
.landing-tooth[data-tooth-label$="2"] .tooth-svg { transform: scaleX(.74); }
.landing-tooth[data-tooth-label$="3"] .tooth-svg { transform: scaleX(.82); }
.landing-tooth[data-tooth-label$="4"] .tooth-svg,
.landing-tooth[data-tooth-label$="5"] .tooth-svg { transform: scaleX(.9); }

@media screen and (max-width: 980px) {
  .landing { width: min(100% - 36px, 720px); grid-template-columns: 1fr; gap: 42px; padding-block: 56px; }
  .landing-copy { max-width: 680px; }
}
@media screen and (max-width: 620px) {
  .catalog-page .record-heading { margin-top: 18px; }
  .template-heading, .template-actions { align-items: flex-start; flex-direction: column; }
  .catalog-actions { justify-content: flex-start; }
  .catalog-archive-columns { grid-template-columns: 1fr; padding-inline: 14px; }
  .catalog-archive-note { padding-inline: 14px; }
  .catalog-archive-actions { justify-content: flex-start; }
  .catalog-archive-list > div { align-items: flex-start; flex-direction: column; }
  .catalog-archive-list small { text-align: left; }
  .finance-overview .panel-heading { padding: 18px; }
  .finance-overview .dashboard-finance-filter { margin: 12px 12px 0; }
  .finance-overview .finance-cards { padding: 10px 12px 14px; }
  .landing { width: min(100% - 24px, 520px); padding-block: 38px; }
  .landing h1 { font-size: clamp(2.7rem, 14vw, 4rem); }
  .landing-chart { padding: 20px 16px; }
  .landing-teeth { gap: 1px; padding-block: 22px; }
  .landing-tooth .tooth-svg { width: 36px !important; height: 50px !important; }
}

/* Compact practice dashboard and focused reports. */
#patients, #upcoming-works, #analytics-filters, #overview, #works, #analytics-patients, #operations {
  scroll-margin-top: 84px;
}
.dashboard-intro {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 4px 0 18px;
}
.dashboard-intro a {
  display: grid;
  gap: 8px;
  padding: 20px 22px;
  border: 1px solid #e0e5ed;
  border-radius: 16px;
  color: #172033;
  background: #fff;
  text-decoration: none;
  box-shadow: 0 8px 25px rgba(23, 32, 51, .045);
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.dashboard-intro a:hover { border-color: #9da4df; box-shadow: 0 12px 28px rgba(36, 44, 74, .09); transform: translateY(-2px); }
.dashboard-intro small, .dashboard-intro span { color: #667085; }
.dashboard-intro strong { font-size: clamp(1.5rem, 2.5vw, 2.1rem); letter-spacing: -.04em; }
.dashboard-intro span { font-size: .8rem; }
.dashboard-main-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; gap: 18px; margin-bottom: 18px; }
.dashboard-main-grid .secure-panel { margin: 0; min-width: 0; }
.dashboard-upcoming .secure-list a { gap: 10px; }
.dashboard-upcoming .secure-list b { color: #4f56c9; white-space: nowrap; }
.analytics-section-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.analytics-section-nav a { padding: 8px 12px; border-radius: 10px; color: #4f56c9; background: #eef0ff; font-size: .84rem; font-weight: 700; text-decoration: none; }
.analytics-section-nav a:hover { background: #e0e4ff; }
.analytics-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 0 0 18px; }
.analytics-page .analytics-controls .filter-strip { width: fit-content; margin: 0; }
.analytics-selects { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.analytics-selects label { display: grid; gap: 5px; color: #667085; font-size: .8rem; font-weight: 700; }
.analytics-selects select { min-width: 165px; max-width: 270px; min-height: 43px; padding: 8px 11px; border: 1px solid #d7dfeb; border-radius: 10px; color: #172033; background: #fff; }
.analytics-selects .button { min-height: 43px; }
.analytics-balance { gap: 5px; padding: 22px 26px; border: 1px solid #dfe4ee; border-radius: 16px; color: #172033; background: #fff; box-shadow: 0 8px 25px rgba(23, 32, 51, .045); }
.analytics-balance::after { display: none; }
.analytics-balance span, .analytics-balance small { color: #667085; }
.analytics-balance strong { color: #172033; font-size: clamp(2rem, 4vw, 3.1rem); }
.analytics-balance .money-negative { color: #a23842; }
.analytics-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.analytics-grid article { min-height: 116px; padding: 17px; border-radius: 15px; box-shadow: 0 6px 20px rgba(23, 32, 51, .04); }
.analytics-grid article strong { font-size: 1.28rem; }
.analytics-panel { margin-top: 18px; }
.analytics-table { padding: 4px 22px 14px; }
.analytics-table-head, .analytics-table-row { display: grid; grid-template-columns: minmax(0, 2fr) .55fr .5fr .7fr .6fr 1fr; align-items: center; gap: 12px; padding: 13px 4px; border-bottom: 1px solid #e8ebf0; }
.analytics-table-head { color: #667085; font-size: .78rem; }
.analytics-table-row:last-child { border-bottom: 0; }
.analytics-table-row strong { font-weight: 650; }
.analytics-table-row b { text-align: right; white-space: nowrap; }
.analytics-table-head span:last-child { text-align: right; }
.analytics-scope-note { margin: 14px 22px 0; color: #667085; font-size: .82rem; }
.finance-overview, .analytics-page, #patients { transition: opacity .18s ease; }
.is-filter-updating { opacity: .55; pointer-events: none; }
.study-form-page { width: min(1100px, calc(100% - 48px)); }
.study-form-page .account-form { max-width: none; }
.study-form-page input[type="file"] { width: 100%; min-height: 48px; padding: 10px; border: 1px solid #d7dfeb; border-radius: 10px; background: #fff; }
.study-form-page input[type="file"]::file-selector-button { margin-right: 12px; padding: 9px 14px; border: 1px solid #d7dfeb; border-radius: 8px; color: #38419c; background: #f4f5ff; font: inherit; font-weight: 700; cursor: pointer; }
.study-form-page input[type="file"]::file-selector-button:hover { border-color: #9da4df; background: #e8eaff; }
.doctor-dashboard { padding-top: 44px; }
.doctor-dashboard .record-heading { margin-bottom: 24px; }
.doctor-dashboard .record-heading h1 { font-size: clamp(2.7rem, 4.4vw, 3.9rem); }
.analytics-page { padding-top: 44px; }
@media screen and (max-width: 900px) {
  .dashboard-main-grid { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media screen and (max-width: 620px) {
  .dashboard-intro, .analytics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-intro a:last-child, .analytics-grid article:last-child { grid-column: 1 / -1; }
  .dashboard-intro a, .analytics-grid article { min-height: 0; padding: 14px; }
  .dashboard-intro strong, .analytics-grid article strong { font-size: 1.2rem; overflow-wrap: anywhere; }
  .dashboard-intro span, .analytics-grid article span { font-size: .73rem; }
  .analytics-heading { gap: 12px; }
  .analytics-heading .button { align-self: flex-start; }
  .study-form-page { width: calc(100% - 24px); }
  .analytics-selects, .analytics-selects label, .analytics-selects select { width: 100%; max-width: none; }
  .analytics-table { overflow: visible; padding-inline: 12px; }
  .analytics-table-head { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .analytics-table-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 16px 4px; }
  .analytics-table-row strong, .analytics-table-row b { grid-column: 1 / -1; text-align: left; }
  .analytics-table-row span, .analytics-table-row b { display: grid; gap: 3px; }
  .analytics-table-row span::before, .analytics-table-row b::before { content: attr(data-label); color: #667085; font-size: .73rem; font-weight: 600; }
}
@media (prefers-reduced-motion: reduce) {
  .finance-overview, .analytics-page, #patients { transition: none; }
}

/* Treatment plan workspace: enter a work first, inspect details when needed. */
.plan-detail-page { display: flex; flex-direction: column; gap: 18px; padding-top: 42px; }
.plan-detail-page > .back-link { align-self: flex-start; }
.plan-detail-page > .record-heading { margin: 0; }
.plan-detail-page > .plan-summary { margin: 0; }
.plan-detail-page .plan-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 18px 22px; }
.plan-detail-page .plan-summary strong { overflow-wrap: anywhere; }
.plan-section-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.plan-section-nav a { padding: 9px 13px; border: 1px solid #dfe4ee; border-radius: 10px; color: #424bb4; background: #fff; font-size: .86rem; font-weight: 700; text-decoration: none; }
.plan-section-nav a:hover { background: #eef0ff; }
.plan-entry { margin: 0; }
.plan-detail-page > .open-note { margin: 0; }
.plan-chart-wrap { scroll-margin-top: 82px; }
.plan-detail-page > .payment-panel { margin: 0; scroll-margin-top: 82px; }
.plan-detail-page > .material-summary { margin: 0; }
#plan-add-work, #plan-works { scroll-margin-top: 82px; }
.plan-quick-form, .plan-payment-form { max-width: none; margin: 0; padding: 22px; border: 0; border-top: 1px solid #e4e8ef; border-radius: 0; box-shadow: none; background: #fff; }
.plan-entry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.plan-entry-grid .form-field { min-width: 0; margin: 0; }
.plan-entry-grid .form-field small { display: block; margin-top: 6px; color: #667085; font-size: .78rem; }
.plan-entry-wide { grid-column: 1 / -1; }
.plan-check-field { align-self: center; }
.plan-check-field label { display: flex !important; align-items: center; gap: 9px; }
.plan-check-field input { width: auto !important; }
.plan-form-fold { margin-top: 16px; border: 1px solid #e0e5ed; border-radius: 12px; background: #fff; }
.plan-form-fold > summary, .plan-chart-wrap > summary, .plan-settings > summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 17px; color: #26314b; font-weight: 750; cursor: pointer; list-style: none; }
.plan-form-fold > summary::-webkit-details-marker, .plan-chart-wrap > summary::-webkit-details-marker, .plan-settings > summary::-webkit-details-marker { display: none; }
.plan-form-fold > summary::after, .plan-chart-wrap > summary::after, .plan-settings > summary::after { content: '+'; margin-left: auto; color: #555ddb; font-size: 1.3rem; line-height: 1; }
.plan-form-fold[open] > summary::after, .plan-chart-wrap[open] > summary::after, .plan-settings[open] > summary::after { content: '−'; }
.plan-form-fold > summary span, .plan-chart-wrap > summary span { margin-left: auto; color: #667085; font-size: .8rem; font-weight: 500; }
.plan-form-fold[open] > summary { border-bottom: 1px solid #e4e8ef; }
.plan-form-fold > .plan-entry-grid, .plan-form-fold > .surface-picker-field { margin: 16px; }
.plan-form-fold > .tooth-picker-field { margin: 16px; }
.plan-quick-form .form-actions, .plan-payment-form .form-actions { margin: 18px 0 0; padding: 0; }
.plan-entry-empty { padding: 20px 22px; }
.plan-entry-empty p { margin: 0 0 12px; }
.plan-works-heading { display: flex; align-items: end; justify-content: space-between; gap: 15px; margin: 4px 0 0; }
.plan-works-heading h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2rem); }
.plan-works-heading p { margin: 4px 0 0; color: #667085; font-size: .88rem; }
.plan-chart-wrap, .plan-settings { border: 1px solid #dfe4ee; border-radius: 16px; background: #fff; box-shadow: 0 8px 25px rgba(23,32,51,.04); }
.plan-chart-wrap > summary { padding: 19px 22px; font-size: 1.12rem; }
.plan-chart-wrap > .secure-panel { margin: 0; border: 0; border-top: 1px solid #e4e8ef; border-radius: 0 0 16px 16px; box-shadow: none; }
.plan-tooth-actions { display: flex; justify-content: flex-end; padding: 0 22px 18px; }
.plan-tooth-actions .button:disabled { opacity: .55; cursor: default; }
.plan-balance { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 18px 22px; border-top: 1px solid #e4e8ef; }
.plan-balance div { display: grid; gap: 4px; }
.plan-balance small { color: #667085; }
.plan-balance strong { font-size: clamp(1.05rem, 2vw, 1.35rem); }
.plan-payment-form { padding-top: 4px; }
.plan-finance-details { margin: 0 22px 22px; }
.plan-finance-details > .finance-groups, .plan-finance-details > .payment-ledger { margin: 0 16px 16px; }
.plan-material-facts { margin: 0 16px 16px; color: #667085; font-size: .84rem; }
.plan-settings > .header-actions { padding: 0 17px 17px; flex-wrap: wrap; }
@media (max-width: 700px) {
  .plan-detail-page { gap: 14px; padding-top: 28px; }
  .plan-detail-page .record-heading h1 { font-size: clamp(2rem, 8vw, 2.75rem); }
  .plan-detail-page .plan-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 10px; padding: 16px; }
  .plan-detail-page .plan-summary strong { font-size: 1rem; }
  .plan-entry-grid { grid-template-columns: 1fr; gap: 13px; }
  .plan-entry-wide { grid-column: auto; }
  .plan-quick-form, .plan-payment-form { padding: 16px; }
  .plan-form-fold > summary span, .plan-chart-wrap > summary span { display: none; }
  .plan-works-heading { align-items: stretch; flex-direction: column; }
  .plan-balance { grid-template-columns: repeat(2, 1fr); padding: 16px; }
  .plan-balance div:last-child { grid-column: 1 / -1; }
  .plan-finance-details { margin-inline: 16px; }
  .plan-tooth-actions { padding-inline: 14px; }
  .plan-tooth-actions .button { width: 100%; }
}

/* Treatment plan workspace. One clinical task at a time, with the facts close by. */
.plan-workspace { width: min(1280px, calc(100% - 48px)); padding-top: 32px; color: #1d2738; }
.plan-workspace-header { margin-bottom: 18px; }
.plan-workspace-header > .back-link { display: inline-block; margin-bottom: 20px; }
.plan-workspace-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.plan-workspace-heading > div:first-child { min-width: 0; }
.plan-workspace-heading h1 { max-width: 850px; margin: 7px 0 0; font-size: clamp(2rem, 3.4vw, 3.3rem); line-height: 1.06; letter-spacing: -.045em; overflow-wrap: anywhere; }
.plan-workspace-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0; color: #66758a; font-size: .84rem; }
.plan-workspace-meta > span:first-child { color: #273850; font-weight: 750; }
.plan-management { display: flex; flex-wrap: wrap; gap: 7px 17px; margin-top: 15px; }
.plan-management a { color: #4954bd; font-size: .82rem; font-weight: 700; text-decoration: none; }
.plan-management a:hover, .plan-stage-tools a:hover, .plan-work-actions a:hover { text-decoration: underline; }
.plan-management .is-danger, .plan-stage-tools .is-danger, .plan-work-actions .is-danger { color: #a94747; }
.plan-state { padding: 5px 9px; border-radius: 999px; color: #4751b8; background: #eef0ff; font-weight: 700; }
.plan-workspace-actions, .plan-tab-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.plan-workspace-actions .button { white-space: nowrap; }
.plan-comment { margin-top: 11px; color: #66758a; font-size: .86rem; }
.plan-comment summary { width: fit-content; color: #4f59c5; font-weight: 700; cursor: pointer; }
.plan-comment p { max-width: 760px; margin: 8px 0 0; line-height: 1.5; }
.plan-fact-strip { display: grid; grid-template-columns: 1.3fr repeat(3, 1fr); gap: 0; margin-bottom: 18px; border: 1px solid #dfe5ee; border-radius: 16px; background: #fff; box-shadow: 0 8px 26px rgba(28, 39, 61, .045); }
.plan-fact-strip > div { display: grid; align-content: center; gap: 7px; min-width: 0; padding: 19px 22px; }
.plan-fact-strip > div + div { border-left: 1px solid #e6eaf1; }
.plan-fact-strip small { color: #6d798b; font-size: .77rem; }
.plan-fact-strip strong { font-size: clamp(1rem, 1.65vw, 1.35rem); letter-spacing: -.03em; overflow-wrap: anywhere; }
.plan-fact-strip progress { width: min(100%, 220px); height: 7px; accent-color: #5662d9; }
.plan-workspace-tabs { position: sticky; z-index: 18; top: 8px; display: flex; gap: 4px; width: fit-content; max-width: 100%; margin-bottom: 18px; padding: 5px; border: 1px solid #dfe5ee; border-radius: 13px; background: rgba(255,255,255,.96); box-shadow: 0 9px 28px rgba(25,34,55,.07); backdrop-filter: blur(12px); }
.plan-workspace-tabs button { display: inline-flex; align-items: center; gap: 7px; padding: 11px 16px; border: 0; border-radius: 9px; color: #687589; background: transparent; font: inherit; font-size: .9rem; font-weight: 700; white-space: nowrap; cursor: pointer; }
.plan-workspace-tabs button[aria-selected="true"] { color: #fff; background: #555ee2; }
.plan-workspace-tabs button span { display: inline-grid; place-items: center; min-width: 22px; padding: 2px 5px; border-radius: 999px; color: inherit; background: rgba(255,255,255,.16); font-size: .74rem; }
.plan-workspace-tabs button:not([aria-selected="true"]):hover { color: #3d47a9; background: #eef0ff; }
.plan-workspace-tabs button:focus-visible, .plan-workspace button:focus-visible, .plan-workspace a:focus-visible, .plan-workspace summary:focus-visible { outline: 3px solid #8891f5; outline-offset: 2px; }
.plan-tab-panel[hidden] { display: none !important; }
.plan-tab-panel { min-width: 0; animation: plan-panel-enter .18s ease-out both; }
@keyframes plan-panel-enter { from { opacity: .6; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.plan-tab-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 0 0 14px; }
.plan-tab-heading h2, .plan-chart-intro h2 { margin: 0; font-size: clamp(1.5rem, 2.3vw, 2rem); letter-spacing: -.035em; }
.plan-tab-heading p, .plan-chart-intro p { margin: 5px 0 0; color: #687589; font-size: .86rem; }
.plan-treatment-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(255px, 300px); align-items: start; gap: 18px; }
.plan-treatment-main, .plan-context { display: grid; align-content: start; gap: 14px; min-width: 0; }
.plan-treatment-main > .plan-tab-heading { margin: 0; }
.plan-composer, .plan-stage, .plan-context-card, .plan-ledger, .plan-finance-breakdown { overflow: hidden; border: 1px solid #dfe5ee; border-radius: 15px; background: #fff; box-shadow: 0 8px 24px rgba(27,38,58,.04); }
.plan-composer > summary { display: flex; align-items: center; gap: 12px; padding: 16px 19px; color: #3f49ae; font-size: .96rem; font-weight: 750; cursor: pointer; list-style: none; }
.plan-composer > summary::-webkit-details-marker { display: none; }
.plan-composer > summary span { color: #738095; font-size: .78rem; font-weight: 500; }
.plan-composer > summary::after { content: '+'; margin-left: auto; color: #5962d1; font-size: 1.25rem; }
.plan-composer[open] > summary::after { content: '−'; }
.plan-composer[open] > summary { border-bottom: 1px solid #e7ebf1; }
.plan-composer .plan-quick-form, .plan-composer .plan-payment-form { padding: 19px; }
.plan-stage-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; padding: 16px 19px; border-bottom: 1px solid #e7ebf1; }
.plan-stage-heading small { color: #6d798b; font-size: .75rem; }
.plan-stage-heading h3 { margin: 3px 0 0; font-size: 1.18rem; }
.plan-stage-tools { display: grid; justify-items: end; gap: 8px; max-width: 365px; text-align: right; }
.plan-stage-tools > span { color: #69768b; font-size: .78rem; }
.plan-stage-tools > div { display: flex; flex-wrap: wrap; justify-content: end; gap: 6px 12px; }
.plan-stage-tools button, .plan-stage-tools a { padding: 0; border: 0; color: #4954bd; background: none; font: inherit; font-size: .77rem; font-weight: 700; text-decoration: none; cursor: pointer; }
.plan-stage-note { margin: 0; padding: 12px 19px; border-bottom: 1px solid #e7ebf1; color: #6d798b; font-size: .82rem; }
.plan-work-card + .plan-work-card { border-top: 1px solid #e9edf2; }
.plan-work-main { display: flex; justify-content: space-between; gap: 20px; padding: 17px 19px 10px; }
.plan-work-title { min-width: 0; }
.plan-work-title h4 { margin: 7px 0 3px; font-size: 1rem; line-height: 1.32; }
.plan-work-title p { margin: 0; color: #6a7689; font-size: .84rem; }
.plan-status { display: inline-block; padding: 4px 9px; border-radius: 999px; font-size: .73rem; font-weight: 750; }
.plan-status.is-planned { color: #946020; background: #fff2db; }
.plan-status.is-in_progress { color: #4a56b8; background: #edf0ff; }
.plan-status.is-done { color: #187251; background: #e5f5ec; }
.plan-work-amount { display: grid; align-content: start; gap: 5px; text-align: right; white-space: nowrap; }
.plan-work-amount strong { font-size: 1.06rem; }
.plan-work-amount small { color: #6d798b; font-size: .75rem; }
.plan-work-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 19px 15px; color: #788497; font-size: .78rem; }
.plan-work-actions { display: flex; flex-wrap: wrap; gap: 6px 17px; margin: 0 19px 12px; }
.plan-work-actions a, .plan-text-action { color: #4954bd; font: inherit; font-size: .78rem; font-weight: 750; text-decoration: none; cursor: pointer; }
.plan-status-edit { margin: 0 19px 4px; font-size: .78rem; }
.plan-status-edit > summary { width: fit-content; padding: 0 0 10px; color: #4954bd; font-weight: 750; cursor: pointer; list-style: none; }
.plan-status-edit > summary::-webkit-details-marker { display: none; }
.plan-status-edit > form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 660px; margin: 4px 0 16px; padding: 15px; border: 1px solid #dfe5ee; border-radius: 11px; background: #f8f9fc; }
.plan-status-edit .form-field { display: grid; gap: 5px; min-width: 0; }
.plan-status-edit .form-field:nth-of-type(3) { grid-column: 1 / -1; }
.plan-status-edit .form-field small { color: #718097; }
.plan-status-edit textarea { min-height: 70px; }
.plan-status-hint { grid-column: 1 / -1; margin: 0; color: #687589; line-height: 1.45; }
.plan-status-hint a { color: #4954bd; }
.plan-status-edit .button { width: fit-content; }
.plan-work-details { margin: 0 19px 15px; border-top: 1px solid #e8ebf1; }
.plan-work-details > summary { padding: 10px 0; color: #687589; font-size: .77rem; font-weight: 650; cursor: pointer; }
.plan-work-details-body { display: grid; gap: 9px; padding: 0 0 6px; color: #586579; font-size: .8rem; }
.plan-work-details-body p { margin: 0; }
.plan-work-details-body .work-materials { display: grid; gap: 5px; margin: 0; }
.plan-cancelled { border-top: 1px solid #e8ebf1; color: #66758a; font-size: .81rem; }
.plan-cancelled > summary { padding: 13px 19px; cursor: pointer; }
.plan-cancelled > div { display: grid; gap: 3px; padding: 9px 19px; border-top: 1px solid #eef0f4; }
.plan-cancelled a { width: fit-content; color: #4954bd; font-weight: 700; text-decoration: none; }
.plan-empty { padding: 20px; color: #687589; font-size: .86rem; }
.plan-context { position: sticky; top: 70px; }
.plan-context-card { display: grid; gap: 9px; padding: 18px; }
.plan-context-card h2 { margin: 0 0 4px; font-size: 1rem; }
.plan-context-card small, .plan-context-card p, .plan-context-card span { color: #687589; font-size: .82rem; }
.plan-context-card p { margin: 0; }
.plan-context-card > strong { font-size: .93rem; }
.plan-context-card > a { color: #4b56c2; font-size: .83rem; font-weight: 700; text-decoration: none; }
.plan-attention-row { display: flex; align-items: baseline; gap: 10px; padding-top: 7px; border-top: 1px solid #edf0f3; }
.plan-attention-row strong { white-space: nowrap; font-size: 1rem; }
.plan-tooth-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.plan-tooth-chips span { min-width: 30px; padding: 5px 7px; border-radius: 7px; color: #3e49ab; background: #eef0ff; font-size: .75rem; font-weight: 750; text-align: center; }
.plan-text-action { width: fit-content; padding: 2px 0; border: 0; background: none; font-size: .83rem; }
.plan-chart-intro { margin-bottom: 15px; }
.plan-workspace #plan-chart .treatment-odontogram { margin: 0; }
.plan-finance-grid, .plan-finance-breakdown-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; overflow: hidden; border: 1px solid #dfe5ee; border-radius: 15px; background: #fff; }
.plan-finance-grid { margin-bottom: 16px; }
.plan-finance-grid > div, .plan-finance-breakdown-grid > div { display: grid; gap: 7px; min-width: 0; padding: 18px; }
.plan-finance-grid > div + div { border-left: 1px solid #e7ebf1; }
.plan-finance-grid small, .plan-finance-breakdown-grid small { color: #687589; font-size: .77rem; }
.plan-finance-grid strong, .plan-finance-breakdown-grid strong { font-size: 1.12rem; overflow-wrap: anywhere; }
.plan-payment-composer { margin-bottom: 16px; }
.plan-ledger-heading { display: flex; align-items: center; justify-content: space-between; padding: 16px 19px; border-bottom: 1px solid #e7ebf1; }
.plan-ledger-heading h3 { margin: 0; font-size: 1.05rem; }
.plan-ledger-heading span { color: #687589; font-size: .78rem; }
.plan-ledger-entry { display: flex; justify-content: space-between; gap: 20px; padding: 15px 19px; }
.plan-ledger-entry + .plan-ledger-entry { border-top: 1px solid #e9edf2; }
.plan-ledger-entry > div:first-child { display: grid; gap: 4px; min-width: 0; }
.plan-ledger-entry small, .plan-ledger-entry span { color: #687589; font-size: .78rem; }
.plan-ledger-entry strong { font-size: .91rem; }
.plan-ledger-entry em { color: #a1454e; font-size: .76rem; font-style: normal; }
.plan-ledger-entry p { margin: 0; font-size: .78rem; }
.plan-ledger-amount { display: grid; align-content: start; justify-items: end; gap: 5px; text-align: right; white-space: nowrap; }
.plan-ledger-amount a { color: #4b56c2; font-size: .77rem; text-decoration: none; }
.plan-ledger-entry.is-reversed { opacity: .65; }
.plan-finance-breakdown { margin-top: 16px; }
.plan-finance-breakdown > summary { padding: 16px 19px; color: #4652b7; font-weight: 750; cursor: pointer; }
.plan-finance-breakdown-grid { margin: 0 17px 17px; border-radius: 10px; box-shadow: none; }
.plan-material-list { display: grid; gap: 7px; padding: 0 19px 17px; color: #687589; font-size: .8rem; }
.plan-workspace > .plan-settings { margin-top: 22px; }

@media (max-width: 1050px) {
  .plan-treatment-layout { grid-template-columns: minmax(0, 1fr) 250px; }
  .plan-fact-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-fact-strip > div:nth-child(3) { border-left: 0; border-top: 1px solid #e7ebf1; }
  .plan-fact-strip > div:nth-child(4) { border-top: 1px solid #e7ebf1; }
}
@media (max-width: 820px) {
  .plan-workspace-heading { align-items: stretch; flex-direction: column; }
  .plan-treatment-layout { grid-template-columns: 1fr; }
  .plan-context { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-finance-grid, .plan-finance-breakdown-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-finance-grid > div:nth-child(3) { border-left: 0; border-top: 1px solid #e7ebf1; }
  .plan-finance-grid > div:nth-child(4) { border-top: 1px solid #e7ebf1; }
}
@media (max-width: 600px) {
  .plan-workspace { width: calc(100% - 24px); padding-top: 26px; }
  .plan-workspace-header > .back-link { margin-bottom: 15px; }
  .plan-workspace-heading h1 { font-size: clamp(1.9rem, 7.8vw, 2.6rem); }
  .plan-workspace-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .plan-workspace-actions .button { min-width: 0; padding-inline: 8px; font-size: .81rem; }
  .plan-fact-strip > div { padding: 13px; }
  .plan-fact-strip strong { font-size: .99rem; }
  .plan-workspace-tabs { width: 100%; top: 4px; }
  .plan-workspace-tabs button { flex: 1; justify-content: center; min-width: 0; padding: 10px 5px; font-size: .79rem; }
  .plan-workspace-tabs button span { display: none; }
  .plan-tab-heading { align-items: stretch; flex-direction: column; }
  .plan-tab-actions { display: grid; grid-template-columns: 1fr; }
  .plan-tab-actions .button { min-width: 0; padding-inline: 7px; font-size: .79rem; }
  .plan-context { grid-template-columns: 1fr; }
  .plan-work-main { gap: 10px; padding: 15px 14px 8px; }
  .plan-work-amount { white-space: normal; }
  .plan-work-amount strong { font-size: .91rem; }
  .plan-work-bottom { align-items: flex-start; flex-direction: column; padding: 0 14px 13px; }
  .plan-stage-heading { flex-direction: column; }
  .plan-stage-tools { justify-items: start; max-width: none; text-align: left; }
  .plan-stage-tools > div { justify-content: start; }
  .plan-work-actions { margin-inline: 14px; }
  .plan-status-edit { margin-inline: 14px; }
  .plan-status-edit > form { grid-template-columns: 1fr; }
  .plan-status-edit .form-field:nth-of-type(3) { grid-column: auto; }
  .plan-work-details { margin-inline: 14px; }
  .plan-ledger-entry { padding-inline: 14px; }
  .plan-finance-grid > div { padding: 13px; }
}
@media (prefers-reduced-motion: reduce) { .plan-tab-panel { animation: none; } }
