:root {
    --primary: #f29f05;
    --primary-hover: #d98a04;
    --primary-light: #fef5e6;
    --bg-color: #f7f9fc;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-main: #334155;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;

    --kpi-yellow: #f59e0b;
    --kpi-yellow-bg: #fef3c7;
    --kpi-blue: #3b82f6;
    --kpi-blue-bg: #dbeafe;
    --kpi-green: #10b981;
    --kpi-green: #10b981;
    --kpi-green-bg: #d1fae5;

    --thead-bg: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    --thead-color: #334155;
    --kpi-card-bg: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    --kpi-card-border: #cbd5e1;
    --kpi-card-circle: rgba(0,0,0,0.04);
    --table-bg: #ffffff;
}

[data-theme="dark"] {
    --bg-color: #050a15;
    --sidebar-bg: #1e293b;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --primary-light: #33230a;

    --thead-bg: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    --thead-color: #94a3b8;
    --kpi-card-bg: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    --kpi-card-border: #334155;
    --kpi-card-circle: rgba(255,255,255,0.03);
    --table-bg: #162032;
}

/* Dropdown options legíveis no tema escuro */
[data-theme="dark"] select option {
    background: #1e293b;
    color: #f8fafc;
}

/* Ícones de calendário/setas nos inputs date/month/number visíveis no tema escuro */
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="month"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.logo-area {
    display: flex;
    align-items: center;
    padding: 24px;
    gap: 12px;
}

.logo-icon {
    background: var(--primary);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.logo-text h1 {
    font-size: 16px;
    font-weight: 700;
}

.logo-text span {
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-main);
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    gap: 12px;
    transition: all 0.2s;
}

.nav-item i {
    color: var(--text-muted);
    font-size: 16px;
    width: 20px;
    text-align: center;
}

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

.nav-item.active {
    background: var(--primary-light);
    color: #ffffff;
}

.nav-item.active i {
    color: var(--primary);
}

/* Group toggle com sub-item ativo */
.nav-group-toggle.active-parent {
    background: rgba(255,255,255,0.04);
    color: #ffffff;
}

/* ── Nav Group (collapsible) ── */
.nav-group {
    display: flex;
    flex-direction: column;
}

.nav-group-toggle {
    cursor: pointer;
}

.nav-group-toggle.open {
    background: var(--bg-color);
}

.nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nav-sub-item {
    padding-left: 44px !important;
    font-size: 13px !important;
    padding-top: 9px !important;
    padding-bottom: 9px !important;
}

.nav-sub-item i {
    font-size: 13px !important;
    width: 16px !important;
}

.sidebar.collapsed .nav-group-items {
    display: none !important;
}

.sidebar.collapsed .nav-group-arrow {
    display: none;
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--kpi-blue-bg);
    color: var(--kpi-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    overflow: hidden;
    flex-shrink: 0;
}

.user-details strong {
    display: block;
    font-size: 14px;
}

.user-details span {
    font-size: 12px;
    color: var(--text-muted);
}

.logout-btn {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-color);
}

.view-section {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color .3s;
}
.view-section:hover { scrollbar-color: rgba(148,163,184,0.35) transparent; }
.view-section::-webkit-scrollbar { width: 5px; }
.view-section::-webkit-scrollbar-track { background: transparent; }
.view-section::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; }
.view-section:hover::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.35); }

.top-header {
    height: 70px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
}

.top-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.content-wrapper {
    padding: 32px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

/* FILTERS BAR */
.filters-bar {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    gap: 16px;
    margin-bottom: 24px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
}

.filter-select {
    padding: 8px 32px 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    font-size: 14px;
    color: var(--text-main);
    outline: none;
}

/* CHARTS GRID */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.chart-box {
    padding: 24px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: box-shadow .2s, transform .15s;
}
.chart-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,.2);
}

.chart-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.chart-header span {
    font-size: 13px;
    color: var(--text-muted);
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 12px;
}

.empty-state i {
    font-size: 48px;
    opacity: 0.3;
}

.skeleton-bar {
    height: 12px;
    background: var(--bg-color);
    border-radius: 6px;
    margin-bottom: 24px;
}

.skeleton-bar.highlight {
    background: var(--primary-light);
}

/* BUTTONS */
.btn {
    border: none;
    cursor: pointer;
    font-weight: 600;
    border-radius: 6px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

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

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

.btn-large {
    padding: 14px 24px;
    font-size: 16px;
    border-radius: 8px;
    width: 100%;
    justify-content: center;
}

/* TABLE ACTIONS BUTTONS */
.action-btn {
    border: none;
    cursor: pointer;
    font-weight: 600;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: all 0.2s;
    background: #f1f5f9;
    color: var(--text-main);
}

.action-btn:hover {
    background: #e2e8f0;
}

.action-danger {
    color: #ef4444;
    background: #fef2f2;
}

.action-danger:hover {
    background: #fee2e2;
}

.action-info {
    color: #0ea5e9;
    background: #f0f9ff;
}

.action-info:hover {
    background: #e0f2fe;
}

.action-warning {
    color: #f59e0b;
    background: #fffbeb;
}

.action-warning:hover {
    background: #fef3c7;
}

/* UPLOAD VIEW */
.upload-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px;
}

.upload-container h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

.upload-container p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 32px;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.file-drop-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    background: #fafbfc;
    position: relative;
    transition: all 0.2s;
}

.file-drop-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-drop-area i {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 12px;
}

.file-drop-area label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.file-drop-area input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-drop-area.has-file {
    border-color: #10b981 !important;
    background-color: rgba(16, 185, 129, 0.15) !important;
}

.file-drop-area.has-file i {
    color: #10b981 !important;
}

.file-name {
    font-size: 12px;
    color: var(--text-muted);
}

.status-box {
    margin-top: 24px;
    padding: 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}

.status-box.sucesso {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #10b981 !important;
    border: 1px solid #10b981 !important;
}

.status-box.erro {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: #ef4444 !important;
    border: 1px solid #ef4444 !important;
}

