:root {
  font-family: "DM Sans", system-ui, sans-serif;
  color: #203f3b;
  background: #f5f7f7;
  --teal: #20695e;
  --line: #e0e8e5;
  --muted: #667b77;
}
* { box-sizing: border-box; }
body { margin: 0; display: grid; grid-template-columns: 238px minmax(0,1fr); min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 8px; padding: 11px 16px; font-weight: 600; }
button:focus-visible, a:focus-visible { outline: 3px solid #c3a46e; outline-offset: 3px; }
aside { background: #fff; border-right: 1px solid var(--line); padding: 36px 22px; display: flex; flex-direction: column; }
.brand { color: #173e38; display: flex; gap: 10px; align-items: center; text-decoration: none; font-size: 24px; font-weight: 700; }
.brand-icon { background: #e3eee8; border-radius: 12px; padding: 7px 12px; font-size: 28px; color: #3c7c68; }
.brand-light { font-weight: 400; }
.brand small { display: block; font-size: 10px; letter-spacing: .13em; margin-top: 3px; }
.nav-label { color: var(--muted); letter-spacing: .12em; font-size: 11px; margin: 46px 12px 18px; }
nav { display: grid; gap: 8px; }
nav button { background: transparent; text-align: left; color: #657570; display: flex; align-items: center; gap: 12px; }
nav button span { font-size: 23px; width: 25px; text-align: center; }
nav button.active { background: #e9f1ec; color: #175447; }
nav button:hover { background: #f1f5f2; }
footer { margin-top: auto; padding: 35px 7px 0; font-size: 13px; }
footer p { font-size: 12px; line-height: 1.8; }
main { min-width: 0; padding: 0 clamp(20px,4vw,58px) 24px; max-width: 1600px; width: 100%; margin: auto; }
.top { min-height: 88px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); font-size: 12px; letter-spacing: .1em; }
.account { display: flex; align-items: center; gap: 9px; font-size: 13px; letter-spacing: 0; }
.account-icon { background: #e1ece6; border-radius: 50%; padding: 10px; color: #235f52; }
.heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 30px 0 22px; flex-wrap: wrap; }
h1 { font-size: 30px; letter-spacing: -.04em; margin: 0 0 6px; font-weight: 600; }
h2 { font-size: 19px; margin: 0 0 14px; }
h3 { font-size: 16px; margin: 0 0 7px; }
p { color: var(--muted); line-height: 1.6; margin: 5px 0; overflow-wrap: anywhere; }
.primary { background: var(--teal); color: white; }
.primary:hover { background: #174f46; }
.outline { border: 1px solid #cfded6; background: white; color: #285b50; }
.quiet { background: #edf3ef; color: #355f52; }
.hero { min-height: 320px; padding: 40px; border-radius: 18px; position: relative; overflow: hidden; color: white; background: #1b5149; display: flex; align-items: center; margin-bottom: 25px; }
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(6px); transform: scale(1.08); }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg,#103e39e8 0%,#163e36bc 38%,#143d2820 78%); }
.hero-copy { position: relative; z-index: 1; max-width: 440px; }
.hero .eyebrow { color: #d4e5d8; font-size: 12px; letter-spacing: .14em; }
.hero h2 { font-family: "Instrument Serif", Georgia, serif; font-weight: 400; font-size: clamp(36px,4vw,55px); line-height: 1.04; margin: 14px 0; }
.hero p { color: #e2ebe3; font-size: 15px; }
.hero .controls { margin-top: 24px; }
.hero .outline { background: #f5f7ed; }
.grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 15px; margin-bottom: 25px; }
.card,.panel { background: white; border: 1px solid var(--line); border-radius: 13px; padding: 23px; }
.card strong { display: block; font-size: 29px; margin-top: 12px; font-weight: 600; letter-spacing: -.04em; }
.meta { color: var(--muted); font-size: 14px; }
.panel { margin-bottom: 20px; }
.row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; border-top: 1px solid var(--line); padding: 17px 0; }
.row:first-child { border-top: 0; }
.row:last-child { padding-bottom: 0; }
.row small { display: block; color: var(--muted); margin-top: 5px; font-size: 13px; }
.row b { overflow-wrap: anywhere; }
.controls,.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions { justify-content: flex-end; margin-top: 20px; }
.notice { font-size: 12px; }
.pill { padding: 5px 10px; border-radius: 30px; background: #e5f1e8; color: #285943; font-size: 12px; white-space: nowrap; }
.pill.pending { background: #fff1d7; color: #8a6025; }
input,select,textarea { width: 100%; padding: 11px; border: 1px solid #cbd9d2; border-radius: 7px; background: white; color: #203f3b; }
select { appearance: none; background-image: linear-gradient(45deg,transparent 50%,#54776b 50%),linear-gradient(135deg,#54776b 50%,transparent 50%); background-position: calc(100% - 17px) 50%,calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
textarea { min-height: 100px; resize: vertical; }
label { font-size: 14px; font-weight: 500; display: grid; gap: 7px; margin-bottom: 14px; }
.search { margin-bottom: 18px; max-width: 460px; }
dialog { width: min(640px,calc(100% - 28px)); max-height: 93vh; border: 1px solid var(--line); border-radius: 16px; padding: 25px; color: inherit; }
dialog::backdrop { background: #153f37a8; backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; }
#error { color: #a23b30; }
#toast:not(:empty) { position: fixed; bottom: 20px; right: 20px; padding: 14px 22px; background: #174c40; color: white; border-radius: 8px; z-index: 10; }
.preserve { white-space: pre-wrap; }
.record-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.record-grid .panel { margin-bottom: 0; }
.details { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.details small { color: var(--muted); display: block; margin-bottom: 5px; }
.detail-wide { grid-column: 1/-1; }
.back { margin-top: 22px; }
.procedure-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 18px; }
.procedure-icon { font-size: 27px; color: #a28a57; margin-bottom: 12px; }
.chart-wrap { overflow: auto; }
.arch { min-width: 850px; max-width: 1000px; margin: auto; position: relative; height: 260px; }
.tooth { position: absolute; width: 49px; height: 76px; padding: 2px; background: transparent; color: #6e8580; transform: translateX(-50%); }
.tooth svg { display: block; width: 38px; height: 47px; margin: auto; fill: #fafcfb; stroke: #9bb6ac; stroke-width: 1.6; filter: drop-shadow(0 2px 2px #35665315); }
.tooth:hover svg { fill: #d8ede1; stroke: #176451; }
.tooth.complete svg { fill: #c5e7d2; stroke: #226649; }
.tooth.planned svg { fill: #ffe5b6; stroke: #a47932; }
.tooth.progress svg { fill: #d3e8f7; stroke: #5484a0; }
.tooth strong { font-size: 13px; font-weight: 500; }
.arch-caption { position: absolute; left: 35%; right: 35%; top: 6%; text-align: center; color: var(--muted); font-size: 14px; }
.arch.lower .arch-caption { top: 86%; }
.chart-sides,.legend { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.legend { justify-content: center; flex-wrap: wrap; margin-top: 15px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--dot,#e5ece8); }
.tooth-info { font-size: 14px; border-left: 3px solid #bda26b; padding: 12px; background: #f6f8f4; margin-bottom: 18px; }
.signature-pad { display: block; border: 1px dashed #9bb2a7; border-radius: 8px; width: 100%; height: 150px; background: #fff; touch-action: none; }
.signature-image { display: block; max-width: 250px; height: 70px; object-fit: contain; object-position: left; }
.signature-note { font-size: 12px; }
.signature-block { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 12px; }
.visit-body { flex: 1; min-width: 220px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media(max-width:1050px) {
  body { grid-template-columns: 200px minmax(0,1fr); }
  .grid { grid-template-columns: repeat(2,1fr); }
  .brand { font-size: 20px; }
  .record-grid { grid-template-columns: 1fr; }
}
@media(max-width:700px) {
  body { display: block; }
  aside { padding: 16px; gap: 12px; }
  .nav-label,footer { display: none; }
  nav { display: flex; overflow-x: auto; gap: 4px; }
  nav button { white-space: nowrap; padding: 8px 10px; font-size: 13px; }
  nav button span { font-size: 18px; width: auto; }
  .brand small { font-size: 9px; }
  .top { min-height: 65px; }
  .top>span { display: none; }
  .hero { padding: 26px; min-height: 330px; }
  .hero-copy { max-width: 280px; }
  .heading { margin-top: 22px; }
  .card,.panel { padding: 17px; }
  .details,.field-row { grid-template-columns: 1fr; }
  .chart-wrap { margin: 0 -10px; }
}
@media print {
  @page { margin: 15mm; }
  body { display: block; background: white; color: black; }
  aside,.top,.notice,.back,.controls,button,.chart-wrap,.legend,.chart-sides { display: none!important; }
  main { max-width: none; padding: 0; }
  .panel { break-inside: auto; }
  .row { break-inside: avoid; }
  .record-grid { display: block; }
  .panel { border-radius: 0; }
}
.profile-logo { width: auto; max-width: 200px; max-height: 90px; object-fit: contain; margin-bottom: 12px; }
.document-sheet { background: white; max-width: 840px; margin: auto; padding: 45px; border: 1px solid var(--line); border-radius: 10px; }
.document-brand { display: flex; gap: 24px; align-items: center; padding-bottom: 22px; border-bottom: 2px solid #396859; margin-bottom: 25px; }
.document-brand p { font-size: 13px; }
.document-sheet h1 { font-size: 25px; text-align: center; margin: 32px 0; }
.patient-doc { padding: 18px; background: #f4f7f5; }
.document-text { color: #263b35; margin: 35px 0; line-height: 1.9; }
.document-signature { margin: 40px 0 25px; padding-top: 20px; border-top: 1px solid var(--line); }
.document-footer { margin-top: 20px; padding: 20px 0; display: flex; align-items: center; gap: 18px; border-top: 1px solid var(--line); font-size: 13px; }
.qr-code { flex-shrink: 0; }
.qr-code svg { width: 110px; height: 110px; }
.doc-code { overflow-wrap: anywhere; font-family: monospace; }
button:disabled { cursor: wait; opacity: .6; }
@media(max-width:700px) { .document-sheet { padding: 18px; } .document-brand { flex-direction: column; align-items: flex-start; } .document-footer { flex-wrap: wrap; } }
@media print {
 .document-sheet { padding: 0; border: 0; max-width: none; }
 .document-footer { display: flex!important; }
 .patient-doc { background: white; }
 .heading { display: none; }
 .document-brand { break-inside: avoid; }
 .document-signature,.document-footer { break-inside: avoid; }
}
.plan-banner { border-radius: 13px; background: #184b40; color: white; padding: 25px; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.plan-banner h2 { margin-bottom: 5px; }
.plan-banner p { color: #dae7de; }
.plan-banner strong { font-size: 32px; }
@media(max-width:600px) { .plan-banner { flex-wrap: wrap; } }

.brand { gap: 8px; font-size: 18px; letter-spacing: -.04em; }
.brand-icon { padding: 5px 8px; font-size: 24px; }
.brand small { letter-spacing: .08em; font-size: 9px; }
@media (min-width:701px) and (max-width:1050px) { .brand { font-size: 15px; } .brand-icon { padding: 4px; } }
.auth-loading aside,.auth-loading main { visibility: hidden; }
.auth-screen { display: block; }
.auth-screen aside,.auth-screen .top,.auth-screen .notice { display: none; }
.auth-screen main { padding: 0; margin: 0; max-width: none; }
.auth-shell { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.auth-photo { position: relative; background: #133f37; min-height: 600px; overflow: hidden; }
.auth-photo img { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; filter: blur(6px); transform: scale(1.08); }
.auth-photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg,#133d3b45,#0b3632eb); }
.auth-photo-copy { position: relative; z-index: 1; color: white; padding: 60px; min-height: 100vh; display: flex; flex-direction: column; justify-content: flex-end; }
.auth-brand { font-size: 24px; font-weight: 600; color: white; text-decoration: none; }
.auth-photo-copy .auth-brand { position: absolute; top: 50px; }
.auth-photo-copy h1 { font-family: "Instrument Serif",Georgia,serif; font-size: clamp(36px,4.5vw,64px); font-weight: 400; line-height: 1.07; margin: 35px 0 20px; }
.auth-photo-copy p { color: #e2eae3; font-size: 18px; max-width: 440px; margin-bottom: 30px; }
.auth-photo-copy span { color: #e3dfc1; font-size: 15px; }
.auth-brand.dark { color: #184b40; display: block; margin-bottom: 32px; }
.auth-card { background: #fff; padding: 45px clamp(25px,5vw,85px); display: flex; flex-direction: column; justify-content: center; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 30px; }
.auth-card h1 { font-size: 30px; line-height: 1.15; margin-bottom: 12px; }
.auth-card form { margin-top: 22px; }
.auth-submit { width: 100%; margin-top: 8px; }
.auth-bottom { font-size: 13px; margin-top: 22px; }
.admin-access { font-size: 12px; color: #647d70; margin-top: 25px; }
#auth-error,#plan-error { color: #a3312b; margin: 10px 0; }
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(260px,1fr)); gap: 22px; max-width: 1000px; margin: 32px auto; }
.plan-option { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 30px; display: flex; flex-direction: column; gap: 16px; }
.plan-option .eyebrow { font-size: 12px; color: #53766a; letter-spacing: .1em; }
.plan-option h2 { font-size: 23px; margin: 0; }
.plan-option.featured { border: 2px solid #2c715d; box-shadow: 0 12px 30px #285d4610; }
.plan-price { font-size: 36px; color: #225b4b; font-weight: 600; letter-spacing: -.04em; }
.plan-price span { font-size: 16px; letter-spacing: 0; font-weight: 400; }
.plan-option ul { padding-left: 20px; line-height: 2; color: var(--muted); }
.plan-option button { margin-top: auto; }
.trial-summary { display: block; font-size: 11px; color: #6c7e72; margin-top: 3px; }
[hidden] { display: none!important; }
@media(max-width:850px) {
 .auth-shell { grid-template-columns: 1fr; }
 .auth-photo { min-height: 260px; }
 .auth-photo-copy { min-height: 300px; padding: 25px; justify-content: flex-end; }
 .auth-photo-copy .auth-brand { top: 25px; font-size: 19px; }
 .auth-photo-copy h1 { font-size: 34px; margin-top: 65px; }
 .auth-photo-copy p { display: none; }
 .auth-card { padding: 32px 25px; }
 .auth-card .auth-brand { display: none; }
 .plans-grid { grid-template-columns: 1fr; }
}
.form-section-title { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.anamnesis-question { background: #f5f8f6; border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.anamnesis-question label:last-child { margin-bottom: 0; }
.faces { border: 1px solid var(--line); border-radius: 8px; padding: 13px; margin: 0 0 18px; display: flex; flex-wrap: wrap; gap: 12px; }
.faces legend { font-size: 14px; }
.faces label { display: flex; align-items: center; gap: 7px; font-size: 13px; margin: 0; }
.faces input { width: 16px; height: 16px; }
.tooth.missing svg { opacity: .4; }
.tooth.missing::after { content: "×"; font-size: 40px; color: #8d514c; position: absolute; left: 12px; top: 10px; }
.account { flex-wrap: wrap; max-width: 100%; }
.account-name { min-width: 0; max-width: 220px; overflow-wrap: anywhere; }
.account button { white-space: nowrap; font-size: 12px; padding: 9px 11px; }
@media(max-width:700px) { .top { padding: 12px 0; } .account-name { max-width: 145px; } .account-icon { padding: 8px; } }
.button-link { display: inline-block; border: 1px solid #cfded6; background: white; color: #285b50; padding: 11px 16px; border-radius: 8px; text-decoration: none; font-weight: 600; }
#external-signed-pdf { margin-top: 12px; }
#digital-signature-error { color: #a3312b; }
#digital-signature-result { color: #20634b; }
