/* Стили новых блоков. Подключается ПОСЛЕ styles.css и только добавляет,
   ничего из старого не переопределяя агрессивно. */

:root {
  --nx-border: rgba(128, 128, 128, 0.22);
  --nx-soft: rgba(128, 128, 128, 0.08);
  --nx-plus: #16a34a;
  --nx-minus: #dc2626;
  --nx-accent: #2563eb;
}

/* ===================== Дашборд ===================== */

.dash-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--nx-border);
  border-radius: 8px;
  overflow: hidden;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  color: inherit;
}
.seg button.active {
  background: var(--nx-accent);
  color: #fff;
}

.wchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--nx-border);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.wchip.on {
  border-color: var(--nx-accent);
  background: rgba(37, 99, 235, 0.1);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  border: 1px solid var(--nx-border);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--nx-soft);
}
.kpi-label { font-size: 12px; opacity: 0.7; }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.2; margin: 4px 0; }
.kpi-delta { font-size: 12px; }
.kpi-up .kpi-delta { color: var(--nx-plus); }
.kpi-down .kpi-delta { color: var(--nx-minus); }
.kpi-flat .kpi-delta { opacity: 0.55; }

.panel {
  border: 1px solid var(--nx-border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-head p { margin: 0; font-size: 12px; opacity: 0.65; }
.panel-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.hbar-row {
  display: grid;
  grid-template-columns: 150px 1fr 56px;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 13px;
}
.hbar-track {
  height: 9px;
  border-radius: 999px;
  background: var(--nx-soft);
  overflow: hidden;
}
.hbar-fill { height: 100%; border-radius: 999px; }
.hbar-row span:last-child { text-align: right; opacity: 0.75; }

.funnel-step { margin-bottom: 10px; }
.funnel-step .funnel-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}
.funnel-track {
  height: 22px;
  background: var(--nx-soft);
  border-radius: 6px;
  overflow: hidden;
}
.funnel-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
}
.funnel-lost { font-size: 11px; color: var(--nx-minus); opacity: 0.85; }

/* ===================== Мастер оффера ===================== */

.steps { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.step-pill {
  padding: 6px 12px;
  border: 1px solid var(--nx-border);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}
.step-pill.active { background: var(--nx-accent); color: #fff; border-color: var(--nx-accent); }
.step-pill.done { border-color: var(--nx-plus); color: var(--nx-plus); }

.fld { margin-bottom: 20px; }
.fld-label { font-weight: 600; font-size: 14px; margin-bottom: 4px; display: block; }
.fld-label .req { color: var(--nx-minus); margin-left: 4px; }
.fld-hint { font-size: 12.5px; opacity: 0.8; margin: 0 0 6px; }
.fld-affects {
  font-size: 12px;
  border-left: 3px solid var(--nx-accent);
  padding: 6px 10px;
  background: rgba(37, 99, 235, 0.07);
  border-radius: 0 6px 6px 0;
  margin: 6px 0;
}
.fld-ex { font-size: 12px; opacity: 0.7; margin: 4px 0; }
.fld-tips { font-size: 12px; margin: 6px 0 0 16px; padding: 0; opacity: 0.85; }
.fld-tips li { margin-bottom: 3px; }
.fld input[type='text'],
.fld input[type='number'],
.fld textarea,
.fld select {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1px solid var(--nx-border);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 14px;
}

.type-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.type-card {
  border: 2px solid var(--nx-border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
}
.type-card.active { border-color: var(--nx-accent); background: rgba(37, 99, 235, 0.07); }
.type-card h4 { margin: 0 0 4px; font-size: 15px; }
.type-card .tc-short { font-size: 12px; font-weight: 600; opacity: 0.8; }
.type-card p { font-size: 12.5px; margin: 6px 0 0; opacity: 0.8; }

.preset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.preset {
  border: 1px solid var(--nx-border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
}
.preset:hover { border-color: var(--nx-accent); }
.preset .p-icon { font-size: 22px; }
.preset h4 { margin: 6px 0 4px; font-size: 14px; }
.preset p { margin: 0; font-size: 12px; opacity: 0.75; }

.wiz-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--nx-border);
}

.match-steps { display: grid; gap: 8px; }
.match-step { display: grid; grid-template-columns: 26px 1fr; gap: 10px; font-size: 12.5px; }
.match-step b { display: block; }
.match-step .n {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--nx-accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}

.offer-type-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.ot-collect { background: rgba(22, 163, 74, 0.15); color: var(--nx-plus); }
.ot-seek { background: rgba(37, 99, 235, 0.15); color: var(--nx-accent); }

/* ===================== Ключи ===================== */

.kw-explain {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.kw-explain-col {
  border: 1px solid var(--nx-border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--nx-soft);
}
.kw-explain-col h4 { margin: 0 0 6px; font-size: 13.5px; }
.kw-explain-col p { margin: 0; font-size: 12.5px; opacity: 0.85; line-height: 1.5; }
.kw-explain-col code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(128, 128, 128, 0.18);
  font-size: 12px;
}

.kw-stats { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; margin-bottom: 12px; }
.kw-stats .kw-warn { color: var(--nx-minus); }

.kw-toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.kw-toolbar input[type='text'],
.kw-toolbar select {
  padding: 8px 11px;
  border: 1px solid var(--nx-border);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 13px;
}
.kw-toolbar input[type='text'] { flex: 1; min-width: 200px; }
.kw-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }

.kw-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .kw-cols { grid-template-columns: 1fr; }
}