/* TABLES V! */
.table-actions {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.search-box {
    position: relative;
    width: 300px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 10px 10px 10px 36px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
}

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

.data-table th,
.data-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.data-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.data-table tbody tr:hover {
    background: var(--bg-color);
}

/* Row hover global — todas as tabelas */
.view-section table tbody tr:hover,
.modal-body-scroll table tbody tr:hover,
[style*="overflow"] table tbody tr:hover {
    background: rgba(148,163,184,0.06);
    transition: background .15s;
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge.orange {
    background: var(--primary-light);
    color: var(--primary);
}

.badge.blue {
    background: var(--kpi-blue-bg);
    color: var(--kpi-blue);
}

.badge.green {
    background: var(--kpi-green-bg);
    color: #059669;
}


/* ===================================================
   SIDEBAR RETRÁTIL
   =================================================== */
.sidebar {
    transition: width 0.25s ease;
    overflow: hidden;
    position: relative;
}

.sidebar.collapsed {
    width: 64px !important;
}

.sidebar.collapsed .sidebar-label {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .logo-area {
    justify-content: center;
    padding: 16px 0;
}

.sidebar.collapsed .logo-icon {
    margin: 0;
}

.sidebar.collapsed .sidebar-footer .user-info {
    justify-content: center;
}

.sidebar.collapsed .user-avatar {
    margin: 0;
}

/* Botão de colapso na logo-area */
.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 6px;
    margin-left: auto;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--border-color);
    color: var(--text-main);
}

.sidebar.collapsed .sidebar-toggle {
    margin-left: 0;
    transform: rotate(180deg);
}

/* Botão hamburger no top-header para mobile / quando sidebar está oculta */
.sidebar-toggle-main {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    padding: 4px 10px;
    border-radius: 6px;
    margin-right: 8px;
}

.sidebar-toggle-main:hover {
    background: var(--border-color);
    color: var(--text-main);
}

/* ===================================================
   DARK MODE — VARIÁVEIS E OVERRIDES
   =================================================== */
body.dark-mode {
    --bg-color: #0f172a;
    --sidebar-bg: #1e293b;
    --card-bg: #1e293b;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    /* mais claro que o padrão para ser legível */
    --border-color: #334155;
    --primary-light: #3d2a07;
}

/* Elementos base */
body.dark-mode,
body.dark-mode p,
body.dark-mode span,
body.dark-mode li,
body.dark-mode label {
    color: var(--text-main);
}

/* Sidebar */
body.dark-mode .sidebar {
    background: var(--sidebar-bg);
    border-color: var(--border-color);
}

body.dark-mode .nav-item {
    color: #94a3b8;
}

body.dark-mode .nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}
body.dark-mode .nav-item.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

body.dark-mode .nav-group-toggle.active-parent {
    background: rgba(255, 255, 255, 0.04);
    color: #ffffff;
}

body.dark-mode .logo-text h1 {
    color: var(--text-main);
}

body.dark-mode .logo-text span {
    color: var(--text-muted);
}

body.dark-mode .sidebar-footer {
    border-color: var(--border-color);
}

body.dark-mode .user-details strong,
body.dark-mode .user-details span {
    color: var(--text-muted);
}

/* Cabeçalho */
body.dark-mode .top-header {
    background: var(--sidebar-bg);
    border-color: var(--border-color);
    color: var(--text-main);
}

body.dark-mode #page-title {
    color: var(--text-main);
}

/* Cards e painéis */
body.dark-mode .card,
body.dark-mode .table-container,
body.dark-mode .upload-container,
body.dark-mode .chart-box {
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-main);
}

/* Filtros */
body.dark-mode .filters-bar {
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-muted);
}

body.dark-mode .filter-group {
    color: var(--text-muted);
}

body.dark-mode .filter-select {
    background: #0f172a;
    border-color: var(--border-color);
    color: var(--text-main);
}

/* Tabela */
body.dark-mode .data-table {
    color: var(--text-main);
}

body.dark-mode .data-table thead th {
    border-color: rgba(255,255,255,0.1) !important;
}

