:root {
  --ink: #12332f;
  --muted: #687c76;
  --green: #07534d;
  --green-dark: #003f3b;
  --lime: #9ecb35;
  --mint: #e2efdf;
  --cream: #eef3ed;
  --paper: #fff;
  --line: #d9e4dd;
  --danger: #a63e32;
  --shadow: 0 20px 55px rgba(0, 55, 49, .13);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 2%, rgba(158, 203, 53, .18), transparent 25rem),
    radial-gradient(circle at 5% 36%, rgba(0, 82, 75, .13), transparent 27rem),
    linear-gradient(145deg, #f4f7f1 0%, #e4eee6 52%, #edf3e9 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.app-shell { max-width: 860px; margin: 0 auto; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px; padding: 14px 20px; border: 1px solid rgba(255,255,255,.08);
  border-radius: 15px;
  background-color: #022a2b;
  background-image: url("logo-chmielewski.png");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: auto 82%;
  box-shadow: 0 13px 32px rgba(0, 52, 47, .18);
}
.brand { display: flex; align-items: center; color: var(--ink); text-decoration: none; }
.brand img { display: block; width: min(360px, 55vw); height: 76px; object-fit: contain; opacity: 0; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.2); border-radius: 50%; color: white; background: rgba(255,255,255,.1); box-shadow: 0 7px 18px rgba(0,30,27,.16); cursor: pointer; }
.icon-btn:hover { background: rgba(158,203,53,.18); }
.icon-btn svg { width: 21px; }

main { padding: 42px 28px 36px; }
.hero { text-align: center; margin-bottom: 34px; }
.eyebrow { margin: 0 0 9px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.hero h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(31px, 7vw, 46px); font-weight: 500; letter-spacing: -.03em; }
.hero > p:last-child { max-width: 510px; margin: 12px auto 0; color: var(--muted); font-size: 14px; line-height: 1.6; }

