
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #0f172a;
  --text-strong: #0a0f1e;
  --muted: #64748b;
  --line: rgba(0,0,0,0.08);
  --line-strong: rgba(0,0,0,0.14);
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --ok-bg: #f0fdf4;
  --warn-bg: #fffbeb;
  --bad-bg: #fef2f2;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --surface-soft: #f1f5f9;
  --surface-muted: #e2e8f0;
}
[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #161d2e;
  --text: #e2e8f0;
  --text-strong: #f1f5f9;
  --muted: #64748b;
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.14);
  --brand: #4f8ff7;
  --brand-strong: #6aa0f8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --ok-bg: rgba(34,197,94,.1);
  --warn-bg: rgba(245,158,11,.1);
  --bad-bg: rgba(239,68,68,.1);
  --shadow: none;
  --surface-soft: rgba(255,255,255,.04);
  --surface-muted: rgba(255,255,255,.08);
}

* { box-sizing: border-box; }

html, body { width: 100%; max-width: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  transition: background .2s, color .2s;
}

body.ui-mobile { overflow-x: hidden; }

.hidden { display: none !important; }

/* ── Топбар ───────────────────────────────────────── */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 52px;
}
.topbar-brand {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -.3px;
  flex-shrink: 0;
  color: var(--text-strong);
  text-decoration: none;
}
.topbar-site {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}
.topbar-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.topbar-dot.ok { background: var(--ok); }
.topbar-dot.warn { background: var(--warn); }
.topbar-dot.bad { background: var(--bad); }
.topbar-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.topbar-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex-shrink: 0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.topbar-theme-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--muted);
  transition: background .15s;
  padding: 0;
}
.topbar-theme-btn:hover { background: var(--surface-soft); box-shadow: none; }

/* ── Табы (underline-стиль) ──────────────────────── */
.charts-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0 0 14px 0;
  overflow-x: auto;
  padding-bottom: 0;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.charts-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  appearance: none;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color .15s;
  font-family: inherit;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); background: none; box-shadow: none; }
.tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  background: none;
}
.tab-panel { display: none; margin: 0 0 14px 0; }
.tab-panel.active { display: block; }

/* ── Лэйаут ──────────────────────────────────────── */
.wrap {
  width: min(1440px, 100%);
  margin: 0 auto;
  max-width: 100%;
}
.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 0;
  align-items: start;
  min-width: 0;
  min-height: calc(100vh - 52px);
}
.app-sidebar {
  position: sticky;
  top: 52px;
  max-height: calc(100vh - 52px);
  overflow: auto;
  border-right: 1px solid var(--line);
  padding: 14px 12px;
}
.app-main {
  min-width: 0;
  max-width: 100%;
  padding: 20px 24px;
}

/* ── Карточки ─────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
[data-theme="dark"] .card {
  box-shadow: none;
  border: 1px solid var(--line);
}

/* Карточка hero */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: linear-gradient(145deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff;
  border-radius: 0;
  margin-bottom: 0;
  box-shadow: none;
  padding: 16px 20px;
}
[data-theme="dark"] .hero { border: none; }
.hero h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  color: #fff;
  font-weight: 900;
}
.hero-note { margin-top: 4px; color: rgba(255,255,255,.75); font-size: 13px; }
.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: normal;
  text-align: center;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.hero-cta a { color: #c7ddff; font-weight: 800; text-decoration: none; overflow-wrap: anywhere; }
.hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
  max-width: 100%;
}
.hero-feedback-btn {
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.15);
  color: #fff;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.hero-feedback-btn:hover {
  background: rgba(255,255,255,.25);
  border-color: rgba(255,255,255,.5);
  box-shadow: none;
}