body.dark-mode .data-table td {
    color: var(--text-main) !important;
    border-color: var(--border-color) !important;
}
.tre-kpi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.tre-status-badge.tre-st-vencido { color: #fff !important; background: #dc2626 !important; border-radius:6px !important; }
.tre-status-badge.tre-st-avencer { color: #fff !important; background: #d97706 !important; border-radius:6px !important; }
.tre-status-badge.tre-st-valido  { color: #fff !important; background: #059669 !important; border-radius:6px !important; }
.tre-status-badge.tre-st-finalizado { color: #fff !important; background: #334155 !important; border-radius:6px !important; }

#view-treinamentos {
    flex-direction: column;
    height: calc(100vh - 80px);
    overflow: hidden;
}
#view-treinamentos > .card.table-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

body.dark-mode .data-table tr:hover {
    background: rgba(255, 255, 255, 0.04);
}
body.dark-mode .view-section table tbody tr:hover,
body.dark-mode [style*="overflow"] table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Textos inline ("Servente de obras" e similares) */
body.dark-mode td span:not(.status-badge),
body.dark-mode td [style*="color:#475569"],
body.dark-mode td [style*="color: #475569"],
body.dark-mode td [style*="color:#64748b"],
body.dark-mode td [style*="color: #64748b"] {
    color: #94a3b8 !important;
}
body.dark-mode td .status-badge {
    color: #fff !important;
}

/* Regras de Rateio / card de conteúdo */
body.dark-mode .rule-card,
body.dark-mode .rule-card h3,
body.dark-mode .rule-card p,
body.dark-mode .rule-card li,
body.dark-mode .rule-card span {
    color: var(--text-main) !important;
}

/* Faz todos os textos dentro de .card ficarem legíveis */
body.dark-mode .card h3,
body.dark-mode .card h4,
body.dark-mode .card p,
body.dark-mode .card li,
body.dark-mode .card span:not(.badge),
body.dark-mode .card strong {
    color: var(--text-main) !important;
}

/* Textos de seções de conteúdo estático */
body.dark-mode .content-section,
body.dark-mode .content-section * {
    color: var(--text-main);
}

/* Inputs e selects */
body.dark-mode input[type="text"],
body.dark-mode input[type="number"],
body.dark-mode select,
body.dark-mode textarea {
    background: #0f172a;
    border-color: var(--border-color);
    color: var(--text-main);
}

body.dark-mode input::placeholder {
    color: var(--text-muted);
}

/* Empty table */
body.dark-mode .empty-table {
    color: var(--text-muted) !important;
}

/* Chart headers */
body.dark-mode .chart-header h3,
body.dark-mode .chart-header span {
    color: var(--text-main);
}

/* Modal */
body.dark-mode .modal-container {
    background: #1e293b !important;
    color: var(--text-main);
}

body.dark-mode .modal-container h3,
body.dark-mode .modal-container p {
    color: var(--text-main) !important;
}

/* =============================================================
   DARK MODE — CORREÇÕES ESPECÍFICAS (elementos marcados em vermelho)
   ============================================================= */

/* Processar Arquivos — área de upload */
body.dark-mode .file-drop-area {
    background: #162032 !important;
    border-color: #334155 !important;
}

body.dark-mode .file-drop-area label,
body.dark-mode .file-drop-area .file-name,
body.dark-mode .file-drop-area i {
    color: #e2e8f0 !important;
}

body.dark-mode .file-drop-area.has-file {
    border-color: #10b981 !important;
    background-color: rgba(16, 185, 129, 0.18) !important;
}

body.dark-mode .file-drop-area.has-file i {
    color: #10b981 !important;
}

/* Badges de horas (ex: 175.8h) — texto fica escuro sobre fundo claro */
body.dark-mode .badge.orange {
    background: #3d2a07 !important;
    color: #fbbf24 !important;
}

body.dark-mode .badge.blue {
    background: #172038 !important;
    color: #60a5fa !important;
}

body.dark-mode .badge.green {
    background: #0d2e22 !important;
    color: #34d399 !important;
}

/* Badges inline no JS (ex: <span style="background:..."> nas horas) */
body.dark-mode .hours-badge,
body.dark-mode [class*="badge"]:not(.status-badge):not(.tre-status-badge) {
    color: #e2e8f0 !important;
}

/* Caixa de busca (Apontamentos) */
body.dark-mode .search-box {
    background: #162032 !important;
    border-color: #334155 !important;
}

body.dark-mode .search-box input {
    background: transparent !important;
    color: #e2e8f0 !important;
}

body.dark-mode .search-box i {
    color: #94a3b8 !important;
}

body.dark-mode .search-box input::placeholder {
    color: #64748b !important;
}

/* Títulos e subtítulos de seções com cor inline (Regras de Rateio, etc.) */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4 {
    color: #f1f5f9 !important;
}

/* Parágrafo de subtítulo (ex: "Entenda como o C-MO cruza...") */
body.dark-mode .view-section>p,
body.dark-mode .view-section>div>p {
    color: #94a3b8 !important;
}

/* Texto da versão em Configurações */
body.dark-mode #view-configuracoes div[style*="color"] {
    color: #94a3b8 !important;
}

/* Cabeçalho da tabela de Apontamentos */
body.dark-mode .apontamentos-table th,
body.dark-mode thead th {
    color: #94a3b8 !important;
    background: #1e293b !important;
}

/* Linhas de status de processamento */
body.dark-mode .status-box {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

/* Textos com cor hardcoded no inline style (mais genérico) */
body.dark-mode [style*="color: #1e293b"],
body.dark-mode [style*="color:#1e293b"],
body.dark-mode [style*="color: #334155"],
body.dark-mode [style*="color:#334155"],
body.dark-mode [style*="color: #0f172a"],
body.dark-mode [style*="color:#0f172a"] {
    color: #e2e8f0 !important;
}

/* Filtros — labels e placeholders */
body.dark-mode .filter-group span {
    color: #94a3b8 !important;
}

/* ===================================================
   TOGGLE SWITCH — TEMA CLARO / ESCURO
   =================================================== */
.theme-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    border-radius: 34px;
    transition: .3s;
}

.theme-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    border-radius: 50%;
    transition: .3s;
}

.theme-switch input:checked+.theme-slider {
    background-color: var(--primary);
}

.theme-switch input:checked+.theme-slider:before {
    transform: translateX(22px);
}
/* ====================================================
   MODAL DE IMPRESSÃO — forçar tema claro (legível)
   ==================================================== */

/* Fundo branco do wrapper sempre */
#print-preview-wrapper {
    background-color: white !important;
}

/* Força cor de texto padrão escura (evita herdar dark mode) */
#print-preview-wrapper * {
    color: #1e293b !important;
}

/* Linhas de cabeçalho escuro: texto branco */
#print-preview-wrapper tr[style*="background:#1e293b"] td,
#print-preview-wrapper tr[style*="background:#1e293b"] th,
#print-preview-wrapper tr[style*="background: #1e293b"] td,
#print-preview-wrapper tr[style*="background: #1e293b"] th {
    color: #ffffff !important;
}

/* Linhas de subtotal azul: texto azul escuro */
#print-preview-wrapper tr[style*="background:#dbeafe"] td,
#print-preview-wrapper tr[style*="background: #dbeafe"] td {
    color: #1e3a8a !important;
}

/* % verde nas linhas normais */
#print-preview-wrapper td[style*="color:#10b981"] {
    color: #10b981 !important;
}

/* ====================================================
   IMPRESSÃO — oculta tudo exceto o preview
   ==================================================== */
@media print {
    body > * { display: none !important; }

    #modal-print-preview {
        display: block !important;
        position: static !important;
        background: none !important;
        padding: 0 !important;
        overflow: visible !important;
    }

    #print-preview-wrapper {
        box-shadow: none !important;
        border-radius: 0 !important;
        max-width: 100% !important;
        padding: 0 !important;
    }

    #print-actions-bar { display: none !important; }

    #print-report-header {
        display: block !important;
        margin-bottom: 14px !important;
        padding-bottom: 10px !important;
        border-bottom: 2px solid #334155 !important;
    }
    #print-report-header.print-hidden {
        display: none !important;
    }

    /* Preserva cores de fundo na impressão */
    #print-preview-wrapper,
    #print-preview-wrapper * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .print-table { width: 100% !important; border-collapse: collapse !important; }
    .print-table th, .print-table td {
        border: 1px solid #94a3b8 !important;
        padding: 5px 8px !important;
        font-size: 10px !important;
    }

    /* Recibo */
    .recibo-page {
        padding: 20px 0 !important;
        page-break-inside: avoid;
    }
}

