:root {
  --bg: #08080B;
  --bg2: #0F0F14;
  --surface: #16161D;
  --surface2: #1E1E28;
  --surface3: #262633;
  --border: #2A2A38;
  --border2: #3A3A4A;
  --text: #E4E4EE;
  --text2: #9090A8;
  --text3: #606078;
  --accent: #6C63FF;
  --accent2: #8B83FF;
  --green: #34D399;
  --green2: rgba(52, 211, 153, 0.12);
  --red: #F87171;
  --red2: rgba(248, 113, 113, 0.12);
  --yellow: #FBBF24;
  --yellow2: rgba(251, 191, 36, 0.12);
  --blue: #60A5FA;
  --blue2: rgba(96, 165, 250, 0.12);
  --orange: #FB923C;
  --orange2: rgba(251, 146, 60, 0.12);
  --pink: #F472B6;
  --pink2: rgba(244, 114, 182, 0.12);
  --teal: #2DD4BF;
  --teal2: rgba(45, 212, 191, 0.12);
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'Sora', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; background: none; border: none; outline: none; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.logo {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  letter-spacing: -0.5px;
}
.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.logo-text .name { font-size: 14px; font-weight: 700; }
.logo-text .sub { font-size: 10px; color: var(--text3); font-family: var(--mono); letter-spacing: 1px; text-transform: uppercase; }

.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
  padding: 16px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 1px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: var(--surface);
  color: var(--text);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item .ico {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}
.nav-item .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  background: var(--surface2);
  padding: 2px 7px;
  border-radius: 100px;
}
.nav-item.active .count { background: var(--accent); color: #fff; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 10px 4px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sys-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text3);
}
.dot-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.back-home {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
  padding: 4px 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.back-home:hover { color: var(--text2); }

/* ============ MAIN ============ */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.page-header {
  padding: 22px 32px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.page-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.page-title h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.page-title .crumb {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text3);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.search-box {
  flex: 1;
  min-width: 280px;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  transition: border-color 0.15s;
}
.search-box:focus-within { border-color: var(--border2); }
.search-box input {
  flex: 1;
  font-size: 13px;
  color: var(--text);
}
.search-box input::placeholder { color: var(--text3); }
.search-box svg { color: var(--text3); flex-shrink: 0; }
.header-actions { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.btn {
  padding: 9px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--border2); background: var(--surface2); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
}

.page-body {
  padding: 24px 32px 80px;
  flex: 1;
}
.page { display: none; }
.page.active { display: block; }

/* ============ FILTER BAR ============ */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
  flex-wrap: wrap;
  align-items: center;
}
.chip {
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px;
  color: var(--text2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--border2); color: var(--text); }
.chip.active { background: rgba(108, 99, 255, 0.12); border-color: var(--accent); color: var(--accent2); }
.chip .x { color: var(--text3); margin-left: 2px; }

/* ============ STAT CARDS ============ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.6;
}
.stat.s-green::before { background: var(--green); }
.stat.s-red::before { background: var(--red); }
.stat.s-yellow::before { background: var(--yellow); }
.stat.s-blue::before { background: var(--blue); }
.stat.s-pink::before { background: var(--pink); }
.stat.s-orange::before { background: var(--orange); }
.stat-label {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: -1px;
  margin-bottom: 4px;
}
.stat-trend {
  font-size: 11px;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-trend.up { color: var(--green); }
.stat-trend.down { color: var(--red); }

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.card.gradient::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.card.g-blue::before { background: linear-gradient(90deg, var(--blue), var(--teal)); }
.card.g-green::before { background: linear-gradient(90deg, var(--green), var(--teal)); }
.card.g-red::before { background: linear-gradient(90deg, var(--red), var(--orange)); }
.card.g-yellow::before { background: linear-gradient(90deg, var(--yellow), var(--orange)); }
.card.g-pink::before { background: linear-gradient(90deg, var(--pink), var(--accent)); }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 600; line-height: 1.3; }
.card-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.card-menu {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  cursor: pointer;
  flex-shrink: 0;
}
.card-menu:hover { background: var(--surface2); color: var(--text); }

/* ============ DASHBOARD GRID ============ */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 22px; }
.grid-12 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 14px;
}
.section-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
.section-head .more {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.section-head .more:hover { color: var(--accent2); cursor: pointer; }

/* ============ PROGRESS ============ */
.progress {
  height: 4px;
  background: var(--surface2);
  border-radius: 100px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 100px;
}
.progress-fill.g { background: linear-gradient(90deg, var(--green), var(--teal)); }
.progress-fill.y { background: linear-gradient(90deg, var(--yellow), var(--orange)); }
.progress-fill.r { background: linear-gradient(90deg, var(--red), var(--orange)); }
.progress-fill.b { background: linear-gradient(90deg, var(--blue), var(--teal)); }

/* ============ AVATAR STACK ============ */
.avatars {
  display: flex;
  align-items: center;
}
.av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface3);
  border: 2px solid var(--surface);
  margin-left: -8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--text);
}
.av:first-child { margin-left: 0; }
.av.plus { background: var(--accent); color: #fff; }

/* ============ BADGES / TAGS ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--mono);
  padding: 3px 9px;
  border-radius: 100px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.b-accent { background: rgba(108, 99, 255, 0.12); color: var(--accent2); }
.b-green { background: var(--green2); color: var(--green); }
.b-yellow { background: var(--yellow2); color: var(--yellow); }
.b-red { background: var(--red2); color: var(--red); }
.b-blue { background: var(--blue2); color: var(--blue); }
.b-orange { background: var(--orange2); color: var(--orange); }
.b-pink { background: var(--pink2); color: var(--pink); }
.b-teal { background: var(--teal2); color: var(--teal); }
.b-mute { background: var(--surface2); color: var(--text3); }

.tags { display: flex; flex-wrap: wrap; gap: 5px; }

/* ============ EMPTY STATE ============ */
.empty {
  border: 1px dashed var(--border2);
  border-radius: 14px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text3);
  background: rgba(255, 255, 255, 0.01);
}
.empty .ico {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
}
.empty .title { font-size: 14px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.empty .desc { font-size: 12px; max-width: 360px; margin: 0 auto; line-height: 1.6; }

/* ============ KANBAN ============ */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  align-items: start;
}
.col {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  min-height: 320px;
}
.col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.col-head .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}
.col-head .name { font-size: 12px; font-weight: 600; flex: 1; }
.col-head .count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 100px;
}

