:root {
    --color-primary: #0F172A;
    --color-primary-light: #1E293B;
    --color-accent: #4F46E5;
    --color-accent-hover: #4338CA;
    --color-accent-gradient: linear-gradient(135deg, #4F46E5 0%, #0EA5E9 100%);
    --color-background: #F8FAFC;
    --color-surface: #FFFFFF;
    --color-surface-hover: #F1F5F9;
    --color-foreground: #0F172A;
    --color-secondary: #475569;
    --color-muted: #64748B;
    --color-muted-bg: #F1F5F9;
    --color-border: #E2E8F0;
    --color-border-hover: #CBD5E1;
    
    --color-success: #059669;
    --color-success-bg: #ECFDF5;
    --color-success-border: #A7F3D0;
    
    --color-destructive: #E11D48;
    --color-destructive-bg: #FFF1F2;
    --color-destructive-border: #FECDD3;
    
    --color-warning: #D97706;
    --color-warning-bg: #FFFBEB;
    --color-warning-border: #FDE68A;

    --color-grupo-vendas-bg: #E8EAF6;
    --color-grupo-vendas-text: #3730A3;
    --color-grupo-pos-vendas-bg: #FFEDD5;
    --color-grupo-pos-vendas-text: #9A3412;

    --radius-xl: 16px;
    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 6px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.12), 0 4px 12px -2px rgba(15, 23, 42, 0.04);
    --shadow-glow: 0 8px 24px -4px rgba(79, 70, 229, 0.25);

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: Consolas, 'SF Mono', Menlo, monospace;
    --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
    --color-primary: #020617;
    --color-primary-light: #0F172A;
    --color-background: #0B0F19;
    --color-surface: #111827;
    --color-surface-hover: #1F2937;
    --color-foreground: #F9FAFB;
    --color-secondary: #9CA3AF;
    --color-muted: #9CA3AF;
    --color-muted-bg: #1F2937;
    --color-border: #374151;
    --color-border-hover: #4B5563;
    
    --color-success-bg: rgba(5, 150, 105, 0.15);
    --color-success-border: rgba(5, 150, 105, 0.3);
    --color-destructive-bg: rgba(225, 29, 72, 0.15);
    --color-destructive-border: rgba(225, 29, 72, 0.3);
    --color-warning-bg: rgba(217, 119, 6, 0.15);
    --color-warning-border: rgba(217, 119, 6, 0.3);

    --color-grupo-vendas-bg: rgba(79, 70, 229, 0.18);
    --color-grupo-vendas-text: #A5B4FC;
    --color-grupo-pos-vendas-bg: rgba(217, 119, 6, 0.2);
    --color-grupo-pos-vendas-text: #FDBA74;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: var(--font-sans);
    background: var(--color-background);
    color: var(--color-foreground);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    padding-bottom: 4rem;
    -webkit-font-smoothing: antialiased;
}

/* Header & Top Bar */
.navbar {
    background: var(--color-primary);
    color: #FFFFFF;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.navbar-container {
    max-width: 1160px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #FFFFFF;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: var(--color-accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
    color: #FFFFFF;
}

.brand-logo-box {
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar .brand-logo-box {
    height: 42px;
}

.brand-logo-box img {
    height: 100%;
    width: auto;
    display: block;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #FFFFFF;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: #94A3B8;
    font-weight: 500;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: #CBD5E1;
    text-decoration: none;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.1);
}

.nav-link-primary {
    background: var(--color-accent);
    color: #FFFFFF !important;
}

.nav-link-primary:hover {
    background: var(--color-accent-hover);
    transform: translateY(-1px);
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
}

.nav-dropdown-toggle svg:last-child {
    transition: transform 0.15s ease;
}

.nav-dropdown.aberto .nav-dropdown-toggle svg:last-child {
    transform: rotate(180deg);
}

.nav-dropdown.active .nav-dropdown-toggle {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.1);
}

.nav-dropdown-painel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    z-index: 20;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
}

.nav-dropdown.aberto .nav-dropdown-painel {
    display: block;
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-foreground);
    text-decoration: none;
    transition: var(--transition);
}

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

.nav-dropdown-item.active {
    color: var(--color-accent);
    background: var(--color-surface-hover);
}

/* Page Container */
.container {
    max-width: 1160px;
    margin: 2rem auto 0;
    padding: 0 1.5rem;
}

.container-wide {
    max-width: 1520px;
}

.container-xwide {
    max-width: 1900px;
}

/* Header Banner inside container */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--color-foreground);
}

.page-subtitle {
    color: var(--color-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* KPI / Summary Cards Row */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-border-hover);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: #EEF2FF;
    color: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-foreground);
    margin-top: 0.1rem;
}

/* Main Cards */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-foreground);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    letter-spacing: -0.01em;
}