/* ── Hist Print Dropdown ── */
#adi-hist-print-menu.show { display:block !important; }
#adi-hist-print-menu button:hover { background:var(--bg-color); }

/* ── Mês Scroll Bar ── */
.mes-scroll-wrap { display:flex; align-items:center; gap:4px; flex:1; min-width:0; }
.mes-scroll-inner { display:flex; gap:6px; overflow-x:auto; scroll-behavior:smooth; flex:1; padding-bottom:2px; scrollbar-width:thin; scrollbar-color:transparent transparent; transition:scrollbar-color .3s; }
.mes-scroll-inner:hover { scrollbar-color:rgba(148,163,184,0.4) transparent; }
.mes-scroll-inner::-webkit-scrollbar { height:4px; }
.mes-scroll-inner::-webkit-scrollbar-track { background:transparent; }
.mes-scroll-inner::-webkit-scrollbar-thumb { background:transparent; border-radius:4px; }
.mes-scroll-inner:hover::-webkit-scrollbar-thumb { background:rgba(148,163,184,0.4); }
.mes-scroll-arrow { background:none; border:1px solid var(--border-color); border-radius:6px; color:var(--text-muted); cursor:pointer; padding:4px 6px; font-size:11px; flex-shrink:0; transition:all .15s; }
.mes-scroll-arrow:hover { background:var(--bg-color); color:var(--text-main); }

/* ── Dashboard ── */
.dash-welcome { padding:20px 24px; }
.dash-avatar {
    width:48px; height:48px; border-radius:50%; background:var(--primary);
    color:#fff; font-size:20px; font-weight:700; display:flex; align-items:center;
    justify-content:center; flex-shrink:0; overflow:hidden; position:relative;
}
.dash-avatar-overlay {
    position:absolute; inset:0; background:rgba(0,0,0,0.45);
    display:flex; align-items:center; justify-content:center;
    color:#fff; font-size:16px; opacity:0; transition:opacity .2s;
    border-radius:50%;
}
.dash-avatar:hover .dash-avatar-overlay {
    opacity:1;
}
.avatar-menu-popup {
    position:absolute; top:54px; left:0; z-index:50;
    background:var(--card-bg); border:1px solid var(--border-color);
    border-radius:8px; box-shadow:0 8px 24px rgba(0,0,0,0.18);
    min-width:160px; padding:4px 0;
}
.avatar-menu-popup a {
    display:flex; align-items:center; gap:8px;
    padding:9px 14px; font-size:12px; color:var(--text-main);
    text-decoration:none; transition:background .12s; white-space:nowrap;
}
.avatar-menu-popup a:hover {
    background:rgba(59,130,246,0.08);
}
.avatar-menu-popup a i { width:14px; text-align:center; }
.dash-top-row {
    display:flex; gap:16px; align-items:stretch;
}
@media (max-width:768px) {
    .dash-top-row { flex-direction:column; }
}
.dash-section-title {
    font-size:13px; font-weight:700; color:var(--text-muted); text-transform:uppercase;
    letter-spacing:.6px; margin:24px 0 10px; display:flex; align-items:center; gap:8px;
}
.dash-section-title i { color:var(--primary); font-size:14px; }
.dash-kpi-grid {
    display:grid; grid-template-columns:repeat(auto-fit, minmax(180px, 1fr));
    gap:16px;
}
.dash-kpi-5 { grid-template-columns:repeat(5, 1fr); }
@media (max-width:900px) { .dash-kpi-5 { grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); } }
.dash-kpi-card {
    background:linear-gradient(135deg, var(--card-bg) 0%, var(--bg-color) 100%);
    border:1px solid var(--border-color); border-radius:10px;
    padding:12px 14px; position:relative; overflow:hidden;
    transition:transform .15s, box-shadow .15s;
}
.dash-kpi-card:hover { transform:translateY(-2px); box-shadow:0 4px 16px rgba(0,0,0,0.08); }
.dash-kpi-blob {
    position:absolute; top:-8px; right:-8px; width:48px; height:48px;
    border-radius:50%; background:var(--kpi-bg);
}
.dash-kpi-header {
    display:flex; align-items:center; gap:6px; margin-bottom:6px;
}
.dash-kpi-header i { color:var(--kpi-accent); font-size:12px; }
.dash-kpi-label { font-size:10px; font-weight:700; color:var(--text-muted); text-transform:uppercase; letter-spacing:.5px; }
.dash-kpi-value { font-size:22px; font-weight:800; color:var(--kpi-accent); line-height:1; }
.dash-kpi-sub { font-size:10px; color:var(--text-muted); margin-top:4px; }

.dash-alert-item {
    display:flex; align-items:center; gap:10px; padding:10px 14px;
    border-radius:8px; cursor:pointer; transition:background .15s; font-size:13px; color:var(--text-main);
}
.dash-alert-item:hover { background:var(--bg-color); }
.dash-alert-dot { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.dash-alert-link { margin-left:auto; font-size:12px; font-weight:600; color:var(--primary); white-space:nowrap; }

.dash-shortcuts {
    display:grid; grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); gap:12px;
}
.dash-shortcut-card {
    background:var(--card-bg); border:1px solid var(--border-color); border-radius:12px;
    padding:18px 14px; display:flex; flex-direction:column; align-items:center; gap:10px;
    cursor:pointer; transition:all .15s; text-align:center;
}
.dash-shortcut-card:hover { border-color:var(--primary); transform:translateY(-2px); box-shadow:0 4px 16px rgba(0,0,0,0.08); }
.dash-shortcut-icon {
    width:44px; height:44px; border-radius:12px; background:var(--primary-light);
    color:var(--primary); display:flex; align-items:center; justify-content:center; font-size:18px;
}
.dash-shortcut-label { font-size:13px; font-weight:600; color:var(--text-main); }

