
/* 1. Variáveis de Cores e Estilos Base (ATUALIZADAS) */
:root {
    --bg-sidebar: #0E163B;      
    --bg-sidebar-hover: #1e293b;
    --bg-main: #f8fafc;         
    --color-primary: #3b66f5;   /* Azul base para gráficos e textos */
    --color-accent: #F3E947; 
    --text-main: #0f172a;
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    
    /* Nova variável para o gradiente do botão */
    --btn-gradient: linear-gradient(90deg, #3b66f5 0%, #4facfe 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    display: flex;
    height: 100vh;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden; /* Evita scroll na página toda, o scroll será no main-content */
}

/* =========================================
    2. SIDEBAR (Menu Lateral)
    ========================================= */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
}

/* Logotipo */
.logo-area {
    display: flex;
    align-items: center;
    padding: 0 24px;
    margin-bottom: 40px;
}
.logo-icon {
    background-color: var(--color-accent);
    color: var(--bg-sidebar);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 18px;
    margin-right: 12px;
}
.logo-text h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
}
.logo-text span {
    font-size: 11px;
    color: #94a3b8;
    letter-spacing: 1px;
}

/* Navegação */
.nav-links {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-grow: 1;
}
.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}
.nav-item:hover {
    background-color: var(--bg-sidebar-hover);
}
.nav-item.active {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
    border-left: 4px solid var(--color-accent);
}
.nav-item i {
    margin-right: 15px;
    width: 20px;
    text-align: center;
    font-size: 16px;
}

/* Badges Amarelos (Números no menu) */
.badge-nav {
    background-color: var(--color-accent);
    color: var(--bg-sidebar);
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: auto;
}

/* Status do Sistema (Rodapé lateral) */
.system-status {
    margin: 24px;
    padding: 15px;
    background-color: rgba(255,255,255,0.03);
    border-radius: 12px;
    font-size: 12px;
    color: #94a3b8;
}
.system-status .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
    margin-right: 6px;
}

/* =========================================
    3. ÁREA PRINCIPAL E TOPBAR
    ========================================= */
.main-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px 10px 40px;
    margin-bottom: 20px;
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border-color); 
}

/* Barra de pesquisa */
.search-bar {
    background-color: var(--surface-3);
    border-radius: 30px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    width: 350px;
    border: 1px solid var(--border-color);
}
.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    margin-left: 10px;
    width: 100%;
    font-size: 14px;
    color: var(--text-main);
}

/* Perfil de Utilizador */
.user-profile {
    display: flex;
    align-items: center;
    gap: 20px;
}
.notification-icon {
    position: relative;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
}
.notification-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background-color: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid var(--bg-main); /* Cria um recorte à volta do sino */
}
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-text {
    text-align: right;
}
.user-text h4 {
    font-size: 14px;
    font-weight: 600;
}
.user-text p {
    font-size: 12px;
    color: var(--text-muted);
}
.user-avatar {
    background-color: var(--color-primary);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
}

/* =========================================
    4. CONTEÚDO DO DASHBOARD
    ========================================= */
.content {
    padding: 0 40px 40px 40px;
}

/* Cabeçalho do conteúdo */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 30px;
}
.page-title span.tag {
    background-color: #eff6ff;
    color: var(--color-primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}
.page-title h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
}
.page-title p {
    color: var(--text-muted);
    font-size: 14px;
}
.header-actions {
    display: flex;
    gap: 15px;
}
.btn-outline {
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 30px;
    color: var(--text-main);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
}

/* Atualização do Botão Principal com Gradiente */
.btn-primary {
    padding: 10px 24px;
    background: var(--btn-gradient); /* Aplica o gradiente aqui */
    border: none;
    border-radius: 30px;
    color: white;
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease; /* Animação suave */
    box-shadow: 0 4px 10px rgba(59, 102, 245, 0.2); /* Sombra subtil azul */
}