/* ── Кнопки ──────────────────────────────────────── */
button {
  appearance: none;
  border: 1px solid var(--brand);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  cursor: pointer;
  transition: background .15s, box-shadow .15s, border-color .15s, opacity .15s, transform .15s;
  font-family: inherit;
}
button:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  box-shadow: 0 4px 12px rgba(37,99,235,.25);
}
button:active { transform: translateY(1px); box-shadow: none; }
button[disabled] { opacity: .5; cursor: not-allowed; }
button.secondary {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface);
  box-shadow: none;
}
button.secondary:hover {
  background: var(--surface-soft);
  border-color: var(--muted);
  box-shadow: none;
}
button.danger { background: var(--bad); border-color: var(--bad); }
button.danger:hover { background: #b91c1c; border-color: #b91c1c; box-shadow: 0 4px 12px rgba(220,38,38,.25); }

/* ── Типографика ─────────────────────────────────── */
.section-title { margin: 0 0 12px 0; font-size: 18px; font-weight: 800; color: var(--text-strong); }
.muted { color: var(--muted); font-size: 13px; }

/* ── Формы ───────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 700; color: var(--text-strong); }
.field .hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.35; }
.field input, .field select, .competitor-form textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.field-url { grid-column: span 6; }
.field-title { grid-column: span 3; }
.field-schedule { grid-column: span 3; }
.field-interval { grid-column: span 3; }
.field-hour { grid-column: span 2; }
.field-minute { grid-column: span 2; }
.field-action { grid-column: span 12; display: flex; align-items: flex-end; justify-content: flex-end; gap: 10px; }
.field-action button { min-width: 180px; }
.create-inline-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.create-row {
  display: grid;
  grid-template-columns: minmax(260px, 3fr) minmax(150px, 1.2fr) minmax(120px, .9fr) minmax(150px, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.create-row .field { min-width: 0; }
.create-row .field label { display: none; }
.create-row .field .hint { display: none; }
.create-row .field input, .create-row .field select { height: 40px; }
.create-row .field-url, .create-row .field-title, .create-row .field-schedule,
.create-row .field-interval, .create-row .field-hour, .create-row .field-minute,
.create-row .field-action { grid-column: auto; }
.create-row .field-action { justify-content: flex-start; align-items: center; }
.create-row .field-action button { min-width: 140px; white-space: nowrap; }
.schedule-interval .daily-only { display: none; }
.schedule-daily .interval-only { display: none; }
.form-errors {
  margin-top: 10px; border-radius: 10px;
  border: 1px solid var(--bad-bg);
  background: var(--bad-bg); color: var(--bad);
  padding: 10px 12px; font-size: 13px;
}
.form-ok {
  margin-top: 10px; border-radius: 10px;
  border: 1px solid var(--ok-bg);
  background: var(--ok-bg); color: var(--ok);
  padding: 10px 12px; font-size: 13px;
}

/* ── Сайдбар ─────────────────────────────────────── */
.sidebar-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.monitors-list { display: grid; gap: 8px; }
.monitor-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: var(--surface);
  display: block;
  transition: border-color .15s;
}
.monitor-item.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}
.monitor-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.monitor-main { min-width: 0; }
.monitor-title { margin: 0 0 3px 0; font-size: 15px; font-weight: 700; color: var(--text-strong); }
.monitor-url { color: var(--muted); font-size: 12px; word-break: break-all; }
.monitor-toggle {
  border: 1px solid var(--line-strong);
  background: var(--surface-soft);
  color: var(--text);
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  flex: 0 0 auto;
}
.monitor-toggle:hover { background: var(--surface-muted); box-shadow: none; border-color: var(--muted); }
.monitor-summary { margin-top: 6px; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.monitor-summary .sep { color: var(--line-strong); }
.monitor-summary .state { font-weight: 700; color: var(--ok); }
.monitor-summary .state.paused { color: var(--warn); }
.monitor-meta { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.monitor-health { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.monitor-extra { margin-top: 10px; display: none; border-top: 1px solid var(--line); padding-top: 10px; }
.monitor-item.expanded .monitor-extra { display: block; }
.monitor-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.monitor-actions button { min-height: 30px; padding: 5px 10px; border-radius: 8px; font-size: 12px; }
.monitor-actions button.quick-run { min-width: 0; white-space: nowrap; }
.monitor-actions button.icon-danger {
  margin-left: auto; width: 30px; min-width: 30px; height: 30px;
  border-radius: 8px; font-size: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--bad-bg); background: var(--bad-bg); color: var(--bad); box-shadow: none;
}
.monitor-actions button.icon-danger svg { width: 15px; height: 15px; display: block; stroke: currentColor; fill: none; stroke-width: 2; }
.monitor-actions button.icon-danger:hover { background: var(--bad-bg); border-color: var(--bad); box-shadow: 0 4px 10px rgba(220,38,38,.15); }

/* ── Пилюли / теги ───────────────────────────────── */
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 700; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.neutral { color: var(--muted); background: var(--surface-soft); }
.pill.source { color: var(--text); background: var(--surface-muted); }
.pill-action { border: 1px solid var(--line-strong); background: var(--surface-soft); color: var(--text); cursor: pointer; }
.pill-action:hover { background: var(--surface-muted); }

/* ── Мобильный хедер ─────────────────────────────── */
.mobile-site-header {
  display: none; align-items: center; gap: 10px;
  margin-bottom: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.mobile-site-meta { min-width: 0; }
.mobile-site-title { font-weight: 800; font-size: 15px; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-site-status { margin-top: 2px; font-size: 12px; color: var(--muted); }
.mobile-site-retry { margin-left: auto; }

/* ── Фильтры дашборда ────────────────────────────── */
.charts-head { display: grid; gap: 10px; margin-bottom: 10px; }
.dashboard-filters {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-soft);
}
.filter-left, .filter-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.segmented {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); overflow: hidden;
}
.seg-btn {
  appearance: none; border: none; border-right: 1px solid var(--line-strong);
  background: transparent; color: var(--muted);
  padding: 7px 11px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.seg-btn:last-child { border-right: none; }
.seg-btn.active { color: var(--text-strong); background: var(--surface-soft); }
.seg-btn:hover { background: var(--surface-muted); }
.toggle-switch {
  position: relative; width: 40px; height: 22px;
  border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface-muted); cursor: pointer; padding: 0;
  box-shadow: none;
}
.toggle-switch .knob {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 999px;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .15s;
}
.toggle-switch.active { background: var(--brand); border-color: var(--brand-strong); }
.toggle-switch.active .knob { transform: translateX(18px); }
.toggle-switch:hover { box-shadow: none; }

/* ── Тулбар графиков ─────────────────────────────── */
.charts-toolbar {
  position: sticky; top: 52px; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px; padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.charts-site { margin: 0; font-size: 15px; font-weight: 700; color: var(--text-strong); }
.charts-controls { display: flex; align-items: center; gap: 8px; }
.charts-controls label { color: var(--muted); font-size: 12px; font-weight: 700; }
.charts-controls select {
  border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface-soft); color: var(--text);
  font-size: 12px; font-weight: 700; padding: 6px 10px; font-family: inherit;
}

/* ── Overview / витальные карточки ──────────────── */
.monitor-overview {
  margin: 0 0 14px 0; border: 1px solid var(--line);
  border-radius: 14px; background: var(--surface-soft); padding: 12px;
}
.overview-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.overview-title { margin: 0; font-size: 15px; font-weight: 800; }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.overview-card { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 10px; }
.overview-card h4 { margin: 0 0 7px 0; font-size: 13px; font-weight: 800; color: var(--text-strong); }
.overview-lines { margin: 0; padding-left: 16px; color: var(--text); font-size: 12px; line-height: 1.5; }
.overview-lines li { margin: 2px 0; }
.overview-link { font-size: 12px; color: var(--brand); text-decoration: none; }
.overview-link:hover { text-decoration: underline; }
.overview-link-note { font-size: 11px; color: var(--muted); margin-top: 4px; }
.overview-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }

.vitals-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.vital-card {
  border-radius: 12px; background: var(--surface); padding: 12px;
  border-top: 3px solid var(--line-strong);
  box-shadow: var(--shadow);
}
[data-theme="dark"] .vital-card { box-shadow: none; border: 1px solid var(--line); border-top: 3px solid var(--line-strong); }
.vital-card.ok { border-top-color: var(--ok); }
.vital-card.warn { border-top-color: var(--warn); }
.vital-card.bad { border-top-color: var(--bad); }
.vital-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 5px; }
.vital-title { margin: 0; color: var(--text-strong); font-size: 13px; font-weight: 800; }
.vital-p75 { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.vital-value { font-size: 44px; line-height: 1; font-weight: 900; margin: 2px 0 6px; color: var(--text-strong); }
.vital-value.ok { color: var(--ok); }
.vital-value.warn { color: var(--warn); }
.vital-value.bad { color: var(--bad); }
.vital-value.neutral { color: var(--muted); }
.vital-hint { font-size: 11px; color: var(--muted); line-height: 1.3; }

.vital-scale { position: relative; padding-top: 4px; }
.vital-bar {
  height: 8px; border-radius: 999px;
  background: linear-gradient(90deg, var(--ok) 0%, var(--ok) 33%, var(--warn) 33%, var(--warn) 66%, var(--bad) 66%);
  opacity: .25; margin-bottom: 4px;
}
.vital-marker {
  position: absolute; top: 0; width: 10px; height: 10px;
  border-radius: 50%; border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px currentColor; transform: translateX(-50%);
}
.vital-marker.ok { color: var(--ok); background: var(--ok); }
.vital-marker.warn { color: var(--warn); background: var(--warn); }
.vital-marker.bad { color: var(--bad); background: var(--bad); }
.vital-scale-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }

/* ── Дашборд-уведомления (watch) ─────────────────── */
.dashboard-watch-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.dashboard-watch-item {
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-soft); padding: 8px 10px; display: grid; gap: 6px;
}
.dashboard-watch-title { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.dashboard-watch-state { font-size: 14px; font-weight: 800; color: var(--text-strong); }
.dashboard-watch-state.ok { color: var(--ok); }
.dashboard-watch-state.warn { color: var(--warn); }
.dashboard-watch-state.bad { color: var(--bad); }
.dashboard-watch-state.neutral { color: var(--muted); }
.dashboard-watch-action { min-height: 28px; padding: 5px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; align-self: start; }

/* ── Графики ─────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.chart-stage {
  position: relative;
  overflow: visible;
}
.chart-stage canvas {
  width: 100%;
  height: 420px;
  display: block;
}
.chart-kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 10px; }
.chart-kpi-title { margin: 0; font-size: 13px; font-weight: 800; color: var(--text-strong); }
.chart-current { font-size: 28px; font-weight: 900; line-height: 1; margin: 4px 0 2px; }
.chart-details { font-size: 11px; color: var(--muted); }
.chart-foot { margin-top: 10px; }
.chart-foot-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.chart-download { font-size: 11px; color: var(--brand); background: none; border: 1px solid var(--line-strong); padding: 4px 8px; border-radius: 6px; }
.chart-download:hover { background: var(--surface-soft); box-shadow: none; }

.threshold-bar { height: 6px; border-radius: 999px; background: var(--surface-muted); margin: 8px 0 4px; overflow: hidden; }
.threshold-marker { position: absolute; }
.threshold-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }

/* ── Метрика-история ─────────────────────────────── */
.metric-story { margin-top: 12px; padding: 10px; background: var(--surface-soft); border-radius: 10px; font-size: 12px; line-height: 1.5; color: var(--text); }
.metric-story-quote { font-style: italic; color: var(--muted); }
.metric-story-conclusion { margin-top: 4px; font-weight: 700; color: var(--text-strong); }

/* ── CWV Insights ────────────────────────────────── */
.cwv-insights { margin-top: 14px; display: grid; gap: 12px; }
.site-ai-summary { padding: 14px; background: var(--surface-soft); border-radius: 12px; border: 1px solid var(--line); margin-bottom: 14px; }

/* ── Конкуренты ──────────────────────────────────── */
.competitor-panel {
  margin: 0 0 14px 0; border: 1px solid var(--line);
  border-radius: 14px; background: var(--surface-soft); padding: 12px;
}
.competitor-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.competitor-title { margin: 0; font-size: 15px; font-weight: 800; }
.competitor-form { display: grid; gap: 8px; }
.competitor-form textarea {
  min-height: 96px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); padding: 10px 12px;
  font-size: 14px; font-family: inherit; line-height: 1.4; resize: vertical; width: 100%;
}
.competitor-form textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.12); outline: none; }
.competitor-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.competitor-status { font-size: 12px; }
.competitor-status.ok { color: var(--ok); }
.competitor-status.error { color: var(--bad); }
.competitor-suggest { margin-top: 10px; padding: 10px; border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--surface-soft); }
.competitor-suggest.hidden { display: none; }
.competitor-suggest-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 10px; margin: 8px 0; }
.competitor-suggest-item { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text); }
.competitor-suggest-item input { width: 16px; height: 16px; }
.competitor-table-wrap {
  margin-top: 10px; border: 1px solid var(--line); border-radius: 12px;
  overflow-x: auto; overflow-y: hidden; max-width: 100%;
  -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; touch-action: pan-x;
  background: var(--surface);
}
.competitor-table { width: 100%; border-collapse: collapse; min-width: 740px; }
.competitor-table th, .competitor-table td {
  border-bottom: 1px solid var(--line); padding: 8px 10px;
  text-align: left; font-size: 12px; color: var(--text); vertical-align: top;
}
.competitor-table th {
  position: sticky; top: 0; background: var(--surface-soft); z-index: 1;
  font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted);
}
.competitor-table tr.main-row td { font-weight: 700; background: var(--surface-soft); }
.competitor-table tr:last-child td { border-bottom: none; }
.competitor-cards { display: grid; gap: 10px; padding: 10px; }
.competitor-card {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-soft); padding: 10px; display: grid; gap: 7px;
}
.competitor-card.main { border-color: var(--brand); box-shadow: 0 0 0 1px rgba(37,99,235,.15); }
.competitor-card h5 { margin: 0; color: var(--text-strong); font-size: 14px; font-weight: 800; }
.competitor-kpis { display: grid; gap: 6px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.competitor-kpi { border-radius: 8px; background: var(--surface-muted); color: var(--text); padding: 6px 8px; font-size: 12px; }
.competitor-kpi b { color: var(--text-strong); }
.competitor-summary { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); color: var(--text); font-size: 13px; line-height: 1.45; }
.competitor-delta { font-size: 13px; font-weight: 700; }
.competitor-delta.good { color: var(--ok); }
.competitor-delta.bad { color: var(--bad); }
.competitor-delta.neutral { color: var(--muted); }

