/* ═══════════════════════════════════════════════════════════════════════
   AMO Hub v3.0 — Modern Dashboard Design System
   Ref: dark sidebar, green accents, warm light bg, modern cards
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Light theme (default) ──────────────────────────────────────────── */
:root {
    --bg:            #f6f7f3;
    --bg-card:       #ffffff;
    --bg-hover:      #eef3ef;
    --bg-sidebar:    #f2f4ef;
    --bg-topbar:     rgba(246,247,243,.92);
    --border:        #dfe5dd;
    --border-light:  #ebefea;
    --text:          #18212f;
    --text-secondary:#546072;
    --text-muted:    #8d98a9;
    --primary:       #9fdfb4;
    --primary-light: rgba(159,223,180,.28);
    --primary-hover: #87d3a1;
    --primary-glow:  rgba(159,223,180,.3);
    --success:       #3aa56d;
    --success-bg:    rgba(58,165,109,.1);
    --warning:       #d4a94f;
    --warning-bg:    rgba(212,169,79,.12);
    --danger:        #d95f5f;
    --danger-bg:     rgba(217,95,95,.1);
    --info:          #84a9f8;
    --info-bg:       rgba(132,169,248,.12);
    --accent:        #8091ff;
    --accent-bg:     rgba(128,145,255,.12);
    --radius:        20px;
    --radius-sm:     16px;
    --radius-xs:     12px;
    --shadow-xs:     0 1px 2px rgba(24,33,47,.03);
    --shadow-sm:     0 8px 24px rgba(24,33,47,.05);
    --shadow:        0 18px 50px rgba(24,33,47,.08);
    --shadow-lg:     0 28px 70px rgba(24,33,47,.14);
    --shadow-glow:   0 0 0 4px var(--primary-glow);
    --sidebar-w:     260px;
    --sidebar-w-collapsed: 72px;
    --topbar-h:      64px;
    --transition:    .2s cubic-bezier(.4,0,.2,1);
    --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    color-scheme: light;
}

/* ── Dark theme ─────────────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg:            #0f1117;
    --bg-card:       #1a1d27;
    --bg-hover:      #22263a;
    --bg-sidebar:    #0f1117;
    --bg-topbar:     rgba(26,29,39,.92);
    --border:        #2a2e3d;
    --border-light:  #1f2233;
    --text:          #f3f4f6;
    --text-secondary:#9ca3af;
    --text-muted:    #6b7280;
    --primary:       #4ade80;
    --primary-light: rgba(74,222,128,.1);
    --primary-hover: #22c55e;
    --primary-glow:  rgba(74,222,128,.2);
    --success:       #4ade80;
    --success-bg:    rgba(74,222,128,.1);
    --warning:       #fbbf24;
    --warning-bg:    rgba(251,191,36,.1);
    --danger:        #f87171;
    --danger-bg:     rgba(248,113,113,.1);
    --info:          #60a5fa;
    --info-bg:       rgba(96,165,250,.1);
    --accent:        #a78bfa;
    --accent-bg:     rgba(167,139,250,.1);
    --shadow-xs:     0 1px 2px rgba(0,0,0,.2);
    --shadow-sm:     0 1px 3px rgba(0,0,0,.25);
    --shadow:        0 4px 12px rgba(0,0,0,.3);
    --shadow-lg:     0 12px 40px rgba(0,0,0,.45);
    color-scheme: dark;
}

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--transition), color var(--transition);
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }

.ico {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: -0.2em;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.85;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ico-16 { width: 16px; height: 16px; }
.ico-18 { width: 18px; height: 18px; }
.ico-20 { width: 20px; height: 20px; }
.ico-24 { width: 24px; height: 24px; }

/* ═══════════════════════════════════════════════════════════════════════
   SIDEBAR — dark navy background
   ═══════════════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: width .25s cubic-bezier(.4,0,.2,1), min-width .25s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
    color: var(--text-secondary);
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(24,33,47,.08) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(24,33,47,.08); border-radius: 4px; }

.sidebar-brand {
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.sidebar-brand .logo {
    width: 42px; height: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(24,33,47,.08);
    background: #fff;
}
.sidebar-brand .logo img {
    width: 100%;
    height: 100%;
    display: block;
}
.brand-text { flex: 1; overflow: hidden; white-space: nowrap; }
.sidebar-brand h2 {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--text);
    background: none;
    -webkit-text-fill-color: var(--text);
    background-clip: unset;
    -webkit-background-clip: unset;
}
.version {
    font-size: .6rem;
    color: #9ca3af;
    background: rgba(255,255,255,.08);
    padding: 2px 7px;
    border-radius: 6px;
    font-weight: 600;
}
.sidebar-collapse-btn {
    background: #fff;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: all var(--transition);
    flex-shrink: 0;
    box-shadow: var(--shadow-xs);
}
.sidebar-collapse-btn:hover { background: var(--bg-hover); color: var(--text); }

.nav-section {
    padding: 18px 20px 8px;
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #99a1ae;
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-section-icon {
    font-size: 14px;
    flex-shrink: 0;
    opacity: .85;
}
.nav-list {
    list-style: none;
    padding: 2px 12px;
}
.nav-list li + li { margin-top: 1px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    text-decoration: none !important;
    font-size: .855rem;
    font-weight: 600;
    transition: all .18s ease;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}
.nav-link:hover {
    background: #ffffff;
    color: var(--text);
    box-shadow: var(--shadow-xs);
}
.nav-link.active {
    background: linear-gradient(180deg, #e9f0ff, #edf3ff);
    color: #4366b0;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(132,169,248,.2);
}
.nav-link.active .nav-icon { color: #4366b0; }
.nav-link.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: #4366b0;
    border-radius: 0 3px 3px 0;
}
.nav-icon {
    width: 20px;
    height: 20px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #8b97a9;
    transition: color var(--transition);
}
.nav-link:hover .nav-icon { color: var(--text); }
.nav-text { overflow: hidden; text-overflow: ellipsis; }

/* Sidebar footer */
.sidebar-footer {
    padding: 14px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255,255,255,.62);
}
.sidebar-account {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-xs);
    background: #ffffff;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.sidebar-account-icon {
    font-size: 16px;
    flex-shrink: 0;
    color: #22c55e;
}
.sidebar-account-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    background: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.sidebar-logout-btn:hover {
    background: rgba(239,68,68,.1);
    color: #ef4444;
    border-color: #ef4444;
}
.sidebar-login-btn {
    border-color: rgba(58,165,109,.25);
    color: var(--success);
}
.sidebar-login-btn:hover {
    background: var(--success-bg);
    color: var(--success);
}
.sidebar-logout-label { white-space: nowrap; }
.sidebar.collapsed .sidebar-account-name,
.sidebar.collapsed .sidebar-logout-label { display: none; }
.sidebar.collapsed .sidebar-account,
.sidebar.collapsed .sidebar-logout-btn { justify-content: center; padding: 10px; }

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: .82rem;
    font-family: var(--font);
    font-weight: 500;
    width: 100%;
    transition: all var(--transition);
    white-space: nowrap;
    overflow: hidden;
}
.theme-toggle:hover { border-color: var(--primary-hover); color: var(--text); background: var(--bg-hover); }
.toggle-icon { font-size: 18px; flex-shrink: 0; }

