/* ─────────────────────────────────────────────
   APAN BI — components.css
   Token-driven; works in light (default) + dark.
   ───────────────────────────────────────────── */

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-s);
  border: 1px solid var(--bd);
  background: var(--sf);
  color: var(--tx2);
  font: 500 12px/1 var(--fn);
  cursor: pointer;
  transition: border-color .15s var(--ease,ease-out), background .15s, color .15s;
  white-space: nowrap;
}
.btn:hover       { border-color: var(--ac); color: var(--ac); }
.btn.btn-primary { background: var(--pu); border-color: var(--pu); color: #fff; }
.btn.btn-primary:hover { background: #272729; border-color: #272729; color: #fff; }
.btn.btn-danger  { background: var(--ac2); border-color: var(--ac2); color: #fff; }
.btn.btn-danger:hover { background: #d62894; border-color: #d62894; }
.btn.act         { background: var(--pu); border-color: var(--pu); color: #fff; }
.btn:disabled    { opacity: .5; cursor: not-allowed; }

/* ── Period filter buttons (pills per design system) ── */
.period-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--bd);
  background: var(--sf2);
  color: var(--tx2);
  font: 500 12px/1 var(--fn);
  cursor: pointer;
  transition: all .15s ease-out;
  white-space: nowrap;
}
.period-btn:hover { border-color: var(--bd2); color: var(--tx); }
.period-btn.act {
  background: var(--pu);
  border-color: var(--pu);
  color: #fff;
}
body.theme-dark .period-btn.act { color: #0E0E0F; background: #fff; border-color: #fff; }

/* ── Card ── */
.card {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow-hover); }
.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--tx2);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 14px;
}

/* ── KPI Card (display number per design system) ── */
.kpi-card {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow .15s;
  min-width: 0;
  overflow: hidden;
}
.kpi-card:hover { box-shadow: var(--shadow-hover); }
.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--tx2);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 8px;
}
.kpi-value {
  font-size: clamp(20px, 2.2vw, 32px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
  color: var(--tx);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-delta {
  font-size: 12px;
  font-weight: 500;
  margin-top: 6px;
  min-height: 14px;
}

/* ── Today banner ── */
.today-banner {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.today-banner-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ac);
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.today-banner-head::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ac);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

/* ── Tags / badges (pill, soft semantic fills) ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--sf2);
  color: var(--tx2);
}
.badge-red    { background: rgba(255,43,170,.10);  color: var(--ac2); }
.badge-yellow { background: rgba(245,165,36,.12);  color: var(--yw); }
.badge-green  { background: rgba(16,185,129,.12);  color: var(--gr); }
.badge-blue   { background: rgba(44,91,255,.10);   color: var(--ac); }
.badge-gray   { background: var(--sf2);            color: var(--tx2); }
.badge-purple { background: rgba(139,92,246,.12);  color: #8b5cf6; }
.badge-cyan   { background: rgba(44,91,255,.10);   color: var(--ac); }

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.tag-ig  { background: rgba(255,43,170,.12); color: var(--ac2); }
.tag-wa  { background: rgba(16,185,129,.12); color: var(--gr); }
.tag-2g  { background: rgba(44,91,255,.10);  color: var(--ac); }
.tag-cpc { background: rgba(245,165,36,.14); color: var(--yw); }
.tag-x   { background: var(--sf2);           color: var(--tx2); }

/* ── Chart wrapper ── */
.chart-wrap {
  position: relative;
  height: 200px;
}
.chart-wrap canvas { max-height: 200px !important; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mu);
  font-size: 12px;
  pointer-events: none;
}

/* ── Table ── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.chip {
  display: inline-flex; align-items: center;
  padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--bd); background: var(--sf2);
  font-size: 12px; font-weight: 600; color: var(--tx2);
  cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--ac); color: var(--tx); }
.chip.act { background: var(--ac); border-color: var(--ac); color: #fff; }

/* Ads-tab specific: компактнее цифры чтобы не переносились */
#tab-ads .kpi-value {
  font-size: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}