.lead-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 13px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.lead-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.lead-card .phone { font-family: var(--mono); font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.lead-card .meta { font-size: 11px; color: var(--text2); margin-bottom: 8px; }
.lead-card .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ============ TABLES ============ */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead { background: var(--bg2); }
th {
  text-align: left;
  padding: 12px 16px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 13px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
td.mono { font-family: var(--mono); }
td.dim { color: var(--text2); }

/* ============ MATRIX ============ */
.matrix-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  overflow-x: auto;
}
.matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
}
.matrix th {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
  padding: 8px 10px;
  text-align: center;
  border: none;
  background: none;
}
.matrix th:first-child { text-align: left; }
.matrix td {
  padding: 0;
  border: none;
}
.matrix .cell {
  height: 42px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text3);
  cursor: pointer;
  transition: all 0.15s;
}
.matrix .cell:hover { transform: scale(1.04); }
.matrix .cell.empty-cell { color: var(--text3); }
.matrix .row-label {
  font-size: 12px;
  color: var(--text2);
  padding: 0 10px;
  white-space: nowrap;
  text-align: left;
}

/* ============ TIMELINE (lead detail) ============ */
.timeline {
  position: relative;
  padding-left: 28px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}
.tl-item {
  position: relative;
  margin-bottom: 18px;
}
.tl-dot {
  position: absolute;
  left: -28px;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface2);
  border: 2px solid var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text);
}
.tl-dot.g { background: var(--green); color: #04221b; }
.tl-dot.y { background: var(--yellow); color: #3a2700; }
.tl-dot.r { background: var(--red); color: #2c0a0a; }
.tl-dot.b { background: var(--blue); color: #0d1d36; }
.tl-dot.a { background: var(--accent); color: #fff; }
.tl-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.tl-desc { font-size: 12px; color: var(--text2); line-height: 1.5; }

/* ============ AI INSIGHT BOX ============ */
.insight {
  background: linear-gradient(135deg, rgba(108, 99, 255, 0.08), rgba(45, 212, 191, 0.05));
  border: 1px solid rgba(108, 99, 255, 0.25);
  border-radius: 14px;
  padding: 18px 22px;
  margin-bottom: 22px;
  position: relative;
}
.insight::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  border-radius: 14px 14px 0 0;
}
.insight-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 8px;
}
.insight-text { font-size: 13px; line-height: 1.6; color: var(--text); }
.insight-text strong { color: var(--accent2); font-weight: 600; }

/* ============ DROPZONE ============ */
.dropzone {
  border: 2px dashed var(--border2);
  border-radius: 14px;
  padding: 36px 24px;
  text-align: center;
  background: rgba(255, 255, 255, 0.01);
  cursor: pointer;
  transition: all 0.2s;
}
.dropzone:hover {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.04);
}
.dropzone .ico {
  width: 48px; height: 48px;
  border-radius: 12px;
  margin: 0 auto 14px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent2);
}
.dropzone .label { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.dropzone .hint { font-size: 11px; color: var(--text3); font-family: var(--mono); }

/* ============ FUNNEL ============ */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.funnel-bar {
  height: 36px;
  border-radius: 8px;
  background: var(--surface2);
  position: relative;
  overflow: hidden;
  flex: 1;
}
.funnel-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding-left: 12px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  color: #fff;
  min-width: 40px;
}
.funnel-fill.g { background: linear-gradient(90deg, var(--green), var(--teal)); color: #04221b; }
.funnel-fill.y { background: linear-gradient(90deg, var(--yellow), var(--orange)); color: #3a2700; }
.funnel-fill.r { background: linear-gradient(90deg, var(--red), var(--orange)); }
.funnel-label { font-size: 12px; min-width: 140px; color: var(--text2); }
.funnel-val { font-size: 12px; font-family: var(--mono); color: var(--text); min-width: 60px; text-align: right; }

/* ============ HEATMAP placeholder ============ */
.heatmap {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
}
.heatmap .h-cell {
  aspect-ratio: 1;
  background: var(--surface2);
  border-radius: 2px;
}

/* ============ SEGMENT DOT ============ */
.seg-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.seg-hot { background: var(--green); }
.seg-warm { background: var(--orange); }
.seg-cold { background: var(--yellow); }
.seg-dead { background: var(--red); }
.seg-sleep { background: var(--pink); }
.seg-goal { background: var(--teal); }

/* ============ DETAIL HERO ============ */
.detail-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 18px;
  display: flex;
  gap: 22px;
  align-items: flex-start;
}
.detail-avatar {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.detail-info { flex: 1; }
.detail-info .phone { font-family: var(--mono); font-size: 22px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; }
.detail-info .meta { font-size: 12px; color: var(--text2); margin-bottom: 12px; }
.detail-score {
  text-align: right;
  flex-shrink: 0;
}
.detail-score .num {
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 800;
  color: var(--green);
  line-height: 1;
}
.detail-score .label {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 4px;
}

/* ============ MISC ============ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}
.muted { color: var(--text3); }
.small { font-size: 11px; }
.mono { font-family: var(--mono); }
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tab {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tab.active { color: var(--text); border-color: var(--accent); }
.tab:hover { color: var(--text); }

/* ============ LOGIN OVERLAY ============ */
.login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at top, #15151D 0%, var(--bg) 60%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.login-overlay.hidden { display: none; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.login-logo .logo { width: 38px; height: 38px; font-size: 16px; border-radius: 11px; }
.login-title { font-size: 18px; font-weight: 700; line-height: 1.1; }
.login-sub { font-size: 11px; font-family: var(--mono); color: var(--text3); letter-spacing: 1.5px; text-transform: uppercase; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.login-field span {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.login-field input {
  padding: 11px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s;
}
.login-field input:focus { border-color: var(--accent); }
.login-error {
  font-size: 12px;
  color: var(--red);
  min-height: 16px;
  font-family: var(--mono);
}
.login-submit {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}
.login-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.login-foot {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
  letter-spacing: 0.5px;
}

/* ============ SIDEBAR USER WIDGET ============ */
.sys-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 4px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.user-info { flex: 1; min-width: 0; }
.user-email {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 9px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.user-logout {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  flex-shrink: 0;
  transition: all 0.15s;
}
.user-logout:hover { background: var(--surface); color: var(--red); }

.dot-pulse.err { background: var(--red); animation: pulseRed 1.6s infinite; }
@keyframes pulseRed {
  0% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(248, 113, 113, 0); }
  100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
}

/* ============ OFFERS GRID ============ */
.offers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.offer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.offer-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.offer-card.r-crimea::before  { background: linear-gradient(90deg, var(--blue), var(--teal)); }
.offer-card.r-sochi::before   { background: linear-gradient(90deg, var(--orange), var(--yellow)); }
.offer-card.r-anapa::before   { background: linear-gradient(90deg, var(--pink), var(--accent)); }
.offer-card.r-baku::before    { background: linear-gradient(90deg, var(--green), var(--teal)); }
.offer-card.r-monolit::before { background: linear-gradient(90deg, var(--red), var(--orange)); }
.offer-card.inactive { opacity: 0.55; }
.offer-card:hover { border-color: var(--border2); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,.3); }

.offer-card .head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.offer-card .code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent2);
  background: rgba(108, 99, 255, 0.1);
  padding: 3px 8px;
  border-radius: 5px;
  letter-spacing: 0.5px;
}
.offer-card .name { font-size: 17px; font-weight: 700; line-height: 1.2; }
.offer-card .desc { font-size: 12px; color: var(--text2); line-height: 1.5; }
.offer-card .script {
  font-size: 12px;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-style: italic;
  line-height: 1.5;
  max-height: 110px;
  overflow: hidden;
  position: relative;
}
.offer-card .script::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 30px;
  background: linear-gradient(to bottom, transparent, var(--bg2));
  pointer-events: none;
}
.offer-card .meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.offer-card .meta b { color: var(--text); font-weight: 600; }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 11, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 24px;
  overflow-y: auto;
}
.modal-backdrop.hidden { display: none; }
.modal-card {
  width: 100%;
  max-width: 580px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
  position: relative;
  overflow: hidden;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}