/* ── Compare / What-if ───────────────────────────── */
.compare-panel { margin: 0 0 14px 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); padding: 12px; }
.whatif-panel { margin: 0 0 14px 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); padding: 12px; }
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.whatif-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.whatif-item { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 10px; }
.whatif-impact { font-size: 24px; font-weight: 900; }
.whatif-impact.good { color: var(--ok); }
.whatif-impact.bad { color: var(--bad); }
.whatif-metrics { font-size: 12px; color: var(--muted); margin-top: 4px; }
.whatif-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ── P1 Analytics ────────────────────────────────── */
.p1-analytics { margin: 0 0 14px; }
.p1-block { margin-bottom: 14px; }
.p1-groups { display: grid; gap: 10px; }
.p1-group-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 10px; }
.p1-group-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 8px; }
.p1-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.p1-table th, .p1-table td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; }
.p1-table th { color: var(--muted); font-weight: 700; font-size: 11px; }
.p1-stack { display: grid; gap: 6px; }
.p1-stack-req { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.p1-stack-bytes { color: var(--muted); font-size: 11px; }
.p1-rum { margin: 0 0 14px; }
.p1-rum-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

/* ── Toast / диалог / Skeleton ───────────────────── */
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 9999; max-width: 340px; }
.toast {
  padding: 10px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  background: var(--text-strong); color: var(--surface); box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: toastIn .2s ease;
}
.toast.success { background: var(--ok); }
.toast.error { background: var(--bad); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.dialog-backdrop {
  position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
}
.dialog-backdrop.hidden { display: none !important; }
.dialog {
  background: var(--surface); border-radius: 16px; padding: 24px;
  max-width: 440px; width: calc(100% - 32px); box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.dialog h3 { margin: 0 0 10px; font-size: 18px; }
.feedback-text {
  width: 100%; min-height: 100px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); padding: 10px 12px; font-family: inherit; font-size: 14px; resize: vertical;
}
.feedback-text:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.feedback-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.feedback-strip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 700;
  background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.3); color: #fff; cursor: pointer;
}
.feedback-strip:hover { background: rgba(255,255,255,.3); box-shadow: none; }