/* ── Tabs (Usuários e Perfis) ── */
.tab-up-bar { display:flex; gap:0; border-bottom:2px solid var(--border-color); margin-bottom:18px; }
.tab-up {
    padding:10px 22px; background:none; border:none; border-bottom:2px solid transparent;
    color:var(--text-muted); font-size:14px; font-weight:600; cursor:pointer; transition:all .2s;
    margin-bottom:-2px;
}
.tab-up:hover { color:var(--text-main); }
.tab-up.active { color:var(--primary); border-bottom-color:var(--primary); }

/* ── Tabela de Permissões (Modal + Cards) ── */
.perm-table { width:100%; border-collapse:collapse; font-size:13px; }
.perm-table thead tr { background:var(--thead-bg, rgba(15,23,42,0.6)); }
.perm-th-module { padding:10px 14px; text-align:left; font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:0.5px; color:var(--thead-color, var(--text-muted)); }
.perm-th-action { padding:10px 6px; text-align:center; font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:0.3px; color:var(--thead-color, var(--text-muted)); width:11%; }
.perm-th-action i { display:block; margin-bottom:2px; font-size:13px; }
.perm-row-module { border-bottom:1px solid var(--border-color); background:var(--card-bg); }
.perm-row-module:hover { background:var(--bg-color); }
.perm-row-sub { border-bottom:1px solid var(--border-color); background:rgba(15,23,42,0.25); }
.perm-row-sub:hover { background:var(--bg-color); }
.perm-row-leaf { border-bottom:1px solid var(--border-color); background:var(--bg-body, var(--card-bg)); }
.perm-row-leaf:hover { background:var(--bg-color); }
.perm-td-module { padding:0; }
.perm-td-module-inner { display:flex; align-items:center; gap:8px; padding:10px 14px; }
.perm-mod-name { flex:1; font-weight:600; color:var(--text-main); font-size:13px; }
.perm-td-sub { padding:8px 14px 8px 44px; font-size:12px; color:var(--text-main); }
.perm-td-leaf { padding:8px 14px 8px 72px; font-size:12px; color:var(--text-muted); }
.perm-td-action { text-align:center; padding:8px 4px; }
.perm-td-action input[type="checkbox"] { width:16px; height:16px; accent-color:var(--primary); cursor:pointer; }
.perm-td-na { background:repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(100,116,139,0.04) 3px, rgba(100,116,139,0.04) 6px); }
.perm-all-cb { width:14px; height:14px; accent-color:var(--primary); cursor:pointer; }
.perm-chevron { font-size:11px; color:var(--text-muted); transition:transform 0.2s; cursor:pointer; width:16px; text-align:center; }
.perm-chevron.open { transform:rotate(90deg); }
.perm-sub-chevron { font-size:10px; color:var(--text-muted); transition:transform 0.2s; cursor:pointer; width:14px; text-align:center; }
.perm-sub-chevron.open { transform:rotate(90deg); }

/* Cards de Perfis na listagem */
.perfil-card { background:var(--card-bg); border:1px solid var(--border-color); border-radius:12px; margin-bottom:16px; overflow:hidden; }
.perfil-card-header { display:flex; align-items:center; justify-content:space-between; padding:16px 20px; border-bottom:1px solid var(--border-color); }
.perfil-card-nome { font-size:18px; font-weight:800; color:var(--text-main); margin-right:12px; }
.perfil-card-desc { font-size:13px; color:var(--text-muted); margin-right:16px; }
.perfil-card-users { font-size:12px; color:var(--text-muted); opacity:0.7; }
.perfil-card-table { width:100%; border-collapse:collapse; }
.perfil-card-table thead tr { background:rgba(15,23,42,0.3); }
.perfil-card-table tbody tr:hover { background:var(--bg-color); }

/* ── PS Accordion sections ── */
.ps-accordion-header:hover { background: var(--bg-color); }

