/* ===== 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;
}

/* ===== 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;
}

.ticket-detail-header .back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    margin-bottom: 12px;
    background: none;
    border: none;
    font-family: inherit;
    padding: 0;
}
.ticket-detail-header .back-btn:hover { color: var(--accent); }

.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 {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    margin-bottom: 12px;
    background: none;
    border: none;
    font-family: inherit;
    padding: 0;
}
.article-detail-header .back-btn:hover { color: var(--accent); }
.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;
}

/* 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 { display: none; }
.clm-tab-content.active, .clm-tab-content[style*="display: block"] { display: block; }

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

/* v196 contract form */
.auto-filled { background-color: #FEF3C7 !important; }
