:root {
    /* Brand Colors */
    --primary: #0D9488;
    --primary-light: #14B8A6;
    --primary-dark: #0F766E;
    --primary-50: #F0FDFA;
    --primary-100: #CCFBF1;
    --primary-200: #99F6E4;
    --primary-500: #14B8A6;
    --primary-600: #0D9488;
    --primary-700: #0F766E;
    --primary-800: #115E59;
    --primary-900: #134E4A;

    /* Accent */
    --accent: #F59E0B;
    --accent-light: #FBBF24;
    --accent-dark: #D97706;

    /* Semantic */
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;

    /* Light Theme (default) */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8FAFC;
    --bg-tertiary: #F1F5F9;
    --bg-hover: #E2E8F0;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-tertiary: #94A3B8;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --sidebar-bg: #0F172A;
    --sidebar-text: #CBD5E1;
    --sidebar-hover: #1E293B;
    --sidebar-active: var(--primary);
    --card-bg: #FFFFFF;
    --input-bg: #FFFFFF;
    --input-border: #CBD5E1;
    --input-focus: var(--primary);
    --table-header-bg: #F8FAFC;
    --table-stripe: #F8FAFC;
    --badge-bg: var(--primary-50);
    --badge-text: var(--primary-700);
    --overlay: rgba(0,0,0,0.5);
    --code-bg: #F1F5F9;

    /* Spacing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 64px;
    --header-height: 64px;
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Transitions */
    --transition: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-tertiary: #334155;
    --bg-hover: #475569;
    --text-primary: #F1F5F9;
    --text-secondary: #CBD5E1;
    --text-tertiary: #64748B;
    --border: #334155;
    --border-light: #1E293B;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
    --sidebar-bg: #020617;
    --sidebar-text: #94A3B8;
    --sidebar-hover: #0F172A;
    --card-bg: #1E293B;
    --input-bg: #1E293B;
    --input-border: #475569;
    --table-header-bg: #1E293B;
    --table-stripe: #1E293B;
    --badge-bg: rgba(13,148,136,0.15);
    --badge-text: #5EEAD4;
    --overlay: rgba(0,0,0,0.7);
    --code-bg: #1E293B;
}

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

html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
    -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; height: auto; }

button, input, select, textarea {
    font-family: inherit; font-size: inherit;
    color: var(--text-primary);
}

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

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-slow);
    min-width: 0;
}

.app-main.collapsed { margin-left: var(--sidebar-collapsed); }

.app-content {
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ============================================ */
/* SIDEBAR */
/* ============================================ */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-slow), transform var(--transition-slow);
    overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

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

.sidebar-brand .brand-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; color: white; font-size: 16px;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    color: white; font-weight: 700; font-size: 15px;
    white-space: nowrap; overflow: hidden;
}

.sidebar-brand .brand-sub {
    color: var(--sidebar-text); font-size: 11px; opacity: 0.7;
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .brand-sub,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-arrow { display: none; }

.sidebar-nav {
    flex: 1; overflow-y: auto; padding: 12px 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.nav-section { margin-bottom: 8px; }

.nav-label {
    display: block;
    padding: 8px 12px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--sidebar-text);
    opacity: 0.5;
}

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

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

.nav-item.active {
    background: var(--primary);
    color: white;
    font-weight: 500;
}

.nav-item .nav-icon {
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 16px;
}

.nav-item .nav-text { flex: 1; font-size: 13.5px; white-space: nowrap; }

.nav-badge {
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ============================================ */
/* HEADER */
/* ============================================ */
.app-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    z-index: 100;
    transition: background var(--transition), border var(--transition);
}

.header-toggle {
    display: none;
    background: none; border: none; cursor: pointer;
    color: var(--text-secondary); font-size: 22px;
    padding: 4px;
}

.header-search {
    flex: 1; max-width: 480px;
    position: relative;
}

.header-search input {
    width: 100%;
    padding: 8px 12px 8px 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    font-size: 13px;
    transition: all var(--transition);
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,148,136,0.1);
}

.header-search .search-icon {
    position: absolute;
    left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-tertiary);
}

.header-actions {
    display: flex; align-items: center; gap: 8px;
    margin-left: auto;
}

.header-btn {
    position: relative;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; cursor: pointer;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: all var(--transition);
    font-size: 18px;
}

.header-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.header-btn .badge-dot {
    position: absolute; top: 6px; right: 6px;
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
}

.user-menu {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 8px 4px 4px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
}

.user-menu:hover { background: var(--bg-tertiary); }

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

.user-info { line-height: 1.3; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-role { font-size: 11px; color: var(--text-tertiary); }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 220px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    padding: 4px;
    animation: dropdownFade 0.15s ease;
}

.dropdown-menu.show { display: block; }

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

.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}

