:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --purple: #7c3aed;
    --purple-light: #ede9fe;
    --teal: #0d9488;
    --teal-light: #ccfbf1;
    --orange: #ea580c;
    --orange-light: #ffedd5;
    --pink: #db2777;
    --pink-light: #fce7f3;
    --indigo: #4f46e5;
    --indigo-light: #e0e7ff;
    --cyan: #0891b2;
    --cyan-light: #cffafe;
    --lime: #65a30d;
    --lime-light: #ecfccb;
    --rose: #e11d48;
    --rose-light: #ffe4e6;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 260px;
    --header-height: 64px;

    /* Surface/background semantic tokens */
    --bg: var(--gray-50);
    --surface: #ffffff;
    --surface-2: var(--gray-50);
    --border: var(--gray-200);
    --text: var(--gray-800);
    --text-muted: var(--gray-500);
    --topbar-bg: #ffffff;
    --th-bg: var(--gray-50);
    --row-hover: var(--gray-50);
    --input-bg: #ffffff;
    --input-border: var(--gray-300);
    --icon-btn-bg: #ffffff;
    --icon-btn-hover: var(--gray-50);

    /* Sidebar (default = dark) */
    --sidebar-bg: var(--gray-900);
    --sidebar-color: #fff;
    --sidebar-border: var(--gray-700);
    --sidebar-section-color: var(--gray-400);
    --sidebar-text-hover: #fff;
}

[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #1e3a5f;
    --success: #22c55e;
    --success-light: #14321f;
    --warning: #f59e0b;
    --warning-light: #3a2a0a;
    --danger: #ef4444;
    --danger-light: #3a1414;
    --purple: #a78bfa;
    --purple-light: #2e1065;
    --teal: #2dd4bf;
    --teal-light: #0f3b39;
    --orange: #fb923c;
    --orange-light: #3a230a;
    --pink: #f472b6;
    --pink-light: #3a1126;
    --indigo: #818cf8;
    --indigo-light: #1e2a5e;
    --cyan: #22d3ee;
    --cyan-light: #0c3a44;
    --lime: #a3e635;
    --lime-light: #1f2e08;
    --rose: #fb7185;
    --rose-light: #3a0f1a;
    --gray-50: #111827;
    --gray-100: #1f2937;
    --gray-200: #374151;
    --gray-300: #cbd5e1;
    --gray-400: #9ca3af;
    --gray-500: #9ca3af;
    --gray-600: #d1d5db;
    --gray-700: #e5e7eb;
    --gray-800: #f3f4f6;
    --gray-900: #0b0f17;
    --bg: #0b0f17;
    --surface: #161b26;
    --surface-2: #1f2937;
    --border: #2d3645;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --topbar-bg: #161b26;
    --th-bg: #1f2937;
    --row-hover: #1f2937;
    --input-bg: #1f2937;
    --input-border: #374151;
    --icon-btn-bg: #1f2937;
    --icon-btn-hover: #374151;
    --sidebar-hover: #1f2937;
    --sidebar-active: #1e3a5f;
    --sidebar-text: #cbd5e1;
}

/* ============================================================
   TEMAS DE CORES (esquemas de cor / accent)
   Cada tema sobrepoe a paleta semantica. Temas "light" herdam
   as superficies claras de :root e apenas trocam o acento;
   temas "dark" definem a paleta completa escura com o acento.
   ============================================================ */

/* Ocean - teal (light) */
[data-theme="ocean"] {
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #ccfbf1;
    --sidebar-bg: #ffffff;
    --sidebar-color: var(--gray-800);
    --sidebar-border: var(--gray-200);
    --sidebar-section-color: var(--gray-500);
    --sidebar-active: #0f766e;
    --sidebar-hover: #f0fdfa;
    --sidebar-text: #134e4a;
    --sidebar-text-hover: var(--gray-900);
}

