:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --bg: #f5f5f5;
    --card: #fff;
    --header: #1e293b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0891b2;
    --text: #333;
    --text-secondary: #666;
    --border: #e2e8f0;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* Layout */
.main-content { padding: 70px 20px 30px; }
.container-fluid { max-width: 1400px; margin: 0 auto; }

/* Grid */
.row { display: flex; flex-wrap: wrap; margin: 0 -10px; }
.col-1 { width: 8.33%; padding: 0 10px; }
.col-2 { width: 16.66%; padding: 0 10px; }
.col-3 { width: 25%; padding: 0 10px; }
.col-4 { width: 33.33%; padding: 0 10px; }
.col-5 { width: 41.66%; padding: 0 10px; }
.col-6 { width: 50%; padding: 0 10px; }
.col-7 { width: 58.33%; padding: 0 10px; }
.col-8 { width: 66.66%; padding: 0 10px; }
.col-9 { width: 75%; padding: 0 10px; }
.col-10 { width: 83.33%; padding: 0 10px; }
.col-11 { width: 91.66%; padding: 0 10px; }
.col-12 { width: 100%; padding: 0 10px; }

/* Cards */
.card {
    background: var(--card);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}
.card-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: #fafafa;
}
.card-stat .stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.card-stat .stat-value { font-size: 22px; font-weight: 700; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th {
    background: #f8f9fa;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
}
.table tbody tr:hover { background: #f8fafc; }
.table .text-right { text-align: right; }
.table .text-center { text-align: center; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.6;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-info { background: #cffafe; color: #0e7490; }
.badge-secondary { background: #f1f5f9; color: #475569; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    line-height: 1.5;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { background: #0e7490; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}
.form-control,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.form-inline { display: flex; gap: 10px; align-items: flex-end; }

/* Page header */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 24px; font-weight: 700; }
.page-header .breadcrumb {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.page-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Topnav */
.topnav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: var(--header);
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.topnav-inner {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 16px;
}
.topnav-left { display: flex; align-items: center; gap: 0; }
.topnav-logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-right: 24px;
}
.topnav-logo:hover { text-decoration: none; color: var(--primary); }
.topnav-menu { display: flex; align-items: center; }
.topnav-link {
    color: #fff;
    padding: 0 12px;
    height: 50px;
    display: flex;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.topnav-link:hover {
    background: rgba(255,255,255,0.1);
    text-decoration: none;
    color: #fff;
}
.topnav-link .arrow { font-size: 10px; margin-left: 4px; }
.topnav-dropdown { position: relative; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: 50px;
    left: 0;
    background: var(--header);
    border: 1px solid #333;
    border-radius: 0 0 6px 6px;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1001;
}
.dropdown-menu.show { display: block; animation: dropIn 0.15s ease-out; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.dropdown-item {
    display: block;
    padding: 10px 16px;
    color: #ccc;
    font-size: 13px;
    transition: background 0.15s;
}
.dropdown-item:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    text-decoration: none;
}
.topnav-right { display: flex; align-items: center; gap: 16px; }
.topnav-clock { color: #94a3b8; font-size: 12px; }
.topnav-user { color: #cbd5e1; font-size: 13px; }
.topnav-logout { color: #f87171 !important; font-size: 13px; }
.topnav-logout:hover { color: #fca5a5 !important; }
.nav-badge {
    display: inline-block;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    padding: 0 4px;
    margin-left: 4px;
    vertical-align: middle;
}

/* Hamburger */
.topnav-hamburger {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 8px;
    height: 50px;
    align-items: center;
}

/* Search global */
.search-global input::placeholder { color: #94a3b8; }
.search-results {
    display: none;
    position: absolute;
    top: 34px;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    min-width: 320px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 2000;
}
.search-results.show { display: block; }
.search-group-label {
    padding: 6px 12px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: #f8f9fa;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.search-item {
    display: block;
    padding: 8px 12px;
    color: var(--text);
    font-size: 13px;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s;
    text-decoration: none;
}
.search-item:hover {
    background: var(--primary-light);
    text-decoration: none;
    color: var(--text);
}
.search-item-detail {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-card {
    background: var(--card);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}
.modal-body { padding: 20px; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Toast */
#toast-container {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toastIn 0.3s ease-out;
    max-width: 400px;
}
.toast-success { background: var(--success); }
.toast-danger { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* Pagination */
.pagination { display: flex; gap: 4px; margin-top: 16px; justify-content: center; }
.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--text);
    border: 1px solid var(--border);
}
.pagination a:hover { background: var(--primary-light); text-decoration: none; }
.pagination .active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; justify-content: center; padding: 40px; }

/* Text utilities */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-secondary { color: var(--text-secondary); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-bold { font-weight: 600; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 18px; }

/* Spacing */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

/* Display */
.d-flex { display: flex; }
.d-none { display: none; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

/* Login page */
.login-body {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
    background: var(--card);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.1);
    padding: 40px 32px;
}
.login-logo {
    text-align: center;
    font-size: 36px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}
.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}
.login-error {
    background: #fee2e2;
    color: #b91c1c;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}
.btn-login {
    width: 100%;
    justify-content: center;
    padding: 10px;
    font-size: 15px;
    margin-top: 8px;
}

/* Filters bar */
.filters-bar {
    background: var(--card);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 16px 20px;
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.filters-bar .form-group { margin-bottom: 0; min-width: 150px; }

/* Status dot */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-dot-success { background: var(--success); }
.status-dot-danger { background: var(--danger); }
.status-dot-warning { background: var(--warning); }

/* DRE */
.dre-table .dre-section-header td {
    background: #f1f5f9;
    padding: 10px 12px;
    font-size: 13px;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--border);
}
.dre-table .dre-item td { border-bottom: 1px solid #f1f5f9; }
.dre-table .dre-subtotal td {
    background: #f8f9fa;
    border-top: 2px solid var(--border);
    border-bottom: 2px solid var(--border);
    padding: 10px 12px;
}
.dre-table .dre-resultado td {
    background: #1e293b;
    color: #fff;
    padding: 14px 12px;
    font-size: 15px;
}
.dre-table .dre-resultado strong { color: inherit; }
.table-responsive { overflow-x: auto; }

/* Print */
@media print {
    .topnav, .filters-bar, .btn, .pagination, #toast-container { display: none !important; }
    .main-content { padding: 0 !important; }
    .card { box-shadow: none !important; break-inside: avoid; }
    body { background: #fff; font-size: 12px; }
    canvas { max-height: 250px !important; }
}

/* Negative values */
.val-neg { color: var(--danger); }

/* Action buttons in tables */
td.acoes { white-space: nowrap; }
.acoes-group { display: flex; gap: 6px; align-items: center; }
.btn-acao {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 4px 10px; font-size: 12px; border-radius: 4px;
    cursor: pointer; white-space: nowrap; font-family: inherit;
    line-height: 1.5; transition: background 0.15s; text-decoration: none;
}
.btn-acao:hover { text-decoration: none; }
.btn-editar { background: #f8f9fa; border: 1px solid #d1d5db; color: #333; }
.btn-editar:hover { background: #e2e8f0; color: #333; }
.btn-toggle { background: #f0fdf4; border: 1px solid #16a34a; color: #16a34a; }
.btn-toggle:hover { background: #dcfce7; }
.btn-toggle.inativo { background: #f8f9fa; border-color: #9ca3af; color: #9ca3af; }
.btn-toggle.inativo:hover { background: #e2e8f0; }
.btn-excluir { background: transparent; border: 1px solid #dc2626; color: #dc2626; }
.btn-excluir:hover { background: #fee2e2; }
.btn-confirmar { background: #f0fdf4; border: 1px solid #16a34a; color: #16a34a; }
.btn-confirmar:hover { background: #dcfce7; }
.btn-senha { background: #f0f9ff; border: 1px solid #0891b2; color: #0891b2; }
.btn-senha:hover { background: #e0f2fe; }

/* Bulk action bar */
.bulk-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #1e293b;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 500;
    animation: dropIn 0.15s ease-out;
}

/* Responsive */
@media (max-width: 1200px) {
    .col-3 { width: 50%; margin-bottom: 10px; }
    .col-5, .col-6, .col-7 { width: 100%; margin-bottom: 10px; }
}
@media (max-width: 768px) {
    .topnav-hamburger { display: flex; }
    .topnav-menu { display: none; flex-direction: column; position: absolute; top: 50px; left: 0; right: 0; background: var(--header); box-shadow: 0 4px 12px rgba(0,0,0,0.3); z-index: 1001; padding: 8px 0; }
    .topnav-menu.show { display: flex; }
    .topnav-menu .topnav-link { height: auto; padding: 12px 20px; }
    .topnav-menu .topnav-dropdown { width: 100%; }
    .topnav-menu .dropdown-menu { position: static; box-shadow: none; border: none; border-radius: 0; background: #263244; }
    .topnav-menu .dropdown-item { padding: 10px 32px; }
    .topnav-clock { display: none; }
    .search-global { display: none; }
    .main-content { padding: 60px 10px 20px; }
    .col-3, .col-4, .col-5, .col-6, .col-7, .col-8 { width: 100%; margin-bottom: 10px; }
    .row { margin: 0; }
    [class^="col-"] { padding: 0; }
    .form-row { flex-direction: column; gap: 0; }
    .filters-bar { flex-direction: column; }
    .page-header-actions { flex-direction: column; gap: 10px; align-items: flex-start; }
    .table { font-size: 12px; }
    .table th, .table td { padding: 8px 6px; }
    canvas { max-height: 250px !important; }
    .modal-card { width: 98%; max-width: none; }
}
@media (max-width: 480px) {
    .login-card { padding: 30px 20px; }
    .login-logo { font-size: 28px; }
    .topnav-user { display: none; }
}
