        :root {
            --primary-color: #2563eb;
            --primary-light: #3b82f6;
            --primary-dark: #1d4ed8;
            --secondary-color: #64748b;
            --success-color: #10b981;
            --danger-color: #ef4444;
            --warning-color: #f59e0b;
            --info-color: #06b6d4;
            --dark-color: #1e293b;
            --light-bg: #f1f5f9;
            --white: #ffffff;
            --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
            --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: var(--light-bg);
            min-height: 100vh;
            overflow-x: hidden;
        }
        
        .sidebar {
            position: fixed;
            top: 0;
            left: 0;
            height: 100vh;
            width: 260px;
            background: linear-gradient(180deg, var(--dark-color) 0%, #0f172a 100%);
            color: white;
            padding-top: 0;
            z-index: 1000;
            display: flex;
            flex-direction: column;
        }
        
        .sidebar-header {
            padding: 24px 20px;
            border-bottom: 1px solid rgba(255,255,255,0.08);
            background: rgba(255,255,255,0.02);
        }
        
        .sidebar .logo {
            text-align: left;
            padding: 0;
            border: none;
            margin: 0;
        }
        
        .sidebar .logo h2 {
            margin: 0;
            color: var(--white);
            font-weight: 700;
            font-size: 1.5rem;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .sidebar .logo h2 i {
            color: var(--info-color);
            font-size: 1.8rem;
        }
        
        .sidebar .logo small {
            color: rgba(255,255,255,0.5);
            font-size: 0.75rem;
            display: block;
            margin-top: 4px;
            margin-left: 34px;
        }
        
        .sidebar-nav {
            flex: 1;
            overflow-y: auto;
            padding: 16px 12px;
        }
        
        .sidebar .nav-item {
            padding: 12px 16px;
            cursor: pointer;
            transition: all 0.2s ease;
            border-radius: 10px;
            margin-bottom: 4px;
            font-size: 0.9rem;
            color: rgba(255,255,255,0.7);
            display: flex;
            align-items: center;
            gap: 12px;
        }
        
        .sidebar .nav-item:hover, .sidebar .nav-item.active {
            background: rgba(255,255,255,0.1);
            color: var(--white);
        }
        
        .sidebar .nav-item.active {
            background: var(--primary-color);
            box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
        }
        
        .sidebar .nav-item i {
            font-size: 1.1rem;
            width: 20px;
            text-align: center;
        }

        .sidebar-footer {
            padding: 16px 20px;
            border-top: 1px solid rgba(255,255,255,0.08);
        }

        /* Garante visibilidade do item Plataforma para superadmins */
        body.is-superadmin #nav-saas,
        body.is-superadmin #nav-saas-separator,
        body.is-superadmin #nav-saas-label {
            display: block !important;
        }
        body.is-superadmin #nav-saas {
            display: flex !important;
        }
        
        .main-content {
            margin-left: 260px;
            padding: 24px 32px;
            min-height: 100vh;
        }
        
        .page-header {
            margin-bottom: 28px;
        }
        
        .page-header h4 {
            font-weight: 600;
            color: var(--dark-color);
            font-size: 1.5rem;
            display: flex;
            align-items: center;
            gap: 12px;
        }
        
        .page-header h4 i {
            color: var(--primary-color);
        }
        
        .page-header .subtitle {
            color: var(--secondary-color);
            font-size: 0.9rem;
            margin-top: 4px;
        }
        
        .stat-card {
            background: var(--white);
            border: none;
            border-radius: 16px;
            box-shadow: var(--card-shadow);
            transition: all 0.3s ease;
            overflow: hidden;
            position: relative;
        }
        
        .stat-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 4px;
            height: 100%;
            background: var(--primary-color);
        }
        
        .stat-card:hover {
            transform: translateY(-4px);
            box-shadow: var(--card-shadow-hover);
        }
        
        .stat-card .stat-icon {
            width: 52px;
            height: 52px;
            border-radius: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
        }
        
        .stat-card .stat-value {
            font-size: 1.75rem;
            font-weight: 700;
            color: var(--dark-color);
            line-height: 1.2;
        }
        
        .stat-card .stat-label {
            font-size: 0.85rem;
            color: var(--secondary-color);
            font-weight: 500;
        }
        
        .content-card {
            background: var(--white);
            border-radius: 16px;
            box-shadow: var(--card-shadow);
            overflow: hidden;
        }
        
        .content-card .card-header {
            padding: 20px 24px;
            border-bottom: 1px solid #e2e8f0;
            background: var(--white);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .content-card .card-header h5 {
            font-weight: 600;
            color: var(--dark-color);
            margin: 0;
            font-size: 1.1rem;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .content-card .card-body {
            padding: 0;
        }
        
        .table {
            margin: 0;
        }
        
        .table thead th {
            background: #f8fafc;
            padding: 14px 20px;
            font-weight: 600;
            color: var(--secondary-color);
            font-size: 0.8rem;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            border: none;
        }
        
        .table tbody td {
            padding: 16px 20px;
            border-color: #f1f5f9;
            vertical-align: middle;
        }
        
        .table tbody tr:hover {
            background: #f8fafc;
        }
        
        .table tbody tr td:first-child {
            font-weight: 600;
            color: var(--dark-color);
        }
        
        .btn-primary {
            background: var(--primary-color);
            border: none;
            padding: 10px 20px;
            border-radius: 10px;
            font-weight: 500;
            transition: all 0.2s;
        }
        
        .btn-primary:hover {
            background: var(--primary-dark);
            transform: translateY(-1px);
        }
        
        .btn-success {
            background: var(--success-color);
            border: none;
        }
        
        .btn-danger {
            background: var(--danger-color);
            border: none;
        }
        
        .btn-action {
            padding: 6px 10px;
            border-radius: 8px;
            margin: 0 2px;
        }
        
        .status-badge {
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 0.75rem;
            font-weight: 600;
            display: inline-block;
        }
        
        .status-aberta { background: #dbeafe; color: #1d4ed8; }
        .status-aguardando_aprovacao { background: #fff7ed; color: #c2410c; }
        .status-em_andamento { background: #fef3c7; color: #b45309; }
        .status-aguardando_peca { background: #f3e8ff; color: #7c3aed; }
        .status-pronta { background: #d1fae5; color: #059669; }
        .status-faturado { background: #fed7aa; color: #ea580c; }
        .status-entregue { background: #e2e8f0; color: #475569; }
        .status-cancelada { background: #fee2e2; color: #dc2626; }
        
        .modal-header {
            background: var(--dark-color);
            color: white;
            border-radius: 0;
            padding: 20px 24px;
        }
        
        .modal-header .btn-close {
            filter: invert(1);
        }
        
        .modal-body {
            padding: 24px;
        }
        
        .modal-footer {
            padding: 16px 24px;
            border-top: 1px solid #e2e8f0;
        }
        
        .form-label {
            font-weight: 500;
            color: var(--dark-color);
            margin-bottom: 6px;
            font-size: 0.9rem;
        }
        
        .form-control, .form-select {
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            padding: 10px 14px;
            transition: all 0.2s;
        }

        .form-select {
            padding-right: 2.25rem;
        }
        
        .form-control:focus, .form-select:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        }
        
        .search-box {
            position: relative;
        }
        
        .search-box input {
            padding-left: 44px;
            border-radius: 10px;
        }
        
        .search-box i {
            position: absolute;
            left: 14px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--secondary-color);
        }
        
        .quick-actions {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }
        
        .quick-actions .btn {
            padding: 8px 16px;
            border-radius: 10px;
            font-size: 0.85rem;
        }
        
        .whatsapp-btn {
            background: #25d366;
            border: none;
        }
        
        .whatsapp-btn:hover {
            background: #128c7e;
        }
        
        .empty-state {
            padding: 60px 20px;
            text-align: center;
        }
        
        .empty-state i {
            font-size: 4rem;
            color: #cbd5e1;
            margin-bottom: 16px;
        }
        
        .empty-state h5 {
            color: var(--secondary-color);
            margin-bottom: 8px;
        }
        
        .empty-state p {
            color: #94a3b8;
            font-size: 0.9rem;
        }
        
        .nav-tabs {
            border: none;
            padding: 0 24px;
            background: #f8fafc;
            border-bottom: 1px solid #e2e8f0;
        }
        
        .nav-tabs .nav-link {
            border: none;
            padding: 16px 20px;
            color: var(--secondary-color);
            font-weight: 500;
            border-bottom: 2px solid transparent;
            transition: all 0.2s;
        }
        
        .nav-tabs .nav-link:hover {
            color: var(--primary-color);
        }
        
        .nav-tabs .nav-link.active {
            color: var(--primary-color);
            border-bottom-color: var(--primary-color);
            background: transparent;
        }
        
        .loading-spinner {
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 40px;
        }
        
        .spinner {
            width: 40px;
            height: 40px;
            border: 3px solid #e2e8f0;
            border-top: 3px solid var(--primary-color);
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        .toast-container {
            position: fixed;
            top: 24px;
            right: 24px;
            z-index: 9999;
        }
        
        .toast {
            border-radius: 12px;
            box-shadow: 0 10px 25px rgba(0,0,0,0.15);
        }
        
        /* === MOBILE TOPBAR === */
        .mobile-topbar {
            display: none;
            position: fixed;
            top: 0; left: 0; right: 0;
            height: 56px;
            background: linear-gradient(180deg, var(--dark-color) 0%, #0f172a 100%);
            z-index: 1050;
            align-items: center;
            padding: 0 16px;
            gap: 12px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        }
        .mobile-topbar .hamburger-btn {
            background: none; border: none;
            color: white; font-size: 1.5rem;
            padding: 4px 8px; cursor: pointer;
            line-height: 1;
        }
        .mobile-topbar .mobile-logo {
            color: white; font-weight: 700;
            font-size: 1.05rem; flex: 1;
        }
        .mobile-topbar .mobile-logo i { color: var(--info-color); }

        /* === SIDEBAR OVERLAY === */
        .sidebar-overlay {
            display: none;
            position: fixed; inset: 0;
            background: rgba(0,0,0,0.55);
            z-index: 1040;
        }
        .sidebar-overlay.active { display: block; }

        /* === TABLET (1024px) === */
        @media (max-width: 1024px) {
            .sidebar { width: 80px; }
            .sidebar .logo h2 span,
            .sidebar .logo small,
            .sidebar .nav-item span,
            .user-info, .sidebar-user i.bi-chevron-up { display: none; }
            .sidebar .nav-item { justify-content: center; padding: 14px; }
            .sidebar-user { justify-content: center; padding: 14px 16px; }
            .main-content { margin-left: 80px; }
        }

        /* === MOBILE (768px) === */
        @media (max-width: 768px) {
            .mobile-topbar { display: flex; }

            .sidebar {
                position: fixed;
                top: 0; left: -280px;
                width: 260px; height: 100vh;
                z-index: 1100;
                transition: left 0.28s ease;
                /* restaura textos que tablet escondia */
            }
            .sidebar .logo h2 span,
            .sidebar .logo small,
            .sidebar .nav-item span,
            .user-info, .sidebar-user i.bi-chevron-up { display: unset !important; }
            .sidebar .nav-item { justify-content: flex-start; padding: 12px 16px; }
            .sidebar-user { justify-content: flex-start; padding: 14px 16px; }
            .sidebar.mobile-open { left: 0; }

            .main-content {
                margin-left: 0;
                padding: 68px 12px 20px;
            }

            /* Page header */
            .page-header { margin-bottom: 16px; }
            .page-header h4 { font-size: 1.1rem; }

            /* Card headers — empilha título e botões */
            .content-card .card-header {
                flex-wrap: wrap;
                gap: 8px;
                padding: 14px 16px;
            }
            .content-card .card-header h5 { font-size: 0.95rem; }

            /* Tabelas — scroll horizontal */
            .content-card .card-body,
            .tab-content { overflow-x: auto; -webkit-overflow-scrolling: touch; }

            /* Nav tabs — scroll horizontal sem quebra */
            .nav-tabs {
                overflow-x: auto; flex-wrap: nowrap;
                white-space: nowrap; padding: 0 8px;
                scrollbar-width: none;
            }
            .nav-tabs::-webkit-scrollbar { display: none; }
            .nav-tabs .nav-link { padding: 12px 14px; white-space: nowrap; }

            /* Stat cards */
            .stat-card .stat-value { font-size: 1.3rem; }
            .stat-card .stat-label { font-size: 0.78rem; }

            /* Botões de ação menores */
            .btn-action { padding: 5px 8px; font-size: 0.78rem; }
            .quick-actions { flex-wrap: wrap; gap: 6px; }
            .quick-actions .btn { font-size: 0.8rem; padding: 6px 12px; }

            /* Modais — ocupa tela toda no mobile */
            .modal-dialog {
                margin: 8px auto;
                max-width: calc(100% - 16px);
            }
            .modal-dialog.modal-lg,
            .modal-dialog.modal-xl { max-width: calc(100% - 16px); }
            .modal-body { padding: 16px; }
            .modal-footer { padding: 12px 16px; }

            /* Toast reposicionado */
            .toast-container { top: 64px; right: 12px; left: 12px; max-width: 100%; }
            .toast { width: 100%; }

            /* Tabela interna — fonte menor */
            .table thead th { font-size: 0.72rem; padding: 10px 10px; }
            .table tbody td { padding: 12px 10px; font-size: 0.85rem; }

            /* Perm grid no modal de usuários */
            .perm-grid { font-size: 11px; gap: 4px 8px; }
        }

        /* === SMALL MOBILE (480px) === */
        @media (max-width: 480px) {
            .main-content { padding: 64px 8px 16px; }
            .stat-card .stat-value { font-size: 1.1rem; }
            .modal-dialog { margin: 4px; max-width: calc(100% - 8px); }
        }
        
        .dashboard-stat {
            padding: 20px 24px;
        }
        
        .dashboard-stat .stat-row {
            display: flex;
            align-items: center;
            gap: 16px;
        }
        
        .list-item {
            padding: 16px 20px;
            border-bottom: 1px solid #f1f5f9;
            display: flex;
            justify-content: space-between;
            align-items: center;
            transition: background 0.2s;
        }
        
        .list-item:hover {
            background: #f8fafc;
        }
        
        .list-item:last-child {
            border-bottom: none;
        }
        
        .list-item .item-info h6 {
            font-weight: 600;
            color: var(--dark-color);
            margin-bottom: 2px;
        }
        
        .list-item .item-info small {
            color: var(--secondary-color);
        }
        #login-screen {
            position: fixed; inset: 0; z-index: 9999;
            background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #0f172a 100%);
            display: flex; align-items: center; justify-content: center;
        }
        #login-screen.hidden { display: none !important; }
        .login-card {
            background: rgba(255,255,255,0.04);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 20px;
            padding: 44px 40px 36px;
            width: 100%; max-width: 420px;
            backdrop-filter: blur(12px);
        }
        .login-logo { text-align: center; margin-bottom: 28px; }
        .login-logo h1 { color: #fff; font-size: 1.8rem; font-weight: 700; margin: 0; }
        .login-logo h1 i { color: #38bdf8; }
        .login-logo small { color: rgba(255,255,255,0.45); font-size: 0.8rem; display: block; margin-top: 4px; }
        .login-field { margin-bottom: 18px; }
        .login-field label { color: rgba(255,255,255,0.6); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; display: block; margin-bottom: 6px; }
        .login-field input {
            width: 100%; background: rgba(255,255,255,0.07);
            border: 1px solid rgba(255,255,255,0.12);
            border-radius: 10px; color: #fff; padding: 11px 14px;
            font-size: 14px; outline: none; transition: border 0.2s;
        }
        .login-field input:focus { border-color: #38bdf8; background: rgba(56,189,248,0.06); }
        .login-field input::placeholder { color: rgba(255,255,255,0.3); }
        .login-btn {
            width: 100%; padding: 12px; border: none; border-radius: 10px;
            background: linear-gradient(90deg, #2563eb, #0ea5e9);
            color: #fff; font-size: 15px; font-weight: 600;
            cursor: pointer; margin-top: 8px; transition: opacity 0.2s, transform 0.1s;
        }
        .login-btn:hover { opacity: 0.92; }
        .login-btn:active { transform: scale(0.98); }
        .login-btn:disabled { opacity: 0.6; cursor: not-allowed; }
        .login-error {
            background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3);
            border-radius: 8px; color: #fca5a5; font-size: 13px;
            padding: 10px 14px; margin-bottom: 16px; display: none;
        }
        .login-error.show { display: block; }

        /* Usuário logado na sidebar */
        .sidebar-user {
            padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.07);
            display: flex; align-items: center; gap: 10px; cursor: pointer;
        }
        .sidebar-user:hover { background: rgba(255,255,255,0.04); }
        .user-avatar {
            width: 36px; height: 36px; border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
            background: linear-gradient(135deg, #2563eb, #0ea5e9);
        }
        .user-info { flex: 1; min-width: 0; }
        .user-info .u-name { color: #fff; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .user-info .u-role { color: rgba(255,255,255,0.4); font-size: 11px; }
        .nav-item.disabled { opacity: 0.3; pointer-events: none; cursor: not-allowed; }

        /* Gerenciar usuários modal */
        .perm-grid { display: grid; grid-template-columns: 1fr repeat(4, auto); gap: 6px 12px; align-items: center; font-size: 13px; }
        .perm-grid .perm-head { font-size: 11px; color: #6b7280; text-align: center; }
        .perm-grid input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; margin: auto; display: block; }
        .setor-badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; color: #fff; }