.card-title svg {
    color: var(--color-accent);
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    align-items: end;
}

.campo {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-secondary);
}

.campo select,
.campo input[type=month],
.campo input[type=number],
.campo input[type=text],
.campo input[type=email],
.campo input[type=password] {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-foreground);
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    transition: var(--transition);
    width: 100%;
}

.campo select:focus,
.campo input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Enhanced Drag & Drop Zone */
.drop-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    background: var(--color-muted-bg);
    color: var(--color-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
}

.drop-zone:hover, .drop-zone.arrastando {
    border-color: var(--color-accent);
    background: #EEF2FF;
    color: var(--color-accent);
}

.drop-zone input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.drop-prompt {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 500;
}

.drop-prompt svg {
    color: var(--color-accent);
}

.file-info-card {
    display: none;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.75rem;
}

.file-info-main {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    overflow: hidden;
}

.file-info-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-info-name {
    font-weight: 600;
    color: var(--color-foreground);
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-info-size {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.file-remove-btn {
    background: none;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.file-remove-btn:hover {
    color: var(--color-destructive);
    background: var(--color-destructive-bg);
}

/* Buttons */
button, .btn {
    font-family: var(--font-sans);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--color-accent);
    color: #FFFFFF;
    border: none;
    padding: 0.7rem 1.4rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--transition);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

button:hover, .btn:hover {
    background: var(--color-accent-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

button:active, .btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-secondary);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--color-muted-bg);
    color: var(--color-foreground);
    border-color: var(--color-border-hover);
    box-shadow: var(--shadow-sm);
}

.btn-excluir {
    background: var(--color-surface);
    color: var(--color-destructive);
    border: 1px solid var(--color-destructive-border);
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
    border-radius: var(--radius-md);
}

.btn-excluir:hover {
    background: var(--color-destructive-bg);
    border-color: var(--color-destructive);
    color: var(--color-destructive);
    box-shadow: none;
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    background: #EEF2FF;
    color: var(--color-accent);
    font-family: var(--font-mono);
}

.badge-neutral {
    background: var(--color-muted-bg);
    color: var(--color-secondary);
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid var(--color-success-border);
}

.badge-destructive {
    background: var(--color-destructive-bg);
    color: var(--color-destructive);
    border: 1px solid var(--color-destructive-border);
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

th {
    background: var(--color-muted-bg);
    color: var(--color-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-foreground);
    white-space: nowrap;
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: var(--color-surface-hover);
}

tbody tr:last-child td {
    border-bottom: none;
}

.num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.acoes {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--color-muted);
}

.empty-state svg {
    color: #CBD5E1;
    margin-bottom: 1rem;
}

.empty-state strong {
    font-size: 1.05rem;
    color: var(--color-foreground);
    margin-bottom: 0.25rem;
}

.empty-state span {
    font-size: 0.88rem;
}

/* Messages & Alerts */
.msg {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    margin-top: 1.25rem;
    border: 1px solid;
    animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg svg {
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.msg-ok {
    background: var(--color-success-bg);
    border-color: var(--color-success-border);
    color: var(--color-success);
}

.msg-erro {
    background: var(--color-destructive-bg);
    border-color: var(--color-destructive-border);
    color: var(--color-destructive);
}

.avisos {
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
    color: var(--color-warning);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1.25rem 0.85rem 2.5rem;
    font-size: 0.85rem;
    margin-top: 1rem;
}

.avisos li {
    margin-bottom: 0.25rem;
}

.dica {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Category Tabs (Details View) */
.tabs-nav {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding-bottom: 2px;
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-muted);
    cursor: pointer;
    transition: var(--transition);
    border-radius: 0;
    box-shadow: none;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--color-foreground);
    background: none;
    box-shadow: none;
    transform: none;
}

.tab-btn.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

/* Fields Grid for Details */
.campos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.campo-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: var(--transition);
}

.campo-card:hover {
    border-color: var(--color-border-hover);
    box-shadow: var(--shadow-sm);
}

.campo-card .rotulo {
    font-size: 0.78rem;
    color: var(--color-muted);
    font-weight: 600;
}

.campo-card .valor {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-foreground);
}

.campo-card .valor.negativo {
    color: var(--color-destructive);
}

/* Loading Overlay */
.overlay-carregando {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.overlay-carregando.ativo {
    display: flex;
    opacity: 1;
}

.overlay-cartao {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 2.5rem 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
    animation: scaleUp 0.25s ease;
    text-align: center;
}

@keyframes scaleUp {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.spinner-lg {
    width: 42px;
    height: 42px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Custom Modal Dialog */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 1.5rem;
}

.modal-backdrop.ativo {
    display: flex;
    opacity: 1;
}

.modal-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    max-width: 440px;
    width: 100%;
    padding: 1.75rem;
    box-shadow: var(--shadow-lg);
    animation: scaleUp 0.2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.modal-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--color-destructive-bg);
    color: var(--color-destructive);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-foreground);
}