/* Collapsed sidebar */
.sidebar.collapsed {
    width: var(--sidebar-w-collapsed);
    min-width: var(--sidebar-w-collapsed);
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .toggle-label,
.sidebar.collapsed .version { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .sidebar-brand {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 12px 0;
    gap: 10px;
    width: 100%;
}
.sidebar.collapsed .sidebar-brand .logo { margin: 0; align-self: center; }
.sidebar.collapsed .sidebar-collapse-btn {
    background: rgba(255,255,255,.06);
    color: #22c55e;
    padding: 8px;
    border: 1px solid rgba(255,255,255,.08);
}
.sidebar.collapsed .sidebar-collapse-btn:hover {
    background: rgba(34,197,94,.1);
    color: #22c55e;
    border-color: rgba(34,197,94,.3);
}
.sidebar.collapsed .sidebar-collapse-btn .sidebar-collapse-icon { display: none !important; }
.sidebar.collapsed .sidebar-collapse-btn .sidebar-expand-icon { display: block !important; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-link::before { display: none; }
.sidebar.collapsed .theme-toggle { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-footer { padding: 12px 10px; }
.sidebar.collapsed .nav-list { padding: 2px 8px; }

.sidebar.collapsed .nav-link[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-sidebar);
    color: #e5e7eb;
    padding: 6px 12px;
    border-radius: var(--radius-xs);
    font-size: .8rem;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255,255,255,.1);
    z-index: 200;
    pointer-events: none;
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 90;
    backdrop-filter: blur(2px);
}

/* ═══════════════════════════════════════════════════════════════════════
   CONTENT AREA
   ═══════════════════════════════════════════════════════════════════════ */
.content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left .25s cubic-bezier(.4,0,.2,1);
}
.sidebar.collapsed ~ .content { margin-left: var(--sidebar-w-collapsed); }

.topbar {
    height: var(--topbar-h);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-topbar);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 50;
    transition: background var(--transition), border-color var(--transition);
}
.topbar-left { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.topbar h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -.02em;
    white-space: nowrap;
}
.topbar-center { flex: 1; display: flex; justify-content: center; min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Search bar in topbar */
.topbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,.8);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 10px 16px;
    width: 100%;
    max-width: 440px;
    color: var(--text-muted);
    font-size: .875rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.topbar-search:focus-within { border-color: var(--primary); box-shadow: var(--shadow-glow); }
.topbar-search input {
    border: none;
    background: transparent;
    color: var(--text);
    font-size: .875rem;
    outline: none;
    flex: 1;
    font-family: var(--font);
    min-width: 0;
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search kbd {
    font-size: .65rem;
    padding: 2px 6px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font);
    flex-shrink: 0;
}

/* Sync status badge */
.sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 600;
    background: rgba(255,255,255,.88);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Notification bell */
.topbar-bell-wrap { position: relative; }
.topbar-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 14px;
    background: rgba(255,255,255,.88);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}
.topbar-bell:hover { border-color: var(--info); color: var(--info); transform: translateY(-1px); }
.topbar-bell .notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    border: 2px solid var(--bg-topbar);
}
.notif-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 280px;
    max-width: 360px;
    max-height: 400px;
    overflow: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}
.notif-dropdown-header {
    padding: 12px 16px;
    font-weight: 700;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-light);
}
.notif-dropdown-list, .notif-dropdown-empty {
    padding: 16px;
    font-size: 0.875rem;
    color: var(--text-muted);
}
.notif-dropdown-empty { text-align: center; }
.notif-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 4px;
    transition: background .15s;
}
.notif-item:hover { background: var(--bg-body); }
.notif-item:last-child { border-bottom: none; }
.notif-item strong { display: block; color: var(--text); margin-bottom: 2px; font-size: .82rem; }
.notif-item.notif-read { opacity: 0.55; }

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    font-size: 20px;
    line-height: 1;
}
.hamburger:hover { background: var(--bg-hover); }

.topbar-quick-start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: 14px;
    background: #18212f;
    color: #fff !important;
    font-size: 16px;
    transition: all var(--transition);
    box-shadow: 0 10px 24px rgba(24,33,47,.18);
}
.topbar-quick-start-btn:hover { transform: translateY(-1px) scale(1.04); box-shadow: 0 14px 28px rgba(24,33,47,.22); }
.topbar-quick-start-btn { border: none; cursor: pointer; }
.topbar-btn-label { margin-left: 6px; font-size: 0.85rem; font-weight: 500; }
@media (max-width: 768px) { .topbar-btn-label { display: none; } }

.topbar-logout-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 8px;
    border: 1px solid var(--danger); color: var(--danger);
    background: transparent; font-size: 0.85rem; font-weight: 500;
    text-decoration: none; transition: all var(--transition);
}
.topbar-logout-btn:hover { background: var(--danger-bg); color: var(--danger); }
.btn-outline-danger { border-color: var(--danger); color: var(--danger); }

.page-body {
    padding: 30px 34px 56px;
    flex: 1;
    max-width: 1480px;
    width: 100%;
    margin: 0 auto;
    min-width: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   PAGE SHELL — единый ритм и шапки разделов
   ═══════════════════════════════════════════════════════════════════════ */
.page-stack {
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.page-header {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.page-header .page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}
.page-header .page-title {
    flex: 1;
    min-width: 0;
}
.page-title {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.page-title .ico { flex-shrink: 0; margin-top: 3px; }
.page-title h1 {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0 0 6px;
    line-height: 1.15;
    color: var(--text);
}
.page-title .text-muted {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.45;
    max-width: 52rem;
}
.page-section {
    margin-top: 0;
}
.page-section--tight-top { margin-top: 28px; }

/* Формы внутри карточек */
.form-card__title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--text);
}
.form-card__lead {
    font-size: 0.9rem;
    margin-bottom: 12px;
    line-height: 1.45;
}
.form-card--mb { margin-bottom: 20px; }
.form-control--w-sm { min-width: 140px; }
.form-control--w-md { min-width: 200px; }
.form-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}
.form-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.form-filter-row .form-group { margin-bottom: 0; }

.table-card__title {
    margin: 0 0 12px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════════ */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
    box-shadow: var(--shadow-sm);
}
.card:hover { box-shadow: var(--shadow); border-color: rgba(132,169,248,.22); transform: translateY(-3px); }

.card-ok   { border-left: 3px solid var(--success); }
.card-warn { border-left: 3px solid var(--warning); }
.card-info { border-left: 3px solid var(--info); }