#tab-ads .kpi-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#tab-ads .help-tip {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--sf2); color: var(--tx2);
  font-size: 10px; font-weight: 700;
  text-align: center; line-height: 14px;
  cursor: help; margin-left: 4px;
  border: 1px solid var(--bd);
}
#tab-ads .help-tip:hover { background: var(--ac); color: #fff; border-color: var(--ac); }
.data-table th {
  background: var(--sf2);
  color: var(--tx2);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  border-bottom: 1px solid var(--bd);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.data-table th:hover { color: var(--tx); }
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--bd);
  vertical-align: middle;
  color: var(--tx);
}
.data-table tr:hover td { background: var(--sf2); }
.data-table tr.row-risk td { background: rgba(255,43,170,.04); }
.data-table tr.row-stale td { background: rgba(245,165,36,.04); }
.data-table .sort-mark { color: var(--ac); font-size: 10px; margin-left: 4px; }
.tbl-empty {
  text-align: center !important;
  color: var(--mu);
  padding: 28px !important;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 0;
  justify-content: flex-end;
}
.pg-btn {
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid var(--bd);
  background: var(--sf);
  color: var(--tx2);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s;
}
.pg-btn:hover       { border-color: var(--bd2); color: var(--tx); }
.pg-btn.act         { background: var(--pu); border-color: var(--pu); color: #fff; }
.pg-info { font-size: 11px; color: var(--mu); padding: 0 4px; }

/* ── Form inputs ── */
.form-input {
  background: var(--sf);
  border: 1px solid var(--bd);
  color: var(--tx);
  padding: 8px 12px;
  border-radius: var(--radius-s);
  font: 13px var(--fn);
  outline: none;
  transition: border-color .15s;
}
.form-input:focus   { border-color: var(--ac); }
.form-input::placeholder { color: var(--mu); }

select.form-input { cursor: pointer; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,18,36,.55);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-backdrop.hidden { display: none; }
.modal-box {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  width: 100%;
  max-width: 720px;
  padding: 24px 28px;
  position: relative;
  box-shadow: var(--shadow-pop);
}
.modal-close {
  position: absolute;
  top: 16px; right: 18px;
  background: none;
  border: none;
  color: var(--mu);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--tx); }
.modal-head { margin-bottom: 18px; }
.modal-head h3 { font-size: 18px; font-weight: 600; padding-right: 28px; }
.modal-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.modal-kpi-item {
  background: var(--sf2);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 10px 12px;
}
.modal-kpi-item .lbl {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--tx2); margin-bottom: 4px; font-weight: 500;
}
.modal-kpi-item .val { font-size: 16px; font-weight: 700; color: var(--tx); }
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.modal-field {
  background: var(--sf2);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 12px 14px;
}
.modal-field .lbl {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--tx2); margin-bottom: 5px; font-weight: 500;
}
.modal-field .val { font-size: 13px; line-height: 1.55; color: var(--tx); }
.modal-field.risk-border { border-left: 3px solid var(--ac2); }
.modal-field.good-border { border-left: 3px solid var(--gr); }
.modal-field.next-border { border-left: 3px solid var(--ac); }
.modal-dialog-wrap {
  background: var(--sf2);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 14px 16px;
  max-height: 320px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.65;
  color: var(--tx);
  white-space: pre-wrap;
  word-break: break-word;
  overscroll-behavior: contain;
}
.modal-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.modal-bot-block {
  background: var(--sf2);
  border: 1px solid var(--bd);
  border-left: 3px solid var(--ac);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--tx);
  margin-bottom: 8px;
}
.modal-bot-block .bot-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 4px 0; border-bottom: 1px dashed var(--bd);
}
.modal-bot-block .bot-row:last-child { border-bottom: none; }
.modal-bot-block .bot-row b { color: var(--tx2); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.modal-bot-block .bot-row span { font-family: var(--mono); font-size: 12px; text-align: right; word-break: break-all; }
.modal-bot-block .bot-status-on  { color: var(--gr); font-weight: 600; }
.modal-bot-block .bot-status-off { color: var(--mu); font-weight: 600; }
.modal-bot-block .bot-msg {
  margin-top: 8px; padding: 8px 10px; background: var(--bg); border-radius: 8px;
  white-space: pre-wrap; font-size: 12px; color: var(--tx); border: 1px solid var(--bd);
}
.modal-bot-block .bot-empty { color: var(--mu); font-style: italic; }
.btn.btn-bot { background: var(--ac); color: #fff; border-color: var(--ac); }
.btn.btn-bot:hover { filter: brightness(1.05); }
.btn.btn-bot[disabled] { opacity: .5; cursor: not-allowed; }
.btn.btn-analyst { background: var(--sf2); border-color: var(--bd2); color: var(--tx); }
.btn.btn-analyst:hover { background: var(--bd); }
.modal-bot-status-msg { font-size: 11px; margin-top: 8px; padding: 6px 10px; border-radius: 6px; }
.modal-bot-status-msg.ok  { background: rgba(16,185,129,.12); color: var(--gr); }
.modal-bot-status-msg.err { background: rgba(255,43,170,.10); color: var(--ac2); }
.modal-bot-status-msg.info{ background: var(--sf2); color: var(--tx2); }

/* ── Funnel ── */
.funnel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bd);
}
.funnel-item:last-child { border-bottom: none; }
.funnel-label { font-size: 13px; color: var(--tx2); min-width: 160px; }
.funnel-bar-wrap { flex: 1; height: 8px; background: var(--sf2); border-radius: 999px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 999px; transition: width .5s; }
.funnel-count { font-size: 14px; font-weight: 700; min-width: 32px; text-align: right; color: var(--tx); }
.funnel-pct { font-size: 11px; color: var(--mu); min-width: 40px; text-align: right; }