.modal-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.modal-head {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-sub { font-size: 12px; color: var(--text3); margin-top: 2px; font-family: var(--mono); }
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 22px;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--surface2); color: var(--text); }
.modal-body {
  padding: 18px 24px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field span {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.form-field small {
  font-size: 10px;
  color: var(--text3);
  font-family: var(--mono);
  margin-top: 2px;
}
.form-field input[type="text"],
.form-field input[type="number"],
.form-field select,
.form-field textarea {
  padding: 10px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13px;
  color: var(--text);
  font-family: var(--sans);
  transition: border-color 0.15s;
  width: 100%;
}
.form-field textarea { font-family: var(--mono); font-size: 12px; line-height: 1.6; resize: vertical; }
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus { border-color: var(--accent); }
.form-error {
  font-size: 12px;
  color: var(--red);
  font-family: var(--mono);
  min-height: 16px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  align-items: center;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-12, .grid-3 { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; padding: 12px; align-items: center; gap: 12px; overflow-x: auto; }
  .sidebar-header { padding: 0; border: none; margin: 0; flex-shrink: 0; }
  .nav-group-label { display: none; }
  .nav-item { flex-shrink: 0; padding: 8px 12px; }
  .nav-item.active::before { display: none; }
  .sidebar-footer { display: none; }
  .stats-row { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .page-body { padding: 18px; }
  .page-header { padding: 14px 18px; }
  .detail-hero { flex-direction: column; }
}