.card-header {
    padding: 18px 20px 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.card-icon {
    width: 42px; height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    font-size: 20px;
    flex-shrink: 0;
}
.card-icon.amo    { background: var(--info-bg);    color: var(--info); }
.card-icon.tg     { background: var(--primary-light); color: var(--primary); }
.card-icon.wa     { background: var(--success-bg); color: var(--success); }
.card-icon.max    { background: var(--warning-bg); color: var(--warning); }
.card-icon.bot    { background: var(--accent-bg); color: var(--accent); }

.card-header h3 { font-size: .95rem; font-weight: 600; }
.card-body { padding: 4px 20px 18px; }
.card-body p { font-size: .84rem; color: var(--text-secondary); margin-top: 6px; }

/* Stat / KPI cards */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* Две карточки на ширину блока: скорость продаж и прогноз (адаптивно) */
.velocity-forecast-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}
.velocity-forecast-cards .velocity-forecast-card {
    min-width: 0;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-3px); border-color: rgba(132,169,248,.2); }
.stat-card-label {
    font-size: .79rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.35;
    max-width: 80%;
}
.stat-card-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    letter-spacing: -.03em;
}
.stat-card-sub {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: 6px;
}
.stat-card-delta {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: .75rem;
    font-weight: 700;
    margin-left: 8px;
    vertical-align: middle;
}
.stat-card-delta.up { color: var(--success); }
.stat-card-delta.down { color: var(--danger); }
.stat-card-icon {
    float: right;
    width: 44px; height: 44px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-top: -2px;
}
.stat-card-icon--success { background: rgba(34, 197, 94, 0.08); color: #22c55e; }
.stat-card-icon--blue   { background: rgba(59, 130, 246, 0.08); color: #3b82f6; }
.stat-card-icon--amber  { background: rgba(245, 158, 11, 0.08); color: #f59e0b; }
.stat-card-icon--violet { background: rgba(139, 92, 246, 0.08); color: #8b5cf6; }
.stat-card-icon--muted  { background: var(--primary-light); color: var(--primary); }
.stat-card-icon--info   { background: var(--info-bg); color: var(--info); }
.stat-card-icon--warn   { background: var(--warning-bg); color: var(--warning); }

/* ═══════════════════════════════════════════════════════════════════════
   STATUS BADGES
   ═══════════════════════════════════════════════════════════════════════ */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}
.status-badge::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-badge.ok     { background: var(--success-bg); color: var(--success); }
.status-badge.ok::before { background: var(--success); }
.status-badge.warn   { background: var(--warning-bg); color: var(--warning); }
.status-badge.warn::before { background: var(--warning); }
.status-badge.info   { background: var(--info-bg); color: var(--info); }
.status-badge.info::before { background: var(--info); }
.status-badge.danger { background: var(--danger-bg); color: var(--danger); }
.status-badge.danger::before { background: var(--danger); }

/* ═══════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-xs);
    font-size: .84rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease, color .18s ease;
    text-decoration: none !important;
    color: #fff;
    line-height: 1.4;
}
.btn-primary { background: #18212f; }
.btn-primary:hover { background: #111926; box-shadow: 0 12px 24px rgba(24,33,47,.18); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: rgba(132,169,248,.28); color: var(--text); background: #fff; }
.btn-success { background: var(--success); }
.btn-success:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: 6px 14px; font-size: .78rem; }
.btn-lg { padding: 12px 28px; font-size: .92rem; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover { border-color: rgba(132,169,248,.28); color: #4366b0; background: #edf3ff; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

.btn-gradient {
    background: var(--primary);
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(34,197,94,.3);
}
.btn-gradient:hover { box-shadow: 0 6px 24px rgba(34,197,94,.4); transform: translateY(-1px); }

/* ═══════════════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════════════ */
.form-inline { margin-top: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: .82rem;
    font-weight: 600;
}
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    background: #fbfcfa;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: .875rem;
    font-family: var(--font);
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}
.input-wide { max-width: 500px; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }

.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 16px;
    box-shadow: var(--shadow-sm);
}

/* Payment page constructor */
.pp-config-layout {
    display: grid;
    grid-template-columns: 1fr minmax(380px, 420px);
    gap: 28px;
    align-items: start;
}
@media (max-width: 1024px) {
    .pp-config-layout { grid-template-columns: 1fr; }
    .pp-config-preview { order: -1; max-height: 420px; }
}
.pp-config-main { min-width: 0; }
.pp-config-preview {
    position: sticky;
    top: 88px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.pp-config-preview-title {
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}
.pp-config-preview iframe {
    width: 100%;
    height: 540px;
    border: none;
    display: block;
}
.pp-config-form .form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.pp-config-form .form-input,
.pp-config-form input[type="text"],
.pp-config-form input[type="color"],
.pp-config-form select,
.pp-config-form textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 0.875rem;
    font-family: var(--font);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.pp-config-form input:focus,
.pp-config-form select:focus,
.pp-config-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}
.pp-config-form .form-group { margin-bottom: 18px; }
.pp-config-form .upload-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.pp-config-form .upload-row input[type="text"] { flex: 1; min-width: 180px; }
.pp-config-form .upload-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.pp-config-form .upload-btn input[type="file"] { position: absolute; width: 0.1px; height: 0.1px; opacity: 0; overflow: hidden; z-index: -1; }
.pp-config-form .color-row { display: flex; gap: 10px; align-items: center; }
.pp-config-form .color-row input[type="color"] { width: 48px; height: 38px; padding: 2px; border-radius: 8px; cursor: pointer; border: 1px solid var(--border); }
.pp-config-form .color-row input[type="text"] { max-width: 120px; }

/* ═══════════════════════════════════════════════════════════════════════
   INFO BOXES
   ═══════════════════════════════════════════════════════════════════════ */
.info-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-xs);
}
.page-intro {
    background: linear-gradient(135deg, rgba(59,130,246,.06), rgba(59,130,246,.02));
    border: 1px solid rgba(59,130,246,.18);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.55;
}
.page-intro p { margin: 0 0 0.5em; }
.page-intro p:last-child { margin-bottom: 0; }
.page-intro strong { color: var(--text); }
.page-intro a { color: var(--primary); }
.info-box p { color: var(--text-secondary); font-size: .87rem; }
.info-box ol, .info-box ul { padding-left: 20px; margin-top: 8px; }
.info-box li { color: var(--text-secondary); font-size: .85rem; margin-bottom: 5px; }
.info-box h4 { margin-top: 14px; margin-bottom: 8px; font-size: .92rem; color: var(--text); }
.info-box-heading { margin-top: 0; margin-bottom: 8px; font-size: .92rem; color: var(--text); font-weight: 700; }
.info-box-warn { border-color: var(--warning, #eab308); background: rgba(234, 179, 8, 0.06); }

.setup-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-xs);
}