.kw-box { border: 1px solid var(--nx-border); border-radius: 12px; overflow: hidden; }
.kw-box.plus { border-top: 3px solid var(--nx-plus); }
.kw-box.minus { border-top: 3px solid var(--nx-minus); }
.kw-box-head { padding: 12px 14px; background: var(--nx-soft); }
.kw-box-head h3 { margin: 0; font-size: 14px; }
.kw-box-head p { margin: 4px 0 0; font-size: 12px; opacity: 0.75; }
.kw-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.2);
  font-size: 12px;
}

.kw-add { display: flex; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--nx-border); }
.kw-add textarea {
  flex: 1;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--nx-border);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 13px;
}

.kw-list { max-height: 620px; overflow-y: auto; }
.kw-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto 28px;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--nx-border);
  font-size: 13px;
}
.kw-row:last-child { border-bottom: 0; }
.kw-row.kw-off { opacity: 0.45; }
.kw-row.kw-row-dead { background: rgba(220, 38, 38, 0.05); }
.kw-phrase { cursor: pointer; word-break: break-word; }
.kw-phrase:hover { text-decoration: underline; }
.kw-badges { display: flex; gap: 4px; }
.kw-badge {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.18);
  white-space: nowrap;
}
.kw-badge.kw-dead { background: rgba(220, 38, 38, 0.18); color: var(--nx-minus); }
.kw-stat { font-size: 12px; font-weight: 600; white-space: nowrap; }
.kw-stat-muted { font-weight: 400; opacity: 0.55; }
.kw-empty { padding: 20px; text-align: center; font-size: 13px; opacity: 0.6; }

/* ===================== Чаты (Telegram-стиль) ===================== */

.tg-wrap {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  border: 1px solid var(--nx-border);
  border-radius: 12px;
  overflow: hidden;
  height: calc(100vh - 170px);
  min-height: 460px;
}
@media (max-width: 900px) {
  .tg-wrap { grid-template-columns: 1fr; height: auto; }
}

.tg-side { border-right: 1px solid var(--nx-border); display: flex; flex-direction: column; min-height: 0; }
.tg-search {
  margin: 10px;
  padding: 8px 11px;
  border: 1px solid var(--nx-border);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 13px;
}
.tg-filters { display: flex; gap: 6px; padding: 0 10px 10px; }
.tg-filter {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--nx-border);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 12px;
  cursor: pointer;
}
.tg-filter.active { background: var(--nx-accent); color: #fff; border-color: var(--nx-accent); }

.tg-list { flex: 1; overflow-y: auto; min-height: 0; }
.tg-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--nx-border);
}
.tg-item:hover { background: var(--nx-soft); }
.tg-item.active { background: rgba(37, 99, 235, 0.12); }
.tg-item-body { min-width: 0; }
.tg-item-top { display: flex; justify-content: space-between; gap: 8px; }
.tg-item-title { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-item-time { font-size: 11px; opacity: 0.6; white-space: nowrap; }
.tg-item-bottom { display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; }
.tg-item-preview { font-size: 12px; opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-item-count {
  font-size: 11px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.2);
}
.tg-item-tags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.tg-tag {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.16);
}
.tg-tag-lead { background: rgba(37, 99, 235, 0.18); color: var(--nx-accent); }
.tg-tag-person { background: rgba(22, 163, 74, 0.18); color: var(--nx-plus); }
.tg-tag-soft { opacity: 0.7; }

.tg-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px;
}

.tg-pane { display: flex; flex-direction: column; min-height: 0; }
.tg-head {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--nx-border);
}
.tg-head-title { font-weight: 600; font-size: 14px; }
.tg-head-user { font-weight: 400; opacity: 0.6; font-size: 12px; }
.tg-head-sub { font-size: 12px; opacity: 0.65; }
.tg-head-actions { display: flex; gap: 6px; }

.tg-whobar {
  padding: 7px 14px;
  font-size: 12px;
  background: rgba(37, 99, 235, 0.08);
  border-bottom: 1px solid var(--nx-border);
}

.tg-messages { flex: 1; overflow-y: auto; padding: 16px; min-height: 0; }
.tg-day { text-align: center; font-size: 11px; opacity: 0.55; margin: 12px 0; }
.tg-msg { display: flex; margin-bottom: 8px; }
.tg-msg.mine { justify-content: flex-end; }
.tg-bubble {
  max-width: 72%;
  padding: 8px 12px;
  border-radius: 14px 14px 14px 4px;
  background: var(--nx-soft);
  border: 1px solid var(--nx-border);
}
.tg-msg.mine .tg-bubble {
  border-radius: 14px 14px 4px 14px;
  background: rgba(37, 99, 235, 0.16);
  border-color: rgba(37, 99, 235, 0.3);
}
.tg-bubble-author { font-size: 11px; font-weight: 600; opacity: 0.7; margin-bottom: 2px; }
.tg-bubble-text { font-size: 13.5px; line-height: 1.45; word-break: break-word; }
.tg-bubble-time { font-size: 10.5px; opacity: 0.55; text-align: right; margin-top: 3px; }

.tg-composer { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--nx-border); }
.tg-composer textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 9px 12px;
  border: 1px solid var(--nx-border);
  border-radius: 18px;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 13.5px;
}

.tg-placeholder {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  opacity: 0.55; font-size: 14px; padding: 40px;
}
.tg-placeholder-icon { font-size: 42px; margin-bottom: 8px; }
.tg-empty-list { padding: 24px 16px; font-size: 13px; opacity: 0.65; text-align: center; }
.tg-empty-list span { font-size: 12px; opacity: 0.8; }