/* Mamfo - blue+orange (cores do logo) */
[data-theme="mamfo"] {
    --primary: #0048c0;
    --primary-dark: #001868;
    --primary-light: #d6e4ff;
    --success: #22c55e;
    --success-light: #dcfce7;
    --warning: #f84000;
    --warning-light: #ffe6d6;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --sidebar-bg: #ffffff;
    --sidebar-color: var(--gray-800);
    --sidebar-border: var(--gray-200);
    --sidebar-section-color: var(--gray-500);
    --sidebar-active: #f84000;
    --sidebar-hover: #fff1ea;
    --sidebar-text: #001868;
    --sidebar-text-hover: var(--gray-900);
}
[data-theme="mamfo"] .btn-primary { background: #0048c0; }
[data-theme="mamfo"] .btn-primary:hover { background: #001868; }
[data-theme="mamfo"] .btn-success { background: #f84000; }
[data-theme="mamfo"] .btn-success:hover { background: #c83400; }
.topbar-sair.btn-outline { color: var(--danger); border-color: var(--danger); }
[data-theme="mamfo"] .topbar-sair.btn-outline { color: #f84000; border-color: #f84000; }
[data-theme="mamfo"] .topbar-sair.btn-outline:hover { background: #fff1ea; }
[data-theme="mamfo"] .topbar-profile { color: #f84000; }
[data-theme="mamfo"] .topbar-profile:hover { color: #c83400; }
[data-theme="mamfo"] .badge-danger { background: #fff1ea; color: #f84000; }

/* Mamfo Dark - blue+orange (cores do logo, fundo escuro) */
[data-theme="mamfo-dark"] {
    --primary: #2f7bff;
    --primary-dark: #0048c0;
    --primary-light: #143a7a;
    --success: #22c55e;
    --success-light: #14321f;
    --warning: #f84000;
    --warning-light: #3a1808;
    --danger: #ef4444;
    --danger-light: #3a1414;
    --gray-50: #111827;
    --gray-100: #1f2937;
    --gray-200: #374151;
    --gray-300: #cbd5e1;
    --gray-400: #9ca3af;
    --gray-500: #9ca3af;
    --gray-600: #d1d5db;
    --gray-700: #e5e7eb;
    --gray-800: #f3f4f6;
    --gray-900: #0b0f17;
    --bg: #0b0f17;
    --surface: #161b26;
    --surface-2: #1f2937;
    --border: #2d3645;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --topbar-bg: #161b26;
    --th-bg: #1f2937;
    --row-hover: #1f2937;
    --input-bg: #1f2937;
    --input-border: #374151;
    --icon-btn-bg: #1f2937;
    --icon-btn-hover: #374151;
    --sidebar-bg: #0b0f17;
    --sidebar-color: #e5e7eb;
    --sidebar-border: #2d3645;
    --sidebar-section-color: #9ca3af;
    --sidebar-active: #f84000;
    --sidebar-hover: #2a1a10;
    --sidebar-text: #cbd5e1;
    --sidebar-text-hover: #ffffff;
}
[data-theme="mamfo-dark"] .btn-primary { background: #0048c0; }
[data-theme="mamfo-dark"] .btn-primary:hover { background: #2f7bff; }
[data-theme="mamfo-dark"] .btn-success { background: #f84000; }
[data-theme="mamfo-dark"] .btn-success:hover { background: #c83400; }

/* Forest - green (light) */
[data-theme="forest"] {
    --primary: #16a34a;
    --primary-dark: #15803d;
    --primary-light: #dcfce7;
    --sidebar-bg: #ffffff;
    --sidebar-color: var(--gray-800);
    --sidebar-border: var(--gray-200);
    --sidebar-section-color: var(--gray-500);
    --sidebar-active: #15803d;
    --sidebar-hover: #f0fdf4;
    --sidebar-text: #14532d;
    --sidebar-text-hover: var(--gray-900);
}

/* Sunset - orange (light) */
[data-theme="sunset"] {
    --primary: #ea580c;
    --primary-dark: #c2410c;
    --primary-light: #ffedd5;
    --sidebar-bg: #ffffff;
    --sidebar-color: var(--gray-800);
    --sidebar-border: var(--gray-200);
    --sidebar-section-color: var(--gray-500);
    --sidebar-active: #c2410c;
    --sidebar-hover: #fff7ed;
    --sidebar-text: #7c2d12;
    --sidebar-text-hover: var(--gray-900);
}

/* Rose - pink (light) */
[data-theme="rose"] {
    --primary: #db2777;
    --primary-dark: #be185d;
    --primary-light: #fce7f3;
    --sidebar-bg: #ffffff;
    --sidebar-color: var(--gray-800);
    --sidebar-border: var(--gray-200);
    --sidebar-section-color: var(--gray-500);
    --sidebar-active: #be185d;
    --sidebar-hover: #fdf2f8;
    --sidebar-text: #831843;
    --sidebar-text-hover: var(--gray-900);
}

/* Amber - gold (light) */
[data-theme="amber"] {
    --primary: #ca8a04;
    --primary-dark: #a16207;
    --primary-light: #fef9c3;
    --sidebar-bg: #ffffff;
    --sidebar-color: var(--gray-800);
    --sidebar-border: var(--gray-200);
    --sidebar-section-color: var(--gray-500);
    --sidebar-active: #a16207;
    --sidebar-hover: #fefce8;
    --sidebar-text: #713f12;
    --sidebar-text-hover: var(--gray-900);
}

/* Midnight - indigo (dark) */
[data-theme="midnight"] {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #312e81;
    --success: #22c55e;
    --success-light: #14321f;
    --warning: #f59e0b;
    --warning-light: #3a2a0a;
    --danger: #ef4444;
    --danger-light: #3a1414;
    --gray-50: #0b1020;
    --gray-100: #151b2e;
    --gray-200: #283047;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #94a3b8;
    --gray-600: #cbd5e1;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --gray-900: #060912;
    --bg: #060912;
    --surface: #0f1626;
    --surface-2: #151b2e;
    --border: #283047;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --topbar-bg: #0f1626;
    --th-bg: #151b2e;
    --row-hover: #151b2e;
    --input-bg: #151b2e;
    --input-border: #283047;
    --icon-btn-bg: #151b2e;
    --icon-btn-hover: #283047;
    --sidebar-hover: #1b2336;
    --sidebar-active: #312e81;
    --sidebar-text: #c7d2fe;
}

/* Grape - purple (dark) */
[data-theme="grape"] {
    --primary: #a855f7;
    --primary-dark: #9333ea;
    --primary-light: #3b0764;
    --success: #22c55e;
    --success-light: #14321f;
    --warning: #f59e0b;
    --warning-light: #3a2a0a;
    --danger: #ef4444;
    --danger-light: #3a1414;
    --gray-50: #140a1f;
    --gray-100: #1f1230;
    --gray-200: #34204d;
    --gray-300: #d8b4fe;
    --gray-400: #a78bfa;
    --gray-500: #a78bfa;
    --gray-600: #d8b4fe;
    --gray-700: #ead8ff;
    --gray-800: #f3e8ff;
    --gray-900: #0c0614;
    --bg: #0c0614;
    --surface: #170d24;
    --surface-2: #1f1230;
    --border: #34204d;
    --text: #ead8ff;
    --text-muted: #a78bfa;
    --topbar-bg: #170d24;
    --th-bg: #1f1230;
    --row-hover: #1f1230;
    --input-bg: #1f1230;
    --input-border: #34204d;
    --icon-btn-bg: #1f1230;
    --icon-btn-hover: #34204d;
    --sidebar-hover: #261638;
    --sidebar-active: #3b0764;
    --sidebar-text: #e9d5ff;
}

/* Slate - neutral dark */
[data-theme="slate"] {
    --primary: #475569;
    --primary-dark: #334155;
    --primary-light: #1e293b;
    --success: #22c55e;
    --success-light: #14321f;
    --warning: #f59e0b;
    --warning-light: #3a2a0a;
    --danger: #ef4444;
    --danger-light: #3a1414;
    --gray-50: #0f172a;
    --gray-100: #1e293b;
    --gray-200: #334155;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #94a3b8;
    --gray-600: #cbd5e1;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --gray-900: #020617;
    --bg: #020617;
    --surface: #0f172a;
    --surface-2: #1e293b;
    --border: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --topbar-bg: #0f172a;
    --th-bg: #1e293b;
    --row-hover: #1e293b;
    --input-bg: #1e293b;
    --input-border: #334155;
    --icon-btn-bg: #1e293b;
    --icon-btn-hover: #334155;
    --sidebar-hover: #1b2538;
    --sidebar-active: #1e293b;
    --sidebar-text: #cbd5e1;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg, var(--gray-900));
    color: var(--sidebar-color, #fff);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 14px 14px;
    border-bottom: 1px solid var(--sidebar-border, var(--gray-700));
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.sidebar-header span {
    color: var(--primary);
}

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

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: var(--sidebar-text, var(--gray-300));
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: var(--sidebar-hover, var(--gray-800));
    color: var(--sidebar-text-hover, #fff);
}

.nav-link.active {
    background: var(--sidebar-active, var(--gray-800));
    color: #fff;
    border-left-color: var(--primary);
}

.nav-section {
    padding: 8px 24px 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-section-color, var(--gray-400));
}

.nav-group {}
.nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 24px 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-section-color, var(--gray-400));
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}
.nav-group-toggle:hover { color: var(--sidebar-text, var(--gray-300)); }
.nav-group-toggle .chevron {
    width: 10px; height: 10px;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.nav-group.open .nav-group-toggle .chevron { transform: rotate(90deg); }
.nav-group-items {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease;
}
.nav-group.open .nav-group-items { max-height: 600px; }

.nav-link svg { width: 20px; height: 20px; flex-shrink: 0; }

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    height: var(--header-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h2 { font-size: 1.25rem; font-weight: 600; }

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
    user-select: none;
}

.theme-picker { position: relative; }
.theme-menu {
    position: absolute;
    top: 44px;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    padding: 8px;
    min-width: 200px;
    display: none;
    z-index: 200;
}
.theme-menu.open { display: block; }

.notif-bell { position: relative; }
.notif-badge {
    position: absolute; top: -4px; right: -4px;
    background: var(--danger, #dc3545); color: #fff;
    font-size: 0.65rem; font-weight: 700;
    min-width: 16px; height: 16px; line-height: 16px;
    border-radius: 8px; padding: 0 4px; text-align: center;
}
.notif-menu {
    position: absolute; top: 44px; right: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    padding: 6px; min-width: 280px; max-width: 320px;
    display: none; z-index: 200;
}
.notif-menu.open { display: block; }
.notif-header { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.notif-empty { padding: 16px 10px; color: var(--text-muted); font-size: 0.85rem; text-align: center; }
.notif-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; text-decoration: none; color: var(--text); font-size: 0.85rem; }
.notif-item:hover { background: var(--surface-2); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--text-muted); }
.notif-urgente .notif-dot { background: #dc3545; }
.notif-aviso .notif-dot { background: #f84000; }
.notif-info .notif-dot { background: #0048c0; }
.theme-menu .theme-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.85rem;
    text-decoration: none;
}
.theme-menu .theme-opt:hover { background: var(--row-hover); color: var(--text); }
.theme-menu .theme-opt.active { background: var(--primary); color: #ffffff; font-weight: 600; }
.theme-swatch {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--border);
}

.page-content { padding: 32px; }

.card {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

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

.card-header h3 { font-size: 1rem; font-weight: 600; }
.header-actions { display: flex; gap: 10px; align-items: center; }
.bulk-actions { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--danger-light, #fff5f5); border: 1px solid #dc3545; border-radius: 8px; }
.bulk-count { font-weight: 600; color: #dc3545; }
.card-body { padding: 24px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.alertas-strip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 22px;
    margin-bottom: 28px;
    border-left: 4px solid var(--warning, #f84000);
}
.alertas-titulo { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin: 0 0 12px; color: var(--text); }
.alertas-chips { display: flex; flex-wrap: wrap; gap: 12px; }
.alerta-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; border-radius: 10px;
    text-decoration: none; color: var(--text);
    background: var(--surface-2); border: 1px solid var(--border);
    transition: transform .12s, box-shadow .12s;
}
.alerta-chip:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.alerta-num { font-size: 1.3rem; font-weight: 700; }
.alerta-label { font-size: 0.82rem; color: var(--text-muted); }
.alerta-urgente { border-color: #dc3545; } .alerta-urgente .alerta-num { color: #dc3545; }
.alerta-aviso { border-color: #f84000; } .alerta-aviso .alerta-num { color: #f84000; }
.alerta-info { border-color: #0048c0; } .alerta-info .alerta-num { color: #0048c0; }

.cliente-tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.cliente-tab { background: none; border: none; padding: 10px 14px; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.cliente-tab:hover { color: var(--text); }
.cliente-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; font-size: 0.72rem; font-weight: 700; color: #fff; background: var(--primary); border-radius: 10px; }
.cliente-tab-panel { animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.stat-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple { background: #f3e8ff; color: #7c3aed; }

.stat-icon svg { width: 24px; height: 24px; }

.stat-info h4 { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-info .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }

.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--text);
}

table th {
    background: var(--th-bg);
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

table tbody tr:hover { background: var(--row-hover); }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-teal { background: var(--teal-light); color: var(--teal); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-pink { background: var(--pink-light); color: var(--pink); }
.badge-indigo { background: var(--indigo-light); color: var(--indigo); }
.badge-cyan { background: var(--cyan-light); color: var(--cyan); }
.badge-lime { background: var(--lime-light); color: var(--lime); }
.badge-rose { background: var(--rose-light); color: var(--rose); }
.badge-gray { background: var(--gray-200); color: var(--gray-600); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn svg { width: 16px; height: 16px; }

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

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }

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

.btn-outline {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--input-border);
}

.btn-outline:hover { background: var(--surface-2); }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--icon-btn-bg);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-icon:hover { background: var(--icon-btn-hover); }
.btn-icon.danger:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

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

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

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 0.875rem;
    transition: border-color 0.15s;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

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

.modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px 16px;
    align-items: start;
}
.modal-grid .form-group {
    margin-bottom: 0;
}
.modal-grid .form-group.span-2 {
    grid-column: span 2;
}
@media (max-width: 560px) {
    .modal-grid { grid-template-columns: 1fr; }
    .modal-grid .form-group.span-2 { grid-column: span 1; }
}

.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.search-bar .form-control { max-width: 400px; }

.filters-bar { margin-bottom: 24px; }
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); }
.sort-link { color: var(--text); text-decoration: none; }
.sort-link:hover { color: var(--primary); }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.modal {
    background: var(--surface);
    border-radius: 16px;
    width: 100%;
    max-width: 960px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

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

.modal-header h3 { font-size: 1.1rem; font-weight: 600; color: var(--text); }

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.drop-zone {
    border: 2px dashed var(--input-border);
    border-radius: 10px;
    padding: 28px 16px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}
.drop-zone .link { color: var(--primary); text-decoration: underline; font-weight: 600; }
.drop-input { display: none; }
.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.file-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
}
.file-list-item.file-error { border-color: #dc3545; background: #fff5f5; }
.file-err-msg { color: #dc3545; font-weight: 600; }
.progress { display: block; flex: 1; height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; max-width: 160px; }
.progress-bar { display: block; height: 100%; width: 0; background: var(--primary); transition: width .2s; }

.modal-preview { max-width: 900px; width: 92%; }
.modal-preview .modal-body { overflow: hidden; }
.modal-preview iframe { background: #fff; }

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: var(--success-light); color: var(--success); }
.alert-danger { background: var(--danger-light); color: var(--danger); }

.pagination {
    display: flex;
    gap: 4px;
    margin-top: 20px;
    justify-content: center;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--text-muted);
    border: 1px solid var(--border);
    background: var(--surface);
}

.pagination a:hover { background: var(--surface-2); }
.pagination .active { background: var(--primary); color: white; border-color: var(--primary); }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .topbar { padding: 0 16px; }
    .page-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
}
