/* ReloFast admin — тёмная тема с лаймовым акцентом */
:root {
  --bg: #0A0C0A;
  --bg-side: #0B0D0B;
  --bg-card: #0F110F;
  --bg-elev: #141714;
  --bg-inset: #121512;
  --border: #1E221E;
  --border-soft: #191C19;

  --lime: #C8FA4B;
  --lime-dim: #A7D63C;
  --lime-glow: rgba(200, 250, 75, 0.18);
  --lime-soft: rgba(200, 250, 75, 0.10);

  --text: #E9EDE9;
  --text-dim: #8B928B;
  --text-mute: #5F665F;

  --danger: #F2555A;
  --warn: #F5B544;

  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --sidebar-w: 300px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
svg { width: 16px; height: 16px; flex-shrink: 0; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Каркас ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; padding: 0 6px; }
.rf-logo {
  width: auto; height: auto; flex-shrink: 0;
  filter: drop-shadow(0 0 14px rgba(200, 250, 75, .28));
}
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.brand-sub { font-size: 12px; color: var(--text-dim); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav::-webkit-scrollbar { width: 0; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav-item.active {
  background: var(--lime);
  color: #0A0C0A;
  font-weight: 600;
  box-shadow: 0 0 26px var(--lime-glow);
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }

.side-foot { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 14px; }
.side-user { padding: 0 8px 14px; }
.side-user-name { font-weight: 600; }
.side-user-role { font-size: 11px; color: var(--lime); letter-spacing: .8px; text-transform: uppercase; }

.btn-logout {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-logout:hover { background: #1B1F1B; }
.btn-logout svg { width: 17px; height: 17px; }

/* ---------- Контент ---------- */
.main { flex: 1; min-width: 0; position: relative; }
.main::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 340px; pointer-events: none;
  background: radial-gradient(120% 100% at 75% 0%, rgba(200,250,75,.05), transparent 65%);
}
.topbar { padding: 26px 34px; border-bottom: 1px solid var(--border-soft); position: relative; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.4px; }
.content { padding: 28px 34px 60px; position: relative; }

/* ---------- Панель фильтров ---------- */
.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.toolbar-spacer { flex: 1; }
.total { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-weight: 500; }
.total svg { width: 17px; height: 17px; }
.total b { color: var(--text); font-size: 16px; }

.chips { display: inline-flex; background: var(--bg-elev); border-radius: var(--radius-pill); padding: 5px; gap: 3px; }
.chip {
  padding: 8px 18px; border-radius: var(--radius-pill);
  color: var(--text-dim); font-weight: 500; font-size: 13px;
  cursor: pointer; border: none; background: none; white-space: nowrap;
  transition: background .15s, color .15s;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--lime); color: #0A0C0A; font-weight: 600; }

.chip-outline {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-pill);
  border: 1px solid var(--lime-dim); color: var(--lime);
  background: transparent; cursor: pointer; font-size: 13px; font-weight: 500;
}
.chip-outline:hover { background: var(--lime-soft); }

.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 11px 20px; min-width: 300px;
}
.search input { background: none; border: none; outline: none; width: 100%; }
.search input::placeholder { color: var(--text-mute); }
.search svg { width: 16px; height: 16px; color: var(--text-mute); flex-shrink: 0; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 22px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--bg-elev);
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, transform .1s;
}
.btn:hover { background: #1B1F1B; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: var(--lime); color: #0A0C0A; border-color: var(--lime);
  box-shadow: 0 0 30px var(--lime-glow);
}
.btn-primary:hover { background: #D3FF63; }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: #1B1F1B; color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; }

/* ---------- Карточки и таблица ---------- */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card-pad { padding: 22px 24px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
thead th {
  text-align: left; padding: 16px 18px;
  font-size: 11px; font-weight: 600; letter-spacing: .9px; text-transform: uppercase;
  color: var(--text-mute); border-bottom: 1px solid var(--border);
}
tbody td { padding: 16px 18px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(255,255,255,.02); }

.cell-user { display: flex; flex-direction: column; gap: 2px; }
.cell-user b { font-weight: 600; }
.cell-user span { color: var(--text-dim); font-size: 13px; }
.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge svg { width: 13px; height: 13px; }
.badge-code { background: var(--lime-soft); color: var(--lime); font-family: ui-monospace, Menlo, monospace; }
.badge-lime { background: var(--lime); color: #0A0C0A; }
.badge-grey { background: var(--bg-elev); color: var(--text-dim); border: 1px solid var(--border); }
.badge-green { background: rgba(120, 230, 120, .12); color: #7DE87D; }
.badge-warn { background: rgba(245, 181, 68, .12); color: var(--warn); }
.badge-danger { background: rgba(242, 85, 90, .12); color: var(--danger); }

.money { display: inline-flex; align-items: center; gap: 7px; color: var(--lime); font-weight: 600; }
.money svg { width: 14px; height: 14px; }
.money.zero { color: var(--text-mute); }

/* ---------- Реф-программы ---------- */
.prog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.prog-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.prog-title h3 { font-size: 18px; font-weight: 700; }
.prog-meta { color: var(--text-dim); font-size: 13px; margin-top: 4px; font-family: ui-monospace, Menlo, monospace; }
.prog-actions { display: flex; gap: 8px; }
.link-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-inset); border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 13px 16px; margin-top: 12px;
}
.link-row svg { width: 15px; height: 15px; color: var(--text-mute); flex-shrink: 0; }
.link-row code { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: 13px; color: var(--text); overflow-x: auto; }
.link-copy { color: var(--text-dim); font-size: 13px; cursor: pointer; white-space: nowrap; }
.link-copy:hover { color: var(--lime); }

/* ---------- Формы ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 7px; font-weight: 500; }
.input, .select, .textarea {
  width: 100%; padding: 12px 16px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 12px; outline: none; transition: border-color .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--lime-dim); }
.textarea { min-height: 90px; resize: vertical; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }
/* Кнопки в строке формы не должны растягиваться наравне с полями */
.row > .btn { flex: 0 0 auto; min-width: 0; }

/* ---------- Статы ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; }
.stat-label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .7px; }
.stat-value { font-size: 30px; font-weight: 700; margin-top: 10px; letter-spacing: -0.6px; }
.stat-value.lime { color: var(--lime); }

/* ---------- Чат ---------- */
.chat { display: flex; flex-direction: column; height: 460px; }
.chat-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 70%; padding: 11px 15px; border-radius: 14px; }
.msg-in { align-self: flex-start; background: var(--bg-elev); border: 1px solid var(--border); }
.msg-out { align-self: flex-end; background: var(--lime); color: #0A0C0A; }
.msg-meta { font-size: 11px; opacity: .6; margin-top: 5px; }
.chat-form { display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); }

/* ---------- Логин ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 34px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }

.empty { padding: 60px 20px; text-align: center; color: var(--text-mute); }
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-size: 13px; }
.alert-error { background: rgba(242,85,90,.1); color: var(--danger); border: 1px solid rgba(242,85,90,.25); }
.alert-ok { background: var(--lime-soft); color: var(--lime); border: 1px solid rgba(200,250,75,.25); }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .content, .topbar { padding-left: 18px; padding-right: 18px; }
}

/* Шапка секции: итоги не должны переноситься по одному слову */
.section-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.section-totals { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }

/* ---------- Живой чат ---------- */
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-fail { color: var(--danger); }
.chat-live {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--lime-dim); opacity: .45;
  transition: opacity .3s, box-shadow .3s;
}
.chat-live.pulse { opacity: 1; box-shadow: 0 0 10px var(--lime); }
.chat-body { scroll-behavior: smooth; }

.icon-btn.copied { border-color: var(--lime); color: var(--lime); }

/* ---------- Этап воронки ---------- */
.stage { display: inline-flex; align-items: center; gap: 9px; }
.stage-bar { display: inline-flex; gap: 3px; flex-shrink: 0; }
.stage-bar i {
  width: 14px; height: 4px; border-radius: 2px;
  background: var(--border); display: block;
}
.stage-bar i.on { background: var(--lime); }
.stage-text { color: var(--text-dim); font-size: 13px; }
