:root {
  --bg: #f4f6f9; --card: #fff; --ink: #18212b; --muted: #5d6875; --line: #dde3ea;
  --brand: #2453d6; --brand-dark: #1a3fa8; --ok: #1e8a4c; --danger: #c0392b;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 800; font-size: 20px; color: var(--ink); text-decoration: none; }
.brand span { color: var(--brand); }
.brand small { font-size: .6em; color: var(--muted); font-weight: 600; }
.topbar-note { color: var(--muted); font-size: 13px; }

.intro { max-width: 760px; margin: 0 auto; padding: 72px 24px; }
.intro h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.1; margin: 0 0 16px; letter-spacing: -0.02em; }
.intro p { font-size: 18px; color: var(--muted); }
.checks { list-style: none; padding: 0; margin: 20px 0 28px; }
.checks li { padding-left: 28px; position: relative; margin: 8px 0; }
.checks li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 800; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-link { background: none; border: none; color: var(--brand); padding: 4px 6px; font-weight: 500; }
.btn-link.danger { color: var(--danger); }
.btn-lg { padding: 14px 26px; font-size: 17px; }
.btn-block { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .6; cursor: wait; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.app { display: grid; grid-template-columns: minmax(340px, 560px) minmax(0, 1fr); gap: 28px; padding: 24px; max-width: 1500px; margin: 0 auto; align-items: start; }
.form-col { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.preview-col { position: sticky; top: 76px; min-width: 0; }
.preview-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-weight: 600; color: var(--muted); }
.preview-wrap { overflow: hidden; border-radius: 6px; box-shadow: 0 10px 40px rgba(20, 30, 50, .14); user-select: none; }
.preview-scale { transform-origin: top left; width: 210mm; }

.steps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.steps button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px 5px 5px; font: inherit; font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.steps i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); font-size: 12px; font-weight: 700; }
.steps .active { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.steps .active i { background: var(--brand); color: #fff; }
.steps .done i { background: #d9f2e3; color: var(--ok); }

fieldset { border: 0; padding: 0; margin: 0; }
.step h2 { margin: 0 0 6px; font-size: 22px; }
.step h3 { margin: 22px 0 8px; font-size: 16px; }
.tip { background: #eef3ff; border-left: 3px solid var(--brand); padding: 9px 12px; border-radius: 0 8px 8px 0; color: #2d3b55; font-size: 14px; margin: 8px 0 16px; }
.tip.small { background: none; border: 0; padding: 0; color: var(--muted); font-size: 13px; margin: 6px 0 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: #34404c; margin-bottom: 12px; }
label small { font-weight: 400; color: var(--muted); }
input, textarea, select { font: inherit; font-size: 15px; font-weight: 400; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(36, 83, 214, .25); border-color: var(--brand); }
.invalid { border-color: var(--danger); background: #fff6f5; }
textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2 .wide { grid-column: 1 / -1; }

.repeat-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 2px; margin-bottom: 12px; background: #fbfcfd; }
.repeat-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 14px; }

.photo-row { display: flex; gap: 16px; align-items: flex-start; margin-top: 4px; }
.photo-preview { width: 90px; height: 120px; border: 1px dashed var(--line); border-radius: 10px; display: grid; place-items: center; font-size: 12px; color: var(--muted); overflow: hidden; flex-shrink: 0; background: var(--bg); }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-row .btn-ghost { display: inline-flex; flex-direction: row; margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 8px; }
.chip { border: 1px dashed #b9c4d2; background: #fff; border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; color: var(--muted); }
.chip:hover { border-color: var(--brand); color: var(--brand); }

.templates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tpl { margin: 0; cursor: pointer; }
.tpl input { position: absolute; opacity: 0; }
.tpl span { display: block; border: 2px solid var(--line); border-radius: 12px; padding: 12px; font-weight: 400; font-size: 13px; color: var(--muted); height: 100%; }
.tpl b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.tpl input:checked + span { border-color: var(--brand); background: #eef3ff; }
.tpl input:focus-visible + span { outline: 2px solid var(--brand); }
.colors { display: flex; flex-wrap: wrap; gap: 14px; }
.colors label { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; margin: 0; }
.colors input { width: auto; }
.colors i { width: 18px; height: 18px; border-radius: 50%; display: inline-block; }
.checklist { margin-top: 20px; background: var(--bg); border-radius: 12px; padding: 4px 16px 10px; }
.checklist ul { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.checklist li { margin: 4px 0; }
.checklist .ok { color: var(--ok); }
.checklist .todo { color: var(--muted); }

.wizard-nav { display: flex; justify-content: space-between; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

.modal { position: fixed; inset: 0; background: rgba(15, 22, 35, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: #fff; border-radius: 18px; max-width: 480px; width: 100%; max-height: 92vh; overflow: auto; padding: 26px; position: relative; }
.modal-card h2 { margin: 0 0 4px; }
.modal-close { position: absolute; top: 10px; right: 14px; border: 0; background: none; font-size: 28px; cursor: pointer; color: var(--muted); }
.price { font-size: 34px; font-weight: 800; margin: 6px 0; color: var(--brand); }
.price small { font-size: 14px; color: var(--muted); font-weight: 500; }
.pay-steps { padding-left: 20px; }
.pay-steps li { margin-bottom: 12px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: auto; }
.error { color: var(--danger); font-size: 14px; }
.code { font-size: 28px; font-weight: 800; letter-spacing: .06em; background: var(--bg); padding: 10px; text-align: center; border-radius: 10px; }

.print-area { display: none; }
@media print {
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; }
  body { background: #fff; }
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; padding: 12px; }
  .preview-col { position: static; }
  .templates { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .grid2 { grid-template-columns: 1fr; }
  .topbar-note { display: none; }
}
