/* ============ base ============ */
:root {
  --primary: #6d28d9;
  --primary-hover: #5b21b6;
  --primary-soft: #f3eefd;
  --bg: #f6f6fa;
  --card: #ffffff;
  --border: #e4e4ee;
  --text: #1f2430;
  --muted: #6b7280;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 18, 40, .05), 0 4px 16px rgba(20, 18, 40, .06);
  --shadow-lg: 0 8px 32px rgba(20, 18, 40, .14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: #ddd0f7; }

#app { min-height: 100vh; display: flex; flex-direction: column; }
.page { width: 100%; max-width: 980px; margin: 0 auto; padding: 24px 20px 64px; flex: 1; }
.page-wide { max-width: 1280px; }

/* ============ topbar ============ */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  height: 56px; display: flex; align-items: center; gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 16px; color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.brand .logo svg { width: 16px; height: 16px; }
.topbar .spacer { flex: 1; }
.topbar .user { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }

/* ============ buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 9px; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 8px 16px; background: transparent; color: var(--text);
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { border-color: var(--border); background: var(--card); }
.btn-outline:hover:not(:disabled) { background: var(--primary-soft); border-color: #d6c8f5; }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: #eeeef5; color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 11px 24px; font-size: 15px; border-radius: 10px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; border-radius: 8px; }
.btn-icon svg { width: 17px; height: 17px; }
.btn .svg { width: 16px; height: 16px; flex: none; }

/* ============ inputs ============ */
.input, .select, .textarea {
  font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 12px; background: var(--card); width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, .13);
}
.input::placeholder, .textarea::placeholder { color: #a3a8b5; }
.textarea { resize: vertical; min-height: 70px; }
.select { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
label.field { display: block; margin-bottom: 14px; }
label.field .field-label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
label.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.checkbox-line { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.checkbox-line input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }

/* ============ cards & misc ============ */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 10px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; border-radius: 99px; padding: 3px 10px;
}
.badge-published { background: var(--ok-soft); color: var(--ok); }
.badge-draft { background: var(--warn-soft); color: var(--warn); }
.badge-closed { background: #ececf1; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.empty .big { font-size: 42px; margin-bottom: 10px; }
.empty h3 { color: var(--text); margin: 0 0 6px; }
.empty p { margin: 0 0 18px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar h1 { font-size: 21px; margin: 0; flex: none; }
.toolbar .spacer { flex: 1; }

/* toast */
#toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #23232e; color: #fff; border-radius: 10px; padding: 10px 18px;
  font-size: 14px; box-shadow: var(--shadow-lg); animation: toast-in .18s ease-out;
  max-width: min(92vw, 480px);
}
.toast.err { background: #7f1d1d; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(18, 15, 35, .45);
  display: flex; align-items: center; justify-content: center; z-index: 900; padding: 20px;
}
.modal { background: var(--card); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; padding: 24px; }
.modal h3 { margin: 0 0 8px; }
.modal p { color: var(--muted); margin: 0 0 18px; }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; }

/* ============ login ============ */
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 30px 16px; }
.login-card { width: 100%; max-width: 380px; padding: 32px 30px; }
.login-card .logo { width: 46px; height: 46px; border-radius: 12px; background: var(--primary); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.login-card .logo svg { width: 24px; height: 24px; }
.login-card h1 { text-align: center; font-size: 21px; margin: 0 0 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: 9px; padding: 9px 13px; font-size: 13.5px; margin-bottom: 14px; display: none; }
.form-error.show { display: block; }

/* ============ forms list ============ */
.forms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.form-card { padding: 18px; display: flex; flex-direction: column; gap: 10px; position: relative; transition: box-shadow .15s, transform .15s; }
.form-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.form-card .fc-top { display: flex; align-items: flex-start; gap: 10px; }
.form-card .fc-icon {
  width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center; flex: none; color: var(--primary);
}
.form-card .fc-icon svg { width: 20px; height: 20px; }
.form-card h3 { margin: 2px 0 0; font-size: 15.5px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.form-card .fc-desc { color: var(--muted); font-size: 13px; margin: 0; min-height: 18px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.form-card .fc-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.form-card .fc-actions { display: flex; gap: 4px; margin-top: 2px; border-top: 1px solid var(--border); padding-top: 10px; flex-wrap: wrap; }
.fc-count { background: var(--primary-soft); color: var(--primary); font-weight: 700; border-radius: 99px; padding: 1px 9px; font-size: 12px; }

/* ============ editor ============ */
.ed-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px;
}
.ed-head .title-input { font-size: 19px; font-weight: 700; border: 1px solid transparent; background: transparent; padding: 6px 10px; border-radius: 9px; flex: 1; min-width: 200px; }
.ed-head .title-input:hover, .ed-head .title-input:focus { border-color: var(--border); background: var(--card); outline: none; }
.ed-head .title-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109, 40, 217, .13); }

.q-list { display: flex; flex-direction: column; gap: 12px; }
.q-card { padding: 16px 18px; }
.q-card.drag-over { outline: 2px dashed var(--primary); outline-offset: 2px; }
.q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.q-num { color: var(--muted); font-weight: 700; font-size: 13px; min-width: 20px; }
.q-head .q-type { flex: 1; }
.q-opts { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 0; }
.q-opt { display: flex; align-items: center; gap: 7px; }
.q-opt .input { flex: 1; }
.q-opt .grip { color: #b6bac6; cursor: default; font-size: 13px; flex: none; width: 14px; text-align: center; }
.q-add-opt { align-self: flex-start; }
.q-scale-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.q-scale-row .input { width: 90px; }
.q-scale-row .arr { color: var(--muted); }
.q-label-input { font-weight: 600; font-size: 15px; }
.q-sub { display: flex; gap: 10px; margin-top: 8px; }
.q-sub .input { font-size: 13.5px; color: var(--muted); }
.req-toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap; }
.req-toggle input { accent-color: var(--danger); width: 15px; height: 15px; cursor: pointer; }

.add-q { margin-top: 14px; }
.add-q-menu { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.add-q-item {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); border-radius: 99px;
  padding: 6px 14px 6px 10px; font-size: 13.5px; font-weight: 600; color: var(--text);
  transition: background .12s, border-color .12s;
}
.add-q-item:hover { background: var(--primary-soft); border-color: #d6c8f5; }
.add-q-item svg { width: 15px; height: 15px; color: var(--primary); }

.ed-settings { margin-top: 14px; padding: 18px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.share-box { display: flex; gap: 8px; align-items: center; }
.share-box .input { font-size: 13px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.dirty-note { color: var(--warn); font-size: 12.5px; display: inline-flex; align-items: center; gap: 5px; }

/* ============ public form ============ */
.pub-wrap { flex: 1; display: flex; justify-content: center; padding: 34px 14px 70px; align-items: flex-start; }
.pub-col { width: 100%; max-width: 640px; display: flex; flex-direction: column; gap: 14px; }
.pub-header { padding: 26px 28px; border-top: 8px solid var(--primary); }
.pub-header h1 { margin: 0 0 6px; font-size: 24px; line-height: 1.25; overflow-wrap: break-word; }
.pub-header p { margin: 0; color: var(--muted); white-space: pre-wrap; overflow-wrap: break-word; }
.pub-branding { text-align: center; color: #a0a4b3; font-size: 12.5px; padding-top: 4px; }
.pub-branding a { color: #a0a4b3; }

.pq { padding: 20px 24px; }
.pq .pq-label { font-weight: 600; font-size: 15px; margin-bottom: 3px; overflow-wrap: break-word; }
.pq .pq-label .star { color: var(--danger); margin-left: 3px; }
.pq .pq-help { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.pq .pq-body { margin-top: 10px; }
.pq.invalid { border-left: 4px solid var(--danger); }
.pq .err-msg { color: var(--danger); font-size: 13px; margin-top: 7px; display: none; }
.pq.invalid .err-msg { display: block; }

.pub-input, .pub-textarea {
  font: inherit; width: 100%; border: none; border-bottom: 1.5px dashed #c9cdda; background: transparent;
  padding: 7px 2px; border-radius: 0; transition: border-color .12s;
}
.pub-input:focus, .pub-textarea:focus { outline: none; border-bottom: 1.5px solid var(--primary); }
.pub-textarea { min-height: 90px; resize: vertical; }

.choice { display: flex; align-items: center; gap: 10px; padding: 7px 2px; cursor: pointer; border-radius: 7px; }
.choice:hover { background: #f5f2fc; }
.choice input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; flex: none; margin: 0; }
.choice .opt-label { overflow-wrap: break-word; }

.scale-row { display: flex; gap: 6px; flex-wrap: wrap; }
.scale-btn {
  min-width: 44px; height: 40px; padding: 0 10px; border-radius: 9px; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--card); font: inherit; font-weight: 600;
  transition: all .1s;
}
.scale-btn:hover { border-color: var(--primary); color: var(--primary); }
.scale-btn.sel { background: var(--primary); border-color: var(--primary); color: #fff; }
.scale-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; margin-top: 5px; }

.hp-field { position: absolute; left: -9999px; top: -9999px; opacity: 0; height: 0; width: 0; }

.thankyou { text-align: center; padding: 60px 30px; }
.thankyou .icon { width: 62px; height: 62px; border-radius: 50%; background: var(--ok-soft); color: var(--ok);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.thankyou .icon svg { width: 30px; height: 30px; }
.thankyou h2 { margin: 0 0 6px; }
.thankyou p { color: var(--muted); margin: 0; white-space: pre-wrap; }

.pub-closed { text-align: center; padding: 70px 30px; }
.pub-closed h2 { margin: 0 0 6px; }
.pub-closed p { color: var(--muted); }

.submit-bar { display: flex; align-items: center; gap: 12px; padding: 4px 6px; }
.submit-bar .note { color: var(--muted); font-size: 12.5px; }

/* ============ responses ============ */
.resp-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.resp-tab { padding: 9px 16px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px; }
.resp-tab:hover { color: var(--text); }
.resp-tab.active { color: var(--primary); border-color: var(--primary); }

.summary-list { display: flex; flex-direction: column; gap: 18px; }
.sq { padding: 18px 22px; }
.sq h4 { margin: 0 0 12px; font-size: 14.5px; }
.sq .total { color: var(--muted); font-weight: 400; font-size: 12.5px; margin-left: 6px; }
.sopt { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 13.5px; }
.sopt .lbl { width: 34%; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sopt .bar-wrap { flex: 1; background: #eef0f6; border-radius: 6px; height: 18px; overflow: hidden; }
.sopt .bar { height: 100%; background: var(--primary); border-radius: 6px; min-width: 2px; transition: width .3s; }
.sopt .cnt { width: 52px; text-align: right; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.sq .answered-note { color: var(--muted); font-size: 13px; }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
table.data { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.data th, table.data td { padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { position: sticky; top: 0; background: #fafafc; font-size: 12.5px; z-index: 2; max-width: 240px; white-space: normal; }
table.data td { max-width: 260px; overflow-wrap: break-word; white-space: pre-wrap; }
table.data tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { color: var(--muted); white-space: nowrap; width: 44px; }
table.data td.date, table.data th.date { color: var(--muted); white-space: nowrap; width: 130px; }
td.cell-del { width: 36px; }
.del-x { color: #c3c7d2; cursor: pointer; background: none; border: none; font-size: 15px; padding: 2px 6px; border-radius: 6px; }
.del-x:hover { color: var(--danger); background: var(--danger-soft); }

.load-more-wrap { text-align: center; margin-top: 16px; }

/* ============ переключатель приёма ответов ============ */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider {
  position: absolute; inset: 0; background: #cfd4de; border-radius: 99px;
  transition: background .15s; cursor: pointer;
}
.switch .slider::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(22, 163, 74, .25); }
.fc-onoff { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.ed-onoff { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--border); border-radius: 9px; padding: 5px 12px 5px 8px; }
.ed-onoff .t { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }

/* ============ тема kleinanzeigen ============ */
.theme-kleinanzeigen {
  --primary: #86B817;
  --primary-hover: #74a312;
  --primary-soft: #F3F9E6;
  --bg: #F4F6F4;
}
.theme-kleinanzeigen .pub-header { border-top-color: #86B817; }
.theme-kleinanzeigen .choice:hover { background: #F3F9E6; }
.theme-kleinanzeigen .pub-input:focus, .theme-kleinanzeigen .pub-textarea:focus { border-bottom-color: #86B817; }
.theme-kleinanzeigen .btn-primary { box-shadow: none; font-weight: 700; }
.ka-logo { margin-bottom: 14px; }
.ka-logo img { display: block; height: 22px; width: auto; }
.pub-col .theme-kleinanzeigen { display: flex; flex-direction: column; gap: 14px; }

/* ============ визард (многошаговые формы) ============ */
.wiz-head { padding: 16px 20px; }
.wiz-progress { background: #E8ECEF; border-radius: 99px; height: 8px; overflow: hidden; }
.wiz-bar { height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s; }
.wiz-label { margin-top: 9px; font-size: 13px; font-weight: 700; color: var(--muted); }
.submit-bar .btn + .btn { margin-left: 0; }
.submit-bar { gap: 10px; }

/* ============ responsive ============ */
@media (max-width: 640px) {
  .page { padding: 16px 12px 48px; }
  .settings-grid { grid-template-columns: 1fr; }
  .toolbar h1 { font-size: 18px; }
  .pub-header { padding: 20px 18px; }
  .pq { padding: 16px 16px; }
  .sopt .lbl { width: 42%; }
  .topbar .user { display: none; }
  .ed-head .title-input { font-size: 17px; }
}

/* фишинг-гейт: зелёное состояние после перехода по ссылке */
.gate-box.gate-ok{background:rgba(46,158,91,.08)}
.gate-box.gate-ok .gate-state{color:var(--ok,#2e9e5b);font-weight:600}
.pub-trust{text-align:center;font-size:12.5px;color:var(--muted);padding:4px 0 8px}
.pub-trust a{color:var(--muted);text-decoration:none;margin:0 6px}
.pub-trust a:hover{text-decoration:underline}
.thankyou-ref{color:var(--muted);font-size:14px;margin-top:10px}

.gate-box .gate-link{display:inline-flex;align-items:center;justify-content:center;gap:8px}

/* ============ мобильная адаптация публичных форм ============ */
@media (max-width: 640px) {
  .gate-box .gate-link { width: 100%; }
  .submit-bar { flex-wrap: wrap; }
  .submit-bar .btn { flex: 1 1 140px; }
  .submit-bar .note, .submit-bar .gate-lock { width: 100%; order: 3; }
  .pub-col { gap: 12px; }
  .pub-header h1 { font-size: 20px; }
  .pq-label { font-size: 14.5px; }
  .pub-input, .pub-textarea, .select { font-size: 16px; } /* без этого iOS зумит страницу при фокусе */
  .wiz-label { font-size: 12.5px; }
  .thankyou { padding: 40px 18px; }
  .pub-branding { text-align: center; }
}
@media (max-width: 380px) {
  .btn-lg { padding: 11px 14px; font-size: 14px; }
}
