/* ===== CSS Variables / Theming ===== */
:root,
[data-theme="light"] {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef1f6;
    --bg-hover: #e8ecf1;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --border-color: #e2e8f0;
    --border-light: #edf2f7;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: #dbeafe;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #6366f1;
    --info-light: #e0e7ff;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #3b82f6;
    --sidebar-hover: #334155;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #293548;
    --bg-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #293548;
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --accent-light: #1e3a5f;
    --success: #34d399;
    --success-light: #064e3b;
    --warning: #fbbf24;
    --warning-light: #78350f;
    --danger: #f87171;
    --danger-light: #7f1d1d;
    --info: #818cf8;
    --info-light: #312e81;
    --sidebar-bg: #0b1120;
    --sidebar-text: #94a3b8;
    --sidebar-active: #60a5fa;
    --sidebar-hover: #1e293b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ===== Login Screen ===== */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    padding: 20px;
}

.login-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--accent), var(--info));
    color: white;
    border-radius: var(--radius-lg);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
}

.logo-icon.small {
    width: 36px;
    height: 36px;
    font-size: 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 0;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.login-logo p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

.login-form .form-group { margin-bottom: 20px; }

.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* Google SSO & Divider */
.login-divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}
.login-divider span {
    background: var(--bg-secondary);
    padding: 0 12px;
    color: var(--text-muted);
    font-size: 13px;
    position: relative;
    z-index: 1;
}
.login-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
}

.btn-google {
    background: white;
    color: #3c4043;
    border: 1px solid #dadce0;
    font-weight: 500;
    gap: 10px;
}
.btn-google:hover {
    background: #f7f8f8;
    border-color: #c6c6c6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
[data-theme="dark"] .btn-google {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}
[data-theme="dark"] .btn-google:hover {
    background: var(--bg-hover);
}

.demo-accounts {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.demo-accounts p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.demo-accounts .btn { margin: 0 4px 8px; }

/* ===== AI Assistant ===== */
.ai-assistant-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    z-index: 90;
}
.ai-assistant-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.ai-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 400px;
    max-height: 500px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    z-index: 90;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease;
}

.ai-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    color: white;
}
.ai-panel-header h3 { font-size: 15px; font-weight: 600; flex: 1; }
.ai-panel-header .close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 18px;
    cursor: pointer;
}
.ai-panel-header .close-btn:hover { color: white; }

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    max-height: 320px;
}

.ai-msg {
    margin-bottom: 12px;
    display: flex;
    gap: 8px;
}
.ai-msg.assistant { }
.ai-msg.user { justify-content: flex-end; }

.ai-msg-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
}
.ai-msg.assistant .ai-msg-bubble {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.ai-msg.user .ai-msg-bubble {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-msg-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    width: fit-content;
}
.ai-msg-typing span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}
.ai-msg-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-msg-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

.ai-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}
.ai-input-area input {
    flex: 1;
    padding: 8px 12px !important;
    font-size: 13px;
}
.ai-input-area button {
    padding: 8px 16px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
}
.ai-input-area button:hover { opacity: 0.9; }

.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
}
.ai-suggestion-chip {
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.ai-suggestion-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

@media (max-width: 768px) {
    .ai-panel { width: calc(100% - 32px); right: 16px; bottom: 80px; }
    .ai-assistant-btn { bottom: 16px; right: 16px; }
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: #1a202c; }
.btn-danger { background: var(--danger); color: white; }

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}
.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 6px 12px;
}
.btn-ghost:hover { background: var(--bg-hover); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-icon {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    font-size: 18px;
    transition: all var(--transition);
    position: relative;
    line-height: 1;
}
.btn-icon:hover { background: var(--sidebar-hover); color: white; }

/* ===== Form Elements ===== */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition);
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

textarea { resize: vertical; min-height: 100px; }
select { cursor: pointer; }

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-group .form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ===== App Layout ===== */
.app {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, min-width 0.3s ease;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar.collapsed {
    width: 64px;
    min-width: 64px;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .user-details,
.sidebar.collapsed .badge { display: none; }

.sidebar.collapsed .sidebar-header { justify-content: center; padding: 16px 8px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }
.sidebar.collapsed .nav-icon { margin-right: 0; }
.sidebar.collapsed .sidebar-footer { padding: 12px 8px; }
.sidebar.collapsed .user-info { justify-content: center; }
.sidebar.collapsed .sidebar-actions { justify-content: center; }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-title {
    font-size: 18px;
    font-weight: 700;
    color: white;
    flex: 1;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    transition: var(--transition);
}
.sidebar-toggle:hover { color: white; }

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    border-radius: var(--radius-md);
    margin-bottom: 2px;
    transition: all var(--transition);
    text-decoration: none;
    position: relative;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: white;
    text-decoration: none;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: white;
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-text { font-size: 14px; font-weight: 500; }

/* Nav Groups — department sections */
.nav-group {
    margin-bottom: 4px;
}
.nav-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}
.nav-group-header:hover {
    background: var(--sidebar-hover);
    color: white;
}
.nav-group-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
.nav-group-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
}
.nav-group-arrow {
    font-size: 10px;
    transition: transform 0.2s;
    opacity: 0.6;
}
.nav-group-items {
    padding-left: 8px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s;
    max-height: 500px;
    opacity: 1;
}
.nav-group-items.collapsed {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}
.nav-group-items .nav-item {
    padding: 8px 14px;
    font-size: 13px;
}
.nav-group-items .nav-item .nav-icon {
    font-size: 14px;
}
.nav-group-items .nav-item .nav-text {
    font-size: 13px;
}
/* Collapsed sidebar: hide group text */
.sidebar.collapsed .nav-group-title,
.sidebar.collapsed .nav-group-arrow {
    display: none;
}
.sidebar.collapsed .nav-group-header {
    justify-content: center;
    padding: 12px;
}
.sidebar.collapsed .nav-group-items {
    padding-left: 0;
}
.sidebar.collapsed .nav-group-items .nav-item {
    justify-content: center;
    padding: 10px;
}

/* Placeholder sections for future departments */
.placeholder-section {
    text-align: center;
    padding: 60px 40px;
    max-width: 600px;
    margin: 0 auto;
}
.placeholder-icon {
    font-size: 72px;
    margin-bottom: 16px;
    opacity: 0.8;
}
.placeholder-section h3 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}
.placeholder-section p {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
}
.placeholder-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 24px;
    text-align: left;
}
.placeholder-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.placeholder-feature span {
    font-size: 16px;
}

/* Department Cards — Command Center */
.dept-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}
.dept-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.dept-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}
.dept-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}
.dept-sales::before { background: linear-gradient(90deg, #3B82F6, #10B981); }
.dept-telephony::before { background: linear-gradient(90deg, #8B5CF6, #6366F1); }
.dept-legal::before { background: linear-gradient(90deg, #F59E0B, #F97316); }
.dept-support::before { background: linear-gradient(90deg, #EF4444, #EC4899); }
.dept-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.dept-card-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.dept-card-icon { font-size: 24px; }
.dept-card-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.dept-kpi { text-align: center; }
.dept-kpi-value {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.dept-kpi-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.dept-card-footer {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: auto;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.app-version {
    font-size: 10px;
    color: rgba(255,255,255,0.35);
    text-align: center;
    margin-top: 8px;
    letter-spacing: 0.02em;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--info));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }

.user-name { display: block; color: white; font-size: 13px; font-weight: 500; }
.user-role { display: block; color: var(--sidebar-text); font-size: 11px; }

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .main-content { margin-left: 64px; }

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

.mobile-menu-btn { display: none; }

.topbar-search { flex: 1; max-width: 480px; }

.search-input {
    background: var(--bg-tertiary) !important;
    border: 1px solid transparent !important;
}
.search-input:focus {
    background: var(--bg-primary) !important;
    border-color: var(--accent) !important;
}
.search-input.large { font-size: 16px; padding: 14px 20px; }

.topbar-actions { margin-left: auto; }

.page-container { padding: 16px 24px; flex: 1; }

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.page-header .page-title { margin-bottom: 0; }

/* ===== Cards ===== */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition);
}
.stat-card:hover { transform: translateY(-1px); }

.stat-card .stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}
.stat-card .stat-label {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 3px;
}
.stat-card .stat-change {
    font-size: 10px;
    margin-top: 4px;
    font-weight: 500;
}
.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

.stat-card .stat-icon {
    float: right;
    font-size: 16px;
    opacity: 0.5;
}

/* ===== Dashboard Charts Grid ===== */
.dashboard-charts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.card-compact {
    padding: 10px 12px;
}
.card-compact .card-title {
    font-size: 11px;
    margin-bottom: 6px;
}
.card-compact canvas {
    width: 100%;
    height: 130px;
    display: block;
}

/* ===== Dashboard Grid ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

/* ===== Filters Bar ===== */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.filter-select {
    width: auto !important;
    min-width: 160px;
}

.filter-search {
    width: auto !important;
    min-width: 200px;
    flex: 1;
}

/* ===== CRM Form Inputs ===== */
.form-input { width: 100%; padding: 8px 12px; font-size: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-primary); color: var(--text-primary); box-sizing: border-box; }
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }

/* ===== CRM Data Tables ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--border); }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.data-table tr.clickable-row:hover { background: var(--bg-secondary); }
.data-table tbody tr { transition: background var(--transition); }

.contacts-table, .companies-table { width: 100%; overflow-x: auto; }

/* ===== Kanban Board ===== */
.kanban-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 16px; min-height: 400px; }
.kanban-column { min-width: 240px; max-width: 280px; flex-shrink: 0; background: var(--bg-secondary); border-radius: var(--radius-lg); padding: 0; display: flex; flex-direction: column; }
.kanban-column-header { padding: 12px 14px; border-bottom: 3px solid; font-weight: 600; font-size: 13px; display: flex; align-items: center; justify-content: space-between; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.kanban-column-header .col-count { background: rgba(0,0,0,.1); padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.kanban-column-body { padding: 8px; flex: 1; overflow-y: auto; max-height: 60vh; display: flex; flex-direction: column; gap: 8px; }
.kanban-card { background: var(--bg-primary); border-radius: var(--radius-md); padding: 12px; box-shadow: var(--shadow-sm); cursor: pointer; transition: box-shadow var(--transition), transform var(--transition); border-left: 3px solid transparent; }
.kanban-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kanban-card-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.kanban-card-amount { font-size: 15px; font-weight: 700; color: var(--accent); }
.kanban-card-meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; display: flex; justify-content: space-between; }

/* ===== Tasks List ===== */
.tasks-list { width: 100%; }
.task-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background var(--transition); cursor: pointer; }
.task-row:hover { background: var(--bg-secondary); }
.task-checkbox { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all var(--transition); }
.task-checkbox.done { background: var(--success); border-color: var(--success); color: #fff; }
.task-type-icon { font-size: 16px; flex-shrink: 0; }
.task-info { flex: 1; min-width: 0; }
.task-title { font-weight: 500; font-size: 14px; }
.task-title.done { text-decoration: line-through; color: var(--text-muted); }
.task-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.task-due { font-size: 12px; white-space: nowrap; }
.task-due.overdue { color: var(--danger); font-weight: 600; }
.task-due.today { color: var(--warning); font-weight: 600; }

/* ===== Tickets Table ===== */
.tickets-table { width: 100%; }

.ticket-row {
    display: grid;
    grid-template-columns: 80px 1fr 120px 100px 120px 140px 100px;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition);
}
.ticket-row:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.ticket-row.header {
    background: var(--bg-tertiary);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: default;
}
.ticket-row.header:hover { border-color: var(--border-color); box-shadow: none; }

.ticket-id {
    font-family: monospace;
    font-size: 13px;
    color: var(--accent);
    font-weight: 600;
}

.ticket-title-cell { min-width: 0; }
.ticket-title-cell .title {
    font-weight: 500;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ticket-title-cell .subtitle {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Status & Priority Badges ===== */
.status-badge, .priority-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    gap: 4px;
}

.status-badge.new { background: var(--info-light); color: var(--info); }
.status-badge.assigned { background: var(--accent-light); color: var(--accent); }
.status-badge.in_progress { background: var(--warning-light); color: var(--warning); }
.status-badge.pending { background: var(--bg-tertiary); color: var(--text-muted); }
.status-badge.resolved { background: var(--success-light); color: var(--success); }
.status-badge.closed { background: var(--bg-tertiary); color: var(--text-muted); }

.priority-badge.critical { background: var(--danger-light); color: var(--danger); }
.priority-badge.high { background: #fff0e6; color: #ea580c; }
[data-theme="dark"] .priority-badge.high { background: #431407; color: #fb923c; }
.priority-badge.medium { background: var(--warning-light); color: var(--warning); }
.priority-badge.low { background: var(--success-light); color: var(--success); }

.sla-indicator { font-size: 12px; font-weight: 500; }
.sla-indicator.ok { color: var(--success); }
.sla-indicator.warning { color: var(--warning); }
.sla-indicator.breached { color: var(--danger); font-weight: 600; }

/* ===== Ticket Detail ===== */
.ticket-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

/* Global Back button — big, orange — applies everywhere */
.back-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    color: #fff !important;
    background: #f97316 !important; /* orange-500 */
    border: none !important;
    border-radius: 8px !important;
    font-family: inherit !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    padding: 10px 20px !important;
    cursor: pointer !important;
    margin-bottom: 14px !important;
    box-shadow: 0 2px 6px rgba(249, 115, 22, 0.35) !important;
    transition: background 0.15s ease, transform 0.1s ease !important;
}
.back-btn:hover {
    background: #ea580c !important; /* orange-600 */
    color: #fff !important;
    transform: translateX(-2px);
}
.back-btn:active { transform: translateX(0); }

.ticket-detail-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.ticket-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.ticket-meta-item {
    font-size: 13px;
    color: var(--text-secondary);
}
.ticket-meta-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

.ticket-detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
}

.ticket-description {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    line-height: 1.7;
    white-space: pre-wrap;
}

.ticket-sidebar-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
}

.ticket-sidebar-card h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.sidebar-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}
.sidebar-field:last-child { border-bottom: none; }
.sidebar-field .label { color: var(--text-muted); }
.sidebar-field .value { font-weight: 500; }

/* ===== Comments ===== */
.comments-section { margin-top: 24px; }
.comments-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

.comment {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
}

.comment.internal {
    border-left: 3px solid var(--warning);
    background: var(--warning-light);
}

.comment-body { flex: 1; min-width: 0; }
.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.comment-author { font-size: 13px; font-weight: 600; }
.comment-time { font-size: 12px; color: var(--text-muted); }
.comment-internal-badge {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--warning);
    color: #1a202c;
    border-radius: 4px;
    font-weight: 600;
}
.comment-text { font-size: 14px; line-height: 1.6; white-space: pre-wrap; }