/* ── Emotion row ── */
.emotion-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--bd);
}
.emotion-row:last-child { border-bottom: none; }
.emotion-icon { font-size: 16px; width: 24px; text-align: center; }
.emotion-label { font-size: 12px; color: var(--tx); min-width: 100px; }
.emotion-bar-wrap { flex: 1; height: 6px; background: var(--sf2); border-radius: 999px; overflow: hidden; }
.emotion-bar { height: 100%; border-radius: 999px; }
.emotion-count { font-size: 12px; font-weight: 600; min-width: 28px; text-align: right; color: var(--tx); }

/* ── Summary list ── */
.summary-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bd);
}
.summary-item:last-child { border-bottom: none; }
.summary-rank {
  font-size: 11px;
  color: var(--mu);
  min-width: 16px;
  font-family: var(--mono);
  padding-top: 2px;
}
.summary-text {
  font-size: 12px;
  line-height: 1.5;
  color: var(--tx);
  flex: 1;
}
.summary-bar { width: 100%; height: 2px; background: var(--sf2); border-radius: 2px; margin-top: 4px; }
.summary-bar-fill { height: 2px; border-radius: 2px; background: var(--ac); }

/* ── Heatmap ── */
.heatmap-wrap { overflow-x: auto; }
.heatmap-table { border-collapse: collapse; font-size: 10px; }
.heatmap-table th { padding: 3px 6px; color: var(--mu); font-weight: 500; white-space: nowrap; }
.heatmap-table td {
  width: 32px; height: 24px;
  text-align: center;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 10px;
  cursor: default;
  color: var(--tx);
}
.heatmap-table td:hover { outline: 1px solid var(--ac); }

/* ── Source chip (pill) ── */
.src-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

/* ── Notification dot ── */
.notif-dot {
  min-width: 17px; height: 17px;
  border-radius: 999px;
  background: var(--ac2);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.notif-dot.show { display: flex; }

/* ── Sync status dot ── */
.sync-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--gr);
  box-shadow: 0 0 0 3px rgba(16,185,129,.15);
}

/* ── Hot deal row ── */
.hot-row { display: grid; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--bd); }
.hot-row:last-child { border-bottom: none; }

/* ── Пульс дня — signal cards ── */
.pulse-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.pulse-card {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-left: 3px solid var(--ac);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: box-shadow .15s;
}
.pulse-card:hover { box-shadow: var(--shadow-hover); }
.pulse-card.warn { border-left-color: var(--ac2); }
.pulse-card.ok   { border-left-color: var(--gr); }
.pulse-label { font-size: 11px; color: var(--tx2); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; font-weight: 500; }
.pulse-value { font-size: 28px; font-weight: 700; line-height: 1.05; color: var(--tx); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pulse-value.warn { color: var(--ac2); }
.pulse-value.ok   { color: var(--gr); }
.pulse-text { font-size: 12px; color: var(--tx2); line-height: 1.5; margin-top: 8px; }
.pulse-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.pulse-btn {
  background: var(--sf2);
  border: 1px solid var(--bd);
  color: var(--tx);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--fn);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.pulse-btn:hover { border-color: var(--ac); color: var(--ac); }

/* ── Scenario strip ── */
.scenario-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.scenario-card {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-left: 3px solid var(--ac);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  color: var(--tx);
  font-family: var(--fn);
  transition: border-color .15s, background .15s;
}
.scenario-card:hover, .scenario-card.act {
  border-color: var(--ac);
  background: var(--ac-dim);
}
.scenario-card.act { border-left-color: var(--ac); }
.scenario-card strong { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--tx); }
.scenario-card span  { display: block; font-size: 11px; color: var(--tx2); line-height: 1.4; }
.scenario-output {
  display: none;
  background: var(--sf2);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--tx);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 10px;
}
.scenario-output.show { display: block; }

