/* ═══════════════════════════════════════════════════════════════════
   Пульт заявок — тёмная «приборная» тема.
   Палитра построена на семантике: зелёный = деньги, красный = потери,
   синий = нейтральный поток, янтарный = требует решения.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --bg:        #0a0c10;
  --bg-soft:   #0e1117;
  --surface:   #12161f;
  --surface-2: #161b26;
  --border:    #212936;
  --border-soft: #1a212c;

  --text:  #e6edf3;
  --muted: #8b98a9;
  --dim:   #5d6b7d;

  --blue:   #4c8dff;
  --green:  #3fb950;
  --amber:  #e3b341;
  --red:    #f85149;
  --purple: #a371f7;
  --cyan:   #39c5cf;
  --slate:  #6e7b8f;
  --accent: var(--blue);

  --radius: 12px;
  --radius-sm: 8px;
  --gap: 16px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 17px; }
h2 { font-size: 14px; }
p { margin: 0; }
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }

.muted { color: var(--muted); }
.dim { color: var(--dim); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.good { color: var(--green); }
.bad  { color: var(--red); }

/* ─────────────────────────── Каркас ─────────────────────────────── */

.app {
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

#header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(180deg, var(--bg) 72%, rgba(10, 12, 16, 0.86));
  backdrop-filter: blur(8px);
  padding: 18px 0 0;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 18px;
}

.head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(76, 141, 255, 0.22), rgba(163, 113, 247, 0.18));
  border: 1px solid rgba(76, 141, 255, 0.35);
  color: var(--blue);
  font-size: 16px;
}

.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.stale {
  margin-left: 8px; padding: 1px 7px;
  border-radius: 20px; font-size: 11px;
  background: rgba(227, 179, 65, 0.14); color: var(--amber);
  border: 1px solid rgba(227, 179, 65, 0.3);
}

.head-actions { display: flex; align-items: center; gap: 8px; }

/* Сегментированный переключатель периода */
.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 11px; border-radius: 7px;
  color: var(--muted); font-size: 12.5px; font-weight: 500;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--text); background: var(--surface-2); }
.seg-btn.is-active { background: var(--border); color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,0.05); }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.btn:hover { border-color: var(--dim); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; }
.btn-primary {
  background: linear-gradient(180deg, #5b9bff, #3d7de6);
  border-color: #5b9bff;
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: linear-gradient(180deg, #6ba5ff, #4c8dff); border-color: #6ba5ff; }
.btn-icon { padding: 7px 10px; font-size: 14px; line-height: 1; }
.btn-icon.is-on { border-color: var(--amber); color: var(--amber); }
.is-spinning { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; gap: 2px; margin-top: 14px; }

.tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 9px 14px;
  color: var(--muted); font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--blue); }

/* ────────────────────── Фильтры и период ────────────────────────── */

#filters { margin-bottom: 16px; }

.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 14px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}

.filter { display: flex; flex-direction: column; gap: 5px; }
.filter > span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.filter select, .filter input {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  min-width: 140px;
  outline: none;
}
.filter select:focus, .filter input:focus { border-color: var(--blue); }
.filter-search input { min-width: 230px; }