/* Efeito quando passas o rato por cima do botão */
.btn-primary:hover {
    box-shadow: 0 6px 15px rgba(59, 102, 245, 0.4);
    transform: translateY(-2px); /* Levanta o botão ligeiramente */
}

/* Grelha de KPIs (Cartões) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}
.kpi-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
    position: relative;
}
.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    margin-bottom: 20px;
}
/* Cores de fundo para ícones dos cartões */
.icon-blue { background: #eff6ff; color: #3b82f6; }
.icon-yellow { background: #fefce8; color: #eab308; }
.icon-purple { background: #f5f3ff; color: #8b5cf6; }

.kpi-card .arrow-link {
    position: absolute;
    top: 24px;
    right: 24px;
    color: #cbd5e1;
    font-size: 12px;
    cursor: pointer;
}
.kpi-card h3 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 5px;
}
.kpi-card p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.kpi-trend {
    font-size: 13px;
    font-weight: 500;
}
.trend-blue { color: #3b82f6; }
.trend-red { color: #ef4444; }

/* Secção dos Gráficos */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr; /* O gráfico de linhas ocupa o dobro do espaço */
    gap: 20px;
    margin-bottom: 30px;
}
.chart-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.chart-title h4 {
    font-size: 16px;
    font-weight: 600;
}
.chart-title p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Secção Inferior (Tabelas/Listas) */
.bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
/* Adaptação simples das listas da base do ecrã */
.list-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

/* =========================================
   5. TABELAS E LISTAGENS (Estilo ZugIT)
   ========================================= */
.table-container {
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    padding: 24px;
    overflow-x: auto;
}

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

.zug-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.zug-table td {
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.zug-table tr:last-child td { border-bottom: none; }
.zug-table tr:hover td { background-color: var(--surface-2); cursor: default; }

/* Componente de Colaborador na Tabela */
.user-cell { display: flex; align-items: center; gap: 15px; }
.user-avatar-small {
    background-color: #eff6ff;
    color: var(--color-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    font-size: 14px;
}
.user-details h5 { font-size: 14px; font-weight: 600; color: var(--text-main); margin-bottom: 2px; }
.user-details p { font-size: 13px; color: var(--text-muted); }

/* Badges de Estado */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.badge.ativo { background-color: #ecfdf5; color: #10b981; }
.badge.inativo { background-color: #fef2f2; color: #ef4444; }

/* Botões de Ação na Tabela */
.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px 10px;
    transition: 0.2s;
}
.action-btn:hover { color: var(--color-primary); }

/* =========================================
   6. MODALS (Pop-ups)
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 21, 42, 0.6); /* Fundo escuro semi-transparente */
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 500px;
    border-radius: 20px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    transform: translateY(20px);
    transition: all 0.3s ease;
    overflow: hidden;
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

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

.modal-header h3 { font-size: 18px; font-weight: 600; margin: 0; }
.btn-close {
    background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer;
}
.btn-close:hover { color: var(--text-main); }

.modal-body { padding: 25px; }

/* Para colocar os campos lado a lado no modal */
.form-row { display: flex; gap: 15px; margin-bottom: 20px; }
.form-row .form-group { flex: 1; margin-bottom: 0; }

.modal-footer {
    padding: 20px 25px;
    background: var(--surface-2);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* =========================================
   7. ESTILOS DE FORMULÁRIOS (Inputs Premium)
   ========================================= */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

/* O Segredo do Input Moderno */
.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-main);
    background-color: var(--card-bg);
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
    box-sizing: border-box; /* Impede que o padding estrague a largura */
}

/* Efeito quando o utilizador clica no campo (Focus) */
.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(59, 102, 245, 0.1); /* Um anel azul suave e brilhante */
    background-color: #fcfdff;
}

/* Estilo específico para dropdowns (Select) para remover a seta rude do browser */
select.form-control {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    /* Injeta uma seta SVG moderna e minimalista usando CSS */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    padding-right: 40px; /* Dá espaço para a seta não sobrepor o texto */
    cursor: pointer;
}

/* Badges de Estado de Equipamentos */
.badge.stock { background-color: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.badge.atribuido { background-color: #eff6ff; color: #3b66f5; border: 1px solid #bfdbfe; }
.badge.manutencao { background-color: #fef2f2; color: #ef4444; border: 1px solid #fecaca; }
.badge.abatido { background-color: var(--surface-3); color: #64748b; border: 1px solid #cbd5e1; }

/* Texto de Garantia */
.text-garantia { font-size: 12px; font-weight: 600; }
.garantia-ok { color: #64748b; }
.garantia-alerta { color: #eab308; } /* Amarelo/Laranja para alertas */
.garantia-expirada { color: #ef4444; } /* Vermelho */

.menu-toggle { display: none; background: none; border: none; font-size: 24px; color: var(--text-main); cursor: pointer; }
/* =========================================
   8. RESPONSIVIDADE MOBILE (Smartphones)
   ========================================= */
@media (max-width: 768px) {
    /* Esconde a sidebar fora do ecrã por defeito */
    .sidebar {
        position: fixed;
        left: -280px; /* fora do ecrã (a sidebar tem 260px) */
        top: 0;
        height: 100vh;
        z-index: 9999;
        transition: left 0.3s ease;
    }
    
    /* Classe que o JS vai adicionar para mostrar a sidebar */
    .sidebar.open { left: 0; }
    
    /* Ajusta a área principal */
    .main-content { margin-left: 0 !important; width: 100%; padding: 15px; }
    
    /* Tabelas com scroll horizontal para não quebrarem o layout */
    .table-responsive { overflow-x: auto; display: block; width: 100%; }

    .menu-toggle { display: block; margin-bottom: 15px; }
    
    /* Classe para mostrar a barra quando clicarmos num botão de menu (Hamburger) */
    .sidebar.active {
        left: 0;
    }

    /* O conteúdo principal passa a ocupar 100% do ecrã */
    .main-wrapper {
        margin-left: 0;
        width: 100%;
    }

    /* Ajustes para o topo não ficar apertado */
    .topbar {
        padding: 15px 20px;
    }
    
    .search-bar {
        width: 60%; /* Encolhe a barra de pesquisa no telemóvel */
    }
}

/* Badges de Estado de Pedidos (Helpdesk) */
.badge.pendente { background-color: #fef9c3; color: #ca8a04; border: 1px solid #fef08a; } /* Amarelo */
.badge.analise { background-color: #e0e7ff; color: #4f46e5; border: 1px solid #c7d2fe; } /* Roxo/Índigo */
.badge.concluido { background-color: #dcfce7; color: #16a34a; border: 1px solid #bbf7d0; } /* Verde */
.badge.cancelado { background-color: #f3f4f6; color: #6b7280; border: 1px solid #e5e7eb; } /* Cinza */

.nav-item {
    display: flex;
    align-items: center;
    position: relative;
    padding: 12px 20px;
    text-decoration: none;
    color: #64748b;
    border-radius: 12px;
    margin-bottom: 5px;
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.badge-count {
    background: #ef4444; /* Vermelho para Pedidos */
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: auto; /* Empurra para a direita */
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}


/* =========================================
   9. DROPDOWN DE PERFIL
   ========================================= */
.profile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 15px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    width: 200px;
    padding: 10px 0;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}
.profile-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.dropdown-item { display: flex; align-items: center; padding: 10px 20px; color: var(--text-main); text-decoration: none; font-size: 14px; font-weight: 500; transition: 0.2s; }
.dropdown-item i { margin-right: 12px; color: var(--text-muted); width: 16px; text-align: center; }
.dropdown-item:hover { background: var(--surface-2); color: var(--color-primary); }
.dropdown-item:hover i { color: var(--color-primary); }
.dropdown-divider { height: 1px; background: var(--border-color); margin: 8px 0; }

/* Estilos para o botão de Sair */
.text-danger { color: #ef4444 !important; }
.text-danger i { color: #ef4444 !important; }
.dropdown-item.text-danger:hover { background: #fef2f2; color: #dc2626 !important; }
.dropdown-item.text-danger:hover i { color: #dc2626 !important; }

/* =========================================
   10. DROPDOWN DE NOTIFICAÇÕES
   ========================================= */
.notification-dropdown {
    position: absolute;
    top: 100%;
    right: -10px; /* Alinha ligeiramente à direita do sino */
    margin-top: 15px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    width: 320px;
    padding: 0;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    cursor: default; /* Impede que o cursor do sino passe para o menu */
    text-align: left;
}
.notification-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.notification-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 14px;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.notification-item { display: flex; align-items: flex-start; padding: 15px 20px; text-decoration: none; border-bottom: 1px solid var(--border-color); transition: 0.2s; }
.notification-item:last-child { border-bottom: none; }
.notification-item:hover { background: var(--surface-2); }
.notif-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; justify-content: center; align-items: center; margin-right: 15px; flex-shrink: 0; font-size: 14px; }
.notif-icon.blue { background: #eff6ff; color: #3b82f6; }
.notif-icon.yellow { background: #fefce8; color: #eab308; }
.notif-content h5 { font-size: 13px; color: var(--text-main); margin: 0 0 4px 0; font-weight: 600; }
.notif-content p { font-size: 12px; color: var(--text-muted); margin: 0; line-height: 1.4; }
.notification-empty { padding: 30px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }
/* Logótipo do tenant no menu lateral */
.logo-icon.has-logo { background: #fff; padding: 4px; overflow: hidden; }
.logo-icon.has-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Gestão de equipamentos */
.badge.encomendado { background-color: #f5f3ff; color: #7c3aed; border: 1px solid #ddd6fe; }
.badge.perdido { background-color: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.tag-etiqueta { font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 12px; background: #0f172a; color: #fff; padding: 3px 8px; border-radius: 6px; white-space: nowrap; text-decoration: none; }
.sn-code { font-family: ui-monospace, Consolas, monospace; background: var(--surface-3); padding: 3px 7px; border-radius: 4px; font-size: 12px; }
.sn-rep { font-size: 10px; font-weight: 700; color: #7c3aed; background: #f5f3ff; padding: 2px 6px; border-radius: 10px; margin-left: 4px; cursor: help; }
.eq-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.eq-toolbar .form-control { padding: 9px 12px; font-size: 13px; width: auto; min-width: 130px; }
.eq-search { flex: 1 1 260px; position: relative; }
.eq-search input { width: 100%; padding-left: 34px; }
.eq-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { background: var(--surface-3); border: 1px solid #e2e8f0; padding: 6px 14px; border-radius: 50px; font-size: 13px; font-weight: 500; color: #64748b; text-decoration: none; white-space: nowrap; }
.chip:hover { background: #e2e8f0; } .chip.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.chip small { opacity: .7; margin-left: 4px; }
.kpi-link { text-decoration: none; color: inherit; display: block; transition: transform .15s, box-shadow .15s; }
.kpi-link:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.07); }
.bulk-bar { display: none; position: sticky; bottom: 14px; z-index: 20; background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 14px; align-items: center; gap: 12px; flex-wrap: wrap; box-shadow: 0 10px 30px rgba(0,0,0,.25); margin-top: 14px; }
.bulk-bar.show { display: flex; }
.bulk-bar select, .bulk-bar input { padding: 8px 10px; border-radius: 8px; border: 0; font-size: 13px; }
.bulk-bar .btn-primary { padding: 8px 16px; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 16px; font-size: 13px; color: var(--text-muted); }
.pager a, .pager span.cur { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-color); text-decoration: none; color: var(--text-main); background: var(--card-bg); }
.pager span.cur { background: #0f172a; color: #fff; border-color: #0f172a; }
.th-sort { color: inherit; text-decoration: none; white-space: nowrap; }
.th-sort:hover { color: var(--color-primary); }
.eq-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.eq-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 16px; padding: 22px; margin-bottom: 20px; }
.eq-card h3 { margin: 0 0 14px; font-size: 16px; }
.eq-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 18px; }
.eq-fields .form-group { margin: 0; }
.eq-fields label, .eq-card .form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 5px; }
.eq-dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 14px; margin: 0; }
.eq-dl dt { color: var(--text-muted); } .eq-dl dd { margin: 0; font-weight: 500; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-color); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .dot { width: 30px; height: 30px; border-radius: 50%; background: #eef2ff; color: var(--color-primary); display: grid; place-items: center; flex: none; font-size: 12px; }
.timeline small { color: var(--text-muted); display: block; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color); margin-bottom: 18px; }
.tabs a { padding: 10px 18px; font-weight: 600; font-size: 14px; color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; padding: 9px 16px; border-radius: 10px; font-weight: 600; cursor: pointer; font-size: 13px; }
@media (max-width: 900px) { .eq-grid { grid-template-columns: 1fr; } }

/* Helpdesk */
.badge.aguarda { background-color: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.prio { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.prio-baixa { background: var(--surface-3); color: #64748b; } .prio-normal { background: #e0e7ff; color: #4338ca; }
.prio-alta { background: #ffedd5; color: #c2410c; } .prio-urgente { background: #fee2e2; color: #b91c1c; animation: pulso 2s infinite; }
@keyframes pulso { 50% { box-shadow: 0 0 0 4px rgba(220,38,38,.15); } }
.tk-tipo { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.conversa { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 82%; padding: 12px 16px; border-radius: 14px; font-size: 14px; line-height: 1.5; background: var(--surface-3); }
.msg.minha { align-self: flex-end; background: #e0e7ff; }
.msg.nota { background: #fffbeb; border: 1px dashed #fcd34d; align-self: stretch; max-width: 100%; }
.msg.sistema { align-self: center; background: transparent; color: var(--text-muted); font-size: 12px; text-align: center; max-width: 100%; padding: 2px; }
.msg small { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.tipo-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.tipo-card { border: 2px solid var(--border-color); border-radius: 14px; padding: 14px; cursor: pointer; background: var(--card-bg); display: block; }
.tipo-card:hover { border-color: #93c5fd; } .tipo-card input { display: none; }
.tipo-card:has(input:checked) { border-color: var(--color-primary); background: #eff6ff; }
.tipo-card i { font-size: 20px; color: var(--color-primary); margin-bottom: 6px; display: block; } .tipo-card small { color: var(--text-muted); font-size: 12px; }

/* =========================================
   12. FASE 2: ACESSIBILIDADE, MENU MÓVEL, SUBSCRIÇÃO, ONBOARDING
   ========================================= */
/* Foco visível para quem navega com o teclado */
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid var(--color-primary); outline-offset: 2px; border-radius: 6px;
}
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 10001; background: var(--card-bg); color: var(--text-main); padding: 10px 16px; border-radius: 8px; font-weight: 600; }
.skip-link:focus { left: 8px; }
.content:focus { outline: none; }

/* Cabeçalho: botões reais (teclado + leitores de ecrã) com o aspeto anterior */
.icon-btn { position: relative; background: none; border: 0; padding: 6px; color: var(--text-muted); font-size: 18px; cursor: pointer; line-height: 1; }
.user-btn { display: flex; align-items: center; gap: 12px; background: none; border: 0; padding: 0; cursor: pointer; text-align: right; color: inherit; font: inherit; }
.user-info { position: relative; }
.user-nome { display: block; font-size: 14px; font-weight: 600; }
.user-role { display: block; font-size: 12px; color: var(--text-muted); }
.dropdown-btn { width: 100%; background: none; border: 0; cursor: pointer; font: inherit; }
.pill-novas { font-size: 11px; background: #eff6ff; color: var(--color-primary); padding: 2px 8px; border-radius: 10px; font-weight: 700; }

/* Menu lateral: grupos e estado do plano como ligação */
.nav-grupo { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; padding: 16px 20px 6px; font-weight: 700; }
a.system-status { display: block; text-decoration: none; }
a.system-status:hover { background-color: rgba(255,255,255,0.07); }
.system-status .dot.dot-off { background-color: #f59e0b; }

/* Menu móvel: fundo escuro por trás, fecha ao tocar fora ou com Esc */
.menu-backdrop { display: none; }
@media (max-width: 768px) {
    .menu-toggle { position: fixed; top: 12px; left: 12px; z-index: 9998; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 10px; width: 44px; height: 44px; margin: 0; }
    .topbar { padding-left: 70px; }
    body.menu-aberto .menu-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 9990; }
    .content { padding: 0 16px 32px; }
    .user-text { display: none; }
    .page-header { flex-wrap: wrap; gap: 12px; }
    table { font-size: 13px; }
}

/* Faixas de aviso (trial, modo só de leitura, funcionalidades de outro plano) */
.banner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 18px; border-radius: 12px; margin: 0 0 20px; font-size: 14px; line-height: 1.5; }
.banner > i { font-size: 18px; }
.banner > div { flex: 1; min-width: 220px; }
.banner .btn-primary { text-decoration: none; white-space: nowrap; }
.banner-aviso { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.banner-erro { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.banner-info { background: #f5f3ff; border: 1px solid #ddd6fe; color: #5b21b6; }

/* Etiquetas de estado (iguais às da área da plataforma) */
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; vertical-align: middle; }
.pill-ativo { background: #dcfce7; color: #15803d; } .pill-trial { background: #dbeafe; color: #1d4ed8; } .pill-expirado { background: #fef9c3; color: #a16207; }

/* Subscrição: medidores de utilização e planos */
.medidor { margin-bottom: 14px; }
.medidor-topo { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.medidor-barra { height: 8px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.medidor-barra span { display: block; height: 100%; background: var(--color-primary); border-radius: 6px; }
.medidor-barra span.quase { background: #f59e0b; } .medidor-barra span.cheio { background: #ef4444; }
.planos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.plano-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; }
.plano-card.destaque { border: 2px solid var(--color-primary); box-shadow: 0 8px 24px rgba(59, 102, 245, .12); }
.plano-card h4 { margin: 0 0 8px; font-size: 17px; }
.plano-preco { font-size: 30px; font-weight: 700; margin-bottom: 12px; }
.plano-preco small { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.plano-limites, .plano-recursos { list-style: none; margin: 0 0 12px; padding: 0; font-size: 13px; line-height: 1.9; }
.plano-limites { font-weight: 600; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
.plano-recursos i { color: #16a34a; width: 16px; }
.plano-recursos li.realce { background: #f5f3ff; border-radius: 6px; font-weight: 600; }
.breve { font-size: 10px; background: var(--surface-3); color: var(--text-muted); padding: 1px 6px; border-radius: 6px; text-transform: uppercase; font-weight: 700; }
.plano-form { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.plano-form label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.btn-block { width: 100%; justify-content: center; }

/* Primeiros passos (onboarding) */
.passos { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.passo { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--card-bg); }
.passo .n { flex: 0 0 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; background: #eff6ff; color: var(--color-primary); }
.passo.feito .n { background: #dcfce7; color: #15803d; }
.passo.feito .passo-txt b { text-decoration: line-through; color: var(--text-muted); }
.passo-txt { flex: 1; font-size: 14px; } .passo-txt span { display: block; font-size: 12px; color: var(--text-muted); }
.passo a.btn-outline { text-decoration: none; white-space: nowrap; }
.progresso { height: 6px; background: var(--surface-3); border-radius: 6px; margin: 4px 0 16px; overflow: hidden; }
.progresso span { display: block; height: 100%; background: #16a34a; }

/* Estado vazio com ação */
.vazio { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.vazio > i { font-size: 34px; opacity: .45; margin-bottom: 12px; display: block; }
.vazio h4 { color: var(--text-main); margin: 0 0 6px; font-size: 16px; }
.vazio p { margin: 0 auto 16px; max-width: 460px; font-size: 14px; }
.vazio .acoes { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.vazio .acoes a { text-decoration: none; }

/* Zona para largar ficheiros (importação) */
.dropzone { border: 2px dashed var(--border-color); padding: 30px; border-radius: 10px; margin-bottom: 20px; background: var(--surface-2); cursor: pointer; transition: border-color .3s; }
.dropzone:hover, .dropzone:focus-visible { border-color: var(--color-primary); }

/* Paginação e barra de pesquisa das listas */
.paginacao { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 16px; font-size: 13px; }
.paginacao a, .paginacao span { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-color); text-decoration: none; color: var(--text-main); background: var(--card-bg); }
.paginacao span.atual { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.paginacao span.info { border: 0; background: none; color: var(--text-muted); }
.lista-ferramentas { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.lista-ferramentas .form-control { max-width: 320px; }
.tabela-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .menu-toggle, .menu-backdrop, .skip-link, .banner { display: none !important; } }

/* Ligações com aspeto de botão */
a.btn-primary, a.btn-outline { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
    .passo { flex-wrap: wrap; }
    .passo-txt { flex: 1 1 calc(100% - 50px); }
    .passo a.btn-outline { margin-left: 44px; }
    .header-actions { flex-wrap: wrap; }
}

/* =========================================
   13. MODO ESCURO
   Segue o sistema (prefers-color-scheme) ou a escolha guardada (html[data-theme]).
   ========================================= */
:root { --surface-2: #f8fafc; --surface-3: #f1f5f9; color-scheme: light; }
html[data-theme="dark"] {
    --bg-main: #0b1120; --card-bg: #111a2e; --surface-2: #0f1729; --surface-3: #1a2540;
    --text-main: #e2e8f0; --text-muted: #94a3b8; --border-color: #23314f;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
        --bg-main: #0b1120; --card-bg: #111a2e; --surface-2: #0f1729; --surface-3: #1a2540;
        --text-main: #e2e8f0; --text-muted: #94a3b8; --border-color: #23314f;
        color-scheme: dark;
    }
}
/* Regras escritas para um único seletor ficam ativas em ambos os casos (tema escolhido ou sistema) */
html[data-theme="dark"] body, html[data-theme="dark"] .main-wrapper { background: var(--bg-main); color: var(--text-main); }
html[data-theme="dark"] .form-control, html[data-theme="dark"] select, html[data-theme="dark"] textarea, html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="search"], html[data-theme="dark"] input[type="email"], html[data-theme="dark"] input[type="number"], html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="password"] { background: var(--surface-2); color: var(--text-main); border-color: var(--border-color); }
html[data-theme="dark"] .btn-outline, html[data-theme="dark"] .action-btn, html[data-theme="dark"] .paginacao a, html[data-theme="dark"] .paginacao span:not(.atual):not(.info) { background: var(--surface-2); color: var(--text-main); border-color: var(--border-color); }
html[data-theme="dark"] .zug-table th { background: var(--surface-3); color: var(--text-muted); }
html[data-theme="dark"] .zug-table td { border-color: var(--border-color); }
html[data-theme="dark"] .badge.cancelado, html[data-theme="dark"] .badge.abatido { background: var(--surface-3); border-color: var(--border-color); }
html[data-theme="dark"] .banner-aviso { background: #2a2210; border-color: #5c4813; color: #fcd34d; }
html[data-theme="dark"] .banner-erro { background: #2a1215; border-color: #5c1d24; color: #fca5a5; }
html[data-theme="dark"] .banner-info { background: #1d1838; border-color: #3b3270; color: #c4b5fd; }
html[data-theme="dark"] .msg-success { background: #0f2a1c; color: #86efac; border-color: #14532d; }
html[data-theme="dark"] .msg-error { background: #2a1215; color: #fca5a5; border-color: #5c1d24; }
/* Estilos inline mais comuns nas páginas (fundos brancos/cinza-claro e texto escuro) */
html[data-theme="dark"] [style*="background:#fff"], html[data-theme="dark"] [style*="background: #fff"], html[data-theme="dark"] [style*="background: white"],
html[data-theme="dark"] [style*="background:white"], html[data-theme="dark"] [style*="background-color: #fff"], html[data-theme="dark"] [style*="background: #ffffff"] { background: var(--card-bg) !important; }
html[data-theme="dark"] [style*="background:#f8fafc"], html[data-theme="dark"] [style*="background: #f8fafc"], html[data-theme="dark"] [style*="background:#f1f5f9"],
html[data-theme="dark"] [style*="background: #f1f5f9"], html[data-theme="dark"] [style*="background:#fffdf5"], html[data-theme="dark"] [style*="background:#eff6ff"],
html[data-theme="dark"] [style*="background: #eff6ff"] { background: var(--surface-3) !important; }
html[data-theme="dark"] [style*="color:#0f172a"], html[data-theme="dark"] [style*="color: #0f172a"], html[data-theme="dark"] [style*="color:#334155"],
html[data-theme="dark"] [style*="color: #334155"], html[data-theme="dark"] [style*="color: var(--text-main)"] { color: var(--text-main) !important; }
html[data-theme="dark"] [style*="border:1px solid #e2e8f0"], html[data-theme="dark"] [style*="border: 1px solid #e2e8f0"], html[data-theme="dark"] [style*="border-bottom: 1px solid #e2e8f0"] { border-color: var(--border-color) !important; }
html[data-theme="dark"] img.logo-claro { filter: brightness(1.05); }
html[data-theme="dark"] .logo-icon.has-logo { background: #fff; } /* os logótipos são feitos para fundo claro */

/* Seletor do tema (menu do perfil) */
.tema-opcoes { display: flex; gap: 4px; padding: 6px 14px 10px; }
.tema-opcoes button { flex: 1; border: 1px solid var(--border-color); background: var(--surface-2); color: var(--text-main); border-radius: 8px; padding: 6px 4px; font: inherit; font-size: 12px; cursor: pointer; }
.tema-opcoes button[aria-pressed="true"] { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.tema-titulo { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 6px 20px 0; font-weight: 700; }

/* =========================================
   14. LISTAS EM CARTÕES NO TELEMÓVEL
   O app.js marca as tabelas de dados com .tabela-cartoes e põe em cada célula o título da coluna (data-label).
   ========================================= */
@media (max-width: 768px) {
    table.tabela-cartoes thead { display: none; }
    table.tabela-cartoes, table.tabela-cartoes tbody, table.tabela-cartoes tr, table.tabela-cartoes td { display: block; width: 100%; box-sizing: border-box; }
    table.tabela-cartoes tr { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; margin: 0 0 10px; padding: 8px 0; }
    table.tabela-cartoes td { border: 0 !important; padding: 5px 14px !important; display: flex; gap: 12px; justify-content: space-between; align-items: center; text-align: right; min-height: 0; }
    table.tabela-cartoes td::before { content: attr(data-label); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; text-align: left; flex: 0 0 38%; }
    table.tabela-cartoes td[data-label=""]::before, table.tabela-cartoes td[colspan]::before { display: none; }
    table.tabela-cartoes td[colspan] { display: block; text-align: center; }
    table.tabela-cartoes td > * { max-width: 62%; }
    table.tabela-cartoes td[data-label=""] > *, table.tabela-cartoes td[colspan] > * { max-width: none; }
    table.tabela-cartoes tr:hover td { background: transparent !important; }
    .table-container { background: transparent; border: 0; box-shadow: none; padding: 0; overflow: visible; }
}