/* ── ColFilter: filtros por coluna estilo Excel ── */
th.cf-th {
    position: relative;
}
th.cf-th.cf-filtered {
    background: #1e3560 !important;
}
.cf-th-inner {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 100%;
}
.cf-th-actions {
    display: flex;
    align-items: center;
    gap: 1px;
    flex-shrink: 0;
    margin-left: auto;
}
.cf-sort-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #475569;
    font-size: 10px;
    padding: 3px 3px;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color .15s, background .15s;
}
.cf-sort-btn:hover { color: #a78bfa; background: rgba(139,92,246,.2); }
.cf-sort-btn.active { color: #8b5cf6; background: rgba(139,92,246,.25); }
.cf-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #475569;
    font-size: 10px;
    padding: 3px 5px;
    border-radius: 4px;
    line-height: 1;
    transition: color .15s, background .15s;
}
.cf-btn:hover { color: #93c5fd; background: rgba(37,99,235,.2); }
.cf-btn.active { color: #3b82f6; background: rgba(37,99,235,.25); }
.cf-dropdown {
    display: none;
    position: fixed;
    min-width: 230px;
    max-width: 300px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,.55);
    z-index: 99999;
    overflow: hidden;
}
.cf-dropdown.open { display: block; }
.cf-search-wrap {
    padding: 8px 10px 6px;
    border-bottom: 1px solid var(--border-color);
}
.cf-search {
    width: 100%;
    padding: 5px 8px;
    background: var(--bg-main, #0f172a);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-main);
    font-size: 12px;
    outline: none;
}
.cf-search:focus { border-color: #2563eb; }
.cf-select-all {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 4px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    user-select: none;
}
.cf-select-all:hover { color: var(--text-main); }
.cf-options {
    max-height: 200px;
    overflow-y: auto;
    padding: 2px 0;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color .3s;
}
.cf-options:hover { scrollbar-color: rgba(148,163,184,0.4) transparent; }
.cf-options::-webkit-scrollbar { width: 4px; }
.cf-options::-webkit-scrollbar-track { background: transparent; }
.cf-options::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; }
.cf-options:hover::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.4); }
.cf-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-main);
    transition: background .1s;
    user-select: none;
}
.cf-option:hover { background: var(--border-color); }
.cf-option input[type="checkbox"] {
    accent-color: #3b82f6;
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    cursor: pointer;
}
.cf-option-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cf-no-results {
    padding: 10px 12px;
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}
.cf-actions {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--border-color);
    background: rgba(0,0,0,.15);
}
.cf-actions button {
    flex: 1;
    padding: 5px 8px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: opacity .15s;
}
.cf-actions button:hover { opacity: .82; }
.cf-btn-clear { background: #374151; color: #9ca3af; }
.cf-btn-apply { background: #2563eb; color: white; }

/* ── PontoTel: Resize + Col Toggle ── */
#pt-table { table-layout: fixed; }
#pt-table th, #pt-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#pt-table th { position: relative; }
#pt-table th[style*="text-align:right"] .cf-th-inner { justify-content: flex-end; }
#pt-table th[style*="text-align: right"] .cf-th-inner { justify-content: flex-end; }
#pt-table th[style*="text-align:center"] .cf-th-inner { justify-content: center; }
#pt-table th[style*="text-align: center"] .cf-th-inner { justify-content: center; }
#pt-table td[data-col="alerta"] span { color: #fff !important; }
.pt-resize-handle {
    position: absolute; right: 0; top: 0;
    width: 5px; height: 100%;
    cursor: col-resize; background: transparent; z-index: 5;
}
.pt-resize-handle:hover, .pt-resize-handle.active { background: #3b82f6; }
.pt-col-dropdown {
    position: fixed; z-index: 9999;
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 10px; padding: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
    max-height: 400px; overflow-y: auto; min-width: 200px;
}
.pt-col-dropdown label {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px; cursor: pointer; border-radius: 6px;
    font-size: 13px; color: var(--text-color);
}
.pt-col-dropdown label:hover { background: rgba(255,255,255,.06); }

/* ── MultiSelect Filter (filtros estilo Excel) ── */
.ms-wrap { display: inline-block; vertical-align: middle; }
.ms-trigger {
    display: inline-flex; align-items: center; gap: 2px;
    padding: 5px 10px; border-radius: 8px;
    border: 1px solid var(--border-color); background: var(--bg-color);
    color: var(--text-main); font-size: 11px; font-weight: 600;
    cursor: pointer; transition: all .2s; white-space: nowrap; max-width: 240px;
}
.ms-trigger:hover { border-color: #3b82f6; color: #93c5fd; }
.ms-trigger.ms-open { border-color: #3b82f6; background: rgba(59,130,246,0.1); }
.ms-trigger.ms-has-filter { border-color: #ef4444; color: #ef4444; }
.ms-trigger-text { overflow: hidden; text-overflow: ellipsis; }
.ms-dropdown {
    display: none; position: fixed; min-width: 260px; max-width: 320px;
    background: var(--card-bg, #1e293b); border: 1px solid var(--border-color);
    border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    z-index: 99999; font-size: 12px;
}
.ms-search-wrap { padding: 8px 10px 6px; border-bottom: 1px solid var(--border-color); }
.ms-search {
    width: 100%; padding: 5px 8px;
    background: var(--bg-main, #0f172a); border: 1px solid var(--border-color);
    border-radius: 6px; color: var(--text-main); font-size: 11px; outline: none;
}
.ms-search::placeholder { color: var(--text-muted); }
.ms-search:focus { border-color: #2563eb; }
.ms-toolbar {
    display: flex; gap: 4px; padding: 6px 10px;
    border-bottom: 1px solid var(--border-color);
}
.ms-toolbar button {
    flex: 1; padding: 4px 6px; border-radius: 5px;
    border: 1px solid var(--border-color); background: var(--bg-color);
    color: var(--text-muted); font-size: 10px; font-weight: 600;
    cursor: pointer; transition: all .15s;
}
.ms-toolbar button:hover { border-color: #3b82f6; color: #93c5fd; }
.ms-options {
    max-height: 220px; overflow-y: auto; padding: 2px 0;
    scrollbar-width: thin; scrollbar-color: transparent transparent;
}
.ms-options:hover { scrollbar-color: rgba(148,163,184,0.4) transparent; }
.ms-options::-webkit-scrollbar { width: 4px; }
.ms-options::-webkit-scrollbar-track { background: transparent; }
.ms-options::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; }
.ms-options:hover::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.4); }
.ms-option {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 12px; cursor: pointer; color: var(--text-muted); font-size: 11px;
    transition: background .1s;
}
.ms-option:hover { background: var(--border-color); }
.ms-option input[type="checkbox"] { accent-color: #3b82f6; width: 13px; height: 13px; flex-shrink: 0; cursor: pointer; }
.ms-option-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-no-results { padding: 12px; text-align: center; color: var(--text-muted); font-size: 11px; }
.ms-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px; border-top: 1px solid var(--border-color);
}
.ms-count { font-size: 10px; color: var(--text-muted); font-weight: 600; }
.ms-btn-apply {
    padding: 5px 14px; border-radius: 6px; border: none;
    background: #2563eb; color: white; font-size: 11px; font-weight: 700;
    cursor: pointer; transition: opacity .15s;
}
.ms-btn-apply:hover { opacity: .82; }

/* ── System Dialog (confirm/alert/prompt) ── */
.sys-dlg-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
    animation: sys-dlg-fade .18s ease;
}
@keyframes sys-dlg-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes sys-dlg-pop {
    from { opacity: 0; transform: scale(0.92) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.sys-dlg-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 28px 32px 22px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: sys-dlg-pop .2s ease;
}
.sys-dlg-icon {
    font-size: 38px;
    margin-bottom: 14px;
}
.sys-dlg-icon.dlg-info    { color: #3b82f6; }
.sys-dlg-icon.dlg-success { color: #10b981; }
.sys-dlg-icon.dlg-warning { color: #f59e0b; }
.sys-dlg-icon.dlg-error   { color: #ef4444; }
.sys-dlg-icon.dlg-danger  { color: #ef4444; }
.sys-dlg-msg {
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-line;
    margin-bottom: 20px;
    word-break: break-word;
}
.sys-dlg-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-main);
    font-size: 14px;
    margin-bottom: 18px;
    outline: none;
    transition: border-color .15s;
}
.sys-dlg-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.sys-dlg-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.sys-dlg-buttons button {
    padding: 9px 22px;
    border-radius: 10px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
    min-width: 100px;
}
.sys-dlg-buttons button:hover { opacity: 0.88; }
.sys-dlg-buttons button:active { transform: scale(0.97); }
.sys-dlg-btn-cancel {
    background: transparent;
    border: 1px solid var(--border-color) !important;
    color: var(--text-muted);
}
.sys-dlg-btn-cancel:hover {
    background: var(--bg-color);
    color: var(--text-main);
}
.sys-dlg-btn-ok,
.sys-dlg-btn-confirm {
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    color: white;
}
.sys-dlg-btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: white;
}

/* ===================================================
   MOBILE RESPONSIVE
   =================================================== */

/* Overlay escuro quando sidebar aberta no mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 998;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── Tablet: ≤ 1024px ── */
@media (max-width: 1024px) {
    .content-wrapper { padding: 16px !important; }
    .top-header { padding: 0 16px !important; }
    .data-table th, .data-table td { padding: 10px 12px; font-size: 13px; }
}

/* ── Mobile: ≤ 768px ── */
@media (max-width: 768px) {
    /* Sidebar off-screen */
    .sidebar {
        position: fixed !important;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 260px !important;
        z-index: 999;
        transition: left .25s ease;
        box-shadow: none;
    }
    .sidebar.mobile-open {
        left: 0;
        box-shadow: 4px 0 24px rgba(0,0,0,.3);
    }
    /* Ignore collapsed state on mobile — always full width sidebar */
    .sidebar.collapsed {
        width: 260px !important;
    }
    .sidebar.collapsed .sidebar-label { display: inline !important; }
    .sidebar.collapsed .nav-item { justify-content: flex-start !important; padding: 12px 16px !important; }
    .sidebar.collapsed .logo-area { justify-content: flex-start !important; padding: 24px !important; }
    .sidebar.collapsed .nav-group-items { display: flex !important; }
    .sidebar.collapsed .nav-group-arrow { display: inline !important; }

    /* Hide desktop sidebar toggle */
    .sidebar-toggle { display: none !important; }

    /* Show hamburger in header */
    .sidebar-toggle-main { display: flex !important; }

    /* Header compact */
    .top-header {
        height: 54px !important;
        padding: 0 12px !important;
    }
    .top-header h2 { font-size: 15px !important; }

    /* Content compact */
    .content-wrapper { padding: 10px !important; }

    /* Cards */
    .card { border-radius: 8px; }

    /* Tables scroll horizontal */
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 8px 6px; font-size: 12px; white-space: nowrap; }

    /* KPI cards */
    .dash-kpi-grid { gap: 8px; }
    .dash-kpi-card { padding: 10px 12px; }
    .dash-kpi-value { font-size: 18px; }

    /* Charts single column */
    .dash-charts-grid { grid-template-columns: 1fr !important; gap: 12px !important; }

    /* Filter toolbars wrap vertical */
    .mes-scroll-wrap { max-width: 100%; }

    /* Equipes KPI cards */
    #eq-kpi-row { padding: 10px !important; gap: 8px !important; }
    #eq-kpi-row .eq-kpi-card { min-width: 100px !important; padding: 10px 12px !important; }
    #eq-kpi-row .eq-kpi-card div:last-child { font-size: 22px !important; }

    /* Dialog cards */
    .sys-dlg-card { max-width: 92vw !important; padding: 20px 16px 16px !important; }

    /* Dashboard welcome */
    .dash-welcome { padding: 14px 12px !important; }
    .dash-avatar { width: 38px !important; height: 38px !important; font-size: 16px !important; }

    /* Shortcuts grid */
    .dash-shortcuts { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important; gap: 8px !important; }
    .dash-shortcut-card { padding: 12px 8px !important; }
    .dash-shortcut-icon { width: 36px !important; height: 36px !important; font-size: 15px !important; }
    .dash-shortcut-label { font-size: 11px !important; }

    /* Print preview */
    #modal-print-preview { padding: 0 !important; }
    #print-actions-bar { flex-wrap: wrap !important; gap: 6px !important; padding: 8px !important; }
    #print-actions-bar button { font-size: 12px !important; padding: 6px 10px !important; }

    /* Toolbar inputs/selects stretch on mobile */
    #view-equipes input[type="text"],
    #view-equipes input[type="date"],
    #view-equipes select {
        width: 100% !important; min-width: 0 !important; flex: 1 1 100% !important;
    }
    #view-equipes button { flex: 1 1 auto !important; justify-content: center !important; }

    /* General view toolbar inputs */
    .view-section input[type="text"],
    .view-section input[type="date"],
    .view-section input[type="month"] {
        min-width: 0 !important;
    }
    .view-section select {
        min-width: 0 !important; max-width: 100% !important;
    }
}

/* ── Small phone: ≤ 480px ── */
@media (max-width: 480px) {
    .top-header { height: 48px !important; }
    .top-header h2 { font-size: 13px !important; }
    .content-wrapper { padding: 8px !important; }

    .data-table th, .data-table td { padding: 6px 4px; font-size: 11px; }

    .dash-kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .dash-kpi-5 { grid-template-columns: repeat(2, 1fr) !important; }
    .dash-kpi-card { padding: 8px 10px; }
    .dash-kpi-value { font-size: 16px; }
    .dash-kpi-value { font-size: 18px; }
    .dash-kpi-label { font-size: 10px; }

    #eq-kpi-row { flex-direction: column !important; }
    #kb-kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .kb-coluna { min-width: 240px !important; }
}

/* ── Kanban Board ── */
.kb-coluna {
    flex: 1 1 0;
    min-width: 220px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    max-height: 100%;
    overflow: hidden;
}
.kb-coluna-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px 12px 0 0;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}
.kb-coluna-titulo { flex: 1; }
.kb-coluna-count {
    background: rgba(255,255,255,0.25);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}
.kb-coluna-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity .2s;
}
.kb-coluna-header:hover .kb-coluna-actions { opacity: 1; }
.kb-coluna-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 60px;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color .3s;
}
.kb-coluna-body:hover {
    scrollbar-color: rgba(148,163,184,0.4) transparent;
}
.kb-coluna-body::-webkit-scrollbar {
    width: 4px;
}
.kb-coluna-body::-webkit-scrollbar-track {
    background: transparent;
}
.kb-coluna-body::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
}
.kb-coluna-body:hover::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.4);
}
.kb-coluna.drag-over {
    border: 2px dashed #3b82f6;
    background: rgba(59,130,246,0.05);
}

/* ── Kanban Card ── */
.kb-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    user-select: none;
}
.kb-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.kb-card.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}
.kb-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
}
.kb-card-titulo {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
    line-height: 1.3;
}
.kb-card-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.kb-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
}
.kb-card-data {
    font-size: 10px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}