.config-info { margin-top: 24px; }
.config-info h4 { margin-bottom: 10px; font-size: .92rem; }
.info-table { width: 100%; max-width: 600px; }
.info-table td { padding: 8px 14px; font-size: .85rem; }
.info-table td:first-child { color: var(--text-muted); font-weight: 500; white-space: nowrap; }

.amo-check-result { padding: 12px 16px; background: var(--bg); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.amo-data-block { padding: 16px; background: var(--bg); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.amo-data-section { margin-bottom: 20px; }
.amo-data-section:last-child { margin-bottom: 0; }
.amo-data-section strong { display: block; margin-bottom: 8px; font-size: 0.9rem; }
.amo-pipeline-list, .amo-fields-list { margin: 0; padding-left: 20px; font-size: 0.85rem; color: var(--text-secondary); }
.amo-pipeline-list ul { margin: 4px 0; padding-left: 18px; }
.amo-data-block .data-table { margin-top: 8px; }

.config-list-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: var(--bg);
}
.config-list-item .config-name { font-weight: 600; margin-right: 8px; }
.config-list-item .config-slug { font-size: 0.8rem; color: var(--text-muted); }

code {
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: .82rem;
    color: var(--primary);
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ═══════════════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════════════ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.table-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}
.table-card .data-table {
    border: none;
    box-shadow: none;
    margin-bottom: 0;
    border-radius: 0;
}
.data-table th {
    background: #f8faf7;
    padding: 14px 18px;
    text-align: left;
    font-size: .72rem;
    color: #7d8797;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.data-table td {
    padding: 14px 18px;
    border-top: 1px solid var(--border-light);
    font-size: .85rem;
}
.data-table tr:hover td { background: #fbfcfa; }
.data-table a { font-weight: 500; }
.data-table a.link { color: var(--primary); text-decoration: none; }
.data-table a.link:hover { text-decoration: underline; color: var(--primary-hover); }
.td-center { text-align: center; }
.data-table input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }

/* ═══════════════════════════════════════════════════════════════════════
   PIPELINE / FIELDS
   ═══════════════════════════════════════════════════════════════════════ */
.pipeline-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
.pipeline-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}
.pipeline-header h3 { font-size: 1rem; font-weight: 600; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: .72rem;
    font-weight: 600;
    background: var(--bg-hover);
    color: var(--text-muted);
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }

.color-dot {
    display: inline-block;
    width: 14px; height: 14px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 4px;
}
.enum-item {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-hover);
    border-radius: 6px;
    font-size: .78rem;
    margin: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   SETTINGS PAGE
   ═══════════════════════════════════════════════════════════════════════ */
.settings-container {
    width: 100%;
    max-width: 960px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}
.settings-tabs-bar {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.settings-tab {
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.2s, border-color 0.2s;
    font-family: var(--font);
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active {
    color: var(--text);
    border-bottom-color: var(--primary);
}
.settings-intro {
    background: linear-gradient(135deg, rgba(34,197,94,.06), rgba(34,197,94,.02));
    border: 1px solid rgba(34,197,94,.2);
    border-radius: var(--radius);
    padding: 20px 24px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.55;
}
.settings-intro strong { color: var(--text); }
.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition);
    margin-bottom: 28px;
}
.settings-section:last-child { margin-bottom: 0; }
.settings-section:hover { box-shadow: var(--shadow); }
.settings-section-header {
    padding: 22px 28px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-hover);
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.settings-section-header .section-icon:first-child {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.settings-section-header h2,
.settings-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}
.settings-section-desc { font-size: 0.875rem; color: var(--text-muted); margin: 6px 0 0; line-height: 1.5; }
.settings-section-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 10px 0 0 52px;
    line-height: 1.5;
}
.settings-section-header > div > p { margin-left: 0; }

/* Страница виджета: отступы как у интеграций/настроек */
.widget-page { max-width: 960px; }
.widget-section { margin-bottom: 28px; }
.widget-section:last-child { margin-bottom: 0; }
.widget-section-body { padding: 22px 28px; }

.settings-section-header h2 {
    display: flex;
    align-items: center;
    gap: 12px;
}
.settings-section-header h2 .section-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.settings-section-header h2 .section-icon.amo { background: rgba(59,130,246,.12); color: #3b82f6; }
.settings-section-header h2 .section-icon.amojo { background: rgba(139,92,246,.12); color: #8b5cf6; }
.settings-section-header h2 .section-icon.tg { background: rgba(34,197,94,.12); color: var(--primary); }
.settings-section-header h2 .section-icon.wa { background: rgba(34,197,94,.08); color: #0d9488; }
.settings-section-header h2 .section-icon.pay { background: rgba(245,158,11,.12); color: #f59e0b; }
.settings-section-header h2 .section-icon.ai { background: rgba(99,102,241,.12); color: #6366f1; }
.settings-section-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 10px 0 0 52px;
    line-height: 1.5;
}
.settings-section-header a { color: var(--primary); font-weight: 500; }
.settings-list {
    display: flex;
    flex-direction: column;
}
.settings-item {
    padding: 20px 28px;
    border-bottom: 1px solid var(--border-light);
    display: grid;
    grid-template-columns: 1fr minmax(280px, 1fr);
    gap: 16px 24px;
    align-items: start;
}
.settings-item:last-child { border-bottom: none; }
.settings-item-header { grid-column: 1; }
.settings-item-info { min-width: 0; }
.settings-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.settings-label .badge-required {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}
.settings-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.45;
}
.settings-item-control {
    grid-column: 2;
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
}
.settings-item-control input {
    flex: 1;
    min-width: 0;
}
@media (max-width: 768px) {
    .settings-item { grid-template-columns: 1fr; }
    .settings-item-control { grid-column: 1; }
    .settings-section-header p { margin-left: 0; }
}

/* Вкладки настроек: одинаковые отступы и gap между секциями */
.settings-tab-panel {
    display: flex;
    flex-direction: column;
    gap: 28px;
    width: 100%;
    max-width: 960px;
}
.settings-tab-panel-mapping .settings-section .settings-item-control {
    flex-wrap: wrap;
}

/* Единый стиль блоков маппинга (контакты, критерии сделок, каналы рассылки) */
.mapping-editor-section .mapping-block {
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    padding: 16px 20px;
    margin-bottom: 16px;
}
.mapping-editor-section .mapping-block:last-of-type { margin-bottom: 0; }
.mapping-block-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: var(--text);
}
.mapping-block-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0 0 12px 0;
    line-height: 1.4;
}
.mapping-block-content {
    margin-bottom: 12px;
}
.mapping-block-content .data-table,
.mapping-block-content .mapping-table {
    width: 100%;
    font-size: 0.88rem;
}
.mapping-block-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.mapping-result-box {
    border-top: 1px solid var(--border-light);
}
.mapping-result-box-inner {
    background: var(--bg-hover);
    border-radius: var(--radius-xs);
    padding: 18px 20px;
    margin: 0 28px 20px;
}

/* Вкладка «Поля и каналы»: схема и шаги */
.integration-guide {
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 20px 22px;
    margin-bottom: 8px;
}
.integration-guide-title {
    margin: 0 0 8px 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}
.integration-guide-lead {
    margin: 0 0 14px 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary);
}
.integration-guide-list {
    margin: 0 0 16px 0;
    padding-left: 1.25rem;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--text-secondary);
}
.integration-guide-list li { margin-bottom: 8px; }
.integration-guide-list li:last-child { margin-bottom: 0; }
.integration-guide-channels {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-top: 4px;
    border-top: 1px dashed var(--border-light);
}
.integration-guide-channels-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 4px;
}
.channel-pill {
    display: inline-block;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.integration-ai-section {
    margin-top: 0;
}
.integration-tab-intro {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 960px;
}
.mapping-block-step .mapping-step-head {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 12px;
}
.mapping-step-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin-top: 2px;
}
.mapping-block-step .mapping-block-title {
    margin-bottom: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════
   ANALYTICS
   ═══════════════════════════════════════════════════════════════════════ */
.analytics-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding: 14px 20px;
    margin-bottom: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}