.steps { display: grid; grid-template-columns: auto 1fr auto 1fr auto 1fr auto; align-items: start; max-width: 570px; margin: 0 auto 34px; }
.steps i { height: 1px; margin: 18px 7px 0; background: var(--line); }
.step { position: relative; display: grid; justify-items: center; gap: 7px; padding: 0; border: 0; color: #8e9994; background: transparent; cursor: pointer; }
.step span { width: 37px; height: 37px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--cream); font-size: 12px; font-weight: 700; }
.step small { font-size: 10px; font-weight: 700; }
.step.active, .step.done { color: var(--green); }
.step.active span { color: white; border-color: var(--green); background: linear-gradient(145deg, var(--green), var(--green-dark)); box-shadow: 0 7px 18px rgba(0,77,70,.28), 0 0 0 3px rgba(158,203,53,.13); }
.step.done span { border-color: var(--green); background: #e3efda; }

#visitForm { border: 1px solid rgba(0, 76, 69, .12); border-radius: 24px; background: rgba(255,255,255,.91); box-shadow: var(--shadow); overflow: hidden; }
.form-step { display: none; padding: 34px; animation: reveal .25s ease; }
.form-step.active { display: block; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } }
.section-heading { display: flex; align-items: center; gap: 14px; padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid var(--line); }
.section-heading p, .dialog-head p { margin: 0 0 4px; color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.section-heading h2, .dialog-head h2 { margin: 0; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.section-icon { width: 43px; height: 43px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 13px; color: var(--green); background: linear-gradient(145deg, #eef6e6, #d8eadf); box-shadow: inset 0 0 0 1px rgba(0,79,71,.06); }
.section-icon svg { width: 22px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 16px; }
.field { position: relative; display: flex; flex-direction: column; gap: 8px; }
.field.full, .field-grid > .full { grid-column: 1 / -1; }
.field > span, .signature-heading p { color: #3b4d48; font-size: 11px; font-weight: 750; letter-spacing: .03em; }
.field b, .signature-heading b { color: var(--danger); }
.field input:not([type="range"]), .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 11px; outline: none;
  color: var(--ink); background: #fcfdfb; padding: 13px 14px; transition: .2s border, .2s box-shadow;
}
.field textarea { min-height: 100px; overflow-y: hidden; resize: none; line-height: 1.5; }
.field input:focus, .field textarea:focus { border-color: #6da593; box-shadow: 0 0 0 3px rgba(65, 135, 116, .1); }
.field input.invalid, .field textarea.invalid { border-color: var(--danger); }
.field em { position: absolute; right: 13px; bottom: 14px; color: var(--muted); font-size: 11px; font-style: normal; }
.field output { position: absolute; right: 0; top: 0; width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--green); font-size: 11px; font-weight: 700; }
input[type="range"] { accent-color: var(--green); height: 42px; }
.icd-field input { text-transform: uppercase; font-weight: 700; letter-spacing: .08em; }
.interview-block {
  min-width: 0; margin: 0; padding: 18px; border: 1px solid var(--line);
  border-radius: 13px; background: #f8faf7;
}
.interview-block legend {
  padding: 0 9px; color: var(--green); font-family: Georgia, serif;
  font-size: 18px; font-weight: 600;
}
.clinical-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.clinical-line { display: grid; grid-template-columns: 95px 1fr; align-items: start; gap: 9px; }
.clinical-line.full { grid-column: 1 / -1; }
.clinical-line strong { padding-top: 13px; color: var(--ink); font-size: 11px; line-height: 1.3; }
.clinical-line strong b, .check b i { color: var(--danger); font-style: normal; }
.clinical-line textarea, .clinical-line input {
  min-height: 92px; width: 100%; padding: 13px 14px; border: 1px solid var(--line);
  border-radius: 10px; outline: none; color: var(--ink); background: white; line-height: 1.5; resize: none;
}
.clinical-line textarea { overflow-y: hidden; }
.clinical-line input { min-height: 45px; resize: none; }
.clinical-line textarea:focus, .clinical-line input:focus { border-color: #6da593; box-shadow: 0 0 0 3px rgba(65, 135, 116, .1); }
.clinical-line textarea.invalid { border-color: var(--danger); }
.history-line { grid-template-columns: 68px 1fr; }
.special-questions { padding-bottom: 9px; }
.special-list { display: grid; grid-template-columns: 1fr; }
.special-list label {
  display: grid; grid-template-columns: minmax(190px, .8fr) 1.2fr; align-items: center;
  gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line);
}
.special-list span { color: #3b4d48; font-size: 10px; font-weight: 700; line-height: 1.25; }
.special-list input {
  min-width: 0; width: 100%; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; outline: none; color: var(--ink); background: white; font-size: 10px;
}
.special-list input:focus { border-color: #6da593; box-shadow: 0 0 0 3px rgba(65, 135, 116, .1); }
.template-picker {
  padding: 17px 18px; border: 1px solid rgba(0, 76, 69, .13);
  border-radius: 13px; background: linear-gradient(145deg, #f3f8ef, #edf5ef);
}
.template-picker > label { display: block; margin-bottom: 9px; color: #3b4d48; font-size: 11px; font-weight: 750; }
.template-picker > div { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.template-picker select {
  min-width: 0; width: 100%; padding: 12px 38px 12px 13px; border: 1px solid var(--line);
  border-radius: 9px; outline: none; color: var(--ink); background: white; font-size: 11px;
}
.template-picker select:focus { border-color: #6da593; box-shadow: 0 0 0 3px rgba(65, 135, 116, .1); }
.template-picker button {
  padding: 0 17px; border: 0; border-radius: 9px; color: white;
  background: var(--green); font-size: 10px; font-weight: 750; cursor: pointer;
}
.template-picker button:hover { background: var(--green-dark); }
.template-picker small { display: block; margin-top: 8px; color: var(--muted); font-size: 9px; }

.consent-card, .signature-card { margin-bottom: 18px; padding: 21px; border: 1px solid var(--line); border-radius: 15px; background: #fdfdfb; }
.consent-title { display: flex; align-items: center; gap: 10px; }
.consent-title > span { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 8px; color: var(--green-dark); background: #e2efd7; font-size: 9px; font-weight: 800; }
.consent-title h3 { margin: 0; font-family: Georgia, serif; font-size: 17px; font-weight: 600; }
.legal-copy { margin: 15px 0; padding: 14px; border-radius: 9px; color: #566762; background: #f3f5f1; font-size: 10px; line-height: 1.6; }
.legal-copy p { margin: 0 0 7px; }
.legal-copy p:last-child { margin: 0; }
.regulations-copy, .rodo-copy { padding: 17px 18px; }
.regulations-copy, .acupuncture-copy { max-height: 330px; overflow-y: auto; scrollbar-color: #8eb4a7 #e8ede9; }
.regulations-copy h4, .rodo-copy h4, .acupuncture-copy h4 { margin: 0 0 13px; color: var(--ink); font-family: Georgia, serif; font-size: 14px; }
.regulations-copy ol, .rodo-copy ol { margin: 0; padding-left: 22px; }
.regulations-copy li, .rodo-copy li { margin-bottom: 10px; padding-left: 3px; }
.regulations-copy li:last-child, .rodo-copy li:last-child { margin-bottom: 0; }
.acupuncture-copy { padding: 17px 18px; }
.acupuncture-copy h5 { margin: 14px 0 6px; color: var(--green-dark); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.optional-consent { border-color: rgba(158, 203, 53, .42); }
.optional-badge {
  display: inline-block; margin: 13px 0 0; padding: 6px 9px; border-radius: 20px;
  color: var(--green-dark); background: #e9f2d4; font-size: 9px; font-weight: 750;
}
.check { display: grid; grid-template-columns: 20px 1fr; align-items: center; gap: 10px; cursor: pointer; }
.check input { position: absolute; opacity: 0; }
.check span { width: 20px; height: 20px; display: grid; place-items: center; border: 1px solid #acb8b2; border-radius: 5px; }
.check input:checked + span { border-color: var(--green); background: var(--green); }
.check input:checked + span::after { content: "✓"; color: white; font-size: 13px; font-weight: 800; }
.check b { font-size: 11px; font-weight: 650; }
.signature-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.signature-heading p { margin: 0 0 4px; }
.signature-heading small { color: var(--muted); font-size: 10px; }
.signature-heading button { border: 0; color: var(--green); background: none; font-size: 10px; font-weight: 750; cursor: pointer; }
.canvas-wrap { position: relative; height: 160px; border: 1px dashed #9caaa5; border-radius: 10px; background: white; overflow: hidden; }
#signatureCanvas { width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.sign-hint { position: absolute; left: 12%; right: 12%; bottom: 20px; padding-bottom: 5px; border-bottom: 1px solid #d7ddda; color: #adb6b2; text-align: center; font-family: Georgia, serif; font-size: 10px; pointer-events: none; }
.signature-note { display: flex; align-items: center; gap: 7px; margin: 11px 0 0; color: var(--muted); font-size: 9px; }
.signature-note svg { width: 14px; }

.validation-message { display: none; margin: 0 34px 18px; padding: 11px 14px; border-radius: 9px; color: var(--danger); background: #fff0ed; font-size: 11px; }
.validation-message.visible { display: block; }
.form-actions { display: flex; justify-content: space-between; gap: 12px; padding: 20px 34px; border-top: 1px solid var(--line); background: #fafbf8; }
.btn { min-height: 45px; padding: 0 22px; border: 1px solid transparent; border-radius: 10px; font-size: 11px; font-weight: 750; letter-spacing: .02em; cursor: pointer; transition: .2s transform, .2s background; }
.btn:active { transform: translateY(1px); }
.btn.primary { color: white; background: linear-gradient(135deg, var(--green), var(--green-dark)); box-shadow: 0 9px 20px rgba(0,72,65,.22); }
.btn.primary:hover { background: linear-gradient(135deg, #0a645b, var(--green-dark)); }
.btn.secondary { border-color: var(--line); background: white; }
.btn.wide { width: 100%; margin-top: 10px; }
#prevButton { visibility: hidden; }
.finish { display: none; }
.privacy-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 20px 0 0; color: var(--muted); font-size: 9px; }
.privacy-note svg { width: 13px; }

dialog { width: min(560px, calc(100% - 24px)); max-height: calc(100vh - 28px); padding: 0; border: 0; border-radius: 20px; color: var(--ink); background: var(--paper); box-shadow: 0 25px 80px rgba(14,42,34,.25); overflow: auto; }
dialog::backdrop { background: rgba(20,43,37,.48); backdrop-filter: blur(3px); }
.dialog-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 23px 25px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); }
.dialog-head > button { margin-left: auto; border: 0; color: var(--muted); background: none; font-size: 27px; cursor: pointer; }
.success-head > span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--green); font-weight: 800; }
.dialog-body { padding: 24px; }
.summary-card { padding: 18px; border-radius: 13px; background: #f5f6f2; }
.summary-card h3 { margin: 0 0 5px; font-family: Georgia, serif; font-size: 20px; }
.summary-card p { margin: 3px 0; color: var(--muted); font-size: 11px; }
.summary-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin: 17px 0 0; }
.summary-card dt { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.summary-card dd { margin: 3px 0 0; font-size: 11px; font-weight: 700; }
.send-info { display: flex; align-items: center; gap: 12px; margin: 15px 0 5px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; }
.send-info svg { width: 22px; color: var(--green); }
.send-info small { display: block; color: var(--muted); font-size: 9px; }
.send-info strong { font-size: 11px; }
.helper { margin: 12px 2px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.text-button { display: block; margin: 18px auto 0; border: 0; color: var(--green); background: none; font-size: 11px; font-weight: 750; cursor: pointer; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.history-item:first-child { padding-top: 0; }
.history-item h3 { margin: 0 0 4px; font-size: 13px; }
.history-item p { margin: 0; color: var(--muted); font-size: 10px; }
.history-item button { border: 0; color: var(--green); background: transparent; font-size: 10px; font-weight: 700; cursor: pointer; }
.empty { padding: 30px 10px; color: var(--muted); text-align: center; font-size: 12px; }
#printDocument { display: none; }
.document-preview {
  display: none; position: fixed; z-index: 100; inset: 0; overflow-y: auto;
  padding: 78px 14px 30px; background: #dfe9e1;
}
.document-preview.active { display: block; }
.preview-toolbar {
  position: fixed; z-index: 101; top: 0; left: 0; right: 0;
  display: flex; justify-content: center; gap: 10px; padding: 10px;
  background: #022a2b; box-shadow: 0 5px 18px rgba(0,0,0,.18);
}
.preview-paper {
  max-width: 794px; margin: 0 auto; padding: 32px; color: #172b26;
  background: white; box-shadow: 0 12px 40px rgba(0,42,43,.15); font-family: Arial, sans-serif;
}
.preview-paper .print-header { display: flex; justify-content: space-between; align-items: end; padding-bottom: 18px; border-bottom: 2px solid #246b5b; }
.preview-paper .print-header img { width: 290px; height: 100px; object-fit: contain; object-position: left center; }
.preview-paper .print-header aside { text-align: right; font-size: 11px; }
.preview-paper .print-section { padding: 17px 0; border-bottom: 1px solid #dfe5e0; }
.preview-paper .print-section h2 { margin: 0 0 10px; color: #246b5b; font-size: 15px; text-transform: uppercase; }
.preview-paper .print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.preview-paper .print-field span { display: block; margin-bottom: 3px; color: #6f7e78; font-size: 10px; text-transform: uppercase; }
.preview-paper .print-field p { margin: 0; font-size: 12px; line-height: 1.45; white-space: pre-wrap; }
.preview-paper .print-field.full { grid-column: 1 / -1; }
.preview-paper .print-consent, .preview-paper .print-regulations li, .preview-paper .print-regulations p { font-size: 11px; line-height: 1.45; }
.preview-paper .print-final-consent { break-inside: avoid; page-break-inside: avoid; }
.preview-paper .print-signature { width: 250px; height: 100px; object-fit: contain; object-position: left bottom; border-bottom: 1px solid #777; }
.preview-paper .print-footer { margin-top: 18px; color: #6f7e78; font-size: 10px; text-align: center; }
body.preview-open { overflow: hidden; }

@media (max-width: 600px) {
  .topbar { margin: 8px 8px 0; padding: 10px 12px; border-radius: 12px; }
  .brand img { width: 250px; max-width: 68vw; height: 58px; }
  main { padding: 27px 12px 24px; }
  .hero { margin-bottom: 26px; }
  .steps { margin-bottom: 25px; }
  .steps i { margin-left: 3px; margin-right: 3px; }
  .step small { display: none; }
  .form-step { padding: 23px 18px; }
  .field-grid { grid-template-columns: 1fr; }
  .field.full, .field-grid > .full { grid-column: auto; }
  .clinical-grid, .special-list { grid-template-columns: 1fr; }
  .clinical-line, .history-line { grid-template-columns: 1fr; gap: 4px; }
  .clinical-line strong { padding-top: 0; }
  .special-list label { grid-template-columns: minmax(115px, .85fr) 1.15fr; }
  .template-picker > div { grid-template-columns: 1fr; }
  .template-picker button { min-height: 42px; }
  .signature-card { padding: 16px; }
  .canvas-wrap {
    width: min(100%, 360px);
    height: 70svh;
    min-height: 480px;
    max-height: 680px;
    margin: 0 auto;
  }
  .sign-hint {
    left: 15%;
    right: 15%;
    bottom: 28px;
  }
  .form-actions { padding: 16px 18px; }
  .validation-message { margin-left: 18px; margin-right: 18px; }
  .btn { padding: 0 17px; }
  .document-preview { padding: 76px 7px 20px; }
  .preview-toolbar .btn { min-height: 46px; padding: 0 13px; }
  .preview-paper { padding: 18px 14px; }
  .preview-paper .print-header { align-items: start; gap: 7px; }
  .preview-paper .print-header img { width: 185px; height: 72px; }
  .preview-paper .print-grid { grid-template-columns: 1fr; }
  .preview-paper .print-field.full { grid-column: auto; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: white; }
  .app-shell, dialog, .preview-toolbar { display: none !important; }
  .document-preview.active { position: static; display: block; overflow: visible; padding: 0; background: white; }
  .document-preview.active .preview-paper { max-width: none; margin: 0; padding: 0; box-shadow: none; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .document-preview:not(.active) { display: none !important; }
  #printDocument { display: none !important; }
  .print-header { display: flex; justify-content: space-between; align-items: end; padding-bottom: 18px; border-bottom: 2px solid #246b5b; }
  .print-header img { width: 290px; height: 100px; object-fit: contain; object-position: left center; border-radius: 7px; }
  .print-header aside { text-align: right; font-size: 9px; }
  .print-section { break-inside: avoid; padding: 17px 0; border-bottom: 1px solid #dfe5e0; }
  .print-section h2 { margin: 0 0 10px; color: #246b5b; font-size: 13px; text-transform: uppercase; }
  .print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
  .print-field span { display: block; margin-bottom: 3px; color: #6f7e78; font-size: 8px; text-transform: uppercase; }
  .print-field strong, .print-field p { margin: 0; font-size: 10px; line-height: 1.45; }
  .print-field.full { grid-column: 1 / -1; }
  .print-consent { margin: 8px 0; font-size: 9px; line-height: 1.45; }
  .print-consents-start { break-before: page; page-break-before: always; }
  .print-regulations { break-inside: auto; }
  .print-final-consent { break-inside: avoid; page-break-inside: avoid; }
  .print-regulations ol { margin: 0; padding-left: 18px; }
  .print-regulations li { break-inside: avoid; margin-bottom: 6px; font-size: 8px; line-height: 1.4; }
  .print-signature { width: 250px; height: 100px; object-fit: contain; object-position: left bottom; border-bottom: 1px solid #777; }
  .print-footer { margin-top: 18px; color: #6f7e78; font-size: 8px; text-align: center; }
}
