:root {
  --ink: #27272b;
  --muted: #504f55;
  --faint: #6d6c77;
  --disabled: #9a98a9;
  --line: #e7e6f3;
  --line-strong: #e7e6f3;
  --surface: #ffffff;
  --canvas: #f9f9ff;
  --raised: #f1f1f8;
  --primary: #0381e9;
  --primary-ink: #0069c0;
  --primary-deep: #0059a4;
  --primary-hover: #daf0ff;
  --primary-wash: #eef8ff;
  --primary-soft: #4ab8ff;
  --ok: #22c55e;
  --ok-wash: #dcfce7;
  --warn: #b45309;
  --warn-wash: #fdf3e6;
  --err: #c0362c;
  --err-wash: #fbecea;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-btn: 6px;
  --shadow: 0 4px 16px #00000029, 0 0 2px #00000014;
  --font: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 860px; margin: 0 auto; padding: 32px 24px 80px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.brand .mark { width: 33px; height: 23px; flex: none; display: block; }
.brand .wordmark { width: 102px; height: 13px; flex: none; display: block; }
.brand span { color: var(--faint); font-size: 12px; line-height: 16px; margin-left: auto; }

.steps { display: flex; gap: 8px; margin: 0 0 24px; padding: 0; list-style: none; min-width: 0; }
.step {
  flex: 1 1 0; display: flex; align-items: center; gap: 8px;
  font-size: 12px; line-height: 16px; color: var(--disabled);
  margin: 0; padding: 0; min-width: 0;
}
.step .lbl { min-width: 0; white-space: nowrap; }
.step .dot {
  width: 20px; height: 20px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 12px; font-weight: 400;
  color: var(--disabled); flex: none;
}
.step.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.active .dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.active { color: var(--ink); font-weight: 700; }
.step .bar { height: 1px; background: var(--line); flex: 1; min-width: 8px; }
.step:last-child .bar { display: none; }

h1 { font-size: 24px; line-height: 32px; font-weight: 700; letter-spacing: 0; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; line-height: 20px; }
.loading { color: var(--muted); font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card + .card { margin-top: 16px; }
.pad { padding: 20px; }

.tariff {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 20px; background: var(--primary-wash);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.tariff .name { font-weight: 700; font-size: 22px; line-height: 32px; }
.tariff .term { color: var(--muted); font-size: 14px; line-height: 20px; margin-top: 4px; }
.tariff .price { font-size: 24px; line-height: 32px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.tariff .vat { color: var(--faint); font-size: 12px; line-height: 16px; text-align: right; }
.lock {
  font-size: 12px; line-height: 16px; color: var(--faint); margin-top: 10px;
}

.qlabel { font-weight: 700; font-size: 14px; line-height: 20px; margin: 24px 0 12px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice {
  text-align: left; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; cursor: pointer;
  font: inherit; color: inherit;
}
.choice:hover { background: var(--primary-wash); border-color: var(--primary-soft); }
.choice .ci { font-weight: 700; font-size: 16px; line-height: 24px; display: flex; align-items: center; gap: 8px; }
.choice .cd { color: var(--muted); font-size: 14px; margin-top: 4px; }
.choice .tag {
  margin-left: auto; font-size: 12px; font-weight: 400; color: var(--muted);
  background: var(--raised); padding: 4px 8px; border-radius: 8px;
}
.ico { width: 20px; height: 20px; flex: none; color: var(--primary); }

.seg {
  display: inline-flex; background: var(--raised); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px; margin-bottom: 20px;
}
.seg button {
  border: 0; background: transparent; font: inherit; font-size: 14px; font-weight: 400;
  color: var(--muted); padding: 8px 16px; border-radius: 8px; cursor: pointer; line-height: 20px;
}
.seg button.on { background: var(--surface); color: var(--ink); }

.lookup { max-width: 560px; width: 100%; }
.lookup-ctrl { display: flex; gap: 12px; align-items: stretch; width: 100%; }
.lookup-ctrl .inp { flex: 1; min-width: 0; width: 100%; }
.lookup-ctrl .btn { flex: none; min-width: 140px; }
.field label {
  display: block; font-size: 14px; line-height: 20px; font-weight: 700; color: var(--ink); margin-bottom: 6px;
}
.hint-mini { margin: 6px 0 0; font-weight: 400; font-size: 12px; line-height: 16px; color: var(--faint); }
.req { color: var(--err); font-weight: 700; margin-left: 2px; }
.opt {
  display: block; font-size: 12px; line-height: 16px; font-weight: 400;
  color: var(--faint); margin-top: 2px;
}
.callout {
  margin-top: 12px; padding: 10px 12px; border-radius: 8px;
  background: var(--warn-wash); color: var(--warn); font-size: 14px; line-height: 20px;
}
.callout.ok { background: var(--ok-wash); color: #15803d; }
.callout.err { background: var(--err-wash); color: var(--err); }
input.inp {
  width: 100%; font: inherit; font-size: 14px; line-height: 20px; padding: 0 12px;
  height: 40px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-variant-numeric: tabular-nums;
}
input.inp:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-hover); }

.btn {
  font: inherit; font-weight: 400; font-size: 16px; line-height: 24px;
  border-radius: var(--radius-btn);
  padding: 0 16px; height: 40px; min-height: 40px; cursor: pointer; border: 1px solid transparent;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-ink); }
.btn.primary:disabled { background: var(--primary-soft); color: #fff; cursor: not-allowed; opacity: 0.55; }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--canvas); }
a.btn.primary { color: #fff; }
a.btn.ghost { color: var(--ink); }

.dropzone {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 20px 16px; text-align: center; color: var(--muted); background: var(--canvas); cursor: pointer;
  font-size: 14px; line-height: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.dropzone:hover { border-color: var(--primary-soft); background: var(--primary-wash); }
.dropzone .drop-ico { width: 24px; height: 24px; display: block; flex: none; }
.dropzone b { color: var(--ink); display: block; margin: 0; font-weight: 700; max-width: 36em; }
.dropzone span { max-width: 36em; }

.field-note {
  font-size: 12px; line-height: 16px; color: var(--muted); margin-top: 6px;
}

.grow {
  display: flex; flex-direction: column; gap: 16px; min-width: 0;
  max-width: 760px;
}
.field-row {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: start;
  min-width: 0;
}
.field-row .rl {
  font-size: 14px; line-height: 20px; font-weight: 700; color: var(--ink);
  padding-top: 10px; min-width: 0;
}
.field-row .rv { min-width: 0; }
.field-row .rv input,
.field-row .rv textarea {
  width: 100%; font: inherit; font-size: 14px; line-height: 20px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
}
.field-row .rv input { height: 40px; font-variant-numeric: tabular-nums; }
.field-row .rv textarea {
  min-height: 40px; padding: 8px 12px; resize: none;
  overflow: hidden; white-space: pre-wrap; word-break: break-word;
}
.field-row .rv input:focus,
.field-row .rv textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-hover); }
.field-row .badge { margin-top: 8px; width: max-content; justify-self: start; align-self: start; }
.badge {
  font-size: 12px; line-height: 16px; font-weight: 400; padding: 4px 8px; border-radius: 8px;
  white-space: nowrap; display: inline-flex; align-items: center; gap: 5px;
}
.badge.ok { color: #15803d; background: var(--ok-wash); }
.badge.warn { color: var(--warn); background: var(--warn-wash); }
.badge.err { color: var(--err); background: var(--err-wash); }
.badge.empty {
  color: var(--faint);
  background: transparent;
  border: 1px dashed var(--line);
}
.badge.empty.optional {
  color: var(--disabled);
  border-style: solid;
  border-color: transparent;
  background: var(--raised);
}
.badge.empty::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  flex: none;
}
.badge.empty.optional::before { display: none; }

.legend {
  display: flex; gap: 8px 16px; flex-wrap: wrap; font-size: 12px; line-height: 16px; color: var(--muted);
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.swatch.hollow { background: transparent; border: 1.5px solid var(--faint); box-sizing: border-box; }

.actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; min-width: 0; }
.actions .btn { min-width: 0; }
.actions.forward { justify-content: flex-end; }
.blockers { color: var(--err); font-size: 14px; line-height: 20px; }
.hidden { display: none !important; }

.preview-frame {
  width: 100%; min-height: 640px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff;
}

.success { text-align: center; padding: 32px 20px; }
.check {
  width: 56px; height: 56px; border-radius: 999px; background: var(--ok-wash); color: var(--ok);
  display: grid; place-items: center; margin: 0 auto 16px;
}
.success h2 { margin: 0 0 4px; font-size: 22px; line-height: 32px; font-weight: 700; }
.success .no { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--primary); }
.success p { color: var(--muted); margin: 6px auto 0; max-width: 420px; font-size: 14px; line-height: 20px; }
.success .btns { margin-top: 24px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.note {
  background: var(--primary-wash); border: 1px solid #a1daff; color: var(--primary-deep);
  font-size: 14px; line-height: 20px; border-radius: var(--radius-sm); padding: 14px 16px;
  margin: 24px auto 0; max-width: 460px; text-align: left;
}
.note b { display: block; color: var(--ink); font-weight: 700; margin-bottom: 6px; }
.note p { margin: 0; max-width: none; color: var(--muted); }
.note p + p { margin-top: 8px; }
.note .contacts { margin-top: 10px; }
.note .contacts div { margin-top: 4px; }
.note a { color: var(--primary); font-weight: 700; text-decoration: none; }
.note a:hover { text-decoration: underline; }

.toast {
  position: fixed; left: 50%; bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; font-size: 14px; line-height: 20px;
  padding: 10px 16px; border-radius: 8px; opacity: 0; transition: 0.2s;
  pointer-events: none; z-index: 9;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

html.embed {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background: #fff;
}
html.embed body {
  min-height: 100%;
  height: auto;
  overflow: visible;
  background: #fff;
  overscroll-behavior: contain;
}
html.embed .wrap {
  max-width: none;
  padding: 20px 24px calc(28px + env(safe-area-inset-bottom, 0px));
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
}
html.embed .brand { display: none; }
html.embed .steps { margin: 0 0 20px; }
html.embed .lock { display: none; }
html.embed .toast { bottom: 16px; }

@media (max-width: 560px) {
  .wrap { padding: 20px 12px 40px; }
  html.embed .wrap {
    padding-top: 16px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }
  h1 { font-size: 22px; line-height: 28px; }
  .pad { padding: 16px 12px; }
  #innBox .pad { padding: 14px 12px; }
  .dropzone { padding: 16px 12px; }
  .choices { grid-template-columns: 1fr; }
  .tariff { flex-direction: column; gap: 8px; }
  .tariff .vat, .tariff .price { text-align: left; }
  .lookup { max-width: none; width: 100%; }
  .lookup-ctrl { flex-direction: column; align-items: stretch; gap: 10px; width: 100%; }
  .lookup-ctrl .inp { width: 100%; height: 44px; }
  .lookup-ctrl .btn { width: 100%; min-width: 0; }
  .grow { max-width: none; gap: 14px; }
  .field-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 8px;
    align-items: start;
  }
  .field-row .rl { grid-column: 1; padding-top: 0; }
  .field-row .rv { grid-column: 1 / -1; }
  .field-row .badge { grid-column: 2; grid-row: 1; margin-top: 2px; align-self: start; }
  .steps {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: start;
    gap: 8px 20px;
    margin: 0 0 16px;
    height: auto;
    align-content: start;
  }
  .step {
    flex: none;
    width: auto;
    min-width: 0;
    gap: 6px;
    font-size: 13px;
    line-height: 18px;
    align-self: start;
  }
  .step .bar { display: none; }
  html.embed .steps { margin: 0 0 16px; }
  .success { padding: 24px 16px; }
  .success .btns { flex-direction: column; align-items: stretch; }
  .success .btns .btn { width: 100%; }
  .actions { flex-direction: column; align-items: stretch; margin-top: 16px; }
  .actions .btn { width: 100%; height: 44px; }
  input.inp,
  .field-row .rv input,
  .field-row .rv textarea { font-size: 16px; line-height: 22px; }
  .field-row .rv input { height: 44px; }
  .lookup-ctrl .btn { height: 44px; }
  .preview-frame { min-height: 420px; }
}
@media (max-width: 380px) {
  .step { font-size: 12px; }
}