.period-line { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.period-line b { color: var(--text); font-weight: 500; }
.period-line .dot { color: var(--dim); }

/* ─────────────────────────── Алерты ─────────────────────────────── */

.alerts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.alert {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
.alert::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; }
.alert.level-critical::before { background: var(--red); }
.alert.level-warning::before { background: var(--amber); }
.alert.level-good::before { background: var(--green); }

.alert-icon {
  flex: none; width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.level-critical .alert-icon { background: rgba(248, 81, 73, 0.16); color: var(--red); }
.level-warning .alert-icon { background: rgba(227, 179, 65, 0.16); color: var(--amber); }
.level-good .alert-icon { background: rgba(63, 185, 80, 0.16); color: var(--green); }

.alert-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.alert-text { font-size: 12.5px; color: var(--muted); line-height: 1.4; }

.alerts-more { margin: -8px 0 18px; }
.alerts-more summary {
  cursor: pointer; list-style: none;
  font-size: 12.5px; color: var(--muted);
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  display: flex; gap: 8px; align-items: baseline;
}
.alerts-more summary::-webkit-details-marker { display: none; }
.alerts-more summary::before { content: '▸'; color: var(--dim); }
.alerts-more[open] summary::before { content: '▾'; }
.alerts-more summary:hover { border-color: var(--dim); color: var(--text); }
.alerts-more summary .muted { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alerts-more .alerts { margin-top: 10px; }

/* ─────────────────────────── KPI ────────────────────────────────── */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.kpi {
  position: relative;
  padding: 14px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.045em; }
.kpi-value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; margin-top: 8px; line-height: 1.05; }
.kpi-sub { font-size: 12px; color: var(--dim); margin-top: 4px; }
.kpi-spark { margin-top: 10px; height: 32px; }
.kpi-spark .spark { width: 100%; height: 32px; display: block; }

.kpi-progress { height: 3px; background: var(--border-soft); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.kpi-progress i { display: block; height: 100%; border-radius: 3px; }

.delta {
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  padding: 2px 7px; border-radius: 20px;
}
.delta.is-good { color: var(--green); background: rgba(63, 185, 80, 0.12); }
.delta.is-bad  { color: var(--red);   background: rgba(248, 81, 73, 0.12); }
.delta.is-flat, .delta.is-none { color: var(--dim); background: var(--border-soft); }

/* ─────────────────────────── Карточки ───────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
}

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-sub { font-size: 12px; color: var(--muted); margin-top: 3px; max-width: 62ch; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: var(--bg-soft); border: 1px solid var(--border);
  padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.badge-good { color: var(--green); border-color: rgba(63, 185, 80, 0.3); }
.badge-warn { color: var(--amber); border-color: rgba(227, 179, 65, 0.3); }
.badge-bad  { color: var(--red);   border-color: rgba(248, 81, 73, 0.3); }

.grid { display: grid; gap: var(--gap); margin-bottom: var(--gap); }
.grid-main   { grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr); align-items: start; }
.grid-second { grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr); align-items: start; }
.grid-two    { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.stack-col   { display: flex; flex-direction: column; gap: var(--gap); }

.insight {
  margin-top: 14px; padding: 11px 13px;
  background: rgba(76, 141, 255, 0.06);
  border: 1px solid rgba(76, 141, 255, 0.18);
  border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
}
.insight b { color: var(--text); }

.empty { color: var(--dim); font-size: 13px; padding: 24px 0; text-align: center; }
.empty.big { padding: 40px 0; font-size: 14px; }

.fatal { padding: 60px 20px; text-align: center; max-width: 560px; margin: 0 auto; }
.fatal h2 { font-size: 18px; margin-bottom: 10px; }
.fatal p { color: var(--muted); margin-bottom: 12px; }

/* ─────────────────────────── Графики ────────────────────────────── */

.chart { width: 100%; display: block; overflow: visible; }
.card-flow .chart { height: auto; max-height: 260px; }
.chart .grid { stroke: var(--border-soft); stroke-width: 1; }
.chart .grid.dashed { stroke: var(--green); stroke-dasharray: 4 4; opacity: 0.5; }
.chart .axis-line { stroke: var(--border); }
.chart .axis { fill: var(--dim); font-size: 10px; font-family: var(--font); }
.chart .axis-title { fill: var(--dim); font-size: 10px; letter-spacing: 0.03em; }
.chart .dot-label { fill: var(--muted); font-size: 10.5px; }
.bar-g:hover rect:not(.bar-hit) { filter: brightness(1.25); }
.matrix { height: 360px; }

.legend-inline { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.legend-inline span { display: inline-flex; align-items: center; gap: 5px; }
.legend-inline i, .legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* Донат */
.donut-wrap { position: relative; display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.donut { flex: none; }
.donut circle { transition: opacity 0.15s; }
.donut:hover circle { opacity: 0.55; }
.donut circle:hover { opacity: 1; }
.donut-center {
  position: absolute; left: 84px; top: 50%; transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
.donut-center b { display: block; font-size: 22px; font-weight: 650; }
.donut-center span { font-size: 11px; color: var(--muted); }

.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 150px; display: grid; gap: 7px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend-label { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-share { color: var(--dim); font-size: 11.5px; min-width: 38px; text-align: right; }

/* Воронка */
.funnel { display: grid; gap: 14px; }
.funnel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.funnel-label { font-size: 12.5px; font-weight: 500; }
.funnel-value { font-size: 15px; font-weight: 650; }
.funnel-track { position: relative; height: 26px; background: var(--bg-soft); border-radius: 6px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 6px; transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.funnel-bar.tone-blue   { background: linear-gradient(90deg, rgba(76,141,255,.85), rgba(76,141,255,.45)); }
.funnel-bar.tone-cyan   { background: linear-gradient(90deg, rgba(57,197,207,.85), rgba(57,197,207,.4)); }
.funnel-bar.tone-green  { background: linear-gradient(90deg, rgba(63,185,80,.9), rgba(63,185,80,.45)); }
.funnel-bar.tone-purple { background: linear-gradient(90deg, rgba(163,113,247,.85), rgba(163,113,247,.4)); }
.funnel-conv {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11.5px; font-weight: 600; color: var(--muted);
}
.funnel-conv.is-weak { color: var(--red); }
.funnel-hint { font-size: 11.5px; color: var(--dim); margin-top: 4px; }
.funnel-row { cursor: default; }

/* ─────────────────────── Очередь действий ───────────────────────── */

.queue { display: grid; gap: 18px; }
.qgroup-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.qgroup h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; display: flex; align-items: center; gap: 7px; }
.qgroup.tone-red h3 { color: var(--red); }
.qgroup.tone-amber h3 { color: var(--amber); }
.qgroup.tone-blue h3 { color: var(--blue); }
.qgroup.tone-cyan h3 { color: var(--cyan); }
.qcount { background: var(--border); color: var(--text); border-radius: 20px; padding: 1px 8px; font-size: 11px; }
.qgroup-hint { font-size: 11.5px; color: var(--dim); }

.qlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }

.qitem {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
}
.qitem:hover { border-color: var(--border); background: var(--surface-2); }
.qitem.is-local { border-style: dashed; border-color: rgba(76, 141, 255, 0.4); }

.qitem-score {
  flex: none; width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 650; color: var(--muted);
}
.qitem-main { min-width: 0; flex: 1; }
.qitem-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.qitem-niche { font-weight: 550; font-size: 13px; }
.qitem-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--muted); align-items: center; }
.qitem-comment { color: var(--dim); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch; }
.qmore { font-size: 12px; color: var(--dim); padding: 7px 2px 0; }

.contact { color: var(--blue); text-decoration: none; font-variant-numeric: tabular-nums; }
.contact:hover { text-decoration: underline; }
.contact.is-masked { color: var(--dim); cursor: help; }

/* Чипы статусов */
.chip {
  font-size: 11px; font-weight: 550; padding: 2px 8px; border-radius: 20px;
  border: 1px solid transparent; white-space: nowrap;
}
.chip-green  { background: rgba(63,185,80,.13);  color: var(--green);  border-color: rgba(63,185,80,.28); }
.chip-red    { background: rgba(248,81,73,.13);  color: var(--red);    border-color: rgba(248,81,73,.28); }
.chip-amber  { background: rgba(227,179,65,.13); color: var(--amber);  border-color: rgba(227,179,65,.28); }
.chip-blue   { background: rgba(76,141,255,.13); color: var(--blue);   border-color: rgba(76,141,255,.28); }
.chip-purple { background: rgba(163,113,247,.13);color: var(--purple); border-color: rgba(163,113,247,.28); }
.chip-slate  { background: rgba(110,123,143,.14);color: #a3b0c2;       border-color: rgba(110,123,143,.3); }
.chip-cyan   { background: rgba(57,197,207,.13); color: var(--cyan);   border-color: rgba(57,197,207,.28); }
.chip-ghost  { background: transparent; color: var(--dim); border-color: var(--border); }
.chip-vol    { background: var(--surface-2); color: var(--muted); border-color: var(--border); font-variant-numeric: tabular-nums; }

.mini-btn {
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--muted);
  border-radius: 7px; padding: 3px 8px; font-size: 11px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.mini-btn:hover { color: var(--text); border-color: var(--dim); }
.mini-btn-accent { color: var(--blue); border-color: rgba(76,141,255,.35); }
.draft-cell { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }

/* ─────────────────────────── Таблицы ────────────────────────────── */

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0 10px 9px; border-bottom: 1px solid var(--border);
}
th.num, td.num { text-align: right; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg-soft); }

.cell-key { font-weight: 500; }
.bars .col-bar { width: 42%; }
.stack { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--border-soft); min-width: 12px; }
.stack i { display: block; height: 100%; }
.seg-green { background: var(--green); }
.seg-blue  { background: var(--blue); opacity: .75; }
.seg-slate { background: var(--slate); }
.seg-red   { background: var(--red); }

.table-wrap { max-height: 70vh; overflow: auto; margin: 0 -6px; }
.table-wrap thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--text); }
.sortable.is-sorted { color: var(--blue); }
.sortable.is-sorted::after { content: ' ↑'; }
.sortable.is-sorted.desc::after { content: ' ↓'; }
.leads td { white-space: normal; }
.cell-comment { color: var(--muted); max-width: 34ch; }
.leads tr.stage-qualified td:first-child { box-shadow: inset 2px 0 0 var(--green); }
.leads tr.stage-spam { opacity: 0.55; }
.leads tr.is-local { background: rgba(76, 141, 255, 0.045); }
.leads tr.is-local td:first-child { box-shadow: inset 2px 0 0 var(--blue); }