.skeleton {
  border-radius: 8px; background: var(--surface-soft);
  animation: pulse 1.4s ease infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ── Мобильные сворачиваемые секции ──────────────── */
.mobile-foldable { position: relative; }
.mobile-fold-toggle {
  display: none; width: 100%; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); border-radius: 10px;
  padding: 8px 10px; font-size: 13px; font-weight: 800;
  align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer;
}
.mobile-fold-toggle .arrow { transition: transform .15s; }
.mobile-foldable:not(.folded) .mobile-fold-toggle .arrow { transform: rotate(180deg); }
.mobile-foldable.folded .mobile-fold-body { display: none; }

/* ── Tooltip ──────────────────────────────────────── */
.chart-tooltip {
  position: fixed; z-index: 200; pointer-events: none;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 10px 12px; font-size: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  min-width: 240px; max-width: 360px;
  transition: opacity .1s;
}
.chart-tooltip.below { top: auto; }
.chart-tooltip-title { font-weight: 800; margin-bottom: 6px; font-size: 13px; }
.chart-tooltip-row { display: flex; justify-content: space-between; gap: 12px; }
.chart-tooltip-val { font-weight: 700; }

/* ── Адаптив (мобайл) ────────────────────────────── */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--line); padding: 12px; }
  .app-main { padding: 12px; }
  .create-row { grid-template-columns: 1fr; gap: 8px; }
  .create-row .field input, .create-row .field select { height: 44px; }
  .field-url, .field-title, .field-schedule, .field-interval { grid-column: span 12; }
  .field-action { grid-column: span 12; }
  .mobile-site-header { display: flex; }
  .mobile-fold-toggle { display: flex; }
  .dashboard-watch-controls { grid-template-columns: 1fr; }
  .overview-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vitals-strip { grid-template-columns: 1fr; }
  .chart-stage canvas { height: 280px; }
  .compare-grid, .whatif-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .overview-grid { grid-template-columns: 1fr; }
  .overview-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
