/* CRM Gues v3 — Visual Redesign */
/* Plus Jakarta Sans · Dark sidebar · Indigo accent */

  :root {
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: #eef2ff;
  --accent-muted: rgba(99, 102, 241, 0.12);
  --sidebar-bg: #0f1117;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-text: #9ca3af;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(99, 102, 241, 0.18);
  --content-bg: #f4f5f7;
  --bg-primary: #ffffff;
  --bg-secondary: #f4f5f7;
  --bg-tertiary: #e8e9ed;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --text-info: #6366f1;
  --border-tertiary: #e5e7eb;
  --border-secondary: #d1d5db;
  --border-radius-sm: 8px;
  --border-radius-md: 10px;
  --border-radius-lg: 14px;
  --border-radius-xl: 18px;
  --color-background-info: #eef2ff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --transition: 0.15s ease;
  --row-grid: minmax(172px, 1.45fr) 128px minmax(0, 1fr) 100px 120px;
  --geo-grid: 130px 118px 120px minmax(0, 1fr) 92px 108px;
}
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--border-radius-md);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn--full { width: 100%; }

/* ── Auth extras ── */
.auth-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.auth-logo-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
.auth-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}
.auth-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ── Sidebar extras ── */
.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.sidebar-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--sidebar-text-active);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.sidebar-brand-ver {
  font-size: 10px;
  font-weight: 600;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sidebar-user-block {
  padding: 0 6px 14px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 14px;
}
.sidebar-nav-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-text);
  padding: 10px 8px 6px;
  opacity: 0.7;
}
.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--sidebar-border);
}
.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--sidebar-active);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