/* ── Task list (менеджер) ── */
.task-row {
  display: grid;
  grid-template-columns: 90px 60px 1fr;
  gap: 10px;
  align-items: start;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--bd);
  background: var(--sf);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  margin-bottom: 8px;
}
.task-row:hover { border-color: var(--ac); box-shadow: var(--shadow-hover); }
.task-owner { font-size: 11px; color: var(--tx2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-deal  { font-size: 12px; color: var(--ac); font-family: var(--mono); font-weight: 600; }
.task-body  { font-size: 12px; color: var(--tx); line-height: 1.5; }
.task-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-right: 6px;
}
.task-badge.risk    { background: rgba(255,43,170,.10); color: var(--ac2); }
.task-badge.stale   { background: rgba(245,165,36,.12); color: var(--yw); }
.task-badge.low     { background: rgba(139,92,246,.12); color: #8b5cf6; }
.task-badge.default { background: rgba(44,91,255,.10);  color: var(--ac); }
.task-empty { font-size: 13px; color: var(--mu); padding: 16px 0; text-align: center; }

/* ── Script cards (библиотека ответов) ── */
.script-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.script-card {
  position: relative;
  border: 1px solid var(--bd);
  border-radius: 12px;
  background: var(--sf);
  padding: 12px 14px;
  transition: border-color .15s, box-shadow .15s;
}
.script-card:hover { border-color: var(--ac); box-shadow: var(--shadow-hover); }
.script-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--tx);
  margin: 0 70px 6px 0;
  line-height: 1.3;
}
.script-card-body {
  font-size: 12px;
  color: var(--tx2);
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.script-card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
}
.script-icon-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--bd);
  background: var(--bg);
  color: var(--tx2);
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  padding: 0;
}
.script-icon-btn:hover { background: var(--ac); color: #fff; border-color: var(--ac); }
.script-icon-btn.danger:hover { background: var(--ac2, #ff2baa); border-color: var(--ac2, #ff2baa); }
.script-cat-block { margin-bottom: 16px; }
.script-cat-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--mu);
  font-weight: 600;
  margin: 0 0 8px 2px;
}

/* ── Modal (общая) ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-window {
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: 16px;
  max-width: 560px;
  width: 100%;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--tx);
  margin: 0 0 16px;
}
.modal-field { margin-bottom: 12px; }
.modal-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--tx2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}

/* ── Автопилот (AI bot) ── */
.autopilot-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.ap-card {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.ap-card.warn { border-color: var(--yw); background: rgba(245,165,36,.04); }
.ap-card.off  { opacity: .6; }
.ap-label { font-size: 11px; color: var(--tx2); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 5px; font-weight: 500; }
.ap-value { font-size: 24px; font-weight: 700; color: var(--tx); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ap-note  { font-size: 11px; color: var(--tx2); margin-top: 4px; line-height: 1.4; }

.ap-row {
  display: grid;
  grid-template-columns: 80px 60px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--bd);
  cursor: pointer;
}
.ap-row:hover { background: var(--sf2); }
.ap-row:last-child { border-bottom: none; }
.ap-owner { font-size: 11px; color: var(--tx2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-deal  { font-size: 12px; color: var(--ac); font-family: var(--mono); font-weight: 600; }
.ap-text  { font-size: 12px; color: var(--tx2); line-height: 1.45; }
.ap-state-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.ap-state-badge.ready   { background: rgba(16,185,129,.12);  color: var(--gr); }
.ap-state-badge.waiting { background: rgba(245,165,36,.12);  color: var(--yw); }
.ap-state-badge.handoff { background: rgba(255,43,170,.10);  color: var(--ac2); }
.ap-state-badge.sent    { background: rgba(44,91,255,.10);   color: var(--ac); }

.bot-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--tx);
}
.bot-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid;
  font: 600 11px var(--fn);
  cursor: pointer;
  transition: all .15s;
}
.bot-toggle-btn.on  { background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.3); color: var(--gr); }
.bot-toggle-btn.off { background: var(--sf2); border-color: var(--bd); color: var(--tx2); }