.analytics-toolbar label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.analytics-toolbar input[type="date"],
.analytics-toolbar select { width: auto; min-width: 140px; }
.analytics-toolbar .analytics-toolbar__spaced { margin-left: 12px; }
.analytics-toolbar .gap-row { margin-left: auto; }

/* ═ LOGIN (страница входа — те же токены темы) */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    color: var(--text);
    padding: 2rem;
}
.login-page-inner {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.login-brand img {
    width: 44px;
    height: 44px;
    border-radius: 12px;
}
.login-brand h1 {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    margin: 0;
}
.login-card {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 28px 32px;
    box-shadow: var(--shadow);
}
.login-card h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--text);
}
.login-card .login-sub {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 22px;
}
.login-error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    margin-bottom: 16px;
    font-size: 0.85rem;
    border: 1px solid rgba(217, 95, 95, 0.35);
}
.login-card .form-group { margin-bottom: 16px; }
.login-card .form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.9rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-card input:focus {
    outline: none;
    border-color: var(--primary-hover);
    box-shadow: var(--shadow-glow);
    background: var(--bg-card);
}
.login-card button[type="submit"] {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: var(--radius-xs);
    background: var(--success);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    font-family: var(--font);
    cursor: pointer;
    margin-top: 4px;
    transition: background 0.2s, transform 0.15s;
}
.login-card button[type="submit"]:hover {
    background: var(--primary-hover);
    filter: brightness(0.95);
}
.login-hint {
    margin-top: 18px;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
}
.login-hint code {
    background: var(--primary-light);
    color: var(--success);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.78rem;
}

.chart-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
@media (min-width: 1024px) {
    .chart-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-xs);
}
.chart-card h3 {
    font-size: .95rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
}
.chart-card canvas { max-height: 300px; }

/* Dashboard / hero (можно переиспользовать на других страницах) */
.dashboard-hero,
.page-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 24px;
    margin-bottom: 22px;
    background: linear-gradient(135deg, #caefd4 0%, #dff5e6 52%, #eef8f1 100%);
    border: 1px solid rgba(159,223,180,.45);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .dashboard-hero,
[data-theme="dark"] .page-hero {
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.12) 0%, rgba(26, 29, 39, 0.9) 100%);
    border-color: rgba(74, 222, 128, 0.25);
}
.dashboard-hero-copy h2,
.page-hero-copy h2 {
    font-size: 2rem;
    line-height: 1.05;
    letter-spacing: -.04em;
    margin: 0 0 6px;
}
.dashboard-hero-copy p,
.page-hero-copy p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 1rem;
}
.dashboard-hero-actions,
.page-hero-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.dashboard-hero-actions .btn,
.page-hero-actions .btn {
    min-height: 42px;
}
@media (max-width: 900px) {
    .dashboard-hero,
    .page-hero {
        flex-direction: column;
        align-items: flex-start;
    }
    .dashboard-hero-copy h2,
    .page-hero-copy h2 {
        font-size: 1.6rem;
    }
}
.dashboard-toolbar {
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.dashboard-filters {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.dashboard-filters label { font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); }
.dashboard-filters select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: #fbfcfa;
    color: var(--text);
    font-size: 0.9rem;
}
.dash-filter-channel { margin-left: 8px; }
.dashboard-kpis { margin-bottom: 28px; }
.kpi-card { min-width: 180px; }
.dashboard-charts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 28px;
}
@media (min-width: 1024px) {
    .dashboard-charts {
        grid-template-columns: 1.6fr 1fr;
    }
}
.dashboard-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 28px;
}
@media (max-width: 1024px) {
    .dashboard-charts-grid { grid-template-columns: 1fr; }
}
.dashboard-chart-card {
    padding: 22px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.dashboard-chart-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.chart-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 16px; }
.chart-wrap { height: 280px; position: relative; }
.dashboard-section-card {
    margin-top: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.dashboard-section-title {
    margin: 0;
    padding: 18px 22px 14px;
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border-light);
}
.dashboard-section-title .ico { vertical-align: middle; }
.dashboard-section-hint {
    margin: 0 22px 16px;
    padding-top: 0;
}
.dash-table-card {
    margin-top: 12px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
}
.dashboard-recent { overflow-x: auto; }
.data-table-compact { font-size: 0.85rem; }
.data-table-compact th, .data-table-compact td { padding: 10px 12px; }
.text-ellipsis { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-recent-link { margin-top: 0; padding: 12px 16px; font-size: 0.9rem; border-top: 1px solid var(--border-light); background: var(--bg-card); }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: inherit; text-decoration: underline; }
.info-box.compact { padding: 14px 18px; }

