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

.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);
}

.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: 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: 24px;
    font-weight: 700;
    margin-bottom: 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.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: 20px;
    box-shadow: var(--shadow-sm);
}

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

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

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

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}
.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}
.stat-card .stat-change {
    font-size: 11px;
    margin-top: 6px;
    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: 20px;
    opacity: 0.5;
}

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

.card-compact {
    padding: 12px 16px;
}
.card-compact .card-title {
    font-size: 12px;
    margin-bottom: 8px;
}
.card-compact canvas {
    width: 100%;
    height: 160px;
    display: block;
}

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

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

/* ===== 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: 300px; overflow-y: auto; }

.recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background var(--transition);
    font-size: 13px;
}
.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; }
}