.comment-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-top: 16px;
}
.comment-form textarea { margin-bottom: 10px; }
.comment-form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.comment-form-actions label {
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===== Activity Log ===== */
.activity-log { margin-top: 20px; }

.activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-secondary);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 6px;
    flex-shrink: 0;
}
.activity-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== Attachments ===== */
.attachments { margin-top: 16px; }
.attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-right: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    color: var(--text-secondary);
}
.attachment-item:hover { background: var(--bg-hover); color: var(--accent); }

/* ===== Knowledge Base ===== */
.kb-search { margin-bottom: 24px; }

.kb-categories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.kb-category-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}
.kb-category-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.kb-category-card.active {
    border-color: var(--accent);
    background: var(--accent-light);
}
.kb-category-card .icon { font-size: 28px; margin-bottom: 8px; }
.kb-category-card .name { font-size: 14px; font-weight: 600; }
.kb-category-card .count { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.kb-articles { }

.kb-article-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    cursor: pointer;
    transition: all var(--transition);
}
.kb-article-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.kb-article-card .article-icon { font-size: 24px; flex-shrink: 0; margin-top: 2px; }
.kb-article-card .article-info { flex: 1; min-width: 0; }
.kb-article-card .article-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.kb-article-card .article-excerpt {
    font-size: 13px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.kb-article-card .article-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    display: flex;
    gap: 16px;
}

/* Article Detail */
.article-detail-header {
    margin-bottom: 24px;
}
/* article-detail-header .back-btn — uses global .back-btn styles */
/* article back-btn hover uses global styles */
.article-detail-header h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }

.article-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    line-height: 1.8;
    font-size: 15px;
    white-space: pre-wrap;
}

.article-rating {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
}
.article-rating p { font-size: 14px; color: var(--text-secondary); }

/* ===== Reports ===== */
.reports-controls { margin-bottom: 24px; }

.reports-content .report-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}
.reports-content .report-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.report-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.report-table th, .report-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.report-table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

/* ===== Admin ===== */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-md);
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.admin-table th, .admin-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}
.admin-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}
.admin-table tr:hover td { background: var(--bg-hover); }

/* ===== Notifications Panel ===== */
.notif-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}
.notif-header h3 { font-size: 16px; font-weight: 600; }

.notif-list { flex: 1; overflow-y: auto; padding: 12px; }

.notif-item {
    padding: 12px;
    border-radius: var(--radius-md);
    margin-bottom: 6px;
    cursor: pointer;
    transition: background var(--transition);
    font-size: 13px;
    border-left: 3px solid transparent;
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread {
    background: var(--accent-light);
    border-left-color: var(--accent);
}
.notif-item .notif-title { font-weight: 500; margin-bottom: 2px; }
.notif-item .notif-time { font-size: 11px; color: var(--text-muted); }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: 18px; font-weight: 600; }

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    animation: toastIn 0.3s ease;
    min-width: 300px;
    max-width: 420px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--accent); }

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}
.pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination button.active { background: var(--accent); color: white; border-color: var(--accent); }
.pagination button:disabled { opacity: 0.5; cursor: default; }

/* ===== Recent List ===== */
.recent-list { max-height: 240px; overflow-y: auto; }

.recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background var(--transition);
    font-size: 12px;
}
.recent-item:hover { background: var(--bg-hover); }
.recent-item:last-child { border-bottom: none; }
.recent-item .time { margin-left: auto; color: var(--text-muted); font-size: 11px; white-space: nowrap; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 15px; margin-bottom: 16px; }

/* ===== Tag ===== */
.tag {
    display: inline-flex;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== SLA Progress ===== */
.sla-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}
.sla-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}
.sla-bar-fill.ok { background: var(--success); }
.sla-bar-fill.warning { background: var(--warning); }
.sla-bar-fill.breached { background: var(--danger); }

/* ===== Video Embed ===== */
.video-embed {
    position: relative;
    width: 100%;
    max-width: 640px;
    padding-bottom: 56.25%;
    margin: 16px 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-tertiary);
}
.video-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: var(--radius-lg);
}

.article-content {
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .dashboard-charts-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-charts-grid { grid-template-columns: repeat(2, 1fr); }
    .ticket-detail-grid { grid-template-columns: 1fr; }
    .report-grid { grid-template-columns: 1fr; }
    .ticket-row { grid-template-columns: 60px 1fr 100px 80px 100px; }
    .ticket-row > :nth-child(6),
    .ticket-row > :nth-child(7) { display: none; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 100;
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .mobile-menu-btn { display: flex !important; }
    .topbar { padding: 12px 16px; }
    .page-container { padding: 16px; }
    .ticket-row { grid-template-columns: 50px 1fr 80px; font-size: 12px; }
    .ticket-row > :nth-child(4),
    .ticket-row > :nth-child(5),
    .ticket-row > :nth-child(6),
    .ticket-row > :nth-child(7) { display: none; }
    .filters-bar { flex-direction: column; }
    .filter-select, .filter-search { min-width: 100% !important; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-charts-grid { grid-template-columns: 1fr 1fr; }
    .notif-panel { width: 100%; }
    .modal-content { margin: 10px; }
    .messenger-layout { flex-direction: column; }
    .messenger-sidebar { width: 100%; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--border-color); }
}

/* ===== MESSENGER / CHAT ===== */
.messenger-layout {
    display: flex;
    height: calc(100vh - 80px);
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.messenger-sidebar {
    width: 340px;
    min-width: 280px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.messenger-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}
.messenger-sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.messenger-filters {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}
.messenger-filters .search-input {
    width: 100%;
    margin-bottom: 8px;
    padding: 6px 10px;
    font-size: 13px;
}
.messenger-filter-tabs {
    display: flex;
    gap: 4px;
}
.filter-tab {
    flex: 1;
    padding: 4px 6px;
    font-size: 11px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: all .15s;
    text-align: center;
}
.filter-tab.active, .filter-tab:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background .15s;
}
.conversation-item:hover {
    background: var(--bg-hover);
}
.conversation-item.active {
    background: var(--accent-light);
    border-left: 3px solid var(--accent);
}
.conversation-item .avatar {
    width: 40px;
    height: 40px;
    font-size: 14px;
    flex-shrink: 0;
}
.conv-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.conv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.conv-name {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: 6px;
}
.conv-preview {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
}
.channel-badge {
    display: inline-block;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 3px;
    text-transform: uppercase;
}
.channel-badge.telegram { background: #e3f2fd; color: #0288d1; }
.channel-badge.whatsapp { background: #e8f5e9; color: #2e7d32; }
.channel-badge.viber { background: #f3e5f5; color: #7b1fa2; }
.channel-badge.web { background: #fff3e0; color: #e65100; }
.conv-unread {
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conv-archive-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    opacity: 0;
    transition: opacity 0.15s;
    margin-left: auto;
}
.conversation-item:hover .conv-archive-btn {
    opacity: 0.5;
}
.conv-archive-btn:hover {
    opacity: 1 !important;
}

/* Chat area */
.messenger-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    gap: 12px;
    flex-wrap: wrap;
}
.chat-contact-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-contact-name {
    font-weight: 600;
    font-size: 14px;
}
.chat-channel-badge {
    font-size: 11px;
    color: var(--text-muted);
}
.chat-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.chat-actions .filter-select {
    min-width: 140px;
    font-size: 12px;
    padding: 4px 8px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg-primary);
}

.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}
.chat-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.msg-bubble {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
}
.msg-bubble.inbound {
    align-self: flex-start;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}
.msg-bubble.outbound {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.msg-time {
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.6;
}
.msg-bubble.outbound .msg-time { text-align: right; }
.msg-bubble.inbound .msg-time { text-align: left; }
.msg-sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--accent);
}
.msg-bubble.outbound .msg-sender { color: rgba(255,255,255,0.8); }
.msg-system {
    align-self: center;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 4px 12px;
    border-radius: 12px;
}

/* Chat input */
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    align-items: flex-end;
}
.chat-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    max-height: 120px;
    background: var(--bg-primary);
    color: var(--text-primary);
}
.chat-input:focus {
    outline: none;
    border-color: var(--accent);
}
.chat-send-btn {
    padding: 8px 16px;
    font-size: 16px;
    border-radius: 8px;
    flex-shrink: 0;
}

/* ===== Quick Reply Button & Panel ===== */
.quick-reply-btn {
    font-size: 18px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}
.quick-reply-btn:hover { background: var(--accent-light); border-color: var(--accent); }