/* ── Page header ── */
.page-header { margin-bottom: 4px; }
.page-header--leads { margin-bottom: 0; }
.page-title {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.page-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── KPI ── */
.kpi-grid,
#crm-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.kpi-card {
  position: relative;
  background: var(--bg-primary);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--border-radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  border-radius: 3px 0 0 3px;
}
.kpi-card--green::before { background: #10b981; }
.kpi-card--violet::before { background: #8b5cf6; }
.kpi-card--blue::before { background: var(--accent); }
.kpi-card--amber::before { background: #f59e0b; }
.kpi-card--cyan::before { background: #06b6d4; }
.kpi-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-secondary);
  transform: translateY(-1px);
}
.kpi-card__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.kpi-card__value {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
}
.kpi-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.kpi-dot--green { background: #10b981; }
.kpi-dot--violet { background: #8b5cf6; }
.kpi-dot--blue { background: var(--accent); }
.kpi-dot--amber { background: #f59e0b; }
.kpi-dot--cyan { background: #06b6d4; }

/* ── Calendly ── */
.calendly-block {
  background: var(--bg-primary);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--border-radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}
.calendly-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.calendly-block__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.calendly-block__title i { font-size: 18px; color: #f59e0b; }
.calendly-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #fef3c7;
  color: #b45309;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid #fde68a;
}
.calendly-block__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-tertiary);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.cal-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--border-secondary);
  color: var(--text-primary);
}
.cal-btn--icon {
  width: 32px;
  padding: 0;
}

.analytics-empty-inline {
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
}
.geo-country-chips--expanded {
  max-height: none;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--content-bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  padding: 24px 0 32px;
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after { display: none; }

body > .bg-mesh {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 39px,
      rgba(0, 0, 0, 0.012) 39px,
      rgba(0, 0, 0, 0.012) 40px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 39px,
      rgba(0, 0, 0, 0.012) 39px,
      rgba(0, 0, 0, 0.012) 40px
    );
}
  .container { max-width: 1920px; margin: 0 auto; padding: 0 20px; position: relative; z-index: 1; width: 100%; }
  input, select, button, textarea { font-family: inherit; }
  input[type="text"], input[type="date"], select, textarea {
    border: 1px solid var(--border-tertiary);
    border-radius: var(--border-radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  }
  input[type="text"]:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(99, 102, 241,0.18); }

  .row {
  display: grid;
  grid-template-columns: var(--row-grid);
  gap: 12px;
  padding: 13px 16px;
  border-top: 1px solid var(--border-tertiary);
  align-items: start;
  font-size: 13px;
  transition: background var(--transition);
  background: var(--bg-primary);
}
  .row > * { min-width: 0; max-width: 100%; }
  .row > :first-child,
  .row > :nth-child(2) { min-width: auto; max-width: none; overflow: visible; }
  .row:hover {
  background: var(--accent-light);
}
  .row:hover .pencil-btn { opacity: 1; }
  .row.highlight { background: #fff2dc !important; }
  .row.fresh { background: #e6f9ef !important; }

  .phone-cell {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 5px;
    min-width: 0;
  }
  .phone-cell .phone-btn {
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    cursor: pointer;
    font-weight: 650;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    text-align: left;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
  }
  .phone-btn:hover { text-decoration: underline; }
  .phone-copy-btn {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: 1px solid rgba(99, 102, 241, 0.24);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--accent);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 12px;
    opacity: 0.85;
  }
  .phone-copy-btn:hover { opacity: 1; background: var(--accent-light); }
  .phone-wa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 8px;
    background: #dcf8e8;
    color: #12843a;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 15px;
    padding: 0;
  }
  .phone-wa-btn:hover { background: #c4f0d4; }
  .wa-line-pick {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
  }
  .wa-line-pick--compact { margin-left: 2px; }
  .wa-line-pick-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
  }
  .wa-line-pick-label {
    font-size: 12px;
    font-weight: 650;
    color: #334155;
  }
  .wa-line-btn {
    min-width: 28px;
    height: 26px;
    padding: 0 8px;
    border: 1.5px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
  }
  .wa-line-btn:hover { background: #f1f5f9; border-color: #94a3b8; }
  .wa-line-btn.active {
    background: #12843a;
    border-color: #12843a;
    color: #fff;
  }
  .wa-line-pick--compact .wa-line-btn {
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    font-size: 11px;
  }
  .wa-line-card-pick .wa-line-pick { margin-top: 6px; }
  .wa-line-hint {
    margin: 8px 0 0;
    font-size: 11px;
    color: #64748b;
  }
  .wa-chat-empty--setup {
    flex-direction: column;
    text-align: center;
    padding: 24px 16px;
    line-height: 1.5;
  }
  .wa-fallback-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 8px 14px;
    border-radius: 10px;
    background: #dcf8e8;
    color: #12843a;
    font-weight: 600;
    text-decoration: none;
  }
  .wa-fallback-link:hover { background: #c4f0d4; }
  .cal-card .phone-cell { min-width: 0; }

  .status-pill { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 650; white-space: nowrap; max-width: 100%; }
  .mgr-badge { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; font-size: 11px; font-weight: 500; margin-left: auto; }
  .comment-cell { display: flex; align-items: flex-start; gap: 6px; min-width: 0; overflow: hidden; }
  .comment-cell .pencil-btn { flex-shrink: 0; margin-top: 1px; }
  .date-cell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .comment-text-block { flex: 1; min-width: 0; overflow: hidden; }
  .last-comment {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.35;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
  .comment-date-line {
    display: block;
    margin-top: 2px;
    font-size: 10px;
    color: var(--text-tertiary);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .pencil-btn { background: transparent; border: none; cursor: pointer; padding: 5px; border-radius: 6px; color: var(--text-tertiary); opacity: 0.4; transition: opacity 0.15s, background 0.15s; flex-shrink: 0; }
  .pencil-btn:hover { background: var(--bg-secondary); color: var(--text-info); opacity: 1; }
  .pencil-btn.active { opacity: 1; color: var(--text-info); background: var(--color-background-info); }
  .quick-comment-input { width: 100%; height: 28px; font-size: 12px; padding: 0 8px; flex: 1; }
  .date-cell { font-size: 11px; color: var(--text-secondary); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

  .status-option { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--border-radius-md); cursor: pointer; font-size: 12px; white-space: nowrap; }
  .status-option:hover { background: var(--bg-secondary); }
  .status-option.selected { background: var(--color-background-info); }

  .table-head {
  display: grid;
  grid-template-columns: var(--row-grid);
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 5;
  overflow: visible;
}
  .status-filter-cell { position: relative; overflow: visible; }
  #status-header-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: inherit;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    max-width: 100%;
  }
  #status-dropdown {
    display: none;
    position: fixed;
    background: var(--bg-primary);
    border: 0.5px solid var(--border-secondary);
    border-radius: var(--border-radius-md);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    padding: 4px;
    z-index: 12000;
    min-width: 188px;
    max-height: min(360px, 70vh);
    overflow-x: hidden;
    overflow-y: auto;
  }

  .cal-card { background: white; border-radius: var(--border-radius-md); padding: 9px 10px; display: grid; grid-template-columns: 75px 130px 1fr 30px; gap: 10px; align-items: center; font-size: 12px; margin-bottom: 6px; border: 1px solid rgba(99, 102, 241, 0.24); }
  .cal-card:last-child { margin-bottom: 0; }
  .cal-datetime { color: #5d4a22; font-family: ui-monospace, monospace; font-size: 10px; line-height: 1.2; }
  .cal-datetime .time { font-weight: 500; font-size: 13px; display: block; }
  .cal-name { font-weight: 500; }

  .modal-overlay { position: fixed; inset: 0; background: rgba(17,24,39,0.35); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 20px; overflow-y: auto; }
  .modal-card {
  background: var(--bg-primary);
  border-radius: var(--border-radius-lg);
  width: 460px;
  max-width: 100%;
  border: 1px solid var(--border-tertiary);
  box-shadow: var(--shadow-lg);
}
  .modal-card--wa { width: min(920px, 96vw); }
  .modal-tabs-row {
    display: flex;
    gap: 8px;
    padding-top: 0;
  }
  .modal-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border-tertiary);
    background: #fff;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }
  .modal-tab-btn.active {
    background: #e8f5ec;
    border-color: rgba(37, 161, 72, 0.45);
    color: #12843a;
  }
  .modal-wa-panel { padding-top: 10px; }
  .wa-channel-pick {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text-secondary);
  }
  .wa-channel-pick select {
    min-width: 220px;
    height: 32px;
  }
  .wa-chat-host { min-height: 520px; }
  .wa-chat-iframe {
    width: 100%;
    height: min(68vh, 620px);
    border: 1px solid var(--border-tertiary);
    border-radius: 12px;
    background: #f8fafc;
  }
  .wa-chat-loading,
  .wa-chat-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    color: var(--text-secondary);
    font-size: 13px;
    gap: 8px;
  }
  .wa-chat-hint {
    margin: 10px 0 0;
    font-size: 11px;
    color: var(--text-tertiary);
  }
  .modal-section { padding: 15px 20px; border-bottom: 1px solid var(--border-tertiary); }
  .field-label { color: var(--text-secondary); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; font-weight: 500; }
  .field-input { width: 100%; height: 32px; font-size: 13px; padding: 0 8px; }

  .tranche-card { border-radius: var(--border-radius-md); padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; background: var(--bg-secondary); border: 0.5px solid var(--border-tertiary); transition: all 0.15s; }
  .tranche-card:hover { border-color: #3a3a3a; }
  .tranche-card .amount { font-size: 13px; font-weight: 500; font-family: ui-monospace, monospace; display: flex; align-items: center; justify-content: space-between; }
  .tranche-amount-wrap { display: inline-flex; align-items: center; gap: 3px; }
  .tranche-amount-input {
    width: 72px;
    height: 22px;
    border: 0.5px solid var(--border-tertiary);
    border-radius: 6px;
    padding: 0 6px;
    font-size: 12px;
    font-family: ui-monospace, monospace;
    background: rgba(255,255,255,0.88);
    color: var(--text-primary);
  }
  .tranche-card .check-icon { font-size: 14px; opacity: 0; transition: opacity 0.2s; }
  .tranche-card.paid { background: #2c2c2c; border-color: #1a1a1a; }
  .tranche-card.paid .amount, .tranche-card.paid .label, .tranche-card.paid .check-icon { color: white; }
  .tranche-card.paid .tranche-amount-input { color: white; border-color: rgba(255,255,255,0.42); background: rgba(255,255,255,0.1); }
  .tranche-card.paid .check-icon { opacity: 1; }
  .tranche-card.paid .deadline-input { color: white; border-color: rgba(255,255,255,0.4); background: rgba(255,255,255,0.1); }
  .tranche-card .label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); }
  .deadline-input { height: 24px; font-size: 11px; padding: 0 4px; border: 0.5px solid var(--border-tertiary); border-radius: 4px; background: transparent; color: inherit; }
  .comment-history-item { padding: 8px 0; border-bottom: 0.5px solid var(--border-tertiary); }
  .comment-history-item:last-child { border-bottom: none; }

  .leads-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 4px;
    padding: 8px 4px 0;
  }
  .leads-table-toolbar__title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #3730a3;
  }
  .filters-btn--excel {
    background: var(--accent-light);
    border-color: rgba(99, 102, 241, 0.35);
    color: var(--accent-hover);
    font-weight: 600;
  }
  .filters-btn--excel:hover {
    background: #d9e6ff;
    border-color: rgba(99, 102, 241, 0.55);
  }
  .table-wrap {
  background: var(--bg-primary);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--border-radius-lg);
  overflow: visible;
  position: relative;
  box-shadow: var(--shadow-card);
  margin-top: 8px;
}
  .table-wrap #table-body {
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
    overflow-x: hidden;
  }
  .table-wrap::-webkit-scrollbar { width: 8px; }
  #table-body { max-height: 560px; overflow-y: auto; }
  #table-body .virtual-spacer { width: 100%; pointer-events: none; }
  #table-body .virtual-viewport { will-change: transform; contain: layout paint; }
  .auth-wrap {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
}
  .auth-card {
  width: 400px;
  max-width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--border-radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-lg);
}
  .auth-card h2 { margin: 0 0 12px; font-size: 20px; }
  .auth-card .hint { margin: 0 0 14px; font-size: 12px; color: var(--text-secondary); }
  .auth-row { margin-bottom: 10px; }
  .auth-row input { width: 100%; height: 36px; padding: 0 10px; font-size: 13px; }
  .auth-error { min-height: 18px; color: #b53939; font-size: 12px; margin-bottom: 8px; }
  .admin-list-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 9px 11px; border: 1px solid var(--border-tertiary); border-radius: 10px; margin-bottom: 7px; }
  .admin-list-item:last-child { margin-bottom: 0; }
  .user-toolbar { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--text-secondary); background:var(--bg-primary); border:1px solid var(--border-tertiary); border-radius:12px; padding:7px 9px; box-shadow: 0 6px 16px rgba(22, 32, 50, 0.06); }
  .user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  height: 30px;
  border-radius: 8px;
  background: var(--bg-secondary);
  font-size: 11px;
  color: var(--text-secondary);
}
  .toolbar-btn { height:30px; padding:0 12px; border-radius:8px; border:1px solid var(--border-tertiary); background:var(--bg-primary); color:var(--text-secondary); font-size:12px; cursor:pointer; display:inline-flex; align-items:center; gap:6px; transition:all .15s ease; }
  .toolbar-btn:hover { background:var(--bg-secondary); transform:translateY(-1px); }
  .toolbar-btn.logout { background:#ffe9e9; border-color:#f9caca; color:#9f2b2b; font-weight:600; }
  .toolbar-btn.logout:hover { background:#ffdede; }
  .fun-bank-chip {
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    border-radius: 10px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    background: var(--accent-light);
    color: var(--accent-hover);
    font-size: 12px;
    font-weight: 700;
    padding: 0 10px;
    margin-bottom: 8px;
  }
  .fun-bank-chip small {
    opacity: 0.8;
    margin-left: 6px;
    font-weight: 600;
  }
  .fun-sticker-pack {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 10px;
    background: #fff;
  }
  .fun-sticker-chip {
    height: 30px;
    border-radius: 8px;
    border: 1px solid rgba(99, 102, 241, 0.18);
    background-color: var(--bg-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  .fun-sticker-chip img,
  .fun-sticker-chip video {
    width: 26px;
    height: 26px;
    object-fit: contain;
    display: block;
  }
  .fun-cat-floating {
    position: fixed;
    z-index: 700;
    min-width: auto;
    height: auto;
    border-radius: 0;
    border: none;
    background: transparent;
    color: #7a4b00;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: none;
    animation: funCatBounce 1.2s ease-in-out infinite;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0;
  }
  .fun-cat-floating.gold {
    color: #6b3c00;
  }
  .fun-challenge-line {
    margin: 0 0 10px;
    border: 1px dashed rgba(99, 102, 241, 0.35);
    border-radius: 10px;
    background: var(--bg-secondary);
    color: #335187;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
  }
  .fun-cat-floating:hover { transform: scale(1.04); }
  .fun-cat-sticker-frame {
    width: auto;
    height: auto;
    border-radius: 0;
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: none;
  }
  .fun-cat-icon {
    width: 86px;
    height: 86px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 6px 10px rgba(0,0,0,0.35));
  }
  .fun-cat-reward {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: #f7b931;
    line-height: 1;
    text-shadow: 0 2px 6px rgba(0,0,0,0.42);
  }
  .meme-shop-wrap {
    margin-bottom: 12px;
    background: var(--bg-secondary);
  }
  .meme-shop-wrap .analytics-section-toggle span {
    font-weight: 700;
    color: #1f3c79;
  }
  .meme-shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
  }
  .meme-shop-card {
    text-align: left;
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: 12px;
    background: var(--bg-primary);
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-height: 106px;
    cursor: pointer;
    white-space: normal;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  }
  .meme-shop-card:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(99, 102, 241, 0.45);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.16);
  }
  .meme-shop-card:disabled {
    opacity: 0.62;
    filter: grayscale(0.15);
    cursor: not-allowed;
    box-shadow: none;
  }
  .meme-shop-title { font-weight: 700; color: #1f3c79; font-size: 13px; line-height: 1.2; }
  .meme-shop-desc { color: #5b6f95; font-size: 12px; line-height: 1.3; min-height: 32px; }
  .meme-shop-price {
    margin-top: auto;
    color: #0d6b3c;
    font-size: 12px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eaf8ef;
    border: 1px solid #c9ecd7;
  }
  .meme-shop-card--mega {
    border-color: rgba(255, 140, 0, 0.5);
    background: linear-gradient(180deg, #fff9ef 0%, #fff2db 100%);
    box-shadow: 0 8px 18px rgba(255, 163, 51, 0.18);
  }
  .meme-shop-title--mega {
    background: linear-gradient(90deg, #ff7a00 0%, #ff2d95 35%, #7c4dff 70%, #00b3ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: megaPrizeShine 2.4s linear infinite;
    background-size: 220% 220%;
    font-weight: 800;
  }
  @keyframes megaPrizeShine {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
  }
  @keyframes funCatBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
  }
  #crm-root:not(.crm-app) { position: relative; display: flex; flex-direction: column; gap: 34px; }
  #crm-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  width: 100%;
  min-height: calc(100vh - 56px);
  background: var(--content-bg);
  border-radius: var(--border-radius-xl);
  overflow: hidden;
  border: 1px solid var(--border-tertiary);
  box-shadow: var(--shadow-lg);
}
  #crm-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: calc(100vh - 56px);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}
  .sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 16px;
}
  .sidebar-brand i { font-size: 18px; color: var(--text-secondary); }
  .sidebar-user {
  width: 100%;
  justify-content: flex-start;
  background: var(--sidebar-hover);
  border: 1px solid var(--sidebar-border);
  color: var(--sidebar-text-active);
  border-radius: var(--border-radius-md);
  height: 36px;
  padding: 0 10px;
}
  .sidebar-actions { display: grid; gap: 8px; }
  .sidebar-btn { width: 100%; justify-content: center; }
  .sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 4px;
  border-top: none;
}
  .side-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 10px;
  border-radius: var(--border-radius-md);
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
  .side-nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  border-color: var(--sidebar-border);
  transform: none;
}
  .side-nav-link.is-active {
  background: var(--sidebar-active);
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.3);
  font-weight: 600;
}
  #crm-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  min-width: 0;
  padding: 24px 28px 32px;
  background: var(--content-bg);
}
  #crm-root::before { display: none; }
  #crm-root > * { position: relative; z-index: 1; margin-bottom: 0 !important; }
  #crm-main-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    align-items: start;
    width: 100%;
    min-width: 0;
  }
  body.crm-view-stats #admin-stats-wrap {
  background: var(--bg-primary);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
  body.crm-view-stats.analytics-performance-mode #crm-main-layout,
  body.crm-view-stats #crm-main-layout {
    grid-template-columns: 1fr !important;
  }
  #crm-shell > #crm-content {
    min-width: 0;
    width: 100%;
  }
  #crm-content > .table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  #crm-right-pane {
    display: flex;
    flex-direction: column;
    gap: 28px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  #crm-kpi-grid { gap: 22px !important; }
  #crm-calendly-block {
  border: 1px solid var(--border-tertiary) !important;
  border-radius: var(--border-radius-lg) !important;
  background: var(--bg-primary) !important;
  box-shadow: var(--shadow-card) !important;
  padding: 16px 18px !important;
}

  /* —— Панель фильтров —— */
  .filters-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-card);
}
  .filters-panel__main {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 12px;
  }
  .filters-panel__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }
  .filters-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.12s;
    white-space: nowrap;
  }
  .filters-btn i { font-size: 16px; }
  .filters-btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
  .filters-btn--primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
  }
  .filters-btn--ghost {
    background: #fff;
    color: var(--text-secondary);
    border-color: var(--border-tertiary);
  }
  .filters-btn--ghost:hover {
    border-color: rgba(99, 102, 241, 0.35);
    color: var(--accent);
  }
  .filters-panel__search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 220px;
    min-width: 200px;
  }
  .filters-search-icon,
  #search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    color: var(--text-secondary);
    pointer-events: none;
    transition: color 0.2s;
  }
  .filters-panel__search input {
    width: 100%;
    height: 40px;
    padding: 0 12px 0 38px;
    border: 1px solid var(--border-tertiary);
    border-radius: 10px;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: #fff;
    box-shadow: inset 0 1px 2px rgba(17, 24, 39, 0.04);
  }
  .filters-panel__search input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.55);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
  }
  .filters-panel__manager {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 1 200px;
    min-width: 160px;
  }
  .filters-field-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
  }
  .filters-panel__manager select {
    height: 40px;
    padding: 0 10px;
    border: 1px solid var(--border-tertiary);
    border-radius: 10px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
  }
  .filters-panel__period {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid rgba(99, 102, 241, 0.12);
  }
  .period-picker {
    flex: 1 1 280px;
    min-width: 0;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--border-tertiary);
    border-radius: 12px;
  }
  .period-picker__head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    color: #3d5080;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .period-picker__head i {
    font-size: 15px;
    color: var(--accent);
  }
  .period-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
  }
  .period-preset-btn {
    height: 26px;
    padding: 0 10px;
    border: 1px solid var(--border-tertiary);
    border-radius: 999px;
    background: #fff;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
  }
  .period-preset-btn:hover {
    border-color: rgba(99, 102, 241, 0.45);
    color: var(--accent);
    background: var(--bg-secondary);
  }
  .period-preset-btn.is-active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  }
  .period-picker__fields {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  .period-field {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 130px;
    min-width: 0;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
  }
  .period-field:hover,
  .period-field:focus-within {
    border-color: rgba(99, 102, 241, 0.45);
    background: var(--accent-light);
  }
  .period-field__label {
    font-size: 11px;
    font-weight: 700;
    color: #6b7fa8;
    flex-shrink: 0;
    width: 1.2em;
  }
  .period-field input[type="date"] {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    color: #1f2937;
    padding: 0;
    height: 24px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    cursor: pointer;
  }
  .period-field input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
  }
  .period-field {
    position: relative;
  }
  .period-field__sep {
    color: var(--text-tertiary);
    font-size: 14px;
    flex-shrink: 0;
    user-select: none;
  }
  .period-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-tertiary);
    border-radius: 10px;
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }
  .period-clear:hover {
    background: #fff0f0;
    border-color: #f5b8b8;
    color: #c53030;
  }
  .period-clear[hidden] { display: none !important; }
  .period-summary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 140px;
  padding: 10px 16px;
  background: var(--accent);
  border-radius: var(--border-radius-md);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
  .period-summary[hidden] { display: none !important; }
  .period-summary__count {
    display: flex;
    align-items: baseline;
    gap: 6px;
  }
  .period-summary__num {
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
  }
  .period-summary__word {
    font-size: 13px;
    font-weight: 500;
    opacity: 0.92;
  }
  .period-summary__range {
    font-size: 11px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
  }
  .filters-feedback {
    font-size: 12px;
    min-height: 0;
    color: var(--text-secondary);
    padding: 0 2px;
    line-height: 1.5;
  }
  .filters-feedback:empty { display: none; }
  #admin-stats-wrap {
    background: var(--bg-primary);
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: var(--border-radius-lg);
    padding: 20px;
  }
  .admin-stats-tabs {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    background: var(--accent-light);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 4px;
  }
  .admin-tab-btn {
    height: 30px;
    border: none;
    border-radius: 8px;
    padding: 0 12px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
  }
  .admin-tab-btn.active {
    background: #ffffff;
    color: #312e81;
    box-shadow: 0 6px 14px rgba(99, 102, 241, 0.16);
  }
  .analytics-global-toolbar {
    margin: 0 0 8px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: start;
    padding: 10px 12px;
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: 12px;
    background: var(--bg-secondary);
  }
  .analytics-global-toolbar__label {
    font-size: 11px;
    font-weight: 700;
    color: #395184;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .period-presets--compact {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .period-presets--compact .period-preset-btn {
    white-space: nowrap;
    height: 24px;
    padding: 0 9px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .analytics-global-toolbar__dates {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    gap: 8px;
    width: 100%;
  }
  .analytics-date-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 8px;
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: 9px;
    background: #fff;
  }
  .analytics-date-field span {
    font-size: 11px;
    color: #6b7fa8;
    font-weight: 700;
  }
  .analytics-date-field input[type="date"] {
    border: none;
    background: transparent;
    font-size: 12px;
    color: #1f2937;
    height: 22px;
    min-width: 118px;
    padding: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  }
  .analytics-date-field input[type="date"]:focus {
    outline: none;
  }
  @media (max-width: 900px) {
    .analytics-global-toolbar__label { margin-bottom: 2px; }
  }
  @media (max-width: 560px) {
    .analytics-global-toolbar {
      padding: 9px 10px;
    }
    .period-presets--compact {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 6px;
      width: 100%;
    }
    .period-presets--compact .period-preset-btn {
      width: 100%;
      justify-content: center;
      padding: 0 6px;
      font-size: 10px;
    }
    .analytics-global-toolbar__dates {
      display: grid;
      grid-template-columns: 1fr;
      width: 100%;
    }
    .analytics-date-field {
      width: 100%;
      justify-content: space-between;
      height: 30px;
    }
    .analytics-date-field input[type="date"] {
      min-width: 0;
      width: 100%;
      text-align: right;
    }
  }
  #admin-panel-overview { display: block; }
  .crm-donut-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
  }
  .crm-donut {
    --p1: 0deg;
    --p2: 0deg;
    --p3: 0deg;
    width: 122px;
    height: 122px;
    border-radius: 50%;
    background:
      conic-gradient(
        #1f7cff 0deg var(--p1),
        #27c281 var(--p1) var(--p2),
        #f6a623 var(--p2) var(--p3),
        #d6deef var(--p3) 360deg
      );
    position: relative;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), 0 10px 20px rgba(38, 67, 147, 0.16);
    flex-shrink: 0;
  }
  .crm-donut::after {
    content: "";
    position: absolute;
    inset: 17px;
    border-radius: 50%;
    background: #ffffff;
  }
  .crm-donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    pointer-events: none;
  }
  .crm-donut-center .total {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    color: #1e1b4b;
  }
  .crm-donut-center .caption {
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  .crm-donut-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
  }
  .crm-donut-legend .item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
  }
  .crm-donut-legend .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .crm-donut-legend .name {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
  }
  .crm-donut-legend .val {
    color: #1e1b4b;
    font-weight: 600;
  }
  .stat-mini-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 14px;
  }
  .stat-mini-card {
    background: var(--bg-primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--border-radius-md);
    padding: 12px;
  }
  .stat-mini-card .label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
  }
  .stat-mini-card .value {
    font-size: 20px;
    font-weight: 650;
    color: #1e1b4b;
    line-height: 1.1;
  }
  .analytics-scope-hint {
    margin: 0 0 12px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--accent-light);
    border: 1px solid rgba(99, 102, 241, 0.25);
    font-size: 12px;
    color: #4338ca;
    line-height: 1.4;
  }
  .analytics-scope-hint strong { color: #312e81; }
  .analytics-kpi-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
  }
  .analytics-kpi-row--wide {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    margin-bottom: 18px;
  }
  .analytics-kpi {
    background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: 12px;
    padding: 12px;
  }
  .analytics-kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: #1e1b4b;
    line-height: 1.1;
  }
  .analytics-kpi-label {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #2a457f;
  }
  .analytics-kpi-hint {
    margin-top: 2px;
    font-size: 10px;
    color: var(--text-tertiary);
    line-height: 1.3;
  }
  .analytics-section { margin-bottom: 14px; }
  .analytics-collapsible .analytics-section-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    color: #1e1b4b;
    line-height: 1.3;
  }
  .analytics-collapsible .analytics-section-toggle:hover {
    color: var(--accent);
  }
  .analytics-collapsible .analytics-chevron {
    font-size: 16px;
    color: #5b7fd6;
    transition: transform 0.2s ease;
    flex-shrink: 0;
  }
  .analytics-collapsible.is-open .analytics-chevron {
    transform: rotate(90deg);
  }
  .analytics-collapsible:not(.is-open) .analytics-section-body {
    display: none;
  }
  .analytics-collapsible.is-open .analytics-section-body {
    display: block;
    margin-top: 10px;
    padding-top: 2px;
  }
  .analytics-section--card.analytics-collapsible .analytics-section-toggle {
    padding: 0;
  }
  .analytics-section--card.analytics-collapsible.is-open .analytics-section-body {
    border-top: 1px solid rgba(99, 102, 241, 0.15);
    padding-top: 10px;
    margin-top: 8px;
  }
  .analytics-section--card {
    padding: 12px 14px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    background: #fff;
  }
  .analytics-section--warn {
    background: #fffaf5;
    border-color: rgba(242, 164, 39, 0.35);
  }
  .analytics-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e1b4b;
    margin-bottom: 4px;
  }
  .analytics-section-desc {
    margin: 0 0 10px;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
  }
  .analytics-inline-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 8px;
  }
  .analytics-chip-btn {
    height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    border: 1px solid var(--border-tertiary);
    background: #fff;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
  }
  .analytics-chip-btn:hover {
    border-color: rgba(99, 102, 241,.45);
    color: var(--accent);
    background: var(--bg-secondary);
  }
  .analytics-chip-btn.is-active {
    border-color: var(--accent);
    color: #fff;
    background: var(--accent);
    box-shadow: 0 3px 10px rgba(99, 102, 241,.24);
  }
  .analytics-plain-summary {
    font-size: 12px;
    color: #4338ca;
    line-height: 1.55;
  }
  .analytics-plain-summary p { margin: 0 0 6px; }
  .analytics-highlight-line {
    font-size: 13px;
    font-weight: 600;
    color: #8d5d11;
    margin-bottom: 8px;
  }
  .analytics-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
  }
  .analytics-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }
  .analytics-data-table th,
  .analytics-data-table td {
    padding: 7px 8px;
    text-align: left;
    border-bottom: 1px solid #e8eeff;
  }
  .analytics-data-table th {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    font-weight: 600;
  }
  .analytics-data-table tr:last-child td { border-bottom: none; }
  .analytics-data-table .num {
    text-align: right;
    font-weight: 600;
    color: #1e1b4b;
    white-space: nowrap;
  }
  .analytics-status-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
  }
  .analytics-status-row .track {
    grid-column: 1 / -1;
    height: 6px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    overflow: hidden;
  }
  .analytics-status-row .fill {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
  }
  .funnel-step {
    margin-bottom: 10px;
  }
  .funnel-step-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 12px;
    margin-bottom: 4px;
  }
  .funnel-step-head .label { font-weight: 600; color: #1e1b4b; }
  .funnel-step-head .nums { color: #4f46e5; font-weight: 600; white-space: nowrap; }
  .funnel-step .hint { font-size: 10px; color: var(--text-tertiary); margin-bottom: 4px; }
  #advanced-analytics-wrap {
    margin-top: 16px !important;
    border-top: 1px solid var(--border-tertiary) !important;
    padding-top: 14px !important;
    max-height: none;
    overflow: visible;
    padding-right: 0;
    contain: layout paint style;
  }
  #phone-citizenship-stats {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  content-visibility: auto;
  contain-intrinsic-size: 460px;
  }
  .analytics-card {
    padding: 12px 13px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    background: var(--bg-primary);
  }
  .analytics-card-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e1b4b;
    margin-bottom: 4px;
  }
  .analytics-card-title span { color: #4f46e5; }
  .analytics-note {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 11px;
    color: var(--text-secondary);
  }
  .analytics-note-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--border-tertiary);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 11px;
  }
  .status-country-breakdown-wrap {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed rgba(99, 102, 241, 0.25);
  }
  .status-country-grid {
    display: grid;
    gap: 10px;
  }
  .status-country-block {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.18);
    background: linear-gradient(180deg, #fff 0%, var(--st-bg, var(--bg-secondary)) 100%);
  }
  .status-country-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
  }
  .status-country-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--st-fg, #1e1b4b);
  }
  .status-country-total {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
  }
  .status-country-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .status-country-chips .analytics-note-chip strong {
    font-weight: 700;
    color: var(--st-fg, #1e1b4b);
  }
  .status-country-chips .status-country-others {
    border-style: dashed;
    color: var(--text-secondary);
  }
  .status-country-chips .status-country-others strong {
    color: var(--text-primary);
  }
  .analytics-geo-rank-wrap {
    margin-top: 12px;
  }
  .analytics-geo-bars-wrap {
    margin-bottom: 4px;
  }
  .analytics-geo-rank-table .geo-rank-pos {
    color: var(--text-tertiary);
    font-weight: 600;
    width: 36px;
  }
  .analytics-geo-rank-table tbody tr:nth-child(1) .geo-rank-pos,
  .analytics-geo-rank-table tbody tr:nth-child(2) .geo-rank-pos,
  .analytics-geo-rank-table tbody tr:nth-child(3) .geo-rank-pos {
    color: var(--accent);
    font-weight: 700;
  }
  .analytics-geo-more {
    margin: 8px 0 0;
    font-size: 11px;
    color: var(--text-secondary);
  }
  .geo-unknown-note {
    margin-top: 10px;
  }
  .admin-geo-leads-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  .geo-leads-toolbar {
    margin-bottom: 0;
  }
  .geo-leads-search-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }
  .geo-leads-search-row input {
    flex: 1 1 220px;
    min-width: 180px;
    height: 38px;
    padding: 0 12px 0 36px;
    font-size: 14px;
  }
  .geo-leads-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
    font-size: 16px;
    z-index: 1;
  }
  .geo-leads-toolbar__search {
    flex: 1 1 100%;
  }
  .geo-country-chips-label {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
  }
  .geo-country-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 2px 6px;
    margin-bottom: 4px;
  }
  .geo-country-chip {
    cursor: pointer;
  }
  .geo-country-chip--more {
    border-style: dashed;
    color: #3a5fbf;
    background: var(--bg-secondary);
    font-weight: 600;
  }
  .geo-country-chip--more:hover {
    background: var(--accent-light);
  }
  .geo-country-chip.is-active {
    background: #dce8ff;
    border-color: rgba(99, 102, 241, 0.55);
    color: var(--accent-hover);
    font-weight: 600;
  }
  .geo-leads-count-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
  }
  .geo-leads-count {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #2a4a8f;
  }
  .geo-leads-table-wrap {
    margin-top: 0;
  }
  .geo-leads-table-wrap .table-head,
  .geo-leads-table-wrap .geo-leads-row {
    grid-template-columns: 130px 118px 120px minmax(0, 1fr) 92px 108px;
  }
  .geo-lead-country {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
  }
  .geo-lead-comment {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
  .geo-leads-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
  }
  .geo-leads-more-wrap {
    padding: 10px 14px;
    text-align: center;
    border-top: 1px solid var(--border-tertiary);
  }
  #geo-leads-table-body {
    max-height: min(70vh, 720px);
    overflow-y: auto;
  }
  .side-nav-link--admin {
    display: none;
  }
  body.crm-role-admin .side-nav-link--admin {
    display: inline-flex;
  }
  .analytics-card-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
  }
  .analytics-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 4px;
  }
  .analytics-list li,
  .analytics-ol li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: #1e1b4b;
    line-height: 1.3;
  }
  .analytics-list .name,
  .analytics-ol .name {
    color: #243b74;
    min-width: 0;
  }
  .analytics-list .meta,
  .analytics-ol .meta {
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
  }
  .analytics-ol {
    margin: 0;
    padding-left: 16px;
    display: grid;
    gap: 4px;
  }
  .analytics-empty {
    font-size: 12px;
    color: var(--text-secondary);
  }
  #analytics-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 10px;
    margin-bottom: 10px;
  }
  .analytics-chart-card {
    background: var(--bg-primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
  }
  .analytics-funnel-card { grid-column: 1 / -1; }
  .analytics-daily-card { grid-column: 1 / -1; }
  .chart-title {
    font-size: 12px;
    font-weight: 700;
    color: #1b376f;
    margin-bottom: 8px;
  }
  .analytics-subtitle {
    margin: 4px 0 8px;
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
  }
.analytics-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.analytics-summary-line {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 10px;
}
  .bar-chart-row {
    display: grid;
    grid-template-columns: 88px 1fr auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 11px;
  }
  .bar-chart-track {
    height: 7px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    overflow: hidden;
  }
  .bar-chart-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
  }
  .status-donut-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .status-donut {
    --seg1: 25%;
    --seg2: 25%;
    --seg3: 25%;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: conic-gradient(
      var(--accent) 0 var(--seg1),
      #27c281 var(--seg1) calc(var(--seg1) + var(--seg2)),
      #f6a623 calc(var(--seg1) + var(--seg2)) calc(var(--seg1) + var(--seg2) + var(--seg3)),
      #dfe7fb calc(var(--seg1) + var(--seg2) + var(--seg3)) 100%
    );
    position: relative;
    flex-shrink: 0;
  }
  .status-donut::after {
    content: "";
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    background: #fff;
  }
  .status-legend {
    display: grid;
    gap: 4px;
    font-size: 11px;
  }
  .status-legend .item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
  }
  .status-legend .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .funnel-row {
    margin-bottom: 8px;
    display: grid;
    gap: 3px;
    font-size: 11px;
    color: var(--text-secondary);
  }
  .funnel-row:last-child { margin-bottom: 0; }
  .funnel-bar {
    height: 8px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    overflow: hidden;
  }
  .funnel-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
  }
  .daily-cols-wrap {
    height: 140px;
    display: grid;
    grid-template-columns: repeat(14, minmax(0,1fr));
    gap: 6px;
    align-items: end;
  }
  .daily-col {
    display: grid;
    gap: 3px;
    align-content: end;
    justify-items: center;
  }
  .daily-col-track {
    width: 100%;
    height: 84px;
    background: var(--accent-light);
    border-radius: 8px;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
  }
  .daily-col-fill {
    width: 100%;
    background: var(--accent);
    border-radius: 8px;
    min-height: 4px;
  }
  .daily-col-value {
    font-size: 10px;
    color: #4f46e5;
    line-height: 1;
    min-height: 10px;
  }
  .daily-col-label {
    font-size: 10px;
    color: var(--text-tertiary);
    line-height: 1;
    min-height: 10px;
  }
  #admin-stats-wrap.advanced-mode {
    background: var(--bg-primary);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 16px 30px rgba(47, 76, 161, 0.14);
    padding: 22px;
  }
  body.analytics-performance-mode::before,
  body.analytics-performance-mode::after,
  body.analytics-performance-mode > .bg-mesh,
  body.crm-lite-mode::before,
  body.crm-lite-mode::after,
  body.crm-lite-mode > .bg-mesh {
    display: none !important;
  }
  body.crm-lite-mode {
  background: var(--content-bg) !important;
  background-size: auto !important;
}
  body.crm-role-manager #crm-main-layout {
    grid-template-columns: 1fr !important;
  }
  body.crm-role-manager #crm-right-pane {
    grid-column: 1 / -1;
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  body.crm-role-manager #crm-content {
    min-width: 0;
    max-width: 100%;
  }
  body.crm-lite-mode .table-wrap,
  body.crm-lite-mode #crm-topbar,
  body.crm-lite-mode #crm-kpi-grid > div,
  body.crm-lite-mode .analytics-section--card {
    box-shadow: 0 4px 12px rgba(27, 39, 62, 0.06) !important;
  }
  body.crm-lite-mode .fun-cat-floating,
  body.crm-lite-mode .mega-prize-banner {
    animation: none !important;
  }
  body.crm-lite-mode .toolbar-btn:hover {
    transform: none;
  }
  body.crm-lite-mode .row {
    transition: none;
  }
  body.crm-lite-mode .analytics-collapsible:not(.is-open) .analytics-section-body {
    content-visibility: hidden;
    contain-intrinsic-size: 0 120px;
  }
  .lite-mode-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 6px 0;
  padding: 8px 10px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--sidebar-border);
  background: var(--sidebar-hover);
  font-size: 11px;
  color: var(--sidebar-text);
  cursor: pointer;
  user-select: none;
}
  .lite-mode-toggle input { accent-color: var(--accent); }
  .lite-mode-hint {
    display: block;
    margin: 2px 14px 0;
    font-size: 10px;
    color: var(--text-tertiary);
    min-height: 14px;
  }
  body.analytics-performance-mode #admin-stats-wrap.advanced-mode,
  body.analytics-performance-mode #admin-stats-wrap.advanced-mode .analytics-chart-card,
  body.analytics-performance-mode #admin-stats-wrap.advanced-mode .analytics-card {
    box-shadow: none !important;
  }
  body.analytics-performance-mode #admin-stats-wrap.advanced-mode #analytics-charts-grid,
  body.analytics-performance-mode #admin-stats-wrap.advanced-mode .daily-cols-wrap,
  body.analytics-performance-mode #admin-stats-wrap.advanced-mode .status-donut-wrap,
  body.analytics-performance-mode #admin-stats-wrap.advanced-mode #phone-citizenship-stats {
    contain: layout paint;
  }
  #admin-stats-wrap.advanced-mode .admin-stats-tabs {
    margin-bottom: 14px;
  }
  #admin-stats-wrap.advanced-mode .chart-title {
    font-size: 14px;
    margin-bottom: 10px;
  }
  #admin-stats-wrap.advanced-mode #analytics-charts-grid {
    gap: 14px;
    margin-bottom: 14px;
  }
  #admin-stats-wrap.advanced-mode .analytics-chart-card {
    border-radius: 14px;
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
    padding: 12px 14px;
  }
  #admin-stats-wrap.advanced-mode .bar-chart-row {
    grid-template-columns: 120px 1fr auto;
    font-size: 12px;
  }
  #admin-stats-wrap.advanced-mode .bar-chart-track,
  #admin-stats-wrap.advanced-mode .funnel-bar {
    height: 9px;
  }
  #admin-stats-wrap.advanced-mode .status-donut {
    width: 100px;
    height: 100px;
  }
  #admin-stats-wrap.advanced-mode .status-donut::after {
    inset: 15px;
  }
  #admin-stats-wrap.advanced-mode .status-legend {
    font-size: 12px;
    gap: 6px;
  }
  #admin-stats-wrap.advanced-mode .daily-cols-wrap {
    height: 160px;
    gap: 8px;
  }
  #admin-stats-wrap.advanced-mode .daily-col-track {
    height: 98px;
  }
  #admin-stats-wrap.advanced-mode .daily-col-value,
  #admin-stats-wrap.advanced-mode .daily-col-label {
    font-size: 11px;
  }
  #admin-stats-wrap.advanced-mode .analytics-subtitle {
    font-size: 12px;
    margin: 8px 0 10px;
  }
  #admin-stats-wrap.advanced-mode .analytics-card {
    border-radius: 14px;
    padding: 13px 14px;
  }
  #admin-stats-wrap.advanced-mode .analytics-card-title {
    font-size: 14px;
  }
  #admin-stats-wrap.advanced-mode .analytics-list li,
  #admin-stats-wrap.advanced-mode .analytics-ol li {
    font-size: 13px;
  }
  #admin-stats-wrap.advanced-mode #invalid-total-line,
  #admin-stats-wrap.advanced-mode #call-stage-line {
    font-size: 14px !important;
    line-height: 1.45;
    color: #4338ca !important;
    font-weight: 500;
    letter-spacing: 0.01em;
  }
  #admin-stats-wrap.advanced-mode #invalid-breakdown {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(99, 102, 241, 0.25);
  }
  #admin-stats-wrap.advanced-mode #invalid-breakdown .analytics-ol {
    gap: 8px;
    padding-left: 18px;
  }
  #admin-stats-wrap.advanced-mode #invalid-breakdown .analytics-ol li {
    font-size: 14px;
    line-height: 1.4;
    align-items: center;
  }
  #admin-stats-wrap.advanced-mode #invalid-breakdown .analytics-ol .name {
    color: #1b376f;
    font-weight: 500;
  }
  #admin-stats-wrap.advanced-mode #invalid-breakdown .analytics-ol .meta {
    color: #4d6fb2;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }
  #crm-topbar {
    background: var(--bg-primary);
    border: 1px solid var(--border-tertiary);
    border-radius: var(--border-radius-lg);
    padding: 15px 18px;
  }
  #crm-calendly-block {
    border: 1px solid var(--border-tertiary) !important;
    border-radius: var(--border-radius-lg) !important;
    background: var(--bg-primary) !important;
    box-shadow: var(--shadow-card) !important;
  }
  #cal-api-btn, #cal-refresh-btn {
    border-radius: var(--border-radius-md) !important;
    border: 1px solid var(--border-tertiary) !important;
    box-shadow: none;
    transition: background var(--transition), border-color var(--transition);
  }
  #cal-api-btn:hover, #cal-refresh-btn:hover {
    transform: none;
    box-shadow: none;
    background: var(--bg-secondary);
  }
  #crm-filters-bar.filters-panel {
    border-radius: 20px !important;
    padding: 16px !important;
  }
  #reset-filters {
    border-radius: 12px !important;
    font-weight: 600;
  }
  .row:hover {
    background: var(--accent-light);
  }
  #add-btn {
  background: var(--accent) !important;
  box-shadow: var(--shadow-sm) !important;
}
  #add-btn:hover { filter: brightness(1.04); transform: translateY(-1px); }
  #login-btn {
  background: var(--accent) !important;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3) !important;
}
  #status-header-btn, #manager-filter, #reset-filters, #cal-api-btn, #cal-refresh-btn {
    transition: all .15s ease;
  }
  #status-header-btn:hover, #manager-filter:hover, #reset-filters:hover, #cal-api-btn:hover, #cal-refresh-btn:hover {
    transform: translateY(-1px);
  }
  .modal-card {
    background: var(--bg-primary);
  }
  @media (max-width: 980px) {
    body { padding: 16px 0 20px; }
    .container { padding: 0 12px; }
    #crm-shell { grid-template-columns: 1fr; }
    #crm-sidebar { position: static; }
    #crm-main-layout { grid-template-columns: 1fr !important; }
    #crm-root { gap: 22px; }
    #crm-right-pane { gap: 18px; }
    .crm-donut-wrap { flex-direction: column; align-items: flex-start; }
    .stat-mini-grid, #crm-kpi-grid, .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    #analytics-charts-grid { grid-template-columns: 1fr; }
    .analytics-two-col { grid-template-columns: 1fr; }
    .analytics-kpi-row--wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters-panel__main { flex-direction: column; align-items: stretch; }
    .filters-panel__actions { width: 100%; }
    .filters-panel__actions .filters-btn { flex: 1; }
    .filters-panel__search,
    .filters-panel__manager { flex: 1 1 100%; min-width: 0; }
    .filters-panel__period { flex-direction: column; }
    .period-summary { width: 100%; max-width: none; }
    .period-summary__range { max-width: none; }
    .row, .table-wrap > div:first-child { grid-template-columns: 1.2fr .9fr 1.5fr .9fr 1.1fr !important; }
  }

