/* CSS INLINE APRIMORADO */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        :root {
            --primary: #2563eb;
            --primary-dark: #1e40af;
            --primary-light: #60a5fa;
            --secondary: #64748b;
            --success: #10b981;
            --warning: #f59e0b;
            --danger: #ef4444;
            --info: #06b6d4;
            --bg-light: #f8fafc;
            --bg-card-light: #ffffff;
            --text-light: #1e293b;
            --text-secondary-light: #64748b;
            --border-light: #e2e8f0;
            --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px 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);
            --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
            --radius: 0.75rem;
            --radius-lg: 1rem;
            --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .theme-light {
            --bg: var(--bg-light);
            --bg-card: var(--bg-card-light);
            --text: var(--text-light);
            --text-secondary: var(--text-secondary-light);
            --border: var(--border-light);
            --hover-bg: #f1f5f9;
        }

        .theme-dark {
            --bg: #0f172a;
            --bg-card: #1e293b;
            --text: #f1f5f9;
            --text-secondary: #94a3b8;
            --border: #334155;
            --hover-bg: #334155;
        }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            background: var(--bg);
            color: var(--text);
            transition: var(--transition);
            line-height: 1.6;
            overflow-x: hidden;
        }

        /* --- LOGIN STYLES --- */
        .login-container {
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
            padding: 1rem;
            position: relative;
            overflow: hidden;
        }

        .login-container::before, .login-container::after {
            content: '';
            position: absolute;
            background: rgba(255,255,255,0.1);
            border-radius: 50%;
            animation: float 6s ease-in-out infinite;
        }

        .login-container::before {
            width: 500px;
            height: 500px;
            top: -200px;
            right: -200px;
        }

        .login-container::after {
            width: 400px;
            height: 400px;
            background: rgba(255,255,255,0.08);
            bottom: -150px;
            left: -150px;
            animation: float 8s ease-in-out infinite;
        }

        @keyframes float {
            0%, 100% { transform: translateY(0px); }
            50% { transform: translateY(-20px); }
        }

        .login-box {
            background: var(--bg-card);
            padding: 2.5rem;
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-xl);
            width: 100%;
            max-width: 440px;
            backdrop-filter: blur(10px);
            animation: slideUp 0.5s ease-out;
            position: relative;
            z-index: 1;
        }

        @keyframes slideUp {
            from { opacity: 0; transform: translateY(30px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .logo {
            text-align: center;
            margin-bottom: 2rem;
        }

        .logo h1 {
            font-size: 2rem;
            font-weight: 800;
            background: linear-gradient(135deg, var(--primary), #7c3aed);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            margin-bottom: 0.5rem;
        }

        .logo p {
            color: var(--text-secondary);
            font-size: 0.875rem;
            font-weight: 500;
        }

        /* --- FORM STYLES (Robustos) --- */
        .form-group {
            margin-bottom: 1.5rem;
            position: relative;
        }

        .form-group label {
            display: block;
            font-weight: 600;
            margin-bottom: 0.5rem;
            font-size: 0.875rem;
            color: var(--text);
        }

        .form-group input,
        .form-group select,
        .form-group textarea {
            width: 100%;
            padding: 0.875rem 1rem;
            border: 2px solid var(--border);
            border-radius: 0.5rem;
            background: var(--bg);
            color: var(--text);
            font-size: 0.9375rem;
            transition: var(--transition);
            font-family: inherit;
        }

        .form-group input:focus,
        .form-group select:focus,
        .form-group textarea:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        }

        .form-group input.error,
        .form-group select.error,
        .form-group textarea.error {
            border-color: var(--danger);
        }

        .form-error {
            color: var(--danger);
            font-size: 0.8125rem;
            margin-top: 0.25rem;
            display: none;
        }

        textarea {
            resize: vertical;
            min-height: 120px;
        }

        .form-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 1.5rem;
            margin-bottom: 1rem;
        }

        /* --- BUTTON STYLES (Modernos com efeito de clique) --- */
        .btn {
            padding: 0.875rem 1.75rem;
            border: none;
            border-radius: 0.5rem;
            font-weight: 600;
            cursor: pointer;
            transition: var(--transition);
            font-size: 0.9375rem;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            position: relative;
            overflow: hidden;
            text-decoration: none; /* Para usar em links */
        }

        .btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none !important;
            box-shadow: none !important;
        }

        .btn::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 0;
            height: 0;
            border-radius: 50%;
            background: rgba(255,255,255,0.3);
            transform: translate(-50%, -50%);
            transition: width 0.6s, height 0.6s;
        }

        .btn:active::before {
            width: 300px;
            height: 300px;
        }

        .btn-primary {
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            color: white;
            width: 100%;
        }

        .btn-primary:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: var(--shadow-lg);
        }

        .loading-spinner {
            border: 3px solid rgba(255,255,255,0.3);
            border-top: 3px solid white;
            border-radius: 50%;
            width: 20px;
            height: 20px;
            animation: spin 0.8s linear infinite;
            display: none;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .btn.loading .loading-spinner {
            display: inline-block;
        }

        .btn.loading span {
            display: none;
        }
        
        /* Adicionais */
        .btn-small {
            padding: 0.5rem 1rem;
            font-size: 0.8125rem;
        }
        .btn-danger {
            background: var(--danger);
            color: white;
        }
        .btn-danger:hover:not(:disabled) {
            background: #dc2626;
        }

        /* --- DASHBOARD LAYOUT --- */
        .dashboard {
            display: none;
            min-height: 100vh;
        }

        .header {
            background: var(--bg-card);
            padding: 1rem 1.5rem;
            box-shadow: var(--shadow);
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
            flex-wrap: wrap;
            position: sticky;
            top: 0;
            z-index: 100;
            backdrop-filter: blur(8px); /* Efeito moderno */
        }

        .header-left h2 {
            font-size: 1.5rem;
            font-weight: 800;
            background: linear-gradient(135deg, var(--primary), #7c3aed);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        /* Tema Toggle */
        .theme-toggle {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            margin-right: auto;
        }
        
        .theme-toggle span {
            font-size: 0.875rem;
            color: var(--text-secondary);
            font-weight: 500;
        }
        
        .toggle-switch {
            position: relative;
            width: 52px;
            height: 28px;
            cursor: pointer;
        }
        
        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }
        
        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: var(--border);
            border-radius: 34px;
            transition: var(--transition);
        }
        
        .toggle-slider:before {
            position: absolute;
            content: "";
            height: 22px;
            width: 22px;
            left: 3px;
            bottom: 3px;
            background: white;
            border-radius: 50%;
            transition: var(--transition);
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        }
        
        input:checked + .toggle-slider {
            background: var(--primary);
        }
        
        input:checked + .toggle-slider:before {
            transform: translateX(24px);
        }

        /* User Info */
        .user-info {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .user-avatar {
            width: 42px;
            height: 42px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--primary), #7c3aed);
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 1.125rem;
            box-shadow: var(--shadow);
            flex-shrink: 0;
        }

        .user-details {
            display: flex;
            flex-direction: column;
        }

        .user-name {
            font-weight: 600;
            font-size: 0.9375rem;
        }

        .user-role {
            font-size: 0.8125rem;
            color: var(--text-secondary);
        }

        .btn-logout {
            padding: 0.625rem 1.25rem;
            background: transparent;
            border: 2px solid var(--danger);
            color: var(--danger);
            border-radius: 0.5rem;
            font-weight: 600;
            cursor: pointer;
            transition: var(--transition);
            font-size: 0.8125rem;
            margin-left: 1rem;
        }

        .btn-logout:hover {
            background: var(--danger);
            color: white;
            transform: translateY(-2px);
        }

        /* Navigation Tabs */
        .nav-tabs {
            background: var(--bg-card);
            border-bottom: 2px solid var(--border);
            padding: 0 1.5rem;
            display: flex;
            gap: 0.5rem;
            overflow-x: auto;
            position: sticky;
            top: 73px; /* Altura do header */
            z-index: 99;
            scrollbar-width: thin;
        }
        
        .nav-tabs::-webkit-scrollbar {
            height: 4px;
        }

        .nav-tabs::-webkit-scrollbar-thumb {
            background: var(--border);
            border-radius: 4px;
        }

        .nav-tab {
            padding: 1rem 1.5rem;
            background: none;
            border: none;
            color: var(--text-secondary);
            font-weight: 600;
            cursor: pointer;
            border-bottom: 3px solid transparent;
            transition: var(--transition);
            white-space: nowrap;
            font-size: 0.9375rem;
        }

        .nav-tab:hover {
            color: var(--primary);
            background: var(--hover-bg);
        }

        .nav-tab.active {
            color: var(--primary);
            border-bottom-color: var(--primary);
        }

        .main-content {
            padding: 2rem 1.5rem;
            max-width: 1400px;
            margin: 0 auto;
        }

        .tab-content {
            display: none;
            animation: fadeIn 0.4s ease-out;
        }

        .tab-content.active {
            display: block;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* --- STATS GRID --- */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        .stat-card {
            background: var(--bg-card);
            padding: 1.75rem;
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            border-left: 5px solid var(--primary);
            transition: var(--transition);
            position: relative;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }

        .stat-card::before {
            content: '';
            position: absolute;
            top: 0;
            right: 0;
            width: 100px;
            height: 100px;
            background: var(--primary);
            opacity: 0.05;
            border-radius: 50%;
            transform: translate(30%, -30%);
            transition: var(--transition);
        }

        .stat-card:hover {
            transform: translateY(-4px);
            box-shadow: var(--shadow-lg);
        }
        
        /* Stat Card Colors */
        .stat-card.warning { border-left-color: var(--warning); }
        .stat-card.warning::before { background: var(--warning); }
        .stat-card.success { border-left-color: var(--success); }
        .stat-card.success::before { background: var(--success); }
        .stat-card.danger { border-left-color: var(--danger); }
        .stat-card.danger::before { background: var(--danger); }
        .stat-card.info { border-left-color: var(--info); }
        .stat-card.info::before { background: var(--info); }

        .stat-label {
            font-size: 0.875rem;
            color: var(--text-secondary);
            margin-bottom: 0.75rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .stat-value {
            font-size: 2.75rem;
            font-weight: 800;
            color: var(--text);
            position: relative;
            z-index: 1;
            line-height: 1.2;
        }

        /* --- CARD & TABLE STYLES --- */
        .card {
            background: var(--bg-card);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            padding: 1.75rem;
            margin-bottom: 1.5rem;
            border: 1px solid var(--border);
            transition: var(--transition);
        }

        .card:hover {
            box-shadow: var(--shadow-lg);
        }

        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            padding-bottom: 1rem;
            border-bottom: 2px solid var(--border);
        }

        .card-title {
            font-size: 1.375rem;
            font-weight: 700;
            color: var(--text);
        }

        .table-container {
            overflow-x: auto;
            border-radius: 0.5rem;
            border: 1px solid var(--border);
        }
        
        table {
            width: 100%;
            border-collapse: collapse;
        }

        th, td {
            padding: 1rem;
            text-align: left;
            border-bottom: 1px solid var(--border);
        }
        
        th {
            background: var(--hover-bg);
            font-weight: 700;
            font-size: 0.8125rem;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--text-secondary);
            position: sticky;
            top: 0;
            z-index: 10;
        }

        tbody tr {
            transition: var(--transition);
        }

        tbody tr:hover {
            background: var(--hover-bg);
        }
        
        /* Status Badges */
        .status-badge {
            padding: 0.425rem 0.875rem;
            border-radius: 9999px;
            font-size: 0.75rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            display: inline-block;
            white-space: nowrap;
        }

        .status-open { background: rgba(37, 99, 235, 0.15); color: var(--primary); }
        .status-progress { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
        .status-closed { background: rgba(16, 185, 129, 0.15); color: var(--success); }
        .status-high { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
        .status-medium { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
        .status-low { background: rgba(100, 116, 139, 0.15); color: var(--secondary); }
        .status-admin { background: rgba(37, 99, 235, 0.15); color: var(--primary); }
        .status-user { background: rgba(16, 185, 129, 0.15); color: var(--success); }

        /* SLA indicator */
        .sla-ok { color: var(--success); font-weight: 600; }
        .sla-expiring { color: var(--warning); font-weight: 600; }
        .sla-expired { color: var(--danger); font-weight: 600; }

        /* --- MODAL STYLES (Aprimorados) --- */
        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.6);
            backdrop-filter: blur(4px);
            animation: fadeIn 0.3s;
            overflow-y: auto;
        }

        .modal-content {
            background: var(--bg-card);
            margin: 2rem auto;
            padding: 2rem;
            border-radius: var(--radius-lg);
            width: 90%;
            max-width: 850px;
            box-shadow: var(--shadow-xl);
            animation: slideUp 0.3s ease-out;
            border: 1px solid var(--border);
        }
        
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            padding-bottom: 1rem;
            border-bottom: 2px solid var(--border);
        }

        .modal-title {
            font-size: 1.5rem;
            font-weight: 700;
            color: var(--text);
        }

        .btn-close {
            background: none;
            border: none;
            font-size: 2rem;
            color: var(--text-secondary);
            cursor: pointer;
            transition: var(--transition);
            line-height: 1;
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 0.5rem;
        }

        .btn-close:hover {
            color: var(--danger);
            background: rgba(239, 68, 68, 0.1);
        }
        
        /* Ticket Details & History */
        .detail-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 1.5rem;
            margin-bottom: 1.5rem;
            padding-bottom: 1.5rem;
            border-bottom: 1px dashed var(--border);
        }
        
        .detail-item strong {
            color: var(--text-secondary);
            font-size: 0.875rem;
            display: block;
            margin-bottom: 0.375rem;
            font-weight: 600;
            text-transform: uppercase;
        }

        .detail-item p {
            color: var(--text);
            font-size: 1rem;
            font-weight: 500;
        }

        .history-item {
            padding: 1.25rem;
            margin-top: 0.875rem;
            border-radius: 0.5rem;
            background: var(--hover-bg);
            border-left: 3px solid var(--info);
            box-shadow: var(--shadow);
        }

        .history-meta {
            font-size: 0.8125rem;
            color: var(--text-secondary);
            margin-bottom: 0.5rem;
            font-weight: 600;
        }

        .history-content {
            font-size: 0.9375rem;
        }
        
        /* Action buttons in modal */
        .modal-actions {
            display: flex;
            justify-content: flex-end;
            gap: 1rem;
            margin-top: 1.5rem;
            padding-top: 1rem;
            border-top: 1px solid var(--border);
        }

        /* --- TOAST NOTIFICATIONS --- */
        .toast-container {
            position: fixed;
            top: 1rem;
            right: 1rem;
            z-index: 2000;
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
            max-width: 400px;
        }

        .toast {
            background: var(--bg-card);
            padding: 1rem 1.5rem;
            border-radius: 0.5rem;
            box-shadow: var(--shadow-xl);
            display: flex;
            align-items: center;
            gap: 0.75rem;
            min-width: 320px;
            animation: slideInRight 0.4s ease-out, fadeOut 0.4s ease-in 4.6s forwards;
            border-left: 4px solid var(--success);
            opacity: 0; /* Inicialmente escondido */
        }

        @keyframes slideInRight {
            0% { opacity: 0; transform: translateX(100%); }
            100% { opacity: 1; transform: translateX(0); }
        }

        @keyframes fadeOut {
            0% { opacity: 1; height: auto; padding: 1rem 1.5rem; }
            100% { opacity: 0; height: 0; padding: 0 1.5rem; margin-bottom: 0; }
        }

        .toast.success { border-left-color: var(--success); color: var(--success); }
        .toast.error { border-left-color: var(--danger); color: var(--danger); }
        .toast.warning { border-left-color: var(--warning); color: var(--warning); }
        .toast.info { border-left-color: var(--info); color: var(--info); }

        .toast-icon {
            font-size: 1.5rem;
        }

        .toast-message {
            flex: 1;
            font-weight: 500;
            color: var(--text); /* Mantém a cor do texto do tema */
        }
        
        .toast.success .toast-icon { color: var(--success); }
        .toast.error .toast-icon { color: var(--danger); }
        .toast.warning .toast-icon { color: var(--warning); }
        .toast.info .toast-icon { color: var(--info); }
        
        /* Empty State */
        .empty-state {
            text-align: center;
            padding: 4rem 2rem;
            color: var(--text-secondary);
            border: 2px dashed var(--border);
            border-radius: var(--radius);
        }

        .empty-state-icon {
            font-size: 3rem;
            margin-bottom: 1rem;
            opacity: 0.7;
        }

        .empty-state-text {
            font-size: 1.125rem;
            font-weight: 600;
        }
        
        /* Chart Styles (Para Modo Escuro) */
        .theme-dark canvas {
            background: var(--bg-card); /* Ajusta o fundo do gráfico */
            border-radius: var(--radius);
        }
        
        .chart-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 1.5rem;
        }

        .chart-container {
            height: 350px;
            position: relative;
            padding: 0.5rem;
        }

        /* --- MEDIA QUERIES --- */
        @media (max-width: 768px) {
            .header {
                padding: 1rem;
            }
            
            .theme-toggle {
                order: 3;
                width: 100%;
                justify-content: center;
                margin-right: 0;
                margin-top: 1rem;
            }
            
            .user-info {
                gap: 0.5rem;
            }
            
            .btn-logout {
                margin-left: 0.5rem;
            }
            
            .nav-tabs {
                padding: 0 1rem;
                top: 110px; /* Ajusta devido ao toggle */
            }
            
            .main-content {
                padding: 1.5rem 1rem;
            }
            
            .stats-grid {
                grid-template-columns: 1fr;
            }
            
            .form-row {
                grid-template-columns: 1fr;
            }
            
            .chart-grid {
                grid-template-columns: 1fr;
            }

            .modal-content {
                width: 95%;
                padding: 1.5rem;
                margin: 1rem auto;
            }

            .toast-container {
                right: 0.5rem;
                top: 0.5rem;
            }
        }
    