:root {
  --bg: #f4f6fa; --surface: #fff; --text: #172033; --muted: #687387; --border: #e2e7ef;
  --primary: #3b5bdb; --primary-dark: #2f49b8; --primary-soft: #edf1ff;
  --green: #2b8a3e; --green-soft: #e6f6ea; --red: #c92a2a; --red-soft: #fdecec;
  --amber: #b26b00; --amber-soft: #fff4e0; --teal: #0b7285; --teal-soft: #e3f6f8; --gray-soft: #eef0f4;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 14px; }
h3 { font-size: 1rem; margin: 0 0 10px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: #111827; color: #cbd2e0; padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 22px; text-decoration: none; }
.sidebar .brand:hover { text-decoration: none; }
.brand-logo { width: 34px; height: 34px; flex: none; border-radius: 10px; box-shadow: 0 6px 18px rgba(79, 70, 229, .35); }
.wordmark { font-weight: 800; letter-spacing: -.02em; font-size: 1.18rem; color: #fff; line-height: 1; }
.wordmark span { background: linear-gradient(90deg, #a5b4fc, #22d3ee); -webkit-background-clip: text; background-clip: text; color: transparent; }
.wordmark-dark { color: #0f172a; }
.wordmark-dark span { background-image: linear-gradient(90deg, #4f46e5, #06b6d4); }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-brand img { border-radius: 16px; box-shadow: 0 10px 30px rgba(79, 70, 229, .35); }
.login-brand h1 { font-size: 1.9rem; margin: 0; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; color: #cbd2e0; padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; font-weight: 500; }
.sidebar nav a:hover { background: #1f2937; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: #2b3647; color: #fff; }
.sidebar .nav-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #6b7487; padding: 18px 12px 6px; }
.sidebar .user-box { margin-top: auto; border-top: 1px solid #253042; padding: 14px 10px 0; font-size: .88rem; }
.sidebar .user-box form { display: inline; }
.sidebar .user-box button { background: none; border: 0; color: #9aa6b5; cursor: pointer; padding: 0; font: inherit; }
.sidebar .user-box button:hover { color: #fff; }
.main { padding: 28px 34px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }

/* Components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 18px 20px; }
.stat .num { font-size: 1.8rem; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: .88rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--primary); color: #fff; border: 1px solid var(--primary); padding: 9px 16px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 5px 11px; font-size: .85rem; border-radius: 7px; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--gray-soft); color: var(--text); }
.btn-danger { background: #fff; color: var(--red); border-color: #f1c4c4; }
.btn-danger:hover { background: var(--red-soft); color: var(--red); }
.btn-success { background: var(--green); border-color: var(--green); }
.btn-success:hover { background: #237032; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-gray { background: var(--gray-soft); color: #4a5468; }
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-teal { background: var(--teal-soft); color: var(--teal); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #fafbfd; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }

label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { font-weight: 400; color: var(--muted); font-size: .82rem; margin-top: 5px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #d3d9e3; border-radius: 9px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #b8c6ff; border-color: var(--primary); }
textarea { resize: vertical; min-height: 90px; }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.checkbox input { width: auto; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; }

.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.flash-success { background: var(--green-soft); color: var(--green); }
.flash-error { background: var(--red-soft); color: var(--red); }
.flash-info { background: var(--primary-soft); color: var(--primary); }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }
.alert-warning { background: var(--amber-soft); color: #7a4a00; }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-info { background: var(--primary-soft); color: #2b3f99; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 85% -10%, rgba(6, 182, 212, .35), transparent 60%), radial-gradient(900px 600px at -10% 110%, rgba(99, 102, 241, .45), transparent 60%), #0b1022; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 34px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card h1 { text-align: center; margin-bottom: 4px; }
.login-card .btn { width: 100%; margin-top: 6px; padding: 11px; }

/* Wizard */
.wizard-steps { display: flex; gap: 6px; margin-bottom: 22px; flex-wrap: wrap; }
.wizard-steps .ws { flex: 1; min-width: 110px; padding: 10px 12px; border-radius: 10px; background: #fff; border: 1px solid var(--border); font-size: .85rem; color: var(--muted); cursor: pointer; }
.wizard-steps .ws b { display: block; color: var(--text); font-size: .9rem; }
.wizard-steps .ws.active { border-color: var(--primary); background: var(--primary-soft); }
.wizard-steps .ws.active b { color: var(--primary); }
.wizard-steps .ws.done b::after { content: " ✓"; color: var(--green); }
.step { display: none; }
.step.active { display: block; }
.wizard-nav { display: flex; justify-content: space-between; margin-top: 10px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: block; border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; font-weight: 500; background: #fff; }
.choice input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.choice input:focus-visible + span { outline: 2px solid #b8c6ff; }
.swatches { display: flex; gap: 4px; margin-top: 6px; }
.swatches i { width: 18px; height: 18px; border-radius: 5px; display: inline-block; }
.brand-options .choice span { font-size: 1.05rem; }
.domain-search { margin-bottom: 10px; }
.domain-list { max-height: 360px; overflow-y: auto; }
.range-row { display: flex; align-items: center; gap: 16px; }
.range-row input[type=range] { flex: 1; }
.range-value { font-size: 1.6rem; font-weight: 700; min-width: 40px; text-align: center; color: var(--primary); }
.summary dl { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 500; word-break: break-word; }

/* Site detail */
.preview-frame { width: 100%; height: 640px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.preview-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.device-toggle button.active { background: var(--primary-soft); color: var(--primary); border-color: #c5d0ff; }
.logs { background: #0f172a; color: #d6deeb; border-radius: 10px; padding: 14px; font-family: ui-monospace, Menlo, monospace; font-size: .8rem; max-height: 360px; overflow-y: auto; white-space: pre-wrap; }
.logs .l-warning { color: #ffd479; }
.logs .l-error { color: #ff8a8a; }
.logs .ts { color: #6b7a99; }
.score { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.score-circle { width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.3rem; }
.issues { list-style: none; padding: 0; margin: 0; max-height: 380px; overflow-y: auto; }
.issues li { padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; font-size: .88rem; }
.issues li.error { background: var(--red-soft); }
.issues li.warning { background: var(--amber-soft); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
details.integration { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; background: #fff; }
details.integration summary { cursor: pointer; font-weight: 600; }
.test-result { font-size: .85rem; margin-top: 8px; }

@media (max-width: 1000px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 20px 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .summary dl, .kv { grid-template-columns: 1fr; }
}

/* Leads */
.nav-count { margin-left: auto; background: #4c6ef5; color: #fff; border-radius: 999px; padding: 0 8px; font-size: .75rem; font-weight: 700; }
.lead-unread { border-left: 4px solid var(--primary); }
.lead-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.lead-message { white-space: pre-wrap; margin: 0 0 12px; }
.pubkey { display: block; background: #0f172a; color: #d6deeb; padding: 10px 12px; border-radius: 8px; word-break: break-all; font-size: .8rem; user-select: all; }
.meter { height: 6px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; margin-top: 4px; min-width: 80px; }
.meter i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
tr.banned td { opacity: .55; }
/* Wizard: шаблоны и фото */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tpl-card { position: relative; display: block; font-weight: 400; margin: 0; }
.tpl-card input { position: absolute; opacity: 0; }
.tpl-body { display: grid; gap: 4px; overflow: hidden; border: 2px solid var(--border); border-radius: 12px; padding: 10px; background: #fff; cursor: pointer; height: 100%; }
.tpl-card input:checked + .tpl-body { border-color: var(--primary); background: var(--primary-soft); }
.tpl-body iframe { width: 1280px; height: 1000px; border: 0; transform: scale(.17); transform-origin: 0 0; margin-bottom: -830px; margin-right: -1062px; pointer-events: none; border-radius: 6px; background: #fff; }
.tpl-body b { margin-top: 4px; }
.photo-list { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.photo { position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: #fafbfd; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; line-height: 1; }
.photo-main { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(59,91,219,.85); color: #fff; font-size: .7rem; text-align: center; padding: 2px; }

/* Обзор: «Требует внимания» */
.attention { padding: 0; overflow: hidden; }
.attention-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.attention-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.attention-head .count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--red-soft); color: var(--red); font-size: .8rem; font-weight: 700; display: inline-grid; place-items: center; }
.attention-actions { display: flex; gap: 8px; align-items: center; }
.attention-actions form { margin: 0; }
.notices { list-style: none; margin: 0; padding: 0; }
.notice { display: flex; align-items: flex-start; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--border); transition: opacity .18s, transform .18s; }
.notice:last-child { border-bottom: 0; }
.notice-out { opacity: 0; transform: translateX(12px); }
.notice-icon { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; }
.notice-error .notice-icon { background: var(--red-soft); color: var(--red); }
.notice-warning .notice-icon { background: var(--amber-soft); color: var(--amber); }
.notice-body { flex: 1; min-width: 0; }
.notice-title { font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.notice-text { color: var(--muted); font-size: .9rem; margin-top: 2px; overflow-wrap: anywhere; }
.notice-meta { color: var(--muted); font-size: .82rem; margin-top: 3px; }
.notice > .btn, .notice > form { flex: none; margin: 0; }
.notice-x { width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.notice-x:hover { background: var(--gray-soft); color: var(--text); }
.attention-foot { margin: 0; padding: 10px 20px 14px; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--border); }
@media (max-width: 640px) { .notice { padding: 12px 14px; } .attention-head { padding: 14px; } }

/* Мастер: карточки типов сайта и предпросмотр демо */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.type-card { position: relative; display: block; margin: 0; font-weight: 400; }
.type-card input { position: absolute; opacity: 0; }
.type-body { display: flex; gap: 12px; align-items: flex-start; height: 100%; border: 1.5px solid var(--border); border-radius: 12px; padding: 14px 52px 14px 14px; cursor: pointer; background: #fff; transition: border-color .15s, box-shadow .15s; }
.type-body:hover { border-color: #c5d0ff; }
.type-card input:checked + .type-body { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(59, 91, 219, .12); }
.type-card input:focus-visible + .type-body { outline: 2px solid #b8c6ff; }
.type-ico { flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--gray-soft); color: var(--primary); }
.type-card input:checked + .type-body .type-ico { background: #fff; }
.type-icon { width: 22px; height: 22px; }
.type-text { display: grid; gap: 3px; }
.type-text b { font-weight: 600; line-height: 1.3; }
.type-text span { color: var(--muted); font-size: .85rem; line-height: 1.4; }
.type-eye { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: #fff; color: var(--muted); display: grid; place-items: center; cursor: pointer; transition: .15s; }
.type-eye svg { width: 18px; height: 18px; }
.type-eye:hover { color: var(--primary); border-color: #c5d0ff; background: var(--primary-soft); }
.pv-modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; }
.pv-modal[hidden] { display: none; }
.pv-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px); }
.pv-dialog { position: relative; width: min(1280px, 100%); height: min(860px, 100%); background: #fff; border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.35); display: flex; flex-direction: column; overflow: hidden; }
.pv-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pv-heading { display: grid; gap: 2px; }
.pv-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pv-close { width: 34px; height: 34px; border-radius: 9px; border: 0; background: var(--gray-soft); font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--text); }
.pv-close:hover { background: #e2e6ee; }
.pv-body { flex: 1; background: #eef1f6; display: flex; justify-content: center; overflow: hidden; }
.pv-body iframe { width: 100%; height: 100%; border: 0; background: #fff; transition: width .2s; }
@media (max-width: 640px) { .pv-modal { padding: 0; } .pv-dialog { border-radius: 0; height: 100%; } .pv-heading .small { display: none; } }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-5 { grid-template-columns: 1fr 1fr; } }