.modal-body {
    font-size: 0.9rem;
    color: var(--color-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

@media (max-width: 768px) {
    .navbar-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .nav-links {
        width: 100%;
        justify-content: space-between;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.55rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* Instant Search Input */
.search-bar-wrap {
    position: relative;
    margin-bottom: 1.25rem;
}

.search-input {
    width: 100%;
    font-family: var(--font-sans);
    font-size: 0.92rem;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-foreground);
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.search-icon-inside {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-muted);
    pointer-events: none;
}

/* Chart Canvas Wrapper */
.chart-container {
    position: relative;
    width: 100%;
    min-height: 280px;
    max-height: 380px;
    margin-top: 1rem;
}

/* Cabeçalho de impressão (logo + título) — só aparece no papel, nunca na tela */
.print-header {
    display: none;
}

/* Print Styles */
@page {
    margin: 12mm 10mm;
}

@media print {
    .navbar, .btn, button, .theme-toggle-btn, .modal-backdrop, .overlay-carregando, .tabs-nav, .search-bar-wrap, .no-print {
        display: none !important;
    }

    body {
        background: #FFFFFF !important;
        color: #000000 !important;
        padding: 0 !important;
    }

    .container {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .card {
        border: 1px solid #CCCCCC !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    .tab-panel {
        display: block !important;
    }

    /* Tabelas largas (Comparativo, Por Departamento) — fonte e espaçamento
       menores pra caber mais colunas na página, mesmo em paisagem. */
    .table-wrap {
        overflow: visible !important;
    }

    .comp-tabela, .dep-tabela {
        font-size: 0.68rem !important;
    }

    .comp-tabela th, .comp-tabela td,
    .dep-tabela th, .dep-tabela td {
        padding: 4px 6px !important;
    }

    .print-header {
        display: flex !important;
        align-items: center;
        gap: 1.25rem;
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
        border-bottom: 2px solid #0F172A;
    }

    .print-header-logo {
        height: 46px;
        width: auto;
    }

    .print-header-texto {
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
    }

    .print-header-texto strong {
        font-size: 1.05rem;
        color: #0F172A;
    }

    .print-header-texto span {
        font-size: 0.78rem;
        color: #475569;
    }

    .print-header-data {
        margin-top: 0.15rem;
    }
}


/* DRE — Demonstrativo do Resultado do Exercício */
.dre-lista {
    display: flex;
    flex-direction: column;
}

.dre-linha {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.25rem;
    font-size: 0.95rem;
}

.dre-linha .dre-sinal {
    font-weight: 700;
    text-align: center;
    color: var(--color-muted);
}

.dre-linha .dre-rotulo {
    color: var(--color-foreground);
}

.dre-linha .dre-valor {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.dre-linha .dre-valor.vazio {
    color: var(--color-muted);
    font-weight: 400;
    font-style: italic;
}

.dre-subtotal {
    border-top: 2px solid var(--color-border);
    border-bottom: 2px solid var(--color-border);
    font-weight: 700;
    background: var(--color-surface-hover);
}

.dre-subtotal .dre-sinal {
    color: var(--color-accent);
}

.dre-total-final {
    border-top: 3px double var(--color-accent);
    border-bottom: 3px double var(--color-accent);
    font-weight: 800;
    font-size: 1.1rem;
    background: var(--color-accent);
    color: #FFFFFF;
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
}

.dre-total-final .dre-sinal,
.dre-total-final .dre-rotulo,
.dre-total-final .dre-valor {
    color: #FFFFFF;
}

.dre-espaco {
    height: 0.85rem;
}

.dre-linha .dre-valor.negativo {
    color: var(--color-destructive);
}

.dre-total-final .dre-valor.negativo {
    color: #FED7D7;
}

/* DRE — filtros multi-seleção (dropdown com checkboxes) */
.filtro-titulo {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-secondary);
    margin-bottom: 0.35rem;
}

.dropdown-check {
    position: relative;
    min-width: 200px;
}

.dropdown-check-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    background: var(--color-surface);
    color: var(--color-foreground);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.85rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.dropdown-check-toggle:hover {
    border-color: var(--color-accent);
}

.dropdown-check-toggle svg {
    flex-shrink: 0;
    transition: transform 0.15s ease;
    color: var(--color-muted);
}

.dropdown-check.aberto .dropdown-check-toggle svg {
    transform: rotate(180deg);
}

.dropdown-check.aberto .dropdown-check-toggle {
    border-color: var(--color-accent);
}

.dropdown-check-resumo {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.dropdown-check-painel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
    max-height: 260px;
    overflow-y: auto;
}

.dropdown-check.aberto .dropdown-check-painel {
    display: block;
}

.dropdown-check-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.dropdown-check-item:hover {
    background: var(--color-surface-hover);
}

.dropdown-check-item input[type="checkbox"] {
    accent-color: var(--color-accent);
    cursor: pointer;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.dropdown-check-todos {
    font-weight: 600;
}

.dropdown-check-divisor {
    height: 1px;
    background: var(--color-border);
    margin: 0.3rem 0.2rem;
}

/* Comparativo DRE */
.comparativo-periodos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
}

.comparativo-periodo-titulo {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.6rem;
}

.comp-tabela th,
.comp-tabela td {
    white-space: nowrap;
    border-left: 1px solid var(--color-border);
}

.comp-tabela th:first-child,
.comp-tabela td:first-child {
    border-left: none;
}

/* Divisórias mais fortes entre os grupos: Período A | Período B | Variação */
.comp-tabela th:nth-child(4),
.comp-tabela td:nth-child(4),
.comp-tabela th:nth-child(6),
.comp-tabela td:nth-child(6) {
    border-left: 2px solid var(--color-accent);
}

.comp-tabela tr.comp-total-final td:nth-child(4),
.comp-tabela tr.comp-total-final td:nth-child(6) {
    border-left-color: rgba(255, 255, 255, 0.45);
}

.comp-tabela tr.comp-espaco td {
    border-left: none;
}

.comp-subtitulo {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--color-muted);
    margin-top: 0.15rem;
}

.comp-tabela .dre-sinal {
    font-weight: 700;
    color: var(--color-muted);
    margin-right: 0.4rem;
}

.comp-tabela tr.comp-subtotal td {
    font-weight: 700;
    background: var(--color-surface-hover);
    border-top: 2px solid var(--color-border);
    border-bottom: 2px solid var(--color-border);
}

.comp-tabela tr.comp-total-final td {
    font-weight: 800;
    background: var(--color-accent);
    color: #FFFFFF;
}

.comp-tabela tr.comp-total-final td.negativo {
    color: #FED7D7;
}

.comp-tabela tr.comp-total-final .dre-sinal {
    color: #FFFFFF;
}

.comp-tabela tr.comp-espaco td {
    padding: 0.35rem;
    border-bottom: none;
}

.comp-tabela td.negativo {
    color: var(--color-destructive);
}

.comp-tabela td.positivo {
    color: var(--color-success);
}

/* DEF por Departamento */
.dep-tabela th,
.dep-tabela td {
    white-space: nowrap;
    text-align: right;
}

.dep-tabela thead th:first-child,
.dep-tabela tbody td:first-child {
    text-align: left;
}

.dep-tabela th {
    text-align: center;
}

.dep-tabela thead tr:first-child th {
    font-size: 0.85rem;
}

.dep-grupo-vendas {
    background: var(--color-grupo-vendas-bg);
    color: var(--color-grupo-vendas-text);
}

.dep-grupo-pos-vendas {
    background: var(--color-grupo-pos-vendas-bg);
    color: var(--color-grupo-pos-vendas-text);
}

.dep-tabela tbody td.dep-grupo-vendas,
.dep-tabela tbody td.dep-grupo-pos-vendas {
    color: var(--color-foreground);
    font-weight: 700;
}

.dep-linha-subtotal td {
    font-weight: 700;
    background: var(--color-surface-hover);
    border-top: 2px solid var(--color-border);
    border-bottom: 2px solid var(--color-border);
}

.dep-subtotal-grupo td {
    border-bottom: 2px solid var(--color-border);
    text-align: center;
    font-weight: 700;
}

.dep-tabela td.negativo {
    color: var(--color-destructive);
}

.dep-subtotal-grupo + tr td {
    border-top: 2px solid var(--color-border);
}

.dep-tabela tr.dep-linha-patrimonial td:first-child {
    font-weight: 600;
}

.dep-tabela tr.dep-destaque td {
    font-weight: 800;
    background: var(--color-accent);
    color: #FFFFFF;
}

.dep-tabela tr.dep-destaque td.negativo {
    color: #FED7D7;
}

/* Navbar — usuário logado / sair */
.navbar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-left: 0.75rem;
    margin-left: 0.25rem;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
}

.navbar-user-nome {
    font-size: 0.85rem;
    font-weight: 600;
    color: #E2E8F0;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.navbar-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    color: #CBD5E1;
    transition: var(--transition);
}

.navbar-logout:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.1);
}

/* Login / Cadastro (primeiro acesso) */
.auth-body {
    background: var(--color-background);
    min-height: 100vh;
}

.auth-theme-toggle {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    color: var(--color-foreground);
}

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.auth-brand .brand-title {
    color: var(--color-foreground);
}

.auth-brand .brand-logo-box {
    height: 48px;
}

.auth-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-foreground);
    margin-bottom: 1.25rem;
}
