/* Светлая минималистичная тема, мобильный — меню выезжает слева */
:root { --bg: #f6f7f9; --panel: #fff; --line: #e4e7ec; --text: #1d2433; --muted: #6b7385; --accent: #2f6fed; --accent-soft: #eaf1ff; --error: #c62828; --ok: #1f8a4c; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
h1 { margin: 0 0 6px; font-size: 26px; }
.muted { color: var(--muted); margin: 0 0 18px; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 14px; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 230px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 17px; }
.brand-side { padding: 4px 12px 18px; }
.nav-link { display: block; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 15px; }
.nav-link:hover { background: var(--bg); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.logout { margin-top: auto; }
.nav-button { width: 100%; text-align: left; border: 0; background: none; font: inherit; color: var(--muted); cursor: pointer; }
.content { flex: 1; min-width: 0; padding: 32px 36px; max-width: 1000px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.stat-value { font-size: 34px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 14px; margin-top: 6px; }

.form { display: flex; flex-direction: column; gap: 18px; max-width: 620px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=url], input:not([type]) { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: var(--text); }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 6px; font-size: 14px; }
.field-meta .muted { margin: 0; }
.check { display: inline-flex !important; align-items: center; gap: 6px; font-weight: 400 !important; color: var(--muted); margin: 0 !important; cursor: pointer; }
.btn { min-height: 46px; padding: 0 22px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; align-self: flex-start; }
.btn:hover { filter: brightness(1.05); }
.notice { background: #e8f6ee; color: var(--ok); padding: 10px 14px; border-radius: 10px; max-width: 620px; }
.error { color: var(--error); margin: 0; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 22px; }
.login-card .muted { margin: -8px 0 4px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.login-card .btn { align-self: stretch; }

.topbar, .nav-toggle, .backdrop { display: none; }
@media (max-width: 800px) {
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .burger { display: flex; flex-direction: column; justify-content: center; gap: 4px; width: 40px; height: 40px; cursor: pointer; }
  .burger span { display: block; height: 2px; width: 22px; background: var(--text); border-radius: 2px; }
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; height: 100%; transform: translateX(-100%); transition: transform .2s; }
  .nav-toggle:checked ~ .layout .sidebar { box-shadow: 0 0 30px rgba(0,0,0,.12); }
  .nav-toggle:checked ~ .layout .sidebar { transform: none; }
  .nav-toggle:checked ~ .layout .backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(20,25,35,.35); }
  .content { padding: 20px 16px 40px; }
  h1 { font-size: 22px; }
  .stat-value { font-size: 28px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 16px; }
}

/* Этап 2: вебхук, журнал */
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--bg); }
.btn-ghost { background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.link-button { border: 0; background: none; color: var(--accent); font: inherit; font-size: 14px; cursor: pointer; padding: 0; }
.hint { margin-top: 8px; font-size: 14px; }
.hint summary { cursor: pointer; color: var(--accent); }
.hint pre { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow-x: auto; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { padding: 7px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 13px; background: #fafbfc; }
.table tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }
.text-cell { max-width: 320px; overflow-wrap: anywhere; }
.muted-inline { color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--bg); white-space: nowrap; }
.badge-comment { background: #eaf1ff; color: #2f6fed; }
.badge-reply { background: #f1ecff; color: #6b46c1; }
.badge-dm { background: #e8f6ee; color: #1f8a4c; }
.badge-click { background: #fff4e5; color: #b26a00; }
.badge-subscribe { background: #fde8ef; color: #c2185b; }
@media (max-width: 800px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .table td { border: 0; padding: 3px 0; display: flex; gap: 10px; }
  .table td::before { content: attr(data-label); color: var(--muted); min-width: 110px; flex-shrink: 0; font-size: 13px; }
  .table td:empty { display: none; }
  .text-cell { max-width: none; }
  .copy-row { flex-direction: column; }
}

/* Этап 3: автоответы */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.page-head .btn { flex-shrink: 0; display: inline-flex; align-items: center; text-decoration: none; }
.btn-small { min-height: 38px; padding: 0 14px; font-size: 14px; display: inline-flex; align-items: center; text-decoration: none; }
a.btn, a.btn-ghost { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.rule { margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.rule-off { opacity: .75; }
.rule-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.rule h2 { margin: 0 0 6px; font-size: 19px; }
.status { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; margin-right: 6px; }
.status.on { background: #e8f6ee; color: var(--ok); }
.status.off { background: var(--bg); color: var(--muted); }
.tagline { font-size: 13px; color: var(--muted); margin-right: 10px; }
.switch { width: 50px; height: 30px; border-radius: 999px; border: 0; background: #d0d5dd; position: relative; cursor: pointer; flex-shrink: 0; transition: background .15s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: left .15s; }
.switch.on { background: var(--ok); }
.switch.on span { left: 23px; }
.keywords { display: flex; flex-wrap: wrap; gap: 6px; }
.kw { background: var(--accent-soft); color: var(--accent); padding: 3px 10px; border-radius: 999px; font-size: 13px; }
.rule-stats { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; font-size: 14px; color: var(--muted); }
.rule-stats b { font-size: 20px; color: var(--text); }
.rule-stats span { margin-left: 6px; }
.stats-note { font-size: 12px; }
.rule-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { color: var(--muted); text-decoration: none; font-size: 14px; }
.errors { background: #fdecec; color: var(--error); padding: 10px 14px; border-radius: 10px; max-width: 620px; margin-bottom: 14px; }
.errors p { margin: 2px 0; }
.warning { background: #fff4e5; color: #8a5300; padding: 10px 14px; border-radius: 10px; }
textarea, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: var(--text); resize: vertical; }
select { min-height: 44px; }
textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.help { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
fieldset.field { border: 0; padding: 0; margin: 0; }
fieldset legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; padding: 0; }
.radio { display: flex !important; align-items: center; gap: 8px; font-weight: 400 !important; margin: 4px 0 !important; cursor: pointer; }
.radio input { width: 18px; height: 18px; accent-color: var(--accent); }
.posts { margin-top: 6px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.danger-zone { margin-top: 16px; }
.danger { color: var(--error); }
.step { margin-bottom: 14px; }
.step h2 { margin: 0 0 8px; font-size: 18px; }
.step p { margin: 8px 0; }
.copy-block { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; }
.copy-block label { display: none; }
.copy-block pre { flex: 1; min-width: 0; margin: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: 14px; }
.plain { margin: 4px 0; padding-left: 18px; font-size: 14px; overflow-wrap: anywhere; }
@media (max-width: 800px) {
  .page-head { flex-direction: column; }
  .field-row { grid-template-columns: 1fr; }
  .copy-block { flex-direction: column; }
}
.check-form { margin-top: 16px; }
.check-form h2 { margin: 0 0 4px; font-size: 18px; }

/* Этап 4: воронки и сегменты */
.tabs { display: flex; gap: 6px; margin: 4px 0 16px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tab.on { color: var(--accent); border-color: var(--accent); }
.seg-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); margin-right: 6px; }
.steps { display: flex; align-items: stretch; gap: 4px; overflow-x: auto; }
.step-box { flex: 1; min-width: 92px; background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.step-label { font-size: 13px; color: var(--muted); }
.step-num { font-size: 14px; color: var(--muted); margin-top: 2px; }
.step-num b { font-size: 22px; color: var(--text); }
.step-note { font-size: 11px; color: #8a5300; margin-top: 4px; }
.step-arrow { display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: 12px; font-weight: 600; color: var(--accent); min-width: 44px; }
.step-arrow::after { content: "→"; color: var(--muted); font-size: 16px; }
.seg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.seg-card { display: block; text-decoration: none; color: var(--text); border-left: 4px solid var(--c); }
.seg-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.seg-top { display: flex; align-items: center; gap: 8px; }
.seg-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.seg-card p { font-size: 14px; margin: 8px 0; }
.seg-count { font-size: 13px; color: var(--muted); }
.seg-count b { color: var(--text); font-size: 16px; }
.interest { margin-left: auto; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.interest-cold { background: #eef2f7; color: #475569; }
.interest-warm { background: #fff4e5; color: #b26a00; }
.interest-hot { background: #fdecec; color: #c62828; }
.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.color-opt input { display: none; }
.color-opt span { display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--c); cursor: pointer; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.color-opt input:checked + span { box-shadow: 0 0 0 2px var(--text); }
.connect-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--line); }
@media (max-width: 800px) {
  .steps { flex-direction: column; }
  .step-arrow { flex-direction: row; gap: 8px; min-width: 0; }
  .step-arrow::after { content: "↓"; }
}

/* Этап 5: аналитика */
.head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.chart-card { margin-top: 14px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.chart-head h2, .card h2 { margin: 0; font-size: 17px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.chart-wrap { overflow-x: auto; }
.chart { width: 100%; min-width: 560px; height: auto; display: block; }
.chart .grid { stroke: #eef0f3; stroke-width: 1; }
.chart .axis { fill: #8a92a3; font-size: 11px; }
.chart .direct { fill: #52514e; font-size: 11px; }
.chart .hover { fill: transparent; }
.chart .hover:hover { fill: rgba(47,111,237,.06); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 14px; }
.toolbar .chips { margin: 0; }
.filters select { width: auto; min-width: 180px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.two-col .card h2 { margin-bottom: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 38%) 1fr 36px; align-items: center; gap: 10px; padding: 5px 0; font-size: 14px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); text-decoration: none; }
.bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #2a78d6; border-radius: 4px; }
.bar-row b { text-align: right; }
.search { display: flex; gap: 8px; margin: 8px 0 12px; }
.search input { flex: 1; }
.feed-item { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.feed-meta { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.table th a { color: inherit; text-decoration: none; }
.clickable { cursor: pointer; }
.clickable:hover { background: #fafbfc; }
.table a { color: var(--accent); text-decoration: none; }
.weeks { display: inline-flex; align-items: flex-end; gap: 3px; height: 28px; vertical-align: middle; }
.weeks i { width: 8px; border-radius: 2px 2px 0 0; }
.own { background: #f5f9ff; }
.up { color: var(--ok); font-weight: 600; }
.down { color: var(--error); font-weight: 600; }
.spark { width: 120px; height: 28px; }
.stat-small { font-size: 18px; }
.section-title { font-size: 18px; margin: 20px 0 10px; }
.btn[disabled] { opacity: .5; cursor: default; }
@media (max-width: 800px) {
  .two-col { grid-template-columns: 1fr; }
  .head-actions { width: 100%; }
}
.check-grid { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 6px 0; }