.dropdown-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: #FEF2F2; }
[data-theme="dark"] .dropdown-item.danger:hover { background: rgba(239,68,68,0.1); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ============================================ */
/* CARDS */
/* ============================================ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: background var(--transition), border var(--transition);
}

.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.card-title {
    font-size: 15px; font-weight: 600;
    color: var(--text-primary);
}

.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); }

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

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.teal { background: var(--primary-50); color: var(--primary); }
.stat-icon.amber { background: #FEF3C7; color: var(--accent-dark); }
.stat-icon.blue { background: #DBEAFE; color: #2563EB; }
.stat-icon.green { background: #D1FAE5; color: #059669; }
.stat-icon.red { background: #FEE2E2; color: #DC2626; }
.stat-icon.purple { background: #EDE9FE; color: #7C3AED; }

[data-theme="dark"] .stat-icon.teal { background: rgba(13,148,136,0.15); }
[data-theme="dark"] .stat-icon.amber { background: rgba(245,158,11,0.15); }
[data-theme="dark"] .stat-icon.blue { background: rgba(37,99,235,0.15); }
[data-theme="dark"] .stat-icon.green { background: rgba(5,150,105,0.15); }
[data-theme="dark"] .stat-icon.red { background: rgba(220,38,38,0.15); }
[data-theme="dark"] .stat-icon.purple { background: rgba(124,58,237,0.15); }

.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

/* ============================================ */
/* TABLES */
/* ============================================ */
.table-wrapper { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.data-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--table-header-bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

table.data-table tbody tr:nth-child(even) { background: var(--table-stripe); }
table.data-table tbody tr:hover { background: var(--bg-hover); }

/* ============================================ */
/* FORMS */
/* ============================================ */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.form-group { margin-bottom: 16px; }

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

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(13,148,136,0.1);
}

textarea.form-control { resize: vertical; min-height: 80px; }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-hint { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ============================================ */
/* BUTTONS */
/* ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.5;
}

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

.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }

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

.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #DC2626; color: white; }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 6px 8px; }

/* ============================================ */
/* BADGES & STATUS */
/* ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-teal { background: var(--badge-bg); color: var(--badge-text); }
.badge-green { background: #D1FAE5; color: #065F46; }
.badge-red { background: #FEE2E2; color: #991B1B; }
.badge-amber { background: #FEF3C7; color: #92400E; }
.badge-blue { background: #DBEAFE; color: #1E40AF; }
.badge-purple { background: #EDE9FE; color: #5B21B6; }
.badge-gray { background: var(--bg-tertiary); color: var(--text-secondary); }

[data-theme="dark"] .badge-green { background: rgba(16,185,129,0.15); color: #6EE7B7; }
[data-theme="dark"] .badge-red { background: rgba(239,68,68,0.15); color: #FCA5A5; }
[data-theme="dark"] .badge-amber { background: rgba(245,158,11,0.15); color: #FCD34D; }
[data-theme="dark"] .badge-blue { background: rgba(59,130,246,0.15); color: #93C5FD; }
[data-theme="dark"] .badge-purple { background: rgba(124,58,237,0.15); color: #C4B5FD; }

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.active { background: var(--success); }
.status-dot.pending { background: var(--warning); }
.status-dot.inactive { background: var(--text-tertiary); }
.status-dot.error { background: var(--danger); }

/* ============================================ */
/* PAGINATION */
/* ============================================ */
.pagination { margin-top: 20px; }
.pagination-list {
    display: flex; align-items: center; gap: 4px;
    list-style: none; justify-content: center;
}
.pagination-link {
    display: flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition);
}
.pagination-link:hover { background: var(--bg-tertiary); border-color: var(--primary); color: var(--primary); }
.pagination-link.active { background: var(--primary); border-color: var(--primary); color: white; }
.pagination-ellipsis { padding: 0 8px; color: var(--text-tertiary); }

/* ============================================ */
/* ALERTS & FLASH MESSAGES */
/* ============================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex; align-items: flex-start; gap: 10px;
}
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-danger { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-info { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

[data-theme="dark"] .alert-success { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.2); }
[data-theme="dark"] .alert-warning { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.2); }
[data-theme="dark"] .alert-danger { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.2); }
[data-theme="dark"] .alert-info { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.2); }

/* ============================================ */
/* MODAL */
/* ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show { display: flex; }

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.2s ease;
}

.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }

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

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text-tertiary); padding: 4px; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

/* ============================================ */
/* AI CHAT WIDGET */
/* ============================================ */
.ai-chat-btn {
    position: fixed;
    bottom: 24px; right: 24px;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    cursor: pointer;
    font-size: 24px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(13,148,136,0.4);
    z-index: 1500;
    transition: all var(--transition);
}

.ai-chat-btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(13,148,136,0.5); }

.ai-chat-panel {
    display: none;
    position: fixed;
    bottom: 92px; right: 24px;
    width: 400px;
    height: 520px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    z-index: 1500;
    flex-direction: column;
    overflow: hidden;
}