.quick-reply-panel {
    position: absolute;
    bottom: 60px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 20;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.qr-panel-header {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
}
.qr-panel-header .search-input { flex: 1; font-size: 13px; padding: 6px 10px; }
.qr-categories {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.qr-cat-btn {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}
.qr-cat-btn:hover, .qr-cat-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.qr-list {
    overflow-y: auto;
    flex: 1;
    padding: 8px;
}
.qr-item {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
}
.qr-item:hover { background: var(--accent-light); }
.qr-item-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.qr-item-text { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ===== AI Suggestion Bar ===== */
.ai-suggestion-bar {
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
    border: 1px solid #93c5fd;
    border-radius: var(--radius-md);
    padding: 12px;
    margin: 0 12px 8px;
}
[data-theme="dark"] .ai-suggestion-bar {
    background: linear-gradient(135deg, #1e3a5f, #1a3a2a);
    border-color: #3b82f6;
}
.ai-suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
}
.ai-suggestion-text {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre-wrap;
    max-height: 100px;
    overflow-y: auto;
    margin-bottom: 8px;
}
.ai-suggestion-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.ai-confidence-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    margin-left: auto;
}
.ai-confidence-high { background: var(--success-light); color: var(--success); }
.ai-confidence-medium { background: var(--warning-light); color: var(--warning); }
.ai-confidence-low { background: var(--danger-light); color: var(--danger); }

/* ===== AI Analytics Page ===== */
.ai-analytics-content { padding: 0; }
.ai-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.ai-stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    text-align: center;
}
.ai-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.ai-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ai-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.ai-chart-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.ai-chart-card h3 { margin: 0 0 16px; font-size: 15px; color: var(--text-secondary); }
.ai-bar-chart { display: flex; flex-direction: column; gap: 8px; }
.ai-bar-row { display: flex; align-items: center; gap: 8px; }
.ai-bar-label { font-size: 12px; color: var(--text-secondary); min-width: 100px; text-align: right; }
.ai-bar-track { flex: 1; height: 22px; background: var(--bg-tertiary); border-radius: 11px; overflow: hidden; position: relative; }
.ai-bar-fill { height: 100%; border-radius: 11px; transition: width 0.5s ease; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; }
.ai-bar-value { font-size: 11px; font-weight: 600; color: #fff; }
.ai-daily-chart { height: 200px; display: flex; align-items: flex-end; gap: 4px; padding-top: 10px; }
.ai-daily-bar { flex: 1; min-width: 8px; border-radius: 4px 4px 0 0; position: relative; transition: height 0.3s ease; cursor: pointer; }
.ai-daily-bar:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--sidebar-bg);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 10;
}
.ai-kb-table { width: 100%; font-size: 13px; }
.ai-kb-table th { text-align: left; padding: 8px; color: var(--text-muted); border-bottom: 1px solid var(--border-light); font-weight: 500; }
.ai-kb-table td { padding: 8px; border-bottom: 1px solid var(--border-light); color: var(--text-secondary); }
.ai-kb-table tr:hover { background: var(--bg-hover); }