/* Dashboard dialog table avatars and channel icons */
.dialog-client {
    display: flex;
    align-items: center;
    gap: 10px;
}
.dialog-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .82rem;
    flex-shrink: 0;
}
.dialog-channels {
    display: flex;
    gap: 4px;
    align-items: center;
}
.dialog-channel-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.dialog-channel-icon.tg { background: #dbeafe; color: #2563eb; }
.dialog-channel-icon.wa { background: #dcfce7; color: #16a34a; }
.dialog-channel-icon.email { background: #fef3c7; color: #d97706; }

.dialog-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.dialog-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: .72rem;
    font-weight: 600;
}
.dialog-tag.hot { background: #fef2f2; color: #dc2626; }
.dialog-tag.wait { background: #fefce8; color: #ca8a04; }
.dialog-tag.new { background: #f0fdf4; color: #16a34a; }
.dialog-tag.default { background: var(--bg-hover); color: var(--text-muted); }

.btn-reply {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary);
    font-size: .82rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-reply:hover { background: var(--primary-light); }

/* ═══════════════════════════════════════════════════════════════════════
   CHANNELS PAGE
   ═══════════════════════════════════════════════════════════════════════ */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.channel-card {
    scroll-margin-top: 80px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-xs);
    transition: all .2s ease;
    display: flex;
    flex-direction: column;
}
.channel-card:hover { box-shadow: var(--shadow); border-color: var(--primary); transform: translateY(-2px); }
.channel-card-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}
.channel-card-icon {
    width: 46px; height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.channel-card-icon.tg   { background: #e0e7ff; color: #4f46e5; }
[data-theme="dark"] .channel-card-icon.tg { background: rgba(79,70,229,.12); }
.channel-card-icon.wa   { background: #d1fae5; color: #059669; }
[data-theme="dark"] .channel-card-icon.wa { background: rgba(5,150,105,.12); }
.channel-card-icon.max  { background: #fef3c7; color: #d97706; }
[data-theme="dark"] .channel-card-icon.max { background: rgba(217,119,6,.12); }
.channel-card-icon.amo  { background: #ede9fe; color: #7c3aed; }
[data-theme="dark"] .channel-card-icon.amo { background: rgba(124,58,237,.12); }
.channel-card-icon.bot  { background: #fce7f3; color: #db2777; }
[data-theme="dark"] .channel-card-icon.bot { background: rgba(219,39,119,.12); }
.channel-card-icon.web  { background: #e0f2fe; color: #0284c7; }
[data-theme="dark"] .channel-card-icon.web { background: rgba(2,132,199,.12); }

.channel-card-title { font-size: 1.02rem; font-weight: 700; }
.channel-card-desc {
    font-size: .84rem;
    color: var(--text-secondary);
    flex: 1;
    margin-bottom: 14px;
    line-height: 1.55;
}
.channel-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* ═══════════════════════════════════════════════════════════════════════
   QUICK START WIZARD
   ═══════════════════════════════════════════════════════════════════════ */
.quick-start-banner {
    background: var(--primary);
    border-radius: var(--radius);
    padding: 28px 32px;
    margin-bottom: 24px;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(34,197,94,.25);
}
.quick-start-banner::before {
    content: '';
    position: absolute;
    top: -50%; right: -30%;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    pointer-events: none;
}
.quick-start-banner h2 {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 6px;
    position: relative;
}
.quick-start-banner p {
    font-size: .9rem;
    opacity: .9;
    margin-bottom: 20px;
    position: relative;
}
.quick-start-banner .btn { background: #fff; color: var(--primary); font-weight: 700; }
.quick-start-banner .btn:hover { box-shadow: 0 4px 16px rgba(255,255,255,.3); }

.qs-steps {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.qs-step {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    box-shadow: var(--shadow-xs);
    transition: all .2s ease;
    cursor: pointer;
    position: relative;
}
.qs-step:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.qs-step.completed { border-color: var(--success); }
.qs-step.completed .qs-num { background: var(--success); }
.qs-step.active { border-color: var(--primary); box-shadow: var(--shadow-glow); }
.qs-num {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    flex-shrink: 0;
}
.qs-step-body { flex: 1; }
.qs-step-title { font-size: .92rem; font-weight: 700; margin-bottom: 4px; }
.qs-step-desc { font-size: .82rem; color: var(--text-secondary); line-height: 1.5; }
.qs-step-status {
    position: absolute;
    top: 12px; right: 14px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.qs-step.completed .qs-step-status { color: var(--success); }
.qs-step:not(.completed) .qs-step-status { color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════
   FLOW DIAGRAM
   ═══════════════════════════════════════════════════════════════════════ */
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
}

.flow-diagram {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.flow-step {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    flex: 1;
    min-width: 170px;
    text-align: center;
    box-shadow: var(--shadow-xs);
}
.flow-num {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin: 0 auto 10px;
    font-size: .9rem;
}
.flow-step p { font-size: .82rem; color: var(--text-secondary); }
.flow-arrow { font-size: 1.2rem; color: var(--text-muted); }

.recent-activity { margin-top: 24px; }
.recent-activity h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 14px; }

/* ═══════════════════════════════════════════════════════════════════════
   QR CODE
   ═══════════════════════════════════════════════════════════════════════ */
.qr-wrapper {
    background: #fff;
    display: inline-block;
    padding: 16px;
    border-radius: var(--radius);
    margin-top: 12px;
    box-shadow: var(--shadow);
}

/* ═══════════════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: rgba(0,0,0,.35);
    box-sizing: border-box;
}
.modal-overlay.modal-open {
    display: flex;
}
/* Окно внутри overlay: не шире экрана минус отступы; по умолчанию — узкие модалки */
.modal-overlay .modal-dialog {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: min(100vw - 32px, 560px);
    max-height: 90vh;
    overflow: auto;
    margin: auto;
    box-sizing: border-box;
}
.modal-overlay .modal-dialog.modal-dialog-tagging {
    max-width: min(100vw - 24px, 520px);
}
/* Рассылки: ширина по макету, на мобильных — почти на всю ширину */
.modal-overlay .modal-dialog.modal-dialog-broadcast {
    max-width: min(100vw - 16px, 1200px);
}
.broadcast-constructor--wide .modal-body {
    padding: 20px 24px 24px;
}
/* Двухколоночный макет: текст слева, Telegram / CRM справа */
.bc-modal-layout {
    display: grid;
    grid-template-columns: 1fr min(340px, 32%);
    gap: 20px 24px;
    align-items: start;
}
@media (max-width: 900px) {
    .bc-modal-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}
.bc-modal-head-row {
    margin-bottom: 4px;
    flex-wrap: wrap;
}
.bc-modal-head-row .bc-channel-wrap {
    flex: 0 0 auto;
    min-width: min(200px, 100%);
    max-width: 280px;
}
@media (max-width: 520px) {
    .bc-modal-head-row .bc-channel-wrap {
        flex: 1 1 100%;
        min-width: 100%;
        max-width: none;
    }
}
.bc-modal-col--main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.bc-modal-col--aside {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.bc-panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.bc-panel--telegram {
    border-left: 3px solid #229ed9;
}
.bc-panel--media {
    border-left: 3px solid var(--primary);
}
.bc-panel--segment {
    border-left: 3px solid #7c3aed;
}
.bc-panel__title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.bc-panel__hint {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin: 0 0 12px;
}
.bc-panel .form-group:last-child { margin-bottom: 0; }
.bc-segment-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}
@media (max-width: 900px) {
    .bc-segment-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .modal-overlay {
        padding: 8px;
        align-items: flex-start;
    }
    .modal-overlay .modal-dialog.modal-dialog-broadcast {
        max-width: 100%;
        max-height: calc(100vh - 16px);
    }
    .broadcast-constructor--wide .modal-body {
        padding: 14px 12px 16px;
    }
}
.bc-segment-cell label.small {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: block;
}
.bc-segment-cell select[multiple] {
    font-size: 0.85rem;
}
/* Скрытый input + кнопка выбора файла */
.bc-file-picker {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    margin-bottom: 8px;
}
.bc-file-input {
    position: absolute;
    left: 0;
    top: 0;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}
.bc-file-picker__btn {
    flex-shrink: 0;
    pointer-events: auto;
}
.bc-file-picker__name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bc-media-pos {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-top: 4px;
}
.bc-media-block {
    margin-bottom: 14px;
}
.bc-media-block:last-child { margin-bottom: 0; }
.bc-media-block > label:not(.bc-radio-label) {
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
}
#bc-tg-media-panel .bc-telegram-photo-preview {
    margin-top: 8px;
}
.modal-overlay-backdrop {
    position: absolute;
    inset: 0;
    z-index: 1;
    cursor: pointer;
    background: rgba(0,0,0,.35);
}
.quick-start-modal {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    min-height: 200px;
    overflow-y: auto;
    background: var(--bg-card);
    color: var(--text);
    border-radius: var(--radius);
    box-shadow: 0 24px 48px rgba(0,0,0,.2);
    border: 1px solid var(--border);
    animation: modalIn .25s ease;
}
.quick-start-modal .modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.quick-start-modal .modal-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}
.quick-start-modal .modal-body { padding: 24px; }
.qs-modal-intro {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.5;
}
.qs-steps-modal { display: flex; flex-direction: column; gap: 12px; }
.qs-step-modal {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}
.qs-step-modal:hover { background: var(--bg-hover); border-color: var(--primary); }
.qs-step-modal.done {
    background: var(--bg-hover);
    border-color: rgba(34,197,94,.25);
}
.qs-step-modal.done .qs-step-modal-num {
    background: var(--success);
}
.qs-step-modal-num {
    width: 28px; height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
}
.qs-step-modal-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.qs-step-modal-body strong { font-size: 0.95rem; }
.qs-step-modal-body span { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.4; }
.qs-step-modal-body a { color: var(--primary); }
/* Статус шага — внутри блока шага, отдельной строкой (не в углу) */
.qs-step-modal-body .qs-step-status-inline {
    display: block;
    margin-top: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.3;
}
.qs-step-modal.done .qs-step-modal-body .qs-step-status-inline { color: var(--success) !important; }
.qs-step-modal .btn { flex-shrink: 0; }

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    visibility: hidden;
    opacity: 0;
    transition: visibility .2s, opacity .2s;
}
.modal.modal-open { visibility: visible; opacity: 1; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
    cursor: pointer;
}
.modal-dialog {
    position: relative;
    width: 100%;
    max-width: min(100vw - 32px, 500px);
    max-height: 90vh;
    overflow: auto;
    animation: modalIn .2s ease;
    box-sizing: border-box;
}
/* Рассылки (внутри .modal.modal-open): перекрываем узкий max-width выше */
.modal .modal-dialog.modal-dialog-broadcast {
    max-width: min(100vw - 16px, 1200px);
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.05rem; margin: 0; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    transition: color var(--transition);
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px 24px; }
.modal-body .form-group { margin-bottom: 16px; }
.modal-body .form-group:last-of-type { margin-bottom: 0; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* Рассылки: тулбар форматирования и вложения */
.bc-format-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.bc-format-toolbar .btn-format {
    min-width: 32px;
    padding: 4px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background var(--transition), border-color var(--transition);
}
.bc-format-toolbar .btn-format:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}
.bc-format-toolbar .toolbar-hint { font-size: 0.8rem; margin-left: 4px; max-width: 100%; }
.broadcast-constructor .bc-channel-block { margin-bottom: 16px; }
.broadcast-constructor .bc-hint {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.45;
    padding: 10px 12px;
    background: var(--bg-hover);
    border-radius: var(--radius-xs);
    margin-bottom: 14px;
    border-left: 3px solid var(--primary);
}
.broadcast-constructor .bc-toolbar-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.broadcast-constructor .bc-telegram-photo-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.broadcast-constructor .bc-telegram-photo-row input[type="file"] { flex: 1; min-width: 160px; }
.broadcast-constructor .bc-radio-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}
.bc-body-editor { font-family: inherit; resize: vertical; }
.bc-body-preview {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: var(--bg);
    min-height: 40px;
}
.bc-body-preview b { font-weight: 700; }
.bc-body-preview i { font-style: italic; }
.bc-body-preview s { text-decoration: line-through; }
.bc-body-preview ul,
.bc-body-preview ol { margin: 0.4em 0; padding-left: 1.35em; }
.bc-body-preview li { margin: 0.2em 0; }
.bc-body-preview p { margin: 0.35em 0; }
.bc-body-preview tg-spoiler,
.bc-body-preview [data-spoiler] {
    background: var(--text-muted);
    color: var(--text-muted);
    border-radius: 2px;
}
.bc-attach-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.bc-attach-list .attach-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}
.bc-attach-list .attach-item .remove-attach { cursor: pointer; color: var(--danger); }

/* Быстрая рассылка — макет «как в почте» (Кому / Тема / тело) */
.compose-send-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
}
.compose-send-card .card-header {
    background: linear-gradient(180deg, var(--bg-hover) 0%, var(--bg-card) 100%);
    border-bottom: 1px solid var(--border);
}
.compose-send-intro {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin: 0 0 12px;
}
.compose-send-inner {
    padding: 0;
}
.compose-channel-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.compose-channel-row label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0;
}
.compose-channel-row select.form-control {
    min-width: 220px;
    max-width: 100%;
}
.compose-mail-shell {
    padding: 0;
}
.compose-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    min-height: 44px;
}
.compose-row:last-of-type {
    border-bottom: none;
}
.compose-row-label {
    flex: 0 0 88px;
    padding-top: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}
.compose-row-field {
    flex: 1;
    min-width: 0;
}
.compose-row-field .form-control,
.compose-row-field textarea.form-control {
    margin: 0;
}
.compose-row-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.35;
}
.compose-body-block {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}
.compose-body-block > label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    display: block;
    margin-bottom: 8px;
}
.compose-body-block .bc-format-toolbar {
    margin-bottom: 8px;
}
.compose-body-block .bc-body-editor {
    min-height: 140px;
    background: var(--bg-card);
}
.compose-body-block .bc-body-preview {
    margin-top: 8px;
}
.sbl-send-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

/* ═══════════════════════════════════════════════════════════════════════
   TOASTS
   ═══════════════════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    box-shadow: var(--shadow-lg);
    font-size: .85rem;
    animation: toastIn .3s ease;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(12px);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ═══════════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════════ */
.toolbar { margin-bottom: 16px; }
.empty-state { 
    color: var(--text-secondary); 
    padding: 48px 24px; 
    text-align: center;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin-top: 20px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    line-height: 1.5;
}
.duplicates-container { width: 100%; }
.duplicates-panel { margin-top: 24px; }
.duplicates-list { margin-top: 20px; }
.duplicates-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.duplicates-tabs {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.duplicates-count {
    margin-left: 12px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.duplicates-tabs .btn { border-radius: 8px; }
.duplicates-empty-hint {
    padding: 32px 24px;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.9rem;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.duplicates-loading {
    padding: 32px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.hint { color: var(--text-muted); font-size: .82rem; margin-top: 6px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.page-section { margin-top: 28px; }
.page-section h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.page-section h3 {
    font-size: .95rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.connections-list { font-size: .85rem; }
.connection-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}
.connection-row:last-child { border-bottom: none; }
.connection-row span:first-child { flex: 1; }

.status-block { padding: 12px 0; }
.info-section { margin-top: 30px; }
.info-section h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 16px; }

i[class^="lucide-"], i[class*=" lucide-"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 200;
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar.collapsed { transform: translateX(-100%); }
    .sidebar-overlay.active { display: block; }
    .content { margin-left: 0 !important; }
    .hamburger { display: flex; }
    .sidebar-collapse-btn { display: none; }
    .topbar-search { max-width: 280px; }
    .dashboard-charts { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .page-body { padding: 16px; }
    .topbar { padding: 0 16px; }
    .topbar h1 { font-size: 1rem; }
    .topbar-search { display: none; }
    .chart-grid { grid-template-columns: 1fr; }
    .channel-grid { grid-template-columns: 1fr; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .velocity-forecast-cards { grid-template-columns: 1fr; }
    .qs-steps { grid-template-columns: 1fr; }
    .quick-start-banner { padding: 20px; }
    .quick-start-banner h2 { font-size: 1.1rem; }
    .settings-grid { grid-template-columns: 1fr; }
    .dashboard-charts { grid-template-columns: 1fr; }
    .calendar-layout { grid-template-columns: 1fr; }
    .messages-filter-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stat-cards { grid-template-columns: 1fr; }
    .velocity-forecast-cards { grid-template-columns: 1fr; }
    .flow-diagram { flex-direction: column; }
    .flow-arrow { transform: rotate(90deg); }
}

/* ═══════════════════════════════════════════════════════════════════════
   MAPPING UNSAVED BANNER
   ═══════════════════════════════════════════════════════════════════════ */
.mapping-unsaved {
    display: none;
    padding: 10px 18px;
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    border-radius: var(--radius-xs);
    color: var(--warning);
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 16px;
}
.mapping-unsaved.show { display: block; }

/* ═══════════════════════════════════════════════════════════════════════
   CALENDAR PAGE
   ═══════════════════════════════════════════════════════════════════════ */
.calendar-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    align-items: start;
}
.calendar-card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.calendar-card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}
.calendar-students-list {
    margin: 0;
    padding: 0;
    max-height: 320px;
    overflow-y: auto;
}
.calendar-students-empty {
    display: none;
    padding: 12px;
    margin: 0;
}
.calendar-student-item {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
}
.calendar-student-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.calendar-student-phone {
    font-size: 0.8rem;
    margin-top: 4px;
}
.calendar-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.calendar-month-title {
    margin: 0;
    min-width: 180px;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
}
.calendar-btn-add-event {
    margin-left: auto;
}
.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border-light);
    padding: 0 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border-light);
    padding: 12px;
    min-height: 360px;
}
.cal-day {
    background: var(--bg-card);
    padding: 8px;
    min-height: 80px;
    font-size: 0.85rem;
}
.cal-day.other-month {
    color: var(--text-muted);
    opacity: 0.7;
}
.cal-day-num {
    font-weight: 600;
    margin-bottom: 4px;
}
.cal-day-events {
    list-style: none;
    margin: 0;
    padding: 0;
}
.cal-day-events li {
    font-size: 0.75rem;
    padding: 2px 6px;
    margin-bottom: 2px;
    background: var(--primary-light);
    border-radius: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.events-list .event-item {
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    background: var(--bg-hover);
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.events-list .event-item .event-title {
    font-weight: 500;
}
.events-list .event-item .event-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.calendar-events-empty {
    display: none;
}
.modal-overlay .modal-dialog.calendar-modal-dialog {
    max-width: 420px;
}

/* ═══════════════════════════════════════════════════════════════════════
   MESSAGES / ДИАЛОГИ
   ═══════════════════════════════════════════════════════════════════════ */
.messages-filters-card {
    margin-bottom: 20px;
}
.messages-filters-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 16px 0;
}
.messages-filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    align-items: end;
}
.messages-filter-actions {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.messages-load-hint {
    font-size: 0.85rem;
}
.messages-conversations-wrap {
    margin-top: 8px;
}
.messages-conversations {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.messages-loading-placeholder {
    padding: 12px;
    margin: 0;
}
.conv-thread-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.conv-thread-head {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 4px;
    align-items: start;
    text-align: left;
    padding: 14px 16px;
    background: var(--bg-card);
    border: none;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    font: inherit;
    color: inherit;
    transition: background var(--transition);
}
.conv-thread-head:hover {
    background: var(--bg-hover);
}
.conv-thread-title {
    grid-column: 1;
    grid-row: 1;
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 0;
}
.conv-thread-meta {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}
.conv-thread-badge {
    grid-row: 1;
    grid-column: 2;
    min-width: 28px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
}
.conv-chevron {
    grid-row: 1;
    grid-column: 3;
    color: var(--text-muted);
    font-size: 0.7rem;
    line-height: 1.4;
}
.conv-thread-subrow {
    padding: 6px 16px 10px;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg);
}
.conv-lead-link {
    color: var(--success);
    font-weight: 600;
    text-decoration: none;
}
.conv-lead-link:hover {
    text-decoration: underline;
}
.conv-thread-body {
    padding: 12px 16px 16px;
    max-height: 420px;
    overflow-y: auto;
    background: var(--bg);
}
.conv-msg {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-xs);
    max-width: 92%;
}
.conv-msg-in {
    margin-right: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}
.conv-msg-out {
    margin-left: auto;
    background: var(--primary-light);
    border: 1px solid var(--border);
}
.conv-msg-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.conv-msg-text {
    font-size: 0.88rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}
.conv-dir-in { color: var(--info); }
.conv-dir-out { color: var(--success); }

/* ═══════════════════════════════════════════════════════════════════════
   ALERTS PAGE
   ═══════════════════════════════════════════════════════════════════════ */
.alerts-info-banner {
    margin-bottom: 20px;
}
.alerts-type-list {
    margin: 8px 0 0 16px;
    padding: 0;
}
.alerts-type-list li {
    margin-bottom: 4px;
}
.alerts-table-card {
    margin-bottom: 16px;
}
.alerts-log-section {
    margin-top: 28px;
}