/* ── Modal utilities ── */
.modal-card--wide { width: 560px; max-width: 100%; }
.modal-card--medium { width: 500px; max-width: 100%; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.modal-header__title { font-weight: 600; font-size: 15px; color: var(--text-primary); }
.modal-header__phone { font-weight: 700; font-size: 15px; font-family: var(--font-mono); color: var(--text-primary); }
.modal-header__name {
  border: none;
  background: transparent;
  font-size: 14px;
  width: 100%;
  color: var(--text-secondary);
  padding: 2px 0;
}
.modal-header__name:focus { outline: none; color: var(--text-primary); }
.modal-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-tertiary);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-sm);
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--bg-secondary); color: var(--text-primary); }
.modal-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-grid-span { grid-column: 1 / -1; }
.modal-tranches-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.modal-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-tertiary);
  background: var(--bg-primary);
  color: var(--text-secondary);
  transition: all var(--transition);
}
.modal-btn:hover { border-color: var(--border-secondary); color: var(--text-primary); }
.modal-btn--save {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.modal-btn--save:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.modal-btn--delete {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}
.modal-btn--delete:hover { background: #fee2e2; }
.modal-btn--secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.comment-textarea {
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid var(--border-tertiary);
  border-radius: var(--border-radius-md);
  font-size: 13px;
  resize: vertical;
}
.comment-list { margin-top: 12px; font-size: 13px; }
.comment-item { margin-bottom: 8px; line-height: 1.45; }
.comment-item__date { color: var(--text-tertiary); font-size: 11px; font-family: var(--font-mono); margin-right: 6px; }
.admin-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.admin-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
}
.admin-error { min-height: 18px; font-size: 12px; color: #b91c1c; margin-top: 8px; }
.admin-error--ok { color: #059669; }
.audit-log-box {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  background: #0f1117;
  color: #d1d5db;
  font-size: 11px;
  font-family: var(--font-mono);
  border-radius: var(--border-radius-md);
  line-height: 1.5;
}
.table-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}
.table-load-more-wrap {
  padding: 12px 16px;
  border-top: 1px solid var(--border-tertiary);
  text-align: center;
}
.cal-msg { font-size: 12px; padding: 8px 12px; border-radius: var(--border-radius-sm); }
.cal-msg--loading { color: var(--text-secondary); }
.cal-msg--empty { color: var(--text-tertiary); padding: 8px 0; }
.cal-msg--error { color: #92400e; background: #fffbeb; border: 1px solid #fde68a; }
.cal-card--api { background: #fffbeb; border-color: #fde68a; }
.cal-card__api-label { font-size: 11px; color: #92400e; font-weight: 600; }
.feedback--warn { color: #b45309; }
.feedback--ok { color: #047857; }
.feedback--new { color: var(--accent); }
.feedback--muted { color: var(--text-tertiary); }
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.status-option-label { text-transform: none; letter-spacing: 0; }
.admin-list-item__name { font-size: 13px; font-weight: 500; }
.admin-list-item__sub { color: var(--text-tertiary); font-weight: 400; }
.admin-list-item__login { font-size: 11px; color: var(--text-secondary); }
.admin-list-item__actions { display: flex; align-items: center; gap: 6px; }
.admin-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.admin-section-head .field-label { margin: 0; }
.modal-section--last { border-bottom: none; }
.admin-empty { font-size: 12px; color: var(--text-secondary); }

/* ── Sync banner ── */
.sync-banner {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--border-radius-md);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}
.sync-banner--ok {
  background: var(--accent-light);
  color: #3730a3;
  border-color: rgba(99, 102, 241, 0.25);
}
.sync-banner--error {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}