/* ── AI IDE Chat ── */
.ai-chat-section {
  margin-top: 24px;
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--sf);
  box-shadow: var(--shadow);
}
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--sf2);
  border-bottom: 1px solid var(--bd);
  cursor: pointer;
  user-select: none;
}
.ai-chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tx);
}
.ai-chat-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--gr);
  animation: pulse 2s infinite;
}
.ai-chat-toggle-icon { font-size: 12px; color: var(--mu); transition: transform .2s; }
.ai-chat-section.collapsed .ai-chat-toggle-icon { transform: rotate(180deg); }
.ai-chat-body { display: flex; flex-direction: column; }
.ai-chat-section.collapsed .ai-chat-body { display: none; }

.ai-chat-messages {
  padding: 14px 16px;
  min-height: 180px;
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
  line-height: 1.6;
  overscroll-behavior: contain;
  background: var(--sf);
}
.ai-msg { display: flex; flex-direction: column; gap: 3px; }
.ai-msg-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  color: var(--tx2);
}
.ai-msg.user .ai-msg-role { color: var(--ac); }
.ai-msg.assistant .ai-msg-role { color: var(--gr); }
.ai-msg-text {
  background: var(--sf2);
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--tx);
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-msg.user .ai-msg-text { border-color: rgba(44,91,255,.25); background: var(--ac-dim); }
.ai-msg.assistant .ai-msg-text { border-color: rgba(16,185,129,.2); }
.ai-msg-text .ai-h { margin: 10px 0 4px; font-weight: 700; color: var(--tx); line-height: 1.3; }
.ai-msg-text h3.ai-h { font-size: 14px; }
.ai-msg-text h4.ai-h { font-size: 13px; }
.ai-msg-text h5.ai-h { font-size: 12px; color: var(--tx2); text-transform: uppercase; letter-spacing: .04em; }
.ai-msg-text .ai-h:first-child { margin-top: 0; }
.ai-msg-text .ai-ul, .ai-msg-text .ai-ol { margin: 4px 0 4px 18px; padding: 0; }
.ai-msg-text .ai-ul li, .ai-msg-text .ai-ol li { margin: 2px 0; }
.ai-msg-text .ai-hr { border: none; border-top: 1px solid var(--bd); margin: 8px 0; }
.ai-msg-text code { background: var(--sf2); padding: 1px 5px; border-radius: 4px; font: 12px ui-monospace, monospace; }
.ai-msg-text .ai-code { background: var(--sf2); border: 1px solid var(--bd); border-radius: 6px; padding: 8px 10px; margin: 6px 0; font: 12px ui-monospace, monospace; white-space: pre-wrap; overflow-x: auto; }
.ai-msg-text a { color: var(--ac); text-decoration: underline; }
.ai-chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px;
  color: var(--mu);
  font-size: 13px;
  text-align: center;
  flex: 1;
}