.kb-data-atrasada {
    color: #ef4444 !important;
    font-weight: 700;
}
.kb-card-membros {
    display: flex;
    gap: -4px;
}
.kb-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--card-bg);
    margin-left: -6px;
}
.kb-avatar:first-child { margin-left: 0; }
.kb-avatar-foto {
    object-fit: cover;
    padding: 0;
    background: none;
}
.kb-avatar-more {
    background: var(--border-color);
    color: var(--text-muted);
    font-size: 9px;
}

/* ── Badge de atraso no setor (sidebar) ── */
.kb-atraso-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    margin-left: 6px;
    line-height: 1;
}

/* ── Card Action Menu ── */
.kb-card-menu {
    position: relative;
}
.kb-card-menu-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1;
    transition: background .15s, color .15s;
}
.kb-card-menu-btn:hover {
    background: var(--border-color);
    color: var(--text-main);
}
.kb-card-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 50;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    min-width: 140px;
    padding: 4px 0;
    margin-top: 2px;
}
.kb-card-dropdown.show {
    display: block;
}
.kb-card-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-main);
    text-decoration: none;
    cursor: pointer;
    transition: background .12s;
    white-space: nowrap;
}
.kb-card-dropdown-item:hover {
    background: rgba(59,130,246,0.08);
}
.kb-card-dropdown-item i {
    width: 14px;
    text-align: center;
    font-size: 11px;
}
.kb-card-dropdown-danger {
    color: #ef4444;
}
.kb-card-dropdown-danger:hover {
    background: rgba(239,68,68,0.08);
}

