/* ==========================================================================
   Сквозная аналитика — оформление дашборда
   Тёмная тема, без внешних шрифтов и иконок.
   ========================================================================== */

:root {
  --bg: #070b13;
  --bg-soft: #0a101c;
  --panel: #0f1726;
  --panel-2: #121c2e;
  --panel-3: #17223a;
  --border: rgba(148, 163, 184, .14);
  --border-strong: rgba(148, 163, 184, .26);
  --text: #e8eefb;
  --text-soft: #c3cede;
  --muted: #8a9ab3;
  --muted-2: #66758c;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, .12);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, .12);
  --amber: #f5b544;
  --amber-soft: rgba(245, 181, 68, .12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, .12);
  --purple: #a78bfa;
  --cyan: #22d3ee;
  --pink: #f472b6;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 45px -24px rgba(0, 0, 0, .9);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
          Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { 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;
}

body {
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(52, 211, 153, .07), transparent 60%),
    radial-gradient(900px 500px at 10% 0%, rgba(96, 165, 250, .07), transparent 55%);
  background-attachment: fixed;
}

h1, h2, h3, h4 { margin: 0; font-weight: 640; letter-spacing: -.01em; }
a { color: var(--blue); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.icon { width: 18px; height: 18px; fill: none; flex: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 11.5px; }
.w-full { width: 100%; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* --------------------------------------------------------------------------
   Каркас
   -------------------------------------------------------------------------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  width: 238px;
  height: 100vh;
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  background: linear-gradient(180deg, rgba(15, 23, 38, .96), rgba(8, 13, 22, .98));
  border-right: 1px solid var(--border);
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, rgba(52, 211, 153, .2), rgba(96, 165, 250, .12));
  border: 1px solid rgba(52, 211, 153, .3);
  color: var(--green);
  box-shadow: inset 0 0 24px rgba(52, 211, 153, .08);
}
.brand-mark .icon { width: 22px; height: 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.brand-text span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .16em; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  background: transparent; border: 1px solid transparent;
  color: var(--muted); text-align: left; font-size: 13.5px;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-item .icon { width: 17px; height: 17px; opacity: .85; }
.nav-item:hover { background: rgba(148, 163, 184, .07); color: var(--text-soft); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(52, 211, 153, .13), rgba(52, 211, 153, .03));
  border-color: rgba(52, 211, 153, .22);
  color: var(--text);
}
.nav-item.active .icon { color: var(--green); opacity: 1; }
.nav-badge {
  margin-left: auto; font-size: 10.5px; padding: 1px 6px; border-radius: 20px;
  background: rgba(248, 113, 113, .16); color: var(--red);
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 4px; }
.sync-line { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); flex: none; }
.dot.ok { background: var(--green); box-shadow: 0 0 10px rgba(52, 211, 153, .7); }
.dot.demo { background: var(--amber); box-shadow: 0 0 10px rgba(245, 181, 68, .6); }
.dot.err { background: var(--red); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 26px;
  background: rgba(7, 11, 19, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.crumb { font-size: 13px; color: var(--muted); letter-spacing: .02em; white-space: nowrap; }
.filters { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }

.view { width: 100%; max-width: 1560px; margin: 0 auto; padding: 24px 26px 70px; }

/* --------------------------------------------------------------------------
   Кнопки, поля
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 13px; border-radius: 9px;
  background: linear-gradient(180deg, #1a2740, #142033);
  border: 1px solid var(--border-strong);
  color: var(--text-soft); font-size: 12.5px; font-weight: 550;
  transition: .15s ease; white-space: nowrap;
}
.btn:hover { border-color: rgba(148, 163, 184, .45); color: var(--text); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: rgba(148, 163, 184, .05); }
.btn.primary {
  background: linear-gradient(180deg, #34d399, #22b981);
  border-color: rgba(52, 211, 153, .6); color: #05261a; font-weight: 700;
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--red); border-color: rgba(248, 113, 113, .3); background: var(--red-soft); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.icon { padding: 8px; width: 34px; height: 34px; }
.btn.icon .icon { width: 16px; height: 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.select, .input {
  appearance: none;
  padding: 8px 30px 8px 11px;
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(26, 39, 64, .9), rgba(20, 32, 51, .9)) padding-box,
    transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-soft); font-size: 12.5px; max-width: 210px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 15px, calc(100% - 9px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select:focus, .input:focus { outline: none; border-color: rgba(52, 211, 153, .5); }
.input { background-image: none; padding-right: 11px; }
.input.search { padding-left: 32px; background: rgba(148, 163, 184, .05); }
.search-wrap { position: relative; }
.search-wrap .icon { position: absolute; left: 10px; top: 9px; width: 15px; height: 15px; color: var(--muted); }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: rgba(148, 163, 184, .06);
  border: 1px solid var(--border); border-radius: 10px;
}
.seg button {
  padding: 5px 10px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-size: 12px;
}
.seg button:hover { color: var(--text-soft); }
.seg button.active { background: rgba(52, 211, 153, .14); color: var(--green); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, .2); }

.dropdown { position: relative; }
.dropdown .menu, .popover {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50;
  min-width: 190px; padding: 6px;
  background: #101a2b; border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: .14s ease;
}
.dropdown.open .menu, .popover.open { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown .menu button {
  display: block; width: 100%; text-align: left; padding: 8px 10px;
  background: transparent; border: 0; border-radius: 7px; font-size: 12.5px; color: var(--text-soft);
}
.dropdown .menu button:hover { background: rgba(148, 163, 184, .09); }

.popover-wrap { position: relative; }
.popover { right: 0; width: 250px; padding: 14px; }
.popover-month-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; margin-bottom: 10px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.popover-month-nav span {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  text-align: center; white-space: nowrap; text-transform: capitalize;
}
.popover-month-nav .btn.icon { width: 30px; height: 30px; padding: 0; }
.popover .field { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.popover .field span { width: 22px; color: var(--muted); font-size: 12px; }
.popover .field input { flex: 1; }
.popover-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

/* --------------------------------------------------------------------------
   Шапка раздела, карточки
   -------------------------------------------------------------------------- */

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.view-head h1 { font-size: 24px; letter-spacing: -.02em; }
.view-head .sub { margin: 5px 0 0; color: var(--muted); font-size: 12.5px; }
.view-head .sub b { color: var(--text-soft); font-weight: 600; }
.head-actions { display: flex; align-items: center; gap: 8px; }

.card {
  background:
    linear-gradient(180deg, rgba(23, 34, 58, .55), rgba(15, 23, 38, .72));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .02) inset;
  min-width: 0;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h3 { font-size: 14px; letter-spacing: -.01em; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 11.5px; }
.card-head .aside { font-size: 11.5px; color: var(--muted); text-align: right; }

.grid { display: grid; gap: 14px; margin-bottom: 16px; }
.grid.main-2, .grid.side { align-items: start; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.main-2 { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.grid.main-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }
.grid.side { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.span-2 { grid-column: span 2; }

.kpi {
  position: relative; overflow: hidden;
  padding: 16px 17px 14px;
  border-radius: 15px;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(23, 34, 58, .7), rgba(15, 23, 38, .85));
}
.kpi:after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(260px 120px at 110% -20%, var(--kpi-glow, rgba(52, 211, 153, .1)), transparent 70%);
  pointer-events: none;
}
.kpi .kpi-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; letter-spacing: .02em; text-transform: uppercase; }
.kpi .kpi-value { margin-top: 7px; font-size: 26px; font-weight: 680; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi .kpi-value small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi .kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 11.5px; color: var(--muted); min-height: 18px; padding-right: 58px; }
.kpi .kpi-spark { position: absolute; right: 12px; bottom: 10px; opacity: .75; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; padding: 1px 6px; border-radius: 6px; }
.delta .icon { width: 11px; height: 11px; }
.delta.good { color: var(--green); background: var(--green-soft); }
.delta.bad { color: var(--red); background: var(--red-soft); }
.delta.neutral { color: var(--muted); background: rgba(148, 163, 184, .09); }
.delta.flat { color: var(--muted); }

.progress { height: 5px; border-radius: 4px; background: rgba(148, 163, 184, .13); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #22b981, #34d399); }
.progress.warn > i { background: linear-gradient(90deg, #d98b1f, #f5b544); }
.progress.bad > i { background: linear-gradient(90deg, #cf4b4b, #f87171); }

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

.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.data thead th {
  position: sticky; top: 0; z-index: 2;
  background: #121c2e;
  color: var(--muted); font-weight: 550; text-align: left; white-space: nowrap;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
}
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--text-soft); }
table.data thead th .sort { opacity: .45; margin-left: 3px; font-size: 10px; }
table.data tbody td { padding: 10px 12px; border-bottom: 1px solid rgba(148, 163, 184, .07); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr:hover { background: rgba(148, 163, 184, .055); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tfoot td { padding: 10px 12px; font-weight: 650; border-top: 1px solid var(--border-strong); background: rgba(18, 28, 46, .7); }
.cell-main { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cell-main .name { font-weight: 550; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-main .sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.ch-dot { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px; font-size: 11px;
  background: rgba(148, 163, 184, .1); color: var(--text-soft);
  border: 1px solid transparent; white-space: nowrap;
}
.chip.green { background: var(--green-soft); color: var(--green); border-color: rgba(52, 211, 153, .2); }
.chip.red { background: var(--red-soft); color: var(--red); border-color: rgba(248, 113, 113, .2); }
.chip.amber { background: var(--amber-soft); color: var(--amber); border-color: rgba(245, 181, 68, .2); }
.chip.blue { background: var(--blue-soft); color: var(--blue); border-color: rgba(96, 165, 250, .2); }
.chip.muted { color: var(--muted); }
.bar-mini { display: flex; align-items: center; gap: 7px; justify-content: flex-end; }
.bar-mini .track { width: 46px; height: 4px; border-radius: 3px; background: rgba(148, 163, 184, .14); overflow: hidden; }
.bar-mini .track i { display: block; height: 100%; border-radius: 3px; background: var(--green); }
.bar-mini .track i.neg { background: var(--red); }

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

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--muted); font-size: 10.5px; }
.chart .grid-line { stroke: rgba(148, 163, 184, .11); stroke-width: 1; }
.chart .axis-line { stroke: rgba(148, 163, 184, .2); stroke-width: 1; }
.chart .bar-spend { fill: #f5b544; opacity: .95; }
.chart .bar-revenue { fill: #34d399; opacity: .95; }
.chart .bar-negative { fill: #f87171; }
.chart .line-profit { stroke: #60a5fa; stroke-width: 2.4; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .area-profit { fill: url(#profitGrad); opacity: .18; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover { fill: rgba(148, 163, 184, .06); }
.chart .point { fill: #0b1220; stroke: #60a5fa; stroke-width: 2; }
.chart text.legend { font-size: 11px; fill: var(--muted); }
.chart .target-line { stroke: rgba(248, 113, 113, .6); stroke-width: 1.2; stroke-dasharray: 4 4; }

.legend-row { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin: 0 0 6px; font-size: 11.5px; color: var(--muted); }
.legend-row span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.legend-line { width: 14px; height: 2px; background: var(--blue); display: inline-block; border-radius: 2px; }

.axis-caption { font-size: 10.5px; fill: var(--muted-2); }

.hbar-list { display: flex; flex-direction: column; gap: 9px; }
.hbar { display: grid; grid-template-columns: 118px 1fr 66px; align-items: center; gap: 10px; font-size: 12px; }
.hbar .label { color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .rail { position: relative; height: 22px; background: rgba(148, 163, 184, .07); border-radius: 6px; overflow: hidden; }
.hbar .rail .zero { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(148, 163, 184, .3); }
.hbar .fill { position: absolute; top: 3px; bottom: 3px; border-radius: 4px; min-width: 2px; }
.hbar .value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-soft); }
.hbar .value.neg { color: var(--red); }

.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut-center { position: relative; width: 150px; height: 150px; flex: none; }
.donut-center .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center .center b { font-size: 17px; font-weight: 680; }
.donut-center .center span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.donut-legend { display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; min-width: 0; }
.donut-legend .row { display: flex; align-items: center; gap: 7px; }
.donut-legend .row .name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-soft); }
.donut-legend .row .val { color: var(--muted); font-variant-numeric: tabular-nums; }

.funnel { display: flex; flex-direction: column; gap: 4px; }
.funnel-step { display: grid; grid-template-columns: 128px 1fr 82px; align-items: center; gap: 10px; }
.funnel-step .name { font-size: 11.5px; color: var(--muted); }
.funnel-step .track { height: 26px; background: rgba(148, 163, 184, .06); border-radius: 6px; overflow: hidden; }
.funnel-step .track i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, rgba(52, 211, 153, .85), rgba(52, 211, 153, .45)); }
.funnel-step .val { text-align: right; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.funnel-conv { display: grid; grid-template-columns: 128px 1fr 82px; gap: 10px; font-size: 10.5px; color: var(--muted); }
.funnel-conv .mid { padding: 2px 0 2px 2px; border-left: 1px dashed rgba(148, 163, 184, .25); margin-left: 8px; }

.heatmap { overflow-x: auto; }
.heatmap-grid { display: grid; gap: 3px; min-width: 640px; }
.hm-head { font-size: 10px; color: var(--muted); text-align: center; padding: 3px 2px; white-space: nowrap; }
.hm-label { font-size: 11px; color: var(--text-soft); padding: 4px 8px 4px 0; white-space: nowrap; }
.hm-cell {
  min-height: 34px; border-radius: 5px; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, .88);
}
.hm-cell.empty { background: rgba(148, 163, 184, .04); }

/* --------------------------------------------------------------------------
   Инсайты
   -------------------------------------------------------------------------- */

.insights-scroll { max-height: 560px; overflow-y: auto; padding-right: 4px; }
.insights-scroll::-webkit-scrollbar { width: 6px; }
.insights-scroll::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .22); border-radius: 6px; }

.insight {
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted-2);
  border-radius: 10px;
  padding: 11px 13px;
  background: rgba(148, 163, 184, .035);
  margin-bottom: 9px;
}
.insight:last-child { margin-bottom: 0; }
.insight.critical { border-left-color: var(--red); background: linear-gradient(90deg, rgba(248, 113, 113, .07), transparent 60%); }
.insight.warning { border-left-color: var(--amber); background: linear-gradient(90deg, rgba(245, 181, 68, .06), transparent 60%); }
.insight.opportunity { border-left-color: var(--blue); background: linear-gradient(90deg, rgba(96, 165, 250, .06), transparent 60%); }
.insight.good { border-left-color: var(--green); background: linear-gradient(90deg, rgba(52, 211, 153, .06), transparent 60%); }
.insight.info { border-left-color: var(--purple); }
.insight .top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.insight .top .icon { width: 14px; height: 14px; }
.insight.critical .top .icon { color: var(--red); }
.insight.warning .top .icon { color: var(--amber); }
.insight.opportunity .top .icon { color: var(--blue); }
.insight.good .top .icon { color: var(--green); }
.insight.info .top .icon { color: var(--purple); }
.insight .title { font-size: 12.5px; font-weight: 620; }
.insight .sev { margin-left: auto; font-size: 9.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.insight .text { font-size: 12px; color: var(--muted); line-height: 1.45; }
.insight .action { margin-top: 5px; font-size: 11.5px; color: var(--text-soft); }
.insight .action:before { content: "→ "; color: var(--muted-2); }

/* --------------------------------------------------------------------------
   Служебные блоки
   -------------------------------------------------------------------------- */

.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: 10px;
  background: rgba(96, 165, 250, .06);
  border: 1px solid rgba(96, 165, 250, .16);
  color: var(--muted); font-size: 12px; line-height: 1.5;
}
.callout .icon { color: var(--blue); width: 16px; height: 16px; margin-top: 1px; }
.callout b { color: var(--text-soft); }
.callout.warn {
  background: rgba(245, 181, 68, .07);
  border-color: rgba(245, 181, 68, .22);
}
.callout.warn .icon { color: var(--amber); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 20px; font-size: 11px;
  border: 1px solid var(--border-strong); color: var(--muted); background: rgba(148, 163, 184, .04);
}
.pill.green { color: var(--green); border-color: rgba(52, 211, 153, .25); background: var(--green-soft); }
.pill.red { color: var(--red); border-color: rgba(248, 113, 113, .25); background: var(--red-soft); }

.empty {
  padding: 34px 18px; text-align: center; color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: 12px; font-size: 12.5px;
}
.empty b { display: block; color: var(--text-soft); margin-bottom: 4px; font-size: 13px; }

.loading-card {
  display: grid; place-content: center; justify-items: center; gap: 12px;
  padding: 100px 20px; color: var(--muted); font-size: 12.5px;
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(52, 211, 153, .18); border-top-color: var(--green);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tooltip {
  position: fixed; z-index: 100; pointer-events: none;
  background: #0c1524; border: 1px solid var(--border-strong);
  border-radius: 9px; padding: 8px 10px; font-size: 11.5px; line-height: 1.5;
  color: var(--text-soft); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(4px); transition: opacity .1s;
  max-width: 280px;
}
.tooltip.show { opacity: 1; transform: translateY(0); }
.tooltip b { color: var(--text); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  z-index: 120; padding: 10px 16px; border-radius: 10px;
  background: #16233a; border: 1px solid var(--border-strong);
  color: var(--text); font-size: 12.5px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(248, 113, 113, .4); }

/* --------------------------------------------------------------------------
   Drawer (сквозной путь)
   -------------------------------------------------------------------------- */

.drawer { position: fixed; inset: 0; z-index: 80; visibility: hidden; }
.drawer.open { visibility: visible; }
.drawer-overlay {
  position: absolute; inset: 0; background: rgba(4, 8, 14, .66);
  opacity: 0; transition: opacity .2s;
  backdrop-filter: blur(3px);
}
.drawer.open .drawer-overlay { opacity: 1; }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 94vw);
  background: linear-gradient(180deg, #0f1828, #0a111d);
  border-left: 1px solid var(--border-strong);
  box-shadow: -30px 0 80px rgba(0, 0, 0, .6);
  transform: translateX(30px); opacity: 0; transition: .22s ease;
  display: flex; flex-direction: column;
}
.drawer.open .drawer-panel { transform: translateX(0); opacity: 1; }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 20px 22px 14px; border-bottom: 1px solid var(--border);
}
.drawer-head h2 { font-size: 18px; margin-top: 3px; }
.eyebrow { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.drawer-body { padding: 18px 22px 40px; overflow-y: auto; }
.drawer-body::-webkit-scrollbar { width: 8px; }
.drawer-body::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .2); border-radius: 8px; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.summary-grid .item { background: rgba(148, 163, 184, .05); border: 1px solid var(--border); border-radius: 9px; padding: 9px 10px; }
.summary-grid .item span { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.summary-grid .item b { display: block; margin-top: 3px; font-size: 14px; font-weight: 620; }

.timeline { position: relative; margin: 6px 0 18px 5px; padding-left: 22px; }
.timeline:before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 1px; background: rgba(148, 163, 184, .2); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item .dot {
  position: absolute; left: -21px; top: 4px; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid #0d1625; background: var(--muted-2);
}
.tl-item.touch .dot { background: var(--blue); }
.tl-item.call .dot { background: var(--pink); }
.tl-item.email .dot { background: var(--cyan); }
.tl-item.deal .dot { background: var(--amber); }
.tl-item.payment .dot { background: var(--green); }
.tl-item.close.won .dot { background: var(--green); box-shadow: 0 0 12px rgba(52, 211, 153, .6); }
.tl-item.close.lost .dot { background: var(--red); }
.tl-item .when { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-item .what { font-size: 12.5px; color: var(--text-soft); font-weight: 550; margin-top: 1px; }
.tl-item .extra { font-size: 11px; color: var(--muted); margin-top: 1px; }
.tl-item .first-badge {
  display: inline-block; margin-left: 6px; font-size: 9px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--amber); border: 1px solid rgba(245, 181, 68, .3);
  padding: 0 5px; border-radius: 4px;
}
.weights { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 14px; }
.detail-section h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 16px 0 8px; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.mini-table td { padding: 5px 0; border-bottom: 1px solid rgba(148, 163, 184, .08); color: var(--muted); }
.mini-table td:last-child { text-align: right; color: var(--text-soft); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Качество данных / интеграции
   -------------------------------------------------------------------------- */

.score-wrap { display: flex; align-items: center; gap: 22px; }
.score-ring { position: relative; width: 124px; height: 124px; flex: none; }
.score-ring .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.score-ring .center b { font-size: 30px; letter-spacing: -.03em; }
.score-ring .center span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.check { border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; background: rgba(148, 163, 184, .035); }
.check .lbl { font-size: 11px; color: var(--muted); }
.check .val { font-size: 18px; font-weight: 650; margin: 3px 0; }
.check .hint { font-size: 10.5px; color: var(--muted-2); line-height: 1.4; }
.check.good { border-color: rgba(52, 211, 153, .2); }
.check.good .val { color: var(--green); }
.check.warn { border-color: rgba(245, 181, 68, .25); }
.check.warn .val { color: var(--amber); }
.check.bad { border-color: rgba(248, 113, 113, .25); }
.check.bad .val { color: var(--red); }

.utm-builder .row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.utm-builder label.field { display: block; }
.utm-builder label.field span { display: block; font-size: 10.5px; color: var(--muted); margin-bottom: 4px; }
.utm-builder .input { width: 100%; max-width: none; }
.utm-result {
  display: flex; gap: 8px; align-items: center; margin-top: 10px;
  padding: 10px 11px; background: rgba(52, 211, 153, .045);
  border: 1px dashed rgba(52, 211, 153, .3); border-radius: 9px;
}
.utm-result code { flex: 1; font-family: var(--mono); font-size: 10.5px; color: var(--green); overflow-wrap: anywhere; }
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.preset-chip {
  padding: 4px 9px; border-radius: 20px; font-size: 11px; cursor: pointer;
  background: rgba(96, 165, 250, .08); border: 1px solid rgba(96, 165, 250, .2); color: var(--blue);
}
.preset-chip:hover { background: rgba(96, 165, 250, .16); }

.integration { display: flex; gap: 12px; align-items: flex-start; padding: 15px; border: 1px solid var(--border); border-radius: 12px; background: rgba(148, 163, 184, .03); margin-bottom: 10px; }
.integration .logo { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: rgba(96, 165, 250, .1); color: var(--blue); flex: none; }
.integration .body { flex: 1; min-width: 0; }
.integration .body h4 { font-size: 13px; }
.integration .body p { margin: 3px 0 0; font-size: 11.5px; color: var(--muted); }
.integration .side { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.integration .side .when { font-size: 10.5px; color: var(--muted-2); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid label span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.form-grid .input, .form-grid .select { max-width: none; width: 100%; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.webhook-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid rgba(148, 163, 184, .08); font-size: 11.5px; }
.webhook-row:last-child { border-bottom: 0; }
.webhook-row .k { width: 120px; color: var(--muted); flex: none; }
.webhook-row code { flex: 1; font-family: var(--mono); font-size: 10.5px; color: var(--text-soft); overflow-wrap: anywhere; }

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

.only-mobile { display: none; }
.hide-sm { display: inline; }

@media (max-width: 1240px) {
  .grid.main-2, .grid.side { grid-template-columns: 1fr; }
  .grid.main-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .checks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  .sidebar { width: 74px; padding: 18px 10px; }
  .brand-text, .nav-item span, .sidebar-foot .tiny, #sync-text { display: none; }
  .brand { justify-content: center; padding-bottom: 18px; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .sidebar-foot { align-items: center; }
  .sidebar-foot .btn.small { width: 38px; padding: 8px; }
  .sidebar-foot .btn.small .icon { width: 16px; height: 16px; }
  .nav-badge { display: none; }
  .view { padding: 20px 18px 60px; }
  .topbar { padding: 10px 16px; }
}

@media (max-width: 820px) {
  .only-mobile { display: inline-flex; }
  .crumb { display: none; }
  .topbar { flex-wrap: wrap; }
  .filters { gap: 6px; width: 100%; min-width: 0; justify-content: flex-start; }
  .filters > * { min-width: 0; }
  .filters .select { flex: 1 1 140px; max-width: 200px; }
  .filter-period { flex: 0 1 auto; }
  .view { padding: 16px 12px 60px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2, .grid.main-3 { grid-template-columns: 1fr; }
  .kpi .kpi-value { font-size: 22px; }
  .view-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .checks { grid-template-columns: 1fr; }
  .insights-scroll { max-height: none; overflow: visible; }
  .utm-builder .row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .hide-sm { display: none; }
  .select { max-width: 150px; }
  .donut-wrap { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 560px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .filters { gap: 5px; }
  .filters .seg { flex: 1 1 100%; }
  .filters .seg button { flex: 1; padding: 5px 6px; }
  .filters .select { flex: 1 1 120px; max-width: none; font-size: 11.5px; }
  #date-label { max-width: 88px; overflow: hidden; text-overflow: ellipsis; }
  .view { padding: 14px 10px 60px; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 238px;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .brand-text, .nav-item span, #sync-text { display: block; }
  .brand { justify-content: flex-start; }
  .nav-item { justify-content: flex-start; padding: 10px 12px; }
  .sidebar-foot .btn.small { width: 100%; }
  .filters .seg button { padding: 5px 7px; }
  .filters { width: 100%; justify-content: flex-start; }
  .topbar { flex-wrap: wrap; }
}

/* --------------------------------------------------------------------------
   Формы интеграций (ввод ключей)
   -------------------------------------------------------------------------- */

.integration { flex-wrap: wrap; }
.integration.open { border-color: rgba(96, 165, 250, .3); background: rgba(96, 165, 250, .035); }
.integration-form {
  flex-basis: 100%;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.secret-input { display: flex; gap: 6px; align-items: center; }
.secret-input .input { flex: 1; min-width: 0; }
.secret-input .btn { flex: none; }
.clear-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 5px; font-size: 11px; color: var(--red); cursor: pointer;
}
.clear-row input { accent-color: var(--red); }
.field-hint { font-size: 10.5px; color: var(--muted-2); margin-top: 4px; line-height: 1.45; }
.switch-row {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 0 2px; font-size: 12px; color: var(--text-soft); cursor: pointer;
}
.switch-row input { width: 15px; height: 15px; accent-color: var(--green); }
.test-result {
  margin-top: 12px; padding: 12px 13px; border-radius: 10px;
  border: 1px solid var(--border); background: rgba(148, 163, 184, .04);
}
.test-result.ok { border-color: rgba(52, 211, 153, .3); background: rgba(52, 211, 153, .055); }
.test-result.err { border-color: rgba(248, 113, 113, .3); background: rgba(248, 113, 113, .055); }
.result-head { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 8px; }
.test-result.ok .result-head .icon { color: var(--green); }
.test-result.err .result-head .icon { color: var(--red); }
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 18px; }
.kv {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 3px 0; font-size: 11.5px; border-bottom: 1px solid rgba(148, 163, 184, .07);
}
.kv span { color: var(--muted); }
.kv b { font-weight: 550; color: var(--text-soft); text-align: right; }
.result-block { margin-top: 9px; font-size: 11.5px; }
.result-block b { font-weight: 550; color: var(--text-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.result-warnings { margin: 8px 0 0 16px; padding: 0; color: var(--amber); font-size: 11px; line-height: 1.5; }
.setup-block {
  margin-top: 14px; padding: 12px 13px; border-radius: 10px;
  background: rgba(96, 165, 250, .045);
  border: 1px solid rgba(96, 165, 250, .16);
}
.setup-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 620; color: var(--text-soft); margin-bottom: 7px;
}
.setup-title .icon { color: var(--blue); width: 15px; height: 15px; }
.setup-block code {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-soft);
  background: rgba(148, 163, 184, .1); padding: 1px 4px; border-radius: 3px;
  overflow-wrap: anywhere;
}
.setup-steps {
  margin: 0 0 8px 17px; padding: 0;
  font-size: 11.5px; color: var(--muted); line-height: 1.65;
}
.setup-steps b { color: var(--text-soft); }
.inline-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

@media (max-width: 820px) {
  .kv-grid { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Автоматическая UTM-разметка
   -------------------------------------------------------------------------- */

.auto-utm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.auto-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  background: rgba(148, 163, 184, .035);
  min-width: 0;
}
.auto-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 620; color: var(--text-soft);
  margin-bottom: 7px;
}
.auto-title .icon { width: 15px; height: 15px; color: var(--green); }
.auto-block .field { margin-bottom: 8px; }
.auto-block textarea.input {
  width: 100%; max-width: none; resize: vertical; min-height: 96px;
  font-family: var(--mono); font-size: 11px; line-height: 1.5;
}
.bulk-output {
  margin: 10px 0 0;
  padding: 9px 10px;
  background: rgba(7, 11, 19, .7);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono); font-size: 10.5px; line-height: 1.55;
  color: var(--green); white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 180px; overflow: auto;
}
.auto-block code {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-soft);
  background: rgba(148, 163, 184, .1); padding: 1px 4px; border-radius: 3px;
}

@media (max-width: 1080px) {
  .auto-utm-grid { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Редактор статусов сделок (Bitrix24)
   -------------------------------------------------------------------------- */

.stages-editor {
  margin-top: 12px;
  padding: 12px 13px;
  border: 1px solid rgba(167, 139, 250, .2);
  border-radius: 10px;
  background: rgba(167, 139, 250, .045);
}
.stages-editor .setup-title { color: var(--purple); }
.stages-editor .setup-title .icon { color: var(--purple); }
.stages-scroll {
  max-height: 560px;
  overflow-y: auto;
  margin: 10px 0 4px;
  padding-right: 4px;
}
.stage-group { margin-bottom: 14px; }
.stage-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  position: sticky;
  top: 0;
  background: rgba(15, 23, 38, .96);
  padding: 4px 0;
  z-index: 1;
}
.stages-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stage-row {
  display: grid;
  grid-template-columns: 1fr 200px;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(148, 163, 184, .04);
}
.stage-name {
  font-size: 12px;
  color: var(--text-soft);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-row .select { width: 100%; max-width: none; }
@media (max-width: 620px) {
  .stage-row { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Подсказка Callback URL (OAuth Яндекс)
   -------------------------------------------------------------------------- */

.oauth-hint {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border: 1px dashed rgba(96, 165, 250, .35);
  border-radius: 9px;
  background: rgba(96, 165, 250, .05);
}
.oauth-hint-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--blue);
  margin-bottom: 5px;
  letter-spacing: .02em;
}
.oauth-hint-row {
  display: flex; align-items: center; gap: 8px;
}
.oauth-hint-row code {
  flex: 1;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.oauth-code-row {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 12px;
}
.oauth-code-row .input { flex: 1; min-width: 0; }

/* ===== Вход (логин) ===== */
.login-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.login-screen[hidden] { display: none; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px; text-align: center; box-shadow: var(--shadow); }
.login-card .brand-mark { margin: 0 auto; }
.login-card h1 { font-size: 18px; margin: 14px 0 4px; }
.login-card > p { margin: 0 0 20px; }
.login-card .field { display: block; text-align: left; margin-bottom: 12px; }
.login-card .field span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.login-card .field input { width: 100%; }
.login-error { color: var(--red); font-size: 12.5px; margin-bottom: 10px; }

/* ===== Чип пользователя ===== */
.user-chip { display: flex; align-items: center; gap: 8px; padding-left: 12px; border-left: 1px solid var(--border); margin-left: 2px; }
.user-chip[hidden] { display: none; }
.user-name { font-size: 12.5px; color: var(--text); font-weight: 600; white-space: nowrap; }

/* ===== Модалка пользователей ===== */
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-overlay { position: absolute; inset: 0; background: rgba(3, 7, 18, .72); }
.modal-panel { position: relative; width: 100%; max-width: 470px; max-height: 88vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.modal-body { overflow-y: auto; min-height: 0; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { font-size: 16px; margin: 0; }
.users-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-height: 260px; overflow-y: auto; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; background: rgba(148, 163, 184, .05); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.user-row .u-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.user-row .u-role { font-size: 11px; color: var(--muted); }
.user-row select { width: auto; }
.users-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.users-add .field span { display: block; font-size: 10.5px; color: var(--muted); margin-bottom: 4px; }
.users-add .field input, .users-add .field select { width: 100%; }

/* ===== Email-трекинг (расшифровка адреса) ===== */
.email-lookup-form { display: flex; gap: 8px; margin-bottom: 14px; }
.email-lookup-form .input { flex: 1; min-width: 0; }
.email-result-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; background: rgba(148, 163, 184, .04); }
.email-result-title { font-size: 13px; margin-bottom: 10px; color: var(--text-soft); }
.email-result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.email-result-grid .er { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.email-result-grid .er span { font-size: 10px; color: var(--muted-2); }
.email-result-grid .er b { font-size: 12.5px; color: var(--text); word-break: break-word; }

/* ===== Кликабельные KPI и список сделок ===== */
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: rgba(148, 163, 184, .4); transform: translateY(-2px); }
.deal-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 11px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: rgba(148, 163, 184, .04);
  margin-bottom: 7px;
}
.deal-row-main { flex: 1; min-width: 0; cursor: pointer; }
.deal-row-main .name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deal-row-main .sub { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deal-row-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.deal-amount { font-size: 13px; color: var(--text-soft); }
.hit[data-bucket] { cursor: pointer; }

/* ===== Источники внутри канала ===== */
.channel-sources td { background: rgba(148, 163, 184, .03); padding: 0; }
.sources-panel { padding: 12px 16px 14px; }
.sources-title { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .03em; }
.source-item { display: grid; grid-template-columns: 200px 1fr 90px; align-items: center; gap: 12px; padding: 4px 0; }
.src-name { font-size: 12.5px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-rail { height: 8px; background: rgba(148, 163, 184, .1); border-radius: 6px; overflow: hidden; }
.src-rail i { display: block; height: 100%; background: linear-gradient(90deg, #34d399, #60a5fa); border-radius: 6px; }
.src-val { font-size: 12px; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.sources-actions { margin-top: 10px; }
@media (max-width: 620px) {
  .source-item { grid-template-columns: 1fr 90px; }
  .src-rail { display: none; }
}

/* ===== Разбивка пайплайна (направления/статусы) ===== */
.pipe-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; }
.pipe-col { min-width: 0; }
.pipe-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.pipe-col .hbar { gap: 8px; padding: 3px 0; }
@media (max-width: 620px) { .pipe-split { grid-template-columns: 1fr; } }

/* ===== Управление блоками (перемещение / высота / сворачивание) ===== */
.card { position: relative; }
.card-head { position: relative; }
.card-ctl { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.card-head .aside + .card-ctl, .card-head .head-actions + .card-ctl { margin-left: 8px; }
.ctl-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; border-radius: 6px; padding: 0;
}
.ctl-btn:hover { background: rgba(148,163,184,.12); color: var(--text); }
.ctl-grip {
  width: 12px; height: 18px; cursor: grab; opacity: .35; flex: 0 0 auto;
  background-image: radial-gradient(circle, currentColor 1.4px, transparent 1.8px);
  background-size: 6px 6px; background-position: 3px 3px;
}
.ctl-grip:hover { opacity: .8; }
.ctl-grip:active { cursor: grabbing; }
.rz-handle {
  position: absolute; right: 0; bottom: 0; width: 18px; height: 18px;
  cursor: ns-resize; z-index: 3;
}
.rz-handle::after {
  content: ""; position: absolute; right: 4px; bottom: 4px; width: 9px; height: 9px;
  border-right: 2px solid rgba(148,163,184,.5); border-bottom: 2px solid rgba(148,163,184,.5);
  border-bottom-right-radius: 3px;
}
.rz-handle:hover::after { border-color: var(--accent); }
.card.collapsed > :not(.card-head) { display: none !important; }
.card.collapsed .rz-handle { display: none; }
.card[draggable="true"] { opacity: .92; }
.card[draggable="true"] .card-head { cursor: grabbing; }

/* ===== Быстрые периоды в календаре ===== */
.popover-quick { display: flex; gap: 6px; margin-bottom: 10px; }
.popover-quick .btn { flex: 1; justify-content: center; }

/* ===== Кастомная подсказка при наведении (мгновенная) ===== */
.tip { position: relative; cursor: help; }
.tip[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 300;
  background: rgba(15, 23, 42, .96); color: #e2e8f0; padding: 7px 10px;
  border-radius: 6px; font-size: 12px; line-height: 1.45; max-width: 460px;
  white-space: normal; word-break: break-all; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  pointer-events: none;
}

/* ===== Кликабельная ячейка (страница/referrer) ===== */
.cell-link { color: var(--accent, #60a5fa); text-decoration: none; }
.cell-link:hover { text-decoration: underline; }

.brand-sub { font-size: 10px; color: var(--muted); font-weight: 500; letter-spacing: .02em; margin-top: 1px; }