.ai-chat-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-top: 1px solid var(--bd);
  background: var(--sf);
}
.ai-chip {
  background: var(--sf2);
  border: 1px solid var(--bd);
  color: var(--tx2);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11px;
  font-family: var(--fn);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.ai-chip:hover { background: var(--ac-dim); border-color: var(--ac); color: var(--ac); }

.ai-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--bd);
  background: var(--sf);
}
.ai-chat-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: 10px;
  color: var(--tx);
  padding: 9px 12px;
  font: 13px var(--fn);
  outline: none;
  resize: none;
  min-height: 38px;
  max-height: 100px;
  line-height: 1.5;
}
.ai-chat-input:focus { border-color: var(--ac); }
.ai-chat-input::placeholder { color: var(--mu); }
.ai-send-btn {
  background: var(--pu);
  border: none;
  border-radius: 999px;
  color: #fff;
  padding: 0 18px;
  font: 600 12px var(--fn);
  cursor: pointer;
  white-space: nowrap;
  align-self: flex-end;
  height: 38px;
  transition: background .15s;
}
.ai-send-btn:hover { background: #272729; }
body.theme-dark .ai-send-btn { color: #0E0E0F; }
.ai-send-btn:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 768px) {
  .pulse-grid { grid-template-columns: repeat(2, 1fr); }
  .scenario-strip { grid-template-columns: 1fr; }
  .task-row { grid-template-columns: 1fr; gap: 4px; }
  .ap-row { grid-template-columns: 1fr 1fr; }
}

/* ── Ads empty ── */
.ads-placeholder {
  border: 1px dashed var(--bd);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  color: var(--mu);
  font-size: 13px;
  line-height: 1.7;
  background: var(--sf);
}
.ads-placeholder strong { color: var(--tx); }

/* ── DDS table ── */
.dds-amt  { color: var(--ac2); font-weight: 700; font-family: var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums; }
.dds-note { color: var(--mu); font-size: 11px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Alert toast ── */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 800; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--tx);
  box-shadow: var(--shadow-pop);
  max-width: 320px;
  animation: toast-in .22s cubic-bezier(0.2,0,0,1);
}
.toast.toast-risk { border-left: 3px solid var(--ac2); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Login card ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.login-card {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-pop);
}
.login-logo {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 6px;
  color: var(--tx);
}
.login-logo em { color: var(--tx); font-style: italic; font-weight: 700; }
.login-sub { font-size: 13px; color: var(--tx2); margin-bottom: 28px; }
.login-label { font-size: 12px; color: var(--tx2); margin-bottom: 6px; display: block; font-weight: 500; }
.login-field { margin-bottom: 14px; }
.login-error {
  background: rgba(255,43,170,.08);
  border: 1px solid rgba(255,43,170,.25);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--ac2);
  margin-bottom: 14px;
  display: none;
}
.login-error.show { display: block; }