/* ── Priority badges ── */
.kb-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.kb-prioridade-muito_baixa { background: rgba(16,185,129,0.15); color: #10b981; }
.kb-prioridade-baixa { background: rgba(59,130,246,0.15); color: #3b82f6; }
.kb-prioridade-media { background: rgba(245,158,11,0.15); color: #f59e0b; }
.kb-prioridade-alta { background: rgba(249,115,22,0.15); color: #f97316; }
.kb-prioridade-muito_alta { background: rgba(239,68,68,0.15); color: #ef4444; }

/* ── Subtarefa Progress ── */
.kb-progress-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}
.kb-progress {
    flex: 1;
    height: 5px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}
.kb-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    border-radius: 3px;
    transition: width .3s;
}
.kb-progress-text {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

/* ── Scroll Sutil Global ── */
.table-container,
.modal-body-scroll,
[style*="overflow-y:auto"],
[style*="overflow-y: auto"],
[style*="overflow:auto"],
[style*="overflow: auto"],
[style*="max-height"][style*="overflow"] {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color .3s;
}
.table-container:hover,
.modal-body-scroll:hover,
[style*="overflow-y:auto"]:hover,
[style*="overflow-y: auto"]:hover,
[style*="overflow:auto"]:hover,
[style*="overflow: auto"]:hover,
[style*="max-height"][style*="overflow"]:hover {
    scrollbar-color: rgba(148,163,184,0.35) transparent;
}
.table-container::-webkit-scrollbar,
[style*="overflow-y:auto"]::-webkit-scrollbar,
[style*="overflow-y: auto"]::-webkit-scrollbar,
[style*="overflow:auto"]::-webkit-scrollbar,
[style*="overflow: auto"]::-webkit-scrollbar,
[style*="max-height"][style*="overflow"]::-webkit-scrollbar {
    width: 5px; height: 5px;
}
.table-container::-webkit-scrollbar-track,
[style*="overflow-y:auto"]::-webkit-scrollbar-track,
[style*="overflow-y: auto"]::-webkit-scrollbar-track,
[style*="overflow:auto"]::-webkit-scrollbar-track,
[style*="overflow: auto"]::-webkit-scrollbar-track,
[style*="max-height"][style*="overflow"]::-webkit-scrollbar-track {
    background: transparent;
}
.table-container::-webkit-scrollbar-thumb,
[style*="overflow-y:auto"]::-webkit-scrollbar-thumb,
[style*="overflow-y: auto"]::-webkit-scrollbar-thumb,
[style*="overflow:auto"]::-webkit-scrollbar-thumb,
[style*="overflow: auto"]::-webkit-scrollbar-thumb,
[style*="max-height"][style*="overflow"]::-webkit-scrollbar-thumb {
    background: transparent; border-radius: 4px;
}
.table-container:hover::-webkit-scrollbar-thumb,
[style*="overflow-y:auto"]:hover::-webkit-scrollbar-thumb,
[style*="overflow-y: auto"]:hover::-webkit-scrollbar-thumb,
[style*="overflow:auto"]:hover::-webkit-scrollbar-thumb,
[style*="overflow: auto"]:hover::-webkit-scrollbar-thumb,
[style*="max-height"][style*="overflow"]:hover::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.35);
}