/* ===== Contracts / Legal Department ===== */
.contract-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.contract-stat-card { background: var(--bg-secondary); border-radius: 12px; padding: 16px; text-align: center; border: 1px solid var(--border-light); }
.contract-stat-value { font-size: 28px; font-weight: 700; }
.contract-stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.contract-table { width: 100%; border-collapse: collapse; }
.contract-table th { text-align: left; padding: 10px 12px; color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--border-light); }
.contract-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); font-size: 13px; vertical-align: middle; }
.contract-table tr:hover { background: var(--bg-hover); cursor: pointer; }
.contract-table tr.row-draft { border-left: 3px solid #9ca3af; }
.contract-table tr.row-pending { border-left: 3px solid #f59e0b; }
.contract-table tr.row-signed { border-left: 3px solid #10b981; }
.contract-table tr.row-active { border-left: 3px solid var(--accent); }
.contract-table tr.row-terminated { border-left: 3px solid var(--danger); }
.contract-table tr.row-cancelled { border-left: 3px solid #6b7280; }

.contract-status { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.contract-status.status-draft { background: #f3f4f6; color: #6b7280; }
.contract-status.status-pending { background: #fef3c7; color: #92400e; }
.contract-status.status-sent_for_signing { background: #dbeafe; color: #1e40af; }
.contract-status.status-signed { background: #d1fae5; color: #065f46; }
.contract-status.status-active { background: #e0f2fe; color: #075985; }
.contract-status.status-terminated { background: #fee2e2; color: #991b1b; }
.contract-status.status-expired { background: #fef3c7; color: #92400e; }
.contract-status.status-cancelled { background: #f3f4f6; color: #9ca3af; }
.contract-status.status-suspended { background: #fef3c7; color: #78350f; }
.contract-table tr.row-suspended { border-left: 3px solid var(--warning); opacity: 0.7; }
.contract-table tr.row-cancelled { border-left: 3px solid #ccc; opacity: 0.5; }
.pricelist-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; background: #ede9fe; color: #5b21b6; }
.client-type-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; }
.client-type-badge.type-active { background: #d1fae5; color: #065f46; }
.client-type-badge.type-new { background: #dbeafe; color: #1e40af; }
.td-supplier { font-size: 11px; color: #6b7280; }

.contract-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.contract-detail-section { background: var(--bg-secondary); border-radius: 12px; padding: 20px; border: 1px solid var(--border-light); }
.contract-detail-section h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.contract-detail-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border-light); font-size: 13px; }
.contract-detail-row:last-child { border-bottom: none; }
.contract-detail-label { color: var(--text-muted); min-width: 120px; }
.contract-detail-value { color: var(--text-primary); font-weight: 500; text-align: right; }

.contract-party-card { background: var(--bg-primary); border-radius: 10px; padding: 16px; border: 1px solid var(--border-light); }
.contract-party-card h4 { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.contract-party-card .company-name { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.contract-party-card .company-info { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }

.contract-files { margin-top: 16px; }
.contract-file-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg-primary); border-radius: 8px; margin-bottom: 6px; font-size: 13px; }
.contract-file-item:hover { background: var(--bg-hover); }
.contract-file-name { flex: 1; font-weight: 500; }
.contract-file-size { color: var(--text-muted); font-size: 11px; }
.contract-file-download { color: var(--accent); cursor: pointer; font-weight: 600; }

.contract-activity { margin-top: 16px; }
.contract-activity-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-light); font-size: 13px; }
.contract-activity-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.contract-activity-content { flex: 1; }
.contract-activity-action { font-weight: 500; color: var(--text-primary); }
.contract-activity-details { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.contract-activity-time { color: var(--text-muted); font-size: 11px; white-space: nowrap; }

/* Template cards */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.template-card { background: var(--bg-secondary); border-radius: 12px; padding: 20px; border: 1px solid var(--border-light); transition: box-shadow 0.2s; cursor: pointer; }
.template-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.template-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.template-card-title { font-size: 15px; font-weight: 600; }
.template-card-desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.template-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 11px; color: var(--text-muted); }

/* Permissions table */
.permissions-table { width: 100%; border-collapse: collapse; }
.permissions-table th { padding: 10px; text-align: center; font-size: 12px; font-weight: 600; border-bottom: 2px solid var(--border-light); }
.permissions-table th:first-child { text-align: left; }
.permissions-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-light); text-align: center; }
.permissions-table td:first-child { text-align: left; }
.permissions-table select { padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border-light); font-size: 12px; background: var(--bg-primary); }

/* Department badge */
.dept-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; text-transform: uppercase; }
.dept-badge.dept-supply { background: #dbeafe; color: #1e40af; }
.dept-badge.dept-procurement { background: #d1fae5; color: #065f46; }
.dept-badge.dept-services { background: #fef3c7; color: #92400e; }

/* EDO badge */
.edo-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; }
.edo-badge.edo-vchasno { background: #dbeafe; color: #1e40af; }
.edo-badge.edo-medoc { background: #fce7f3; color: #9d174d; }
.edo-badge.edo-original { background: #d1fae5; color: #065f46; }

/* ===== TRAINING — Internal Knowledge Base ===== */
.training-stats {
    display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px;
}
.training-stat-card {
    flex: 1; min-width: 120px; background: var(--bg-secondary); border-radius: 12px;
    padding: 16px; text-align: center; box-shadow: var(--shadow);
}
.training-stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.training-stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; margin-top: 4px; }

.training-progress-bar-container {
    width: 100%; height: 6px; background: var(--bg-primary); border-radius: 3px;
    overflow: hidden; margin-bottom: 24px;
}
.training-progress-bar {
    height: 100%; background: linear-gradient(90deg, var(--accent), var(--success));
    border-radius: 3px; transition: width 0.5s ease;
}

.training-category-section { margin-bottom: 28px; }
.training-category-title {
    font-size: 18px; font-weight: 600; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.training-category-count {
    background: var(--bg-primary); padding: 2px 8px; border-radius: 10px;
    font-size: 12px; color: var(--text-muted); font-weight: 500;
}

.training-articles-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.training-article-card {
    background: var(--bg-secondary); border-radius: 12px; padding: 16px;
    box-shadow: var(--shadow); cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid transparent;
}
.training-article-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.training-article-card.completed { border-left-color: var(--success); opacity: 0.8; }
.training-article-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px;
}
.training-progress-icon { font-size: 16px; }
.training-required-badge {
    background: #fef2f2; color: #dc2626; padding: 2px 8px; border-radius: 10px;
    font-size: 10px; font-weight: 600;
}
.training-difficulty { font-size: 11px; font-weight: 600; }
.training-article-title { font-size: 15px; font-weight: 600; margin: 0 0 6px; line-height: 1.3; }
.training-article-summary { font-size: 13px; color: var(--text-muted); margin: 0 0 10px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.training-article-meta { display: flex; gap: 10px; font-size: 11px; color: var(--text-muted); flex-wrap: wrap; align-items: center; }
.training-tag {
    background: var(--bg-primary); padding: 2px 8px; border-radius: 8px; font-size: 10px;
}

/* Training article view */
.training-article-view { max-width: 800px; }
.training-article-view-meta {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-bottom: 16px; font-size: 13px; color: var(--text-muted);
}
.training-article-progress-badge {
    padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 600;
}
.training-article-progress-badge.status-completed { background: #d1fae5; color: #065f46; }
.training-article-progress-badge.status-in_progress { background: #fef3c7; color: #92400e; }
.training-article-progress-badge.status-not_started { background: #f3f4f6; color: #6b7280; }
.training-article-view-category { font-size: 14px; margin-bottom: 12px; color: var(--text-muted); }
.training-article-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.training-article-body {
    font-size: 15px; line-height: 1.7; color: var(--text-primary);
    background: var(--bg-secondary); border-radius: 12px; padding: 24px;
    box-shadow: var(--shadow); margin-bottom: 16px;
}
.training-article-body h1 { font-size: 22px; margin: 20px 0 8px; }
.training-article-body h2 { font-size: 18px; margin: 18px 0 6px; }
.training-article-body h3 { font-size: 16px; margin: 16px 0 4px; }
.training-article-body code { background: var(--bg-primary); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.training-article-body ul { padding-left: 20px; }
.training-article-author { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.training-article-actions { margin-top: 16px; display: flex; gap: 12px; }
.training-article-completed {
    margin-top: 16px; padding: 12px 16px; background: #d1fae5; color: #065f46;
    border-radius: 8px; font-weight: 500;
}

/* Training categories grid */
.training-categories-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px;
}
.training-category-card {
    background: var(--bg-secondary); border-radius: 12px; padding: 16px;
    box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px;
}
.training-category-card-icon { font-size: 32px; }
.training-category-card-info h4 { margin: 0 0 4px; font-size: 15px; }
.training-category-card-info p { margin: 0 0 4px; font-size: 13px; color: var(--text-muted); }

/* ============================================================
   CLM — Contract Lifecycle Management (Sprint 1)
   ============================================================ */

/* Direction tabs */
.clm-direction-tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.clm-dir-tab {
    padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border-light);
    background: var(--bg-secondary); color: var(--text-secondary); cursor: pointer;
    font-size: 13px; font-weight: 500; transition: all 0.2s;
}
.clm-dir-tab:hover { border-color: var(--accent); color: var(--text-primary); }
.clm-dir-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Amount column */
.td-amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Days remaining badges */
.clm-days { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--bg-primary); color: var(--text-muted); white-space: nowrap; }
.clm-days-warn { background: #FEF3C7; color: #92400E; }
.clm-days-over { background: #FEE2E2; color: #991B1B; }

/* CLM type code in table */
.clm-type-code { font-size: 12px; padding: 2px 6px; border-radius: 4px; background: var(--bg-primary); font-weight: 600; }

/* Wizard steps indicator */
.clm-wizard-steps {
    display: flex; gap: 4px; margin-bottom: 20px; padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}
.clm-step {
    flex: 1; text-align: center; padding: 8px; border-radius: 6px;
    font-size: 13px; color: var(--text-muted); background: var(--bg-primary);
    transition: all 0.2s;
}
.clm-step.active { background: var(--accent); color: #fff; font-weight: 600; }
.clm-step.done { background: var(--success); color: #fff; }

/* Wizard direction radio */
.clm-direction-radio { display: flex; gap: 8px; }
.clm-radio {
    flex: 1; padding: 12px; text-align: center; border-radius: 8px;
    border: 2px solid var(--border-light); cursor: pointer; font-size: 14px;
    transition: all 0.2s;
}
.clm-radio:hover { border-color: var(--accent); }
.clm-radio.active { border-color: var(--accent); background: var(--accent-light); }
.clm-radio input[type="radio"] { display: none; }

/* Review summary */
.clm-review-summary { background: var(--bg-primary); border-radius: 8px; padding: 16px; }
.clm-review-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-light); }
.clm-review-row:last-child { border-bottom: none; }
.clm-review-row span { color: var(--text-muted); }
.clm-review-row strong { color: var(--text-primary); }

/* Contract detail header */
.clm-detail-header { margin-bottom: 16px; }
.clm-detail-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.clm-contract-title { font-size: 15px; color: var(--text-secondary); }
.clm-amount { font-size: 16px; font-weight: 700; color: var(--text-primary); margin-left: auto; }

/* Contract detail tabs */
.clm-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid var(--border-light); padding-bottom: 0; }
.clm-tab {
    padding: 10px 16px; border: none; background: none; cursor: pointer;
    font-size: 13px; color: var(--text-muted); border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all 0.2s;
}
.clm-tab:hover { color: var(--text-primary); }
.clm-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Tab content */
.clm-tab-content { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Approval steps */
.clm-approval-steps { display: flex; flex-direction: column; gap: 12px; }
.clm-approval-step {
    padding: 12px 16px; border-radius: 8px; background: var(--bg-secondary);
    border-left: 3px solid var(--border-light); transition: all 0.2s;
}
.clm-approval-step.step-done { border-left-color: var(--success); background: rgba(16,185,129,0.05); }
.clm-approval-step.step-active { border-left-color: var(--accent); background: rgba(59,130,246,0.05); }
.clm-approval-step.step-rejected { border-left-color: var(--danger); background: rgba(239,68,68,0.05); }
.clm-step-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.clm-step-icon { font-size: 18px; }
.clm-step-num { font-size: 12px; color: var(--text-muted); background: var(--bg-primary); padding: 2px 8px; border-radius: 4px; }
.clm-step-role { font-weight: 500; }
.clm-step-status { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.clm-step-comment { margin-top: 6px; font-size: 13px; color: var(--text-secondary); font-style: italic; }
.clm-step-actions { display: flex; gap: 6px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Addon cards (ДУ, СП) */
.clm-addon-card {
    padding: 12px; border-radius: 8px; background: var(--bg-secondary);
    border-left: 3px solid var(--border-light); margin-bottom: 8px;
}
.clm-addon-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.clm-addon-title { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.clm-addon-actions { display: flex; gap: 6px; margin-top: 8px; }
.row-overdue { background: rgba(239,68,68,0.05); }

/* CLM fields (contract & tender detail) */
.clm-field { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--border-light); gap: 12px; }
.clm-field-label { font-size: 13px; color: var(--text-muted); white-space: nowrap; min-width: 120px; }
.clm-field-value { font-size: 13px; color: var(--text-primary); text-align: right; word-break: break-word; }
.clm-overview-card { background: var(--bg-secondary); border-radius: 10px; padding: 16px; }
.clm-overview-card h4 { margin: 0 0 12px; font-size: 14px; }

/* CLM header */
.clm-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.clm-header h2 { margin: 0; font-size: 20px; }

/* CLM stats bar */
.clm-stats-bar { display: flex; gap: 24px; margin-bottom: 16px; padding: 12px 16px; background: var(--bg-secondary); border-radius: 10px; flex-wrap: wrap; }
.clm-stat { text-align: center; }
.clm-stat-value { display: block; font-size: 22px; font-weight: 700; line-height: 1.2; }
.clm-stat-label { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* CLM tabs */
.clm-tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; border-bottom: 2px solid var(--border-light); padding-bottom: 0; }
.clm-tab { padding: 8px 14px; border: none; background: none; cursor: pointer; font-size: 13px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.clm-tab:hover { color: var(--text-primary); }
.clm-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
/* clm-tab-content: first tab visible, rest hidden via inline style="display:none" */

/* CLM filters */
.clm-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* v196 contract form */
.auto-filled { background-color: #FEF3C7 !important; }
/* Required fields highlight */
.form-input[required], select.form-input[required] { border-color: #ef4444 !important; }
.form-input[required]:valid, select.form-input[required]:valid { border-color: #22c55e !important; }

/* Topbar navigation buttons */
.topbar-nav-btn:hover { background: #f1f5f9 !important; border-color: var(--accent) !important; color: var(--accent) !important; transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.topbar-nav-btn:active { transform: translateY(0); }

/* ============================================================
   Training Module — Sprint 1.1
   ============================================================ */
.kb-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.kb-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
.kb-sidebar h4 { font-size: 13px; color: var(--text-muted); margin: 0 0 8px; text-transform: uppercase; }
.kb-sidebar .kb-cat-list { list-style: none; padding: 0; margin: 0; }
.kb-sidebar .kb-cat-list li { margin-bottom: 4px; }
.kb-sidebar .kb-cat-list a { display: block; padding: 6px 10px; border-radius: 6px; text-decoration: none; font-size: 13px; }
.kb-sidebar .kb-cat-list a:hover { background: #f1f5f9; }
.kb-sidebar .kb-cat-list a.active { background: #e0e7ff; font-weight: 600; }

.kb-main { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.kb-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; cursor: pointer; transition: all .15s ease; }
.kb-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.kb-card h3 { font-size: 14px; margin: 0 0 6px; color: #1e293b; line-height: 1.3; }
.kb-card .kb-summary { font-size: 12px; color: var(--text-muted); margin: 0 0 8px; line-height: 1.4; max-height: 4em; overflow: hidden; }
.kb-card .kb-snippet { font-size: 11px; color: #475569; background: #f8fafc; padding: 6px 8px; border-radius: 4px; margin: 4px 0; }
.kb-card .kb-snippet mark { background: #fef08a; padding: 0 2px; }
.kb-card .kb-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 10px; color: var(--text-muted); }

.kb-badge { padding: 2px 6px; border-radius: 4px; font-size: 9px; font-weight: 600; text-transform: uppercase; }
.kb-badge-internal     { background: #dbeafe; color: #1e40af; }
.kb-badge-product      { background: #d1fae5; color: #065f46; }
.kb-badge-legal        { background: #ede9fe; color: #5b21b6; }
.kb-badge-scripts      { background: #fef3c7; color: #92400e; }
.kb-badge-regulations  { background: #e5e7eb; color: #374151; }
.kb-badge-onboarding   { background: #cffafe; color: #155e75; }
.kb-badge-sales-theory { background: #fee2e2; color: #991b1b; }

.kb-tag { padding: 1px 5px; background: #f1f5f9; border-radius: 3px; font-size: 9px; color: #475569; }
.kb-rating, .kb-views { margin-left: auto; }


/* === Article View (Task 21) === */
.article-page { max-width: 880px; margin: 0 auto; }
.article-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; font-size: 12px; color: var(--text-muted); }
.article-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.btn-active { background: var(--accent) !important; color: #fff !important; }
.article-content { font-size: 15px; line-height: 1.6; color: #1e293b; }
.article-content h1, .article-content h2, .article-content h3 { margin-top: 1.5em; }
.article-content code { background: #f1f5f9; padding: 2px 5px; border-radius: 3px; font-size: 13px;
    font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Menlo', 'Consolas', monospace;
    color: #0f172a; font-variant-ligatures: none; }
.article-content pre { background: #1e293b; color: #f1f5f9; padding: 12px; border-radius: 6px; overflow-x: auto;
    font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Menlo', 'Consolas', monospace;
    font-size: 13px; line-height: 1.35; white-space: pre; tab-size: 4;
    font-variant-ligatures: none; font-feature-settings: 'liga' 0; }
.article-content pre code { background: transparent; color: inherit; padding: 0; }

/* Article view: prev/next/home navigation bar */
.article-nav-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    padding: 10px 12px; margin: 0 0 14px; background: #f8fafc;
    border: 1px solid #e2e8f0; border-radius: 8px; }
.article-nav-bar button[disabled] { opacity: 0.4; cursor: not-allowed; }

/* KB: product hero image gallery (3 imagekit photos under lead paragraph) */
.kb-hero-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px; margin: 16px 0; }
.kb-hero-gallery img { width: 100%; height: 200px; object-fit: contain;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px; }

/* KB: link block to site (category URL + sample SKU table) */
.kb-site-links { background: linear-gradient(to right, #ecfeff, #f0fdfa);
    border: 1px solid #99f6e4; border-radius: 10px; padding: 16px 18px; margin: 24px 0; }
.kb-site-links h2 { margin-top: 0; color: #0f766e; }
.kb-site-links a { color: #0d9488; word-break: break-all; }
.kb-sku-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
.kb-sku-table th { background: #ccfbf1; padding: 8px 10px; text-align: left; font-weight: 600; }
.kb-sku-table td { padding: 8px 10px; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
.kb-sku-table code { background: #fff; padding: 2px 6px; border-radius: 3px; font-size: 12px;
    border: 1px solid #ccfbf1; }
.kb-series-badge { display: inline-block; background: #5eead4; color: #134e4a;
    font-size: 11px; padding: 2px 7px; border-radius: 10px; margin-left: 6px; font-weight: 600; }
.article-content table { border-collapse: collapse; margin: 12px 0; }
.article-content th, .article-content td { border: 1px solid #e2e8f0; padding: 6px 10px; }
.article-content blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: #475569; margin: 12px 0; }
.article-attachments { margin-top: 24px; padding: 14px; background: #f8fafc; border-radius: 6px; }
.article-attachments h4 { margin: 0 0 8px; font-size: 13px; }
.article-attachments ul { list-style: none; padding: 0; margin: 0; }
.article-attachments li { padding: 4px 0; }
.lesson-view { max-width: 880px; margin: 0 auto; }
.lesson-breadcrumb { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.lesson-actions { margin-top: 32px; padding-top: 16px; border-top: 1px solid #e2e8f0; display: flex; gap: 8px; }
.article-comments { margin-top: 32px; }
.article-comments h4 { font-size: 13px; color: var(--text-muted); }
.comment-item { padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.comment-reply { padding-left: 24px; border-left: 2px solid #e2e8f0; }
.comment-form { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; }
.comment-form textarea { flex: 1; }

/* Article Editor (Task 22) */
.article-edit-form { max-width: 880px; margin: 0 auto; }
.article-edit-form .form-row { margin-bottom: 14px; }
.article-edit-form label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.article-edit-form .form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.article-edit-form .form-actions { display: flex; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid #e2e8f0; }

.wysiwyg-toolbar { display: flex; gap: 4px; padding: 6px; background: #f1f5f9; border: 1px solid #e2e8f0; border-bottom: none; border-radius: 6px 6px 0 0; align-items: center; flex-wrap: wrap; }
.wysiwyg-toolbar button { background: #fff; border: 1px solid #cbd5e1; border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.wysiwyg-toolbar button:hover { background: #e2e8f0; }
.wysiwyg-toolbar .sep { color: #cbd5e1; margin: 0 4px; }
.wysiwyg-content { min-height: 320px; max-height: 600px; overflow-y: auto; padding: 14px; background: #fff; border: 1px solid #e2e8f0; border-radius: 0 0 6px 6px; font-size: 14px; line-height: 1.6; }
.wysiwyg-content:focus { outline: 2px solid var(--accent); }

/* === Programs / Enrollments — Sprint 1.2 === */
.my-training-page { max-width: 880px; margin: 0 auto; }
.section-title { font-size: 16px; color: var(--text-muted); margin: 0 0 12px; }
.empty-state { text-align: center; padding: 60px; color: var(--text-muted); }

.enrollment-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.enrollment-card.blocked { opacity: 0.6; background: #f8fafc; }
.enr-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.enr-head h4 { margin: 0; font-size: 15px; }
.enr-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.progress-bar { flex: 1; height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); transition: width .3s ease; }
.progress-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.enr-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }

.badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-warn { background: #fef3c7; color: #92400e; }

/* === Certificates UI — Sprint 1.4 === */
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }

.timeline-list { list-style: none; padding: 0; }
.timeline-item { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; display: flex; gap: 12px; align-items: center; }
.timeline-item.urgent { background: #fef2f2; border-left: 3px solid var(--danger); }
.timeline-deadline { font-size: 11px; font-weight: 600; color: var(--accent); min-width: 80px; }

/* Enrollment Detail */
.enrollment-detail { max-width: 880px; margin: 0 auto; }
.enr-detail-head { margin-bottom: 24px; padding-bottom: 12px; border-bottom: 2px solid #e2e8f0; }
.enr-detail-head h3 { margin: 0 0 4px; }
.module-section { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.module-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 6px; }
.module-purpose { font-size: 12px; color: var(--text-muted); margin: 0 0 10px; font-style: italic; }
.lesson-list { list-style: none; padding: 0; margin: 0 0 8px; }
.lesson-list li { padding: 6px 10px; display: flex; gap: 8px; align-items: center; cursor: pointer; border-radius: 4px; }
.lesson-list li:hover { background: #f1f5f9; }
.lesson-title { flex: 1; }
.assignment-row { padding: 8px 10px; background: #fef3c7; border-radius: 4px; display: flex; gap: 8px; align-items: center; cursor: pointer; margin-top: 4px; }
.assignment-row:hover { background: #fde68a; }
.quiz-row { padding: 8px 10px; background: #ede9fe; border-radius: 4px; display: flex; gap: 8px; align-items: center; cursor: pointer; margin-top: 4px; }
.quiz-row:hover { background: #ddd6fe; }
.quiz-row-meta { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.submission-text { background: #f8fafc; padding: 12px; border-radius: 4px; margin: 8px 0; max-height: 240px; overflow-y: auto; white-space: pre-wrap; }
.module-edit-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.module-edit-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.lesson-edit-list { list-style: none; padding: 0; margin: 0 0 8px; }
.lesson-edit-list li { padding: 6px 10px; background: #f8fafc; border-radius: 4px; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }

/* === Quiz Editor — Sprint 1.3 === */
.quiz-edit-page { max-width: 880px; margin: 0 auto; }
.quiz-edit-head { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid #e2e8f0; }
.question-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.question-card-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.question-text { margin: 8px 0; }
.option-list { list-style: none; padding: 0; margin: 8px 0; }
.option-list li { padding: 4px 10px; background: #f8fafc; border-radius: 4px; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.opt-marker { font-family: monospace; font-weight: 600; min-width: 28px; color: var(--accent); }
.question-explain { background: #fef3c7; padding: 8px 12px; border-radius: 4px; font-size: 13px; margin-top: 8px; }

.opt-edit-list { list-style: none; padding: 0; margin: 8px 0; }
.opt-edit-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }

/* === Quiz Take — Sprint 1.3 === */
.quiz-take-page { max-width: 800px; margin: 0 auto; }
.qt-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.qt-timer { font-family: monospace; font-size: 20px; font-weight: 600; padding: 6px 12px; background: #f1f5f9; border-radius: 6px; }
.qt-progress { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; margin-bottom: 20px; }
.qt-progress-fill { height: 100%; background: var(--accent); transition: width .3s ease; }
.qt-question { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 20px; margin-bottom: 16px; }
.qt-q-text { font-size: 16px; margin: 0 0 16px; }
.qt-answer { display: flex; flex-direction: column; gap: 0; }
.qt-opt { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 6px; margin-bottom: 6px; cursor: pointer; align-items: center; }
.qt-opt:hover { background: #f8fafc; }
.qt-nav { display: flex; justify-content: space-between; margin-top: 16px; }

.qt-ordered ol, .qt-ordered ul { list-style: none; padding-left: 0; margin: 8px 0; }
.qt-ord-selected { margin: 8px 0; }
.qt-ord-selected li { padding: 6px 10px; background: #dcfce7; border-radius: 4px; margin-bottom: 4px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.qt-ord-pool { margin: 8px 0; }
.qt-ord-pool li { padding: 6px 10px; background: #f1f5f9; border-radius: 4px; margin-bottom: 4px; cursor: pointer; list-style: none; }
.qt-ord-pool li:hover { background: #dbeafe; }

.qt-match { }
.qt-match-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 12px 0; }
.qt-match-opt { padding: 12px; background: #f8fafc; border: 2px solid #e2e8f0; border-radius: 6px; cursor: pointer; text-align: center; }
.qt-match-opt:hover { background: #dbeafe; }
.qt-match-opt.pending { border-color: var(--accent); background: #dbeafe; }
.qt-match-opt.paired { background: #dcfce7; border-color: #16a34a; opacity: 0.6; cursor: not-allowed; }
#qtMatchPairs { list-style: none; padding: 0; margin: 8px 0; }
#qtMatchPairs li { padding: 6px 10px; background: #dcfce7; border-radius: 4px; margin-bottom: 4px; display: flex; justify-content: space-between; align-items: center; }

/* === Quiz Result — Sprint 1.3 === */
.qt-result-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 32px; text-align: center; margin-bottom: 24px; }
.qt-result-score { font-size: 56px; font-weight: 700; line-height: 1; margin: 12px 0 4px; }
.qt-result-label { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.qt-result-answers { margin-top: 16px; }
.qt-result-answers h4 { margin-bottom: 10px; }
.qt-result-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 6px; margin-bottom: 6px; }
.qt-result-row.correct { background: #dcfce7; }
.qt-result-row.wrong { background: #fee2e2; }
.qt-result-row.pending { background: #fef3c7; }
.qt-result-q { flex: 1; margin-right: 12px; }
.qt-result-status { white-space: nowrap; font-weight: 500; }

/* === Quiz Result detailed breakdown — Sprint 1.3 === */
.quiz-result-page { max-width: 800px; margin: 0 auto; }
.result-banner { padding: 16px; border-radius: 8px; text-align: center; font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.result-pass { background: #dcfce7; color: #166534; }
.result-fail { background: #fee2e2; color: #991b1b; }
.result-pending { background: #fef3c7; color: #92400e; }
.result-summary { display: flex; gap: 32px; padding: 20px; background: #f8fafc; border-radius: 8px; align-items: center; }
.result-score { font-size: 48px; font-weight: 700; color: var(--accent); }
.result-score small { font-size: 24px; color: #64748b; }
.result-stats { font-size: 14px; }
.result-stats > div { margin-bottom: 4px; }
.result-q { border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; margin-bottom: 10px; background: #fff; }
.result-q.q-correct { border-color: #22c55e; background: #f0fdf4; }
.result-q.q-wrong { border-color: #ef4444; background: #fef2f2; }
.result-q.q-pending { border-color: #f59e0b; background: #fffbeb; }
.result-q.q-skipped { border-color: #cbd5e1; background: #f8fafc; }
.result-q-head { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 14px; }
.result-q-body > div { margin-top: 6px; font-size: 13px; }
.result-q-body ol, .result-q-body ul { margin: 4px 0 0 16px; padding: 0; }
.open-answer { background: #f1f5f9; padding: 8px 10px; border-radius: 4px; white-space: pre-wrap; }
.correct-answer { color: #16a34a; }
.explanation { background: #fef3c7; padding: 6px 10px; border-radius: 4px; }
.ai-feedback { background: #dbeafe; padding: 6px 10px; border-radius: 4px; font-style: italic; }

/* === AI Chat Sidebar — Sprint 1.5 === */
#aiChatFab {
    position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px;
    border-radius: 50%; background: #6366f1; color: #fff; border: none;
    font-size: 24px; cursor: pointer; box-shadow: 0 4px 12px rgba(99,102,241,0.4);
    z-index: 1000; transition: transform 0.2s;
}
#aiChatFab:hover { transform: scale(1.1); }

#aiChatSidebar {
    position: fixed; top: 0; right: 0; width: 420px; height: 100vh;
    background: #fff; box-shadow: -4px 0 16px rgba(0,0,0,0.1);
    z-index: 1001; display: flex; flex-direction: column;
    animation: slideIn 0.2s ease-out;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.ai-chat-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
.ai-chat-head h4 { margin: 0; }

.ai-chat-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.ai-chat-empty p { text-align: center; color: var(--text-muted); margin: 32px 0 12px; }
.ai-chat-suggestions { display: flex; flex-direction: column; gap: 6px; }
.ai-chat-suggestions button { padding: 8px 12px; background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 6px; cursor: pointer; text-align: left; font-size: 12px; }
.ai-chat-suggestions button:hover { background: #e0e7ff; }

.ai-chat-turn { margin-bottom: 16px; font-size: 13px; }
.ai-chat-turn.user { padding: 8px 10px; background: #dbeafe; border-radius: 6px; }
.ai-chat-turn.assistant .ai-msg { padding: 8px 10px; background: #f8fafc; border-radius: 6px; white-space: pre-wrap; }
.ai-citations { font-size: 11px; color: var(--text-muted); margin-top: 6px; padding-left: 8px; border-left: 2px solid #cbd5e1; }
.ai-citations ul { padding-left: 16px; margin: 4px 0; }
.ai-citations a { color: var(--accent); text-decoration: none; }
.ai-citations a:hover { text-decoration: underline; }
.ai-feedback { margin-top: 6px; display: flex; gap: 4px; }
.ai-feedback button { background: none; border: 1px solid #e2e8f0; padding: 2px 8px; border-radius: 4px; cursor: pointer; font-size: 14px; }
.ai-feedback button:hover { background: #f1f5f9; }

.ai-chat-input-row { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid #e2e8f0; align-items: flex-end; }
.ai-chat-input-row textarea { flex: 1; resize: vertical; }

/* === Analytics Dashboards — Sprint 1.6 === */
.analytics-page { max-width: 1100px; margin: 0 auto; }
.analytics-stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.analytics-stat-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; text-align: center; }
.analytics-stat-card-big { background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%); color: #fff; border: none; }
.analytics-stat-card-big .analytics-stat-label { color: rgba(255,255,255,0.85); }
.analytics-stat-num { font-size: 28px; font-weight: 700; line-height: 1.1; }
.analytics-stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.analytics-mini-bar { display: inline-block; width: 80px; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; vertical-align: middle; }
.analytics-mini-bar-fill { height: 100%; background: var(--accent); }

.analytics-simple-list { list-style: none; padding: 0; margin: 8px 0; }
.analytics-simple-list li { padding: 6px 10px; border-bottom: 1px solid #f1f5f9; }

/* Funnel chart */
.funnel-page { max-width: 800px; margin: 0 auto; }
.funnel-bars { margin-top: 24px; }
.funnel-step { display: grid; grid-template-columns: 160px 1fr 60px; gap: 12px; align-items: center; margin-bottom: 10px; }
.funnel-label { font-size: 13px; }
.funnel-bar { height: 32px; background: linear-gradient(90deg, var(--accent), #818cf8); border-radius: 4px; position: relative; min-width: 24px; transition: width 0.3s; }
.funnel-num { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: #fff; font-size: 12px; font-weight: 600; }
.funnel-pct { font-weight: 600; font-size: 14px; color: var(--accent); text-align: right; }
.funnel-final .funnel-bar { background: linear-gradient(90deg, #16a34a, #4ade80); }

/* ╔══════════════════════════════════════════════════════════════════════════╗
   ║  MODERN UI v5.14 — POLISH LAYER                                          ║
   ║  Refined design tokens, sidebar gradient, glass topbar, micro-animations  ║
   ║  Loads last → overrides legacy styles with same specificity              ║
   ╚══════════════════════════════════════════════════════════════════════════╝ */

/* ── Refined tokens ──────────────────────────────────────────────────────── */
:root, [data-theme="light"] {
    /* refined neutrals */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;

    /* punchier accent palette */
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: #eef2ff;
    --accent-glow: 0 0 0 4px rgba(99, 102, 241, 0.12);

    /* status with subtle warmth */
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #3b82f6;
    --info-light: #eff6ff;

    /* deep navy sidebar */
    --sidebar-bg: #0f172a;
    --sidebar-bg-2: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #6366f1;
    --sidebar-hover: #1e293b;

    /* layered shadows */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.10), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
    --shadow-xl: 0 25px 50px -12px rgba(15, 23, 42, 0.20);

    /* radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 9999px;

    --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Typography polish ───────────────────────────────────────────────────── */
body {
    font-feature-settings: 'cv11', 'ss01', 'ss03';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.005em;
}
h1, h2, h3, h4, .page-title {
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.page-title { font-size: 22px; font-weight: 700; }

/* ── Sidebar: gradient + glow active ─────────────────────────────────────── */
.sidebar {
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: 4px 0 24px -8px rgba(15, 23, 42, 0.10);
}
.sidebar-header {
    padding: 18px 16px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-title {
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}
.nav-item {
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 13.5px;
    font-weight: 500;
    transition: all var(--transition);
    border: 1px solid transparent;
}
.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    text-decoration: none;
    transform: translateX(2px);
}
.nav-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.20) 0%, rgba(99, 102, 241, 0.08) 100%);
    color: #fff;
    border-color: rgba(99, 102, 241, 0.25);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 2px;
    background: var(--sidebar-active);
    box-shadow: 0 0 8px var(--sidebar-active);
}
.nav-group-header {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 11px;
    font-weight: 600;
    color: rgba(203, 213, 225, 0.55);
    padding: 12px 14px 6px;
    cursor: pointer;
    transition: color var(--transition);
}
.nav-group-header:hover { color: rgba(255, 255, 255, 0.8); }

/* ── Top bar: glass + cleaner search ─────────────────────────────────────── */
.topbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-xs);
}
.topbar input[type="text"],
.topbar input[type="search"],
.topbar .search-input {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 9px 14px 9px 38px;
    background: var(--bg-tertiary) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>") no-repeat 12px center;
    transition: all var(--transition);
}
.topbar input[type="text"]:focus,
.topbar input[type="search"]:focus,
.topbar .search-input:focus {
    outline: none;
    border-color: var(--accent);
    background-color: #fff;
    box-shadow: var(--accent-glow);
}
.topbar-nav-btn {
    border-radius: var(--radius-md) !important;
    transition: all var(--transition) !important;
}
.topbar-nav-btn:hover {
    border-color: var(--accent) !important;
    color: var(--accent) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* ── Buttons: subtle gradient + lift ─────────────────────────────────────── */
.btn {
    border-radius: var(--radius-md);
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: all var(--transition);
    box-shadow: var(--shadow-xs);
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    box-shadow: 0 1px 3px rgba(99, 102, 241, 0.25), 0 1px 2px rgba(99, 102, 241, 0.10);
}
.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.30);
    transform: translateY(-1px);
}
.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.25);
}
.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.25);
}
.btn-outline {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* ── Cards: soft elevation + lift ────────────────────────────────────────── */
.card, .kb-card, .kb-cat-card, .program-card, .lesson-card,
.empty-state, .stats-card, .reviews-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}
.kb-card { padding: 16px; }
.kb-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}
.kb-card h3 { font-size: 15px; color: var(--text-primary); margin: 0 0 8px; line-height: 1.4; }

/* ── KB sidebar categories ───────────────────────────────────────────────── */
.kb-sidebar {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-xs);
}
.kb-sidebar h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 0 0 10px;
    font-weight: 600;
}
.kb-cat-list li a {
    display: block;
    padding: 7px 10px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13.5px;
    transition: all var(--transition);
}
.kb-cat-list li a:hover {
    background: var(--accent-light);
    color: var(--accent);
    text-decoration: none;
    transform: translateX(2px);
}
.kb-cat-list li a.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

/* ── Filter bar / toolbar polish ─────────────────────────────────────────── */
.kb-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    margin-bottom: 16px;
}
.form-input, .filter-select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-size: 13.5px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all var(--transition);
}
.form-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--accent-glow);
}

/* ── Modal: backdrop blur + smooth pop-in ────────────────────────────────── */
.modal-overlay {
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fadeIn 0.2s ease-out;
}
.modal {
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    animation: scaleIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Article view: refined typography ────────────────────────────────────── */
.article-page { max-width: 920px; padding: 8px 4px; }
.article-content { font-size: 16px; line-height: 1.75; color: var(--text-primary); }
.article-content h2 {
    font-size: 22px; margin-top: 2em; margin-bottom: 0.6em;
    padding-bottom: 0.4em; border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}
.article-content h3 { font-size: 17px; margin-top: 1.5em; color: var(--text-primary); font-weight: 600; }
.article-content p { margin: 0.8em 0; }
.article-content table {
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    margin: 14px 0;
}
.article-content thead { background: var(--bg-tertiary); }
.article-content th { font-weight: 600; color: var(--text-primary); font-size: 13.5px; }
.article-content tbody tr:nth-child(even) { background: var(--bg-tertiary); }
.article-content blockquote {
    background: var(--accent-light);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin: 14px 0;
    color: var(--text-secondary);
}
.article-content .callout {
    background: linear-gradient(135deg, #fef9c3 0%, #fef3c7 100%);
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin: 16px 0;
}
.article-content .callout p { margin: 0; }

/* ── Article navigation bar (prev/next/home) ─────────────────────────────── */
.article-nav-bar {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    box-shadow: var(--shadow-xs);
}

/* ── Tags / Badges ───────────────────────────────────────────────────────── */
.kb-tag {
    display: inline-block;
    padding: 3px 9px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 500;
}
.kb-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.kb-badge-internal     { background: #e0e7ff; color: #4338ca; }
.kb-badge-product      { background: #dcfce7; color: #15803d; }
.kb-badge-legal        { background: #f3e8ff; color: #6b21a8; }
.kb-badge-scripts      { background: #ffedd5; color: #c2410c; }
.kb-badge-regulations  { background: #f1f5f9; color: #334155; }
.kb-badge-onboarding   { background: #cffafe; color: #155e75; }
.kb-badge-sales-theory { background: #fee2e2; color: #b91c1c; }
.kb-badge-support      { background: #e0f2fe; color: #075985; }

/* ── Tables (admin) ──────────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border-collapse: separate;
    border-spacing: 0;
}
.data-table thead { background: var(--bg-tertiary); }
.data-table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13.5px;
    color: var(--text-primary);
}
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-tertiary); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table code {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: ui-monospace, 'SF Mono', monospace;
}

/* ── Page section header ─────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-light);
}

/* ── Loading shimmer (replaces "Завантаження…") ──────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 0%, var(--bg-hover) 50%, var(--bg-tertiary) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-md);
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Toast / Notification ────────────────────────────────────────────────── */
.toast, .notification {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ── Empty states ────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state .icon {
    font-size: 48px;
    opacity: 0.4;
    margin-bottom: 12px;
}

/* ── Hero stats for "My programs" landing ────────────────────────────────── */
.kb-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.kb-stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-xs);
    position: relative;
    overflow: hidden;
}
.kb-stat-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    background: radial-gradient(circle, var(--accent-light), transparent 70%);
    opacity: 0.7;
}
.kb-stat-card .num {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.03em;
    line-height: 1.1;
}
.kb-stat-card .lbl {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 600;
}

/* ── Progress bar (programs) ─────────────────────────────────────────────── */
.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: 8px 0;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, #818cf8 100%);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}
.progress-fill.done { background: linear-gradient(90deg, var(--success) 0%, #34d399 100%); box-shadow: 0 0 8px rgba(16, 185, 129, 0.3); }

/* ── Quick reading time / meta badges ────────────────────────────────────── */
.article-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ── Dark theme refinements ──────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg-primary: #0a0e1a;
    --bg-secondary: #131826;
    --bg-tertiary: #1c2333;
    --bg-hover: #1e2638;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: #1e2638;
    --border-light: #1a2030;
    --accent-light: rgba(99, 102, 241, 0.15);
}
[data-theme="dark"] .topbar { background: rgba(19, 24, 38, 0.85); }
[data-theme="dark"] .article-content .callout {
    background: linear-gradient(135deg, rgba(254, 249, 195, 0.06) 0%, rgba(254, 243, 199, 0.04) 100%);
    border-color: rgba(253, 230, 138, 0.2);
}

/* ── Responsive niceties ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .page-title { font-size: 18px; }
    .kb-toolbar { padding: 10px; }
    .article-content { font-size: 15px; }
    .article-content h2 { font-size: 19px; }
    .kb-stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ════════════════════════════════════════════════════════════════════════════
   LESSON VIEW v5.14 — sidebar with module tree, breadcrumbs, status banners
   ════════════════════════════════════════════════════════════════════════════ */

/* Lesson layout: left sidebar with all modules/lessons + main article */
.lesson-view-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    max-width: 1240px;
    margin: 0 auto;
}
@media (max-width: 1024px) {
    .lesson-view-layout { grid-template-columns: 1fr; }
    .lesson-sidebar { position: static !important; max-height: none !important; }
}

.lesson-sidebar {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-xs);
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    font-size: 13px;
}
.lesson-sidebar h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 14px;
    font-weight: 600;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}
.lesson-sidebar-module { margin-bottom: 14px; }
.lesson-sidebar-module.active .lsm-head {
    color: var(--accent);
    font-weight: 600;
}
.lesson-sidebar-module .lsm-head {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1.3;
}
.lesson-sidebar-module ul {
    list-style: none;
    padding: 0 0 0 12px;
    margin: 0;
    border-left: 2px solid var(--border-light);
}
.lesson-sidebar-module ul li {
    padding: 4px 0;
    font-size: 12.5px;
    line-height: 1.4;
}
.lesson-sidebar-module ul li a {
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.lesson-sidebar-module ul li a:hover {
    background: var(--accent-light);
    color: var(--accent);
}
.lesson-sidebar-module ul li.current a {
    background: var(--accent);
    color: white;
    font-weight: 500;
}
.lesson-sidebar-module ul li.done a {
    color: var(--success);
}
.lesson-sidebar-module ul li.done.current a {
    background: var(--success);
    color: white;
}

/* Main lesson area */
.lesson-main {
    max-width: 880px;
    width: 100%;
}

/* Breadcrumbs (chevron-separated path) */
.lesson-breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-muted);
    padding: 10px 0 18px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 18px;
}
.lesson-breadcrumbs a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}
.lesson-breadcrumbs a:hover {
    color: var(--accent);
    text-decoration: underline;
}
.lesson-breadcrumbs span { color: var(--text-muted); }
.lesson-breadcrumbs .muted { color: var(--text-muted); }
.lesson-breadcrumbs strong {
    color: var(--text-primary);
    font-weight: 600;
}

.lesson-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 12px;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

/* Status banners (quiz progress) */
.lesson-status-banner {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    margin: 16px 0 24px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid;
}
.lesson-status-banner.done {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: #6ee7b7;
    color: #065f46;
}
.lesson-status-banner.ready {
    background: linear-gradient(135deg, #ecfeff 0%, #cffafe 100%);
    border-color: #67e8f9;
    color: #155e75;
}
.lesson-status-banner.pending {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-color: #fcd34d;
    color: #92400e;
}

/* Code blocks: copy button */
.pre-wrap { position: relative; margin: 14px 0; }
.pre-wrap pre { margin: 0; }
.pre-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.10);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    opacity: 0;
    backdrop-filter: blur(4px);
}
.pre-wrap:hover .pre-copy-btn { opacity: 1; }
.pre-copy-btn:hover {
    background: rgba(255, 255, 255, 0.20);
    color: white;
    border-color: rgba(255, 255, 255, 0.30);
}

/* Lesson actions: bottom CTA bar */
.lesson-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 32px;
    padding: 18px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

/* ════════════════════════════════════════════════════════════════════════════
   LESSON QUIZ BLOCK v5.14.5 — prominent test card at end of article
   ════════════════════════════════════════════════════════════════════════════ */

.lesson-quiz-block {
    margin: 32px 0 24px;
    padding: 24px 28px;
    border-radius: var(--radius-xl);
    border: 2px solid;
    background: var(--bg-secondary);
}
.lesson-quiz-block.pending {
    border-color: #fcd34d;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}
.lesson-quiz-block.failed {
    border-color: #fca5a5;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}
.lesson-quiz-block.passed {
    border-color: #6ee7b7;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
}
.lesson-quiz-block.missing {
    border-color: var(--border-color);
    background: var(--bg-tertiary);
}

.lqb-header {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}
.lqb-icon {
    font-size: 42px;
    line-height: 1;
    flex-shrink: 0;
}
.lqb-text h3 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.lqb-text p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}
.lqb-text strong { color: var(--text-primary); }
.lqb-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 4px;
}
.btn-lg {
    padding: 12px 22px !important;
    font-size: 14.5px !important;
    font-weight: 600;
}

/* Sidebar single-lesson item (when module has only 1 lesson) */
.lesson-sidebar-item {
    margin-bottom: 6px;
    padding: 2px 0;
}
.lesson-sidebar-item a {
    display: block;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    line-height: 1.35;
    color: var(--text-primary);
    text-decoration: none;
    border: 1px solid transparent;
    transition: all var(--transition);
}
.lesson-sidebar-item a:hover {
    background: var(--accent-light);
    color: var(--accent);
    border-color: rgba(99, 102, 241, 0.15);
}
.lesson-sidebar-item.current a {
    background: var(--accent);
    color: white;
    font-weight: 600;
    border-color: var(--accent);
}
.lesson-sidebar-item.done a {
    color: var(--success);
}
.lesson-sidebar-item.done.current a {
    background: var(--success);
    color: white;
}

/* ════════════════════════════════════════════════════════════════════════════
   POLISH v5.14.6 — tighter line-height, dark theme contrast, list spacing
   ════════════════════════════════════════════════════════════════════════════ */

/* Tighter typography in articles — was too airy */
.article-content { line-height: 1.6; font-size: 15.5px; }
.article-content p { margin: 0.6em 0; }
.article-content ul, .article-content ol { margin: 0.5em 0; padding-left: 24px; }
.article-content li { margin: 4px 0; line-height: 1.55; }
/* Bullet/numbered lists with nested <p> (common from AI-generated content) */
.article-content li > p,
.article-content li > p:first-child,
.article-content li > p:last-child { margin: 0; }
.article-content li > ul, .article-content li > ol { margin: 4px 0; }
.article-content h2 { margin-top: 1.5em; margin-bottom: 0.5em; }
.article-content h3 { margin-top: 1.2em; margin-bottom: 0.4em; }
.article-content table { margin: 12px 0; }
.article-content table td, .article-content table th { padding: 7px 10px; line-height: 1.4; }

/* ────────────────────────── DARK THEME — full coverage ───────────────────── */
[data-theme="dark"] {
    --bg-primary: #0b1020;
    --bg-secondary: #141b2d;
    --bg-tertiary: #1c2438;
    --bg-hover: #1e2740;
    --text-primary: #e8edf5;
    --text-secondary: #b4bdcd;
    --text-muted: #7a8499;
    --border-color: #232c44;
    --border-light: #1c2438;
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --accent-light: rgba(129, 140, 248, 0.16);
    --success: #34d399;
    --success-light: rgba(52, 211, 153, 0.15);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);
}
[data-theme="dark"] body { background: var(--bg-primary); color: var(--text-primary); }
[data-theme="dark"] .topbar { background: rgba(20, 27, 45, 0.85); border-bottom-color: var(--border-color); }

/* Force backgrounds on common card/panel classes that hardcoded white */
[data-theme="dark"] .kb-card,
[data-theme="dark"] .enrollment-card,
[data-theme="dark"] .module-section,
[data-theme="dark"] .lesson-sidebar,
[data-theme="dark"] .kb-stat-card,
[data-theme="dark"] .kb-sidebar,
[data-theme="dark"] .kb-toolbar,
[data-theme="dark"] .data-table,
[data-theme="dark"] .article-nav-bar,
[data-theme="dark"] .form-input,
[data-theme="dark"] .filter-select,
[data-theme="dark"] .modal {
    background: var(--bg-secondary) !important;
    color: var(--text-primary);
    border-color: var(--border-color);
}
[data-theme="dark"] .data-table thead,
[data-theme="dark"] .data-table tbody tr:hover,
[data-theme="dark"] .article-content thead { background: var(--bg-tertiary) !important; }
[data-theme="dark"] .article-content tbody tr:nth-child(even) { background: var(--bg-tertiary); }
[data-theme="dark"] .data-table th,
[data-theme="dark"] .data-table td { color: var(--text-primary); border-color: var(--border-light); }

/* Lesson cards / progress bars / titles in dark */
[data-theme="dark"] .enrollment-card { background: var(--bg-secondary); border-color: var(--border-color); }
[data-theme="dark"] .enrollment-card h3,
[data-theme="dark"] .enrollment-card h4,
[data-theme="dark"] .enr-head h4,
[data-theme="dark"] .module-head,
[data-theme="dark"] .lesson-title,
[data-theme="dark"] .lesson-breadcrumbs strong,
[data-theme="dark"] .article-content h1,
[data-theme="dark"] .article-content h2,
[data-theme="dark"] .article-content h3,
[data-theme="dark"] .article-content h4 { color: var(--text-primary); }
[data-theme="dark"] .progress-bar { background: var(--bg-tertiary); }
[data-theme="dark"] .progress-label,
[data-theme="dark"] .enr-meta,
[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }

/* Modal in dark */
[data-theme="dark"] .modal { background: var(--bg-secondary); }
[data-theme="dark"] .modal-overlay { background: rgba(0, 0, 0, 0.7); }

/* Article callouts in dark */
[data-theme="dark"] .article-content .callout {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.08), rgba(254, 243, 199, 0.04));
    border-color: rgba(251, 191, 36, 0.25);
    color: var(--text-primary);
}
[data-theme="dark"] .article-content blockquote {
    background: var(--accent-light);
    color: var(--text-primary);
}
[data-theme="dark"] .article-content code {
    background: rgba(255, 255, 255, 0.08);
    color: #fbbf24;
    border-color: var(--border-color);
}

/* Lesson quiz block in dark */
[data-theme="dark"] .lesson-quiz-block.pending {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(245, 158, 11, 0.06));
    border-color: rgba(251, 191, 36, 0.35);
}
[data-theme="dark"] .lesson-quiz-block.passed {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.12), rgba(16, 185, 129, 0.06));
    border-color: rgba(52, 211, 153, 0.35);
}
[data-theme="dark"] .lesson-quiz-block.failed {
    background: linear-gradient(135deg, rgba(248, 113, 113, 0.12), rgba(239, 68, 68, 0.06));
    border-color: rgba(248, 113, 113, 0.35);
}
[data-theme="dark"] .lesson-quiz-block.missing { background: var(--bg-tertiary); }
[data-theme="dark"] .lqb-text h3 { color: var(--text-primary); }
[data-theme="dark"] .lqb-text p { color: var(--text-secondary); }
[data-theme="dark"] .lqb-text strong { color: var(--text-primary); }

/* Status banners in dark */
[data-theme="dark"] .lesson-status-banner.done {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.12), rgba(16, 185, 129, 0.05));
    border-color: rgba(52, 211, 153, 0.3);
    color: #6ee7b7;
}
[data-theme="dark"] .lesson-status-banner.pending {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(245, 158, 11, 0.05));
    border-color: rgba(251, 191, 36, 0.3);
    color: #fbbf24;
}
[data-theme="dark"] .lesson-status-banner.ready {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(6, 182, 212, 0.05));
    border-color: rgba(34, 211, 238, 0.3);
    color: #67e8f9;
}

/* Inputs/selects in dark */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] textarea,
[data-theme="dark"] select,
[data-theme="dark"] .form-input,
[data-theme="dark"] .filter-select {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .topbar input[type="text"] {
    background-color: var(--bg-tertiary);
}

/* Buttons in dark */
[data-theme="dark"] .btn-outline {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}
[data-theme="dark"] .btn-outline:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}
[data-theme="dark"] .topbar-nav-btn {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* KB hero gallery white image bg in dark */
[data-theme="dark"] .kb-hero-gallery img {
    background: #fff;
    border-color: var(--border-color);
}

/* KB site-links in dark */
[data-theme="dark"] .kb-site-links {
    background: linear-gradient(to right, rgba(13, 148, 136, 0.12), rgba(15, 118, 110, 0.06));
    border-color: rgba(20, 184, 166, 0.3);
}
[data-theme="dark"] .kb-site-links h2 { color: #5eead4; }
[data-theme="dark"] .kb-site-links a { color: #5eead4; }
[data-theme="dark"] .kb-sku-table th { background: rgba(20, 184, 166, 0.18); color: var(--text-primary); }
[data-theme="dark"] .kb-sku-table td { border-color: var(--border-color); color: var(--text-primary); }

/* Lesson sidebar in dark */
[data-theme="dark"] .lesson-sidebar-item a,
[data-theme="dark"] .lesson-sidebar-module .lsm-head { color: var(--text-primary); }
[data-theme="dark"] .lesson-sidebar-module ul { border-color: var(--border-color); }
[data-theme="dark"] .lesson-sidebar-module ul li a { color: var(--text-secondary); }
[data-theme="dark"] .lesson-sidebar-module ul li a:hover { background: var(--accent-light); color: var(--accent); }

/* ===================== SALARY CALCULATOR (.salc-*) ===================== */
.salc-wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.salc-breadcrumbs { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.salc-breadcrumbs a { color: var(--accent); text-decoration: none; }
.salc-breadcrumbs a:hover { text-decoration: underline; }
.salc-bc-sep { margin: 0 6px; color: var(--text-muted); }
.salc-back { display: inline-block; margin-bottom: 14px; padding: 7px 14px; border: 1px solid var(--border-color);
  border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--text-secondary); text-decoration: none; background: var(--bg-secondary); }
.salc-back:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--accent); }
.salc-h1 { font-size: 26px; font-weight: 800; color: var(--text-primary); margin: 0 0 6px; }
.salc-sub { color: var(--text-secondary); font-size: 14px; line-height: 1.5; margin: 0 0 16px; }
.salc-tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 2px solid var(--border-color); margin-bottom: 20px; }
.salc-tab { border: none; background: transparent; padding: 10px 14px; font-size: 14px; font-weight: 600;
  color: var(--text-secondary); cursor: pointer; border-radius: 8px 8px 0 0; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.salc-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.salc-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--accent-light); }
.salc-panel { display: none; }
.salc-panel.active { display: block; animation: salcFade .2s ease; }
@keyframes salcFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.salc-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.salc-card { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 12px; padding: 18px 18px 20px; margin-bottom: 16px; }
.salc-card-h { font-size: 16px; font-weight: 700; color: var(--text-primary); margin: 0 0 12px; }
.salc-field { display: block; margin-bottom: 12px; }
.salc-field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.salc-input { width: 100%; box-sizing: border-box; padding: 9px 11px; border: 1px solid var(--border-color);
  border-radius: 8px; font-size: 14px; background: var(--warning-light); color: var(--text-primary); }
.salc-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
select.salc-input { background: var(--bg-secondary); }
.salc-input.salc-mini { padding: 6px 8px; font-size: 13px; }
.salc-hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.salc-result-card { background: linear-gradient(180deg, var(--success-light), var(--bg-secondary)); border-color: var(--success); }
.salc-total-box { text-align: center; padding: 10px 0 14px; }
.salc-total { font-size: 40px; font-weight: 900; color: var(--success); line-height: 1.1; }
.salc-total-cap { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.salc-breakdown { width: 100%; border-collapse: collapse; margin-top: 6px; }
.salc-breakdown td { padding: 8px 4px; border-bottom: 1px solid var(--border-light); font-size: 14px; color: var(--text-secondary); }
.salc-breakdown td.salc-num { text-align: right; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.salc-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.salc-badge { font-size: 12px; background: var(--bg-tertiary); color: var(--text-secondary); padding: 4px 10px; border-radius: 20px; }
.salc-badge b { color: var(--accent); }
.salc-table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; }
.salc-table th { text-align: left; font-size: 12px; color: var(--text-muted); padding: 6px 8px; border-bottom: 2px solid var(--border-color); }
.salc-table td { padding: 5px 8px; font-size: 13px; color: var(--text-secondary); border-bottom: 1px solid var(--border-light); }
.salc-table td.salc-num { text-align: right; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.salc-out { margin-top: 10px; font-size: 15px; color: var(--text-secondary); }
.salc-out b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.salc-tu b { color: var(--success); font-weight: 800; }
.salc-btn { margin-top: 12px; background: var(--accent); color: #fff; border: none; padding: 10px 16px;
  border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.salc-btn:hover { background: var(--accent-hover); }
@media (max-width: 820px) {
  .salc-cols { grid-template-columns: 1fr; }
  .salc-total { font-size: 34px; }
  .salc-tab { padding: 8px 10px; font-size: 13px; }
}

/* ===================== MANAGER DASHBOARD (.mdash-*) ===================== */
.mdash { padding: 4px 0 40px; }
.mdash-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.mdash-title { margin: 0; font-size: 22px; font-weight: 800; color: var(--text-primary); }
.mdash-sub { margin: 2px 0 0; color: var(--text-muted); font-size: 14px; }
.mdash-testbanner { margin: 12px 0 18px; background: var(--warning-light); color: #92400e;
  border: 1px solid var(--warning); border-radius: 10px; padding: 10px 14px; font-size: 13px; }
[data-theme="dark"] .mdash-testbanner { color: var(--warning); }
.mdash-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.mdash-kpi { display: flex; align-items: center; gap: 12px; background: var(--bg-secondary);
  border: 1px solid var(--border-color); border-radius: 12px; padding: 16px; }
.mdash-kpi-ico { font-size: 26px; line-height: 1; }
.mdash-kpi-val { font-size: 22px; font-weight: 800; color: var(--text-primary); line-height: 1.1; }
.mdash-kpi-lbl { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.mdash-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.mdash-w2 { grid-column: span 2; }
.mdash-card { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 12px; padding: 16px; }
.mdash-card-h { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.mdash-tag { font-size: 10px; font-weight: 600; background: var(--warning-light); color: #92400e;
  padding: 2px 7px; border-radius: 20px; text-transform: uppercase; letter-spacing: .04em; }
[data-theme="dark"] .mdash-tag { color: var(--warning); }
.mdash-accent { background: linear-gradient(180deg, var(--success-light), var(--bg-secondary)); border-color: var(--success); }
.mdash-danger { background: linear-gradient(180deg, var(--danger-light), var(--bg-secondary)); border-color: var(--danger); }
.mdash-money { font-size: 28px; font-weight: 900; color: var(--success); line-height: 1.1; }
.mdash-danger .mdash-money { color: var(--danger); }
.mdash-money-cap { font-size: 12px; color: var(--text-muted); margin: 2px 0 10px; }
.mdash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mdash-table th { text-align: left; font-size: 11px; color: var(--text-muted); font-weight: 600; padding: 6px 8px; border-bottom: 2px solid var(--border-color); }
.mdash-table td { padding: 7px 8px; border-bottom: 1px solid var(--border-light); color: var(--text-secondary); }
.mdash-table th.r, .mdash-table td.r { text-align: right; }
.mdash-table td.r { font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; }
.mdash-total td { font-weight: 800; color: var(--text-primary); border-top: 2px solid var(--border-color); border-bottom: none; }
.mdash-mini { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.mdash-mini td { padding: 4px 0; color: var(--text-secondary); }
.mdash-mini td.r { text-align: right; color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.mdash-list { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-secondary); }
.mdash-list li { margin: 3px 0; }
.mdash-pill { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.mdash-pill.ok { background: var(--success-light); color: var(--success); }
.mdash-pill.mid { background: var(--warning-light); color: #92400e; }
.mdash-pill.low { background: var(--danger-light); color: var(--danger); }
.mdash-pill.info { background: var(--accent-light); color: var(--accent); }
.mdash-in { color: var(--success); font-weight: 700; font-variant-numeric: tabular-nums; }
.mdash-date { font-size: 11px; font-weight: 600; color: var(--text-muted); background: var(--bg-tertiary); padding: 2px 7px; border-radius: 6px; }
.mdash-table tbody tr { transition: background .12s; }
.mdash-table tbody tr:hover { background: var(--bg-hover); }
.mdash-table tbody tr.mdash-total:hover { background: transparent; }
.mdash-two { display: flex; gap: 24px; }
.mdash-three { display: flex; gap: 16px; }
.mdash-num { font-size: 26px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.mdash-num-lbl { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
@media (max-width: 1100px) { .mdash-kpis { grid-template-columns: repeat(2, 1fr); } .mdash-grid { grid-template-columns: repeat(2, 1fr); } .mdash-w2 { grid-column: span 2; } }
@media (max-width: 720px) { .mdash-kpis { grid-template-columns: 1fr; } .mdash-grid { grid-template-columns: 1fr; } .mdash-w2 { grid-column: span 1; } }

/* ===================== Конкурентні продажі (competitor_sales) ===================== */
.cs-loading, .cs-empty { padding: 24px; text-align: center; color: var(--text-muted); }
.cs-muted { color: var(--text-muted); font-size: 12px; }
.cs-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.cs-title { font-size: 22px; font-weight: 800; margin: 0; }
.cs-sub { color: var(--text-muted); margin: 4px 0 0; font-size: 13px; }

.cs-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.cs-kpi { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 12px; padding: 14px 16px; }
.cs-kpi-val { font-size: 20px; font-weight: 800; color: var(--accent); }
.cs-kpi-lbl { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.cs-card { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.cs-card-h { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.cs-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.cs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cs-table th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border-color); color: var(--text-muted); font-weight: 600; font-size: 12px; }
.cs-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-light); }
.cs-table tbody tr:hover { background: var(--bg-hover); }
.cs-table .r, .cs-table th.r { text-align: right; }
.cs-table-sm th, .cs-table-sm td { padding: 5px 8px; font-size: 12px; }
.cs-dup-row { opacity: 0.5; text-decoration: line-through; }

.cs-badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.cs-badge.ok { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.cs-badge.mid { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.cs-badge.low { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.cs-badge.info { background: var(--accent-light); color: var(--accent); }

/* charts */
.cs-svg { width: 100%; height: auto; display: block; }
.cs-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; font-size: 12px; }
.cs-legend-item { display: inline-flex; align-items: center; gap: 5px; color: var(--text-muted); }
.cs-legend-item i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.cs-hbars { display: flex; flex-direction: column; gap: 8px; }
.cs-hbar { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 10px; font-size: 12px; }
.cs-hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-hbar-track { background: var(--bg-tertiary); border-radius: 6px; height: 16px; overflow: hidden; }
.cs-hbar-fill { background: linear-gradient(90deg, var(--accent), var(--accent-hover)); height: 100%; border-radius: 6px; }
.cs-hbar-val { font-weight: 600; white-space: nowrap; }

/* tabs */
.cs-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.cs-tab { padding: 8px 14px; border: 1px solid var(--border-color); background: var(--bg-secondary); border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text-muted); }
.cs-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.cs-filterbar { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.cs-filterbar select { min-width: 220px; }

/* import wizard */
.cs-import { max-width: 760px; }
.cs-prev-info { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; padding: 10px 0; border-bottom: 1px solid var(--border-light); margin-bottom: 12px; }
.cs-dup-report { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.cs-dup-report.ok { background: color-mix(in srgb, var(--success) 12%, transparent); }
.cs-dup-report.warn { background: color-mix(in srgb, var(--warning) 14%, transparent); }
.cs-dup-block { margin-top: 8px; }
.cs-details { margin: 10px 0; }
.cs-details summary { cursor: pointer; font-weight: 600; font-size: 13px; padding: 4px 0; }
.cs-dedup-mode { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; font-size: 13px; }

/* buyer card */
.cs-buyer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.cs-buyer-kpis { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; padding: 10px 0; border-bottom: 1px solid var(--border-light); margin-bottom: 12px; }
.cs-registries { display: flex; gap: 8px; flex-wrap: wrap; }
.cs-registries a { font-size: 12px; padding: 3px 10px; border: 1px solid var(--border-color); border-radius: 20px; color: var(--accent); text-decoration: none; }
.cs-registries a:hover { background: var(--accent-light); }
.cs-oc { padding: 12px; border-radius: 10px; margin-bottom: 12px; font-size: 13px; }
.cs-oc.ok { background: color-mix(in srgb, var(--success) 12%, transparent); border: 1px solid color-mix(in srgb, var(--success) 35%, transparent); }
.cs-oc.mid { background: color-mix(in srgb, var(--warning) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); }
.cs-oc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px 16px; margin-top: 8px; }

/* lead CRM */
.cs-lead-block { border: 1px solid var(--border-color); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.cs-lead-block.cs-locked { opacity: 0.92; background: var(--bg-tertiary); }
.cs-lead-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.cs-lead-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.cs-lead-fields label, .cs-lead-notes { display: flex; flex-direction: column; font-size: 12px; gap: 3px; color: var(--text-muted); }
.cs-lead-notes { margin-top: 8px; }
.cs-lead-timeline { margin-top: 12px; border-top: 1px solid var(--border-light); padding-top: 10px; }
.cs-act-form { display: grid; grid-template-columns: 140px 1fr auto; gap: 8px; margin-bottom: 10px; }
.cs-acts { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow: auto; }
.cs-act { display: flex; gap: 10px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--border-light); }
.cs-act-type { font-size: 16px; }

@media (max-width: 1100px) { .cs-grid2 { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .cs-hbar { grid-template-columns: 110px 1fr auto; } .cs-act-form { grid-template-columns: 1fr; } }

/* ===================== Конкурентні продажі — Фаза 2 (ліди/воронка/обогащення) ===================== */
.cs-lead-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.cs-odb { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; padding: 8px 10px; background: var(--bg-tertiary); border-radius: 8px; margin-bottom: 10px; }
.cs-kanban { display: grid; grid-template-columns: repeat(5, minmax(180px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; }
.cs-col { background: var(--bg-tertiary); border-radius: 10px; padding: 10px; min-height: 80px; }
.cs-col-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 13px; }
.cs-lead-kard { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: pointer; font-size: 12px; }
.cs-lead-kard:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.cs-lead-kard.cs-overdue { border-left: 3px solid var(--danger); }
.cs-lk-name { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.cs-lk-row { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.cs-lk-status { margin-top: 8px; font-size: 11px; padding: 3px 6px; }
.cs-od-date { color: var(--danger); font-weight: 600; }
@media (max-width: 900px) { .cs-kanban { grid-template-columns: repeat(2, minmax(160px, 1fr)); } }

/* ===================== Конкурентні продажі — Фаза 3 (дашборд обзвону) ===================== */
.cs-callcard { max-width: 820px; }
.cs-callcard-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.cs-talkpoints { margin: 6px 0 14px; padding-left: 20px; font-size: 13px; line-height: 1.7; }
.cs-talkpoints li { margin-bottom: 4px; }
@media print { .sidebar, .topbar, .cs-callcard-actions, .cs-registries { display: none !important; } }

/* ── Competitor Sales · Phase 3 §9/§10 (near-clone warn + dup-viewer) ── */
.cs-nearclone-warn { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: #fff7e6; border: 1px solid #ffd591; color: #874d00; font-size: 13px; }
.cs-nearclone-warn b { color: #ad6800; }
.cs-nearclone-warn table { margin-top: 8px; }
.cs-excl-near { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-weight: 600; cursor: pointer; }
.cs-excl-near input { width: auto; }
.cs-excl-info { background: #f0f5ff; border: 1px solid #adc6ff; color: #1d39c4; }
.cs-dupview { display: flex; flex-direction: column; }
.cs-dupview .cs-tabs { flex-wrap: wrap; gap: 6px; }
.cs-dupview .cs-card { padding: 12px; }

/* ── Competitor Sales · Phase 4 §3/§4 (lead-base + buyer-detail page) ── */
.cs-buyer-groups { width: 100%; }
.cs-grp-row { cursor: pointer; background: #f7f9fc; }
.cs-grp-row:hover { background: #eef3fb; }
.cs-grp-caret { display: inline-block; width: 14px; color: var(--accent); font-size: 11px; }
.cs-grp-products td { background: #fff; padding: 0 0 8px 0; }
.cs-client-block a { color: var(--accent); font-weight: 600; }
.cs-client-stats { display: flex; gap: 16px; margin-top: 8px; flex-wrap: wrap; font-size: 13px; }
.cs-lead-card .cs-lead-form { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 8px 0; }
.cs-lead-form label { display: flex; flex-direction: column; font-size: 12px; color: var(--text-muted, #667); gap: 2px; }
.cs-lead-form .cs-full { grid-column: 1 / -1; }
.cs-lead-form textarea { min-height: 48px; resize: vertical; }
.cs-lead-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cs-inline { display: inline-block; width: auto; padding: 2px 6px; }
.cs-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.cs-sortable:hover { color: var(--accent); }
.cs-pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 12px; }
.cs-claim-dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.cs-row-hidden { background: #f0f0f0 !important; color: #888; }
.cs-row-hidden td { opacity: 0.75; }
.cs-hidden-banner { background: #f0f0f0; border: 1px solid #ccc; color: #666; padding: 8px 12px; border-radius: 8px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }

/* §5a: звільнені користувачі — сірий рядок */
.user-fired { background: #f0f0f0; color: #888; }
.user-fired td { opacity: 0.8; }