/* ── Manager intro ── */
.mgr-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.mgr-kpi-card {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.mgr-kpi-val { font-size: 40px; font-weight: 700; line-height: 1.05; color: var(--tx); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.mgr-kpi-label { font-size: 12px; color: var(--tx2); margin-top: 6px; text-transform: uppercase; letter-spacing: .08em; font-weight: 500; }
.mgr-kpi-note { font-size: 11px; color: var(--tx2); margin-top: 4px; line-height: 1.4; }

/* ── PDF export ── */
@media print {
  .no-print { display: none !important; }
  .header, .filter-bar, .nav-tabs { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .kpi-card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
}

/* ── Squiggle (KPI-tile signature line) ── */
.squiggle {
  display: block;
  margin-top: 8px;
  height: 56px;
  width: 100%;
}
.squiggle path { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* ─────────────────────────────────────────────
   Right rail (AI consultant — fixed sticky panel)
   ───────────────────────────────────────────── */
.right-rail {
  position: fixed;
  top: 60px;
  right: 0;
  bottom: 0;
  width: 360px;
  background: var(--sf);
  border-left: 1px solid var(--bd);
  display: flex; flex-direction: column;
  z-index: 80;
  box-shadow: -4px 0 24px rgba(15,18,36,.04);
  transform: translateX(0);
  transition: transform .22s cubic-bezier(0.2,0,0,1);
}
.right-rail.collapsed { transform: translateX(100%); }
.right-rail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--bd);
  background: var(--sf);
}
.right-rail-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--tx);
}
.right-rail-close {
  background: var(--sf2); border: 1px solid var(--bd); border-radius: 999px;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--tx2); font-size: 14px;
}
.right-rail-close:hover { color: var(--tx); border-color: var(--bd2); }
.right-rail .ai-chat-section {
  margin: 0; border: none; border-radius: 0; box-shadow: none;
  flex: 1 1 0; min-height: 0; display: flex; flex-direction: column;
}
.right-rail .ai-chat-header { display: none; }
.right-rail .ai-chat-body { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.right-rail .ai-chat-messages { flex: 1 1 0; max-height: none; min-height: 0; }
.right-rail .ai-chat-chips,
.right-rail .ai-chat-input-row { flex-shrink: 0; }

/* Когда rail открыт — двигаем содержимое влево */
.app-shell.with-rail .app-main { padding-right: 360px; }

@media (max-width: 1280px) {
  .right-rail { width: 320px; }
  .app-shell.with-rail .app-main { padding-right: 0; }   /* оверлей на мобилке/планшете */
  .right-rail { box-shadow: -8px 0 32px rgba(15,18,36,.18); }
}
@media (max-width: 480px) {
  .right-rail {
    width: 100%;
    top: 0;
    bottom: 0;
    height: 100dvh;
  }
  .right-rail .ai-chat-input-row {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* ─────────────────────────────────────────────
   Header pill buttons (AI / notifications)
   ───────────────────────────────────────────── */
.hdr-pill {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--bd);
  background: var(--sf2);
  color: var(--tx2);
  font: 500 12px var(--fn);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.hdr-pill:hover { color: var(--tx); border-color: var(--bd2); }
.hdr-pill.act { background: var(--pu); border-color: var(--pu); color: #fff; }
body.theme-dark .hdr-pill.act { background: #fff; color: #0E0E0F; }
.hdr-pill .pill-dot {
  position: absolute; top: -3px; right: -3px;
  min-width: 18px; height: 18px;
  background: var(--ac2); color: #fff;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
  border: 2px solid var(--bg);
}
.hdr-pill .pill-icon { display: inline-flex; align-items: center; }

/* ─────────────────────────────────────────────
   Notifications popover
   ───────────────────────────────────────────── */
.notif-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 360px;
  max-height: 480px;
  overflow-y: auto;
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  z-index: 200;
  display: none;
}
.notif-popover.show { display: block; animation: notif-in .15s ease-out; }
@keyframes notif-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--bd);
  font-size: 13px; font-weight: 600; color: var(--tx);
}
.notif-section {
  padding: 10px 16px;
  border-bottom: 1px solid var(--bd);
}
.notif-section:last-child { border-bottom: none; }
.notif-section-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--tx2); margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.notif-item {
  display: block; padding: 6px 0;
  font-size: 12px; color: var(--tx);
  cursor: pointer;
  border-radius: 6px;
}
.notif-item:hover { color: var(--ac); }
.notif-item .nx-id { color: var(--ac); font-family: var(--mono); font-weight: 700; }
.notif-item .nx-meta { color: var(--mu); font-size: 11px; margin-left: 6px; }
.notif-empty { font-size: 12px; color: var(--mu); padding: 4px 0; }

/* Container for popover positioning relative to its trigger */
.hdr-notif-wrap { position: relative; display: inline-block; }

/* ─────────────────────────────────────────────
   Settings page
   ───────────────────────────────────────────── */
.settings-grid {
  display: grid; grid-template-columns: 1fr; gap: 16px;
  max-width: 720px;
}
.settings-row {
  display: grid; grid-template-columns: 140px 1fr 1fr auto; gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: 12px;
}
.settings-row .month-label {
  font-weight: 600; color: var(--tx); font-size: 13px;
}
.settings-row .form-input { width: 100%; }
@media (max-width: 600px) {
  .settings-row { grid-template-columns: 1fr 1fr; }
  .settings-row .month-label { grid-column: 1 / -1; }
}

/* ─────────────────────────────────────────────
   Monthly Report page
   ───────────────────────────────────────────── */
.report-hero {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.report-hero h2 {
  font-size: 24px; font-weight: 700; letter-spacing: -.02em;
  margin-bottom: 4px; color: var(--tx);
}
.report-hero .sub { font-size: 13px; color: var(--tx2); margin-bottom: 16px; }

.plan-bar {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px;
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: 12px;
}
.plan-bar-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 13px;
}
.plan-bar-head strong { color: var(--tx); font-weight: 600; }
.plan-bar-head .nums { color: var(--tx2); font-family: var(--mono); }
.plan-bar-track {
  height: 10px; background: var(--sf2);
  border-radius: 999px; overflow: hidden;
}
.plan-bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--ac), #8B5CF6);
  transition: width .6s var(--ease,ease-out);
}
.plan-bar-fill.over { background: linear-gradient(90deg, var(--gr), var(--ac)); }
.plan-bar-fill.under { background: linear-gradient(90deg, var(--yw), var(--ac2)); }

.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th { background: var(--sf2); color: var(--tx2); padding: 10px 12px; text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--bd); }
.report-table td { padding: 12px; border-bottom: 1px solid var(--bd); color: var(--tx); }
.report-table .num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