.ai-chat-panel.open { display: flex; animation: modalSlide 0.2s ease; }

.ai-chat-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex; align-items: center; gap: 10px;
}

.ai-chat-header h4 { font-size: 14px; font-weight: 600; }

.ai-chat-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
}

.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
    align-self: flex-start;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-msg.assistant p { margin-bottom: 8px; }
.chat-msg.assistant p:last-child { margin-bottom: 0; }
.chat-msg.assistant strong { color: var(--primary); }
.chat-msg.assistant ul { padding-left: 18px; margin: 6px 0; }
.chat-msg.assistant li { margin-bottom: 4px; }

.ai-chat-input {
    display: flex; gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.ai-chat-input input {
    flex: 1; padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--input-bg);
    font-size: 13px;
}

.ai-chat-input input:focus { outline: none; border-color: var(--primary); }

/* ============================================ */
/* TABS */
/* ============================================ */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab-link {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.tab-link:hover { color: var(--text-primary); }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ============================================ */
/* UTILITIES */
/* ============================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-tertiary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* Page Title */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.page-subtitle { font-size: 13px; color: var(--text-tertiary); margin-top: 2px; }

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-tertiary); margin-bottom: 16px; }
.breadcrumb a { color: var(--text-tertiary); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { opacity: 0.4; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-tertiary);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 13px; max-width: 400px; margin: 0 auto; }

/* QR Code Display */
.qr-card {
    text-align: center;
    padding: 24px;
    background: white;
    border-radius: var(--radius);
    display: inline-block;
}
.qr-card img { width: 200px; height: 200px; }
.qr-card p { font-size: 11px; color: var(--text-tertiary); margin-top: 8px; }

/* Staff ID Card Preview */
.id-card-preview {
    width: 340px;
    background: linear-gradient(135deg, #0F766E, #134E4A);
    border-radius: 12px;
    color: white;
    padding: 24px;
    position: relative;
    overflow: hidden;
}
.id-card-preview::before {
    content: '';
    position: absolute;
    top: -30px; right: -30px;
    width: 120px; height: 120px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}
.id-card-preview .id-logo { font-size: 14px; font-weight: 700; margin-bottom: 20px; }
.id-card-preview .id-photo {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    margin: 0 auto 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}
.id-card-preview .id-name { font-size: 16px; font-weight: 600; text-align: center; }
.id-card-preview .id-title { font-size: 11px; opacity: 0.8; text-align: center; margin-bottom: 16px; }
.id-card-preview .id-qr { background: white; padding: 8px; border-radius: 6px; display: inline-block; }
.id-card-preview .id-qr img { width: 80px; height: 80px; }
.id-card-preview .id-footer { display: flex; justify-content: space-between; font-size: 10px; opacity: 0.6; margin-top: 12px; }

/* Notification Panel */
.notif-panel {
    position: absolute;
    top: calc(100% + 8px); right: 0;
    width: 380px;
    max-height: 480px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
    display: none;
}
.notif-panel.show { display: block; animation: dropdownFade 0.15s ease; }
.notif-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.notif-header h4 { font-size: 14px; font-weight: 600; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item {
    display: flex; gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background var(--transition);
}
.notif-item:hover { background: var(--bg-tertiary); }
.notif-item.unread { background: var(--primary-50); }
[data-theme="dark"] .notif-item.unread { background: rgba(13,148,136,0.05); }
.notif-dot { width: 8px; height: 8px; background: var(--primary); border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.notif-content { flex: 1; }
.notif-content p { font-size: 12px; color: var(--text-secondary); }
.notif-content .notif-time { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }

/* ============================================ */
/* LOGIN PAGE */
/* ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0F172A 0%, #134E4A 100%);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

[data-theme="dark"] .login-card { background: var(--bg-secondary); }

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

.login-logo .logo-icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800; color: white; font-size: 22px;
    margin-bottom: 12px;
}

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

.login-card .form-control { margin-bottom: 16px; }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }

/* ============================================ */
/* RESPONSIVE */
/* ============================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .app-main { margin-left: 0 !important; }
    .header-toggle { display: flex; }
    .stats-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .app-content { padding: 16px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .card-header { flex-direction: column; align-items: flex-start; }
    .user-info { display: none; }
    .header-search { display: none; }
    .ai-chat-panel { width: calc(100vw - 48px); right: 24px; left: 24px; bottom: 80px; }
    .notif-panel { width: calc(100vw - 48px); right: -12px; }
    .modal { margin: 8px; max-height: 90vh; }
    .id-card-preview { width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 24px; }
}

/* Mobile sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* Print */
@media print {
    .sidebar, .app-header, .ai-chat-btn, .ai-chat-panel { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .app-content { padding: 0; }
    .card { break-inside: avoid; border: 1px solid #ddd; }
}

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