/* ──────────────────── Полнота данных / вердикты ─────────────────── */

.quality-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.quality-list li { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.q-label { width: 108px; color: var(--muted); flex: none; }
.q-track { flex: 1; height: 6px; background: var(--border-soft); border-radius: 4px; overflow: hidden; }
.q-track i { display: block; height: 100%; border-radius: 4px; }
.q-val { width: 40px; text-align: right; color: var(--dim); font-size: 11.5px; }

.verdicts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.verdict.tone-green { border-color: rgba(63,185,80,.28); }
.verdict.tone-red { border-color: rgba(248,81,73,.28); }
.verdict.tone-cyan { border-color: rgba(57,197,207,.25); }
.verdict-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.verdict-list li { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.v-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-bar { width: 62px; height: 5px; background: var(--border-soft); border-radius: 3px; overflow: hidden; flex: none; }
.v-bar i { display: block; height: 100%; background: currentColor; opacity: .8; }
.tone-green .v-bar i { background: var(--green); }
.tone-red .v-bar i { background: var(--red); }
.tone-cyan .v-bar i { background: var(--cyan); }
.tone-slate .v-bar i { background: var(--slate); }
.v-num { color: var(--dim); font-size: 11.5px; white-space: nowrap; }

/* ────────────────────────── Подсказка ───────────────────────────── */

.tooltip {
  position: fixed; top: 0; left: 0; z-index: 999;
  max-width: 280px; pointer-events: none;
  padding: 8px 11px; border-radius: 8px;
  background: #05070b; border: 1px solid var(--border);
  color: var(--text); font-size: 12px; line-height: 1.45;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}
.tooltip b { color: #fff; }

/* ───────────────────────── Загрузка ─────────────────────────────── */

.skeleton { display: grid; gap: var(--gap); padding: 40px 0; }
.skeleton div {
  height: 90px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ────────────────────── Модалка «Новая заявка» ──────────────────── */

body.modal-open { overflow: hidden; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(4, 6, 10, 0.68);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 40px;
  overflow-y: auto;
  animation: fade-in 0.15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%; max-width: 460px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: modal-in 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border-soft);
}
.modal-head h2 { font-size: 15px; }
.modal-x {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.modal-x:hover { color: var(--text); background: var(--bg-soft); }

.lead-form { padding: 16px 18px 18px; display: grid; gap: 12px; }
.lead-form label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.lead-form input, .lead-form select, .lead-form textarea {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; color: var(--text); outline: none;
  text-transform: none; letter-spacing: normal; font-family: var(--font);
}
.lead-form input:focus, .lead-form select:focus, .lead-form textarea:focus { border-color: var(--blue); }
.lead-form textarea { resize: vertical; min-height: 44px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modal-note {
  font-size: 12px; color: var(--amber); line-height: 1.5;
  background: rgba(227, 179, 65, 0.08); border: 1px solid rgba(227, 179, 65, 0.25);
  border-radius: var(--radius-sm); padding: 9px 11px;
}
.modal-note a { color: var(--amber); font-weight: 600; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }

/* ────────────────────────── Уведомления ─────────────────────────── */

#toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  background: #05070b; border: 1px solid var(--border); color: var(--text);
  font-size: 12.5px; padding: 10px 14px; border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s;
  max-width: 320px;
}
.toast.is-in { opacity: 1; transform: none; }
.toast-warn { border-color: rgba(227, 179, 65, 0.4); color: var(--amber); }

/* ─────────────────── Режим вставки на сайт ──────────────────────── */

body.is-embed .app { padding: 0 14px 24px; max-width: none; }
body.is-embed #header { padding-top: 12px; }
body.is-embed { background: var(--bg); }

/* ───────────────────────── Адаптив ──────────────────────────────── */

@media (max-width: 1200px) {
  .grid-main, .grid-second { grid-template-columns: 1fr; }
  .grid-two { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app { padding: 0 12px 32px; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .kpi-value { font-size: 24px; }
  .head-row { align-items: flex-start; }
  .head-actions { width: 100%; justify-content: space-between; }
  .seg { overflow-x: auto; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card { padding: 14px; }
  .filter select, .filter input, .filter-search input { min-width: 0; width: 100%; }
  .filter { flex: 1 1 140px; }
  .donut-center { left: 84px; }
  .qitem-comment { max-width: 18ch; }
  .form-row { grid-template-columns: 1fr; }
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal { max-width: none; border-radius: 0; min-height: 100%; }
  #toast { left: 12px; right: 12px; align-items: stretch; }
  .toast { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
