:root {
    --primary:    #1a56db;
    --primary-dk: #1341a6;
    --sidebar-bg: #111827;
    --sidebar-w:  260px;
    --topbar-h:   56px;
    --text-light: #f9fafb;
    --text-muted: #9ca3af;
    --border:     #e5e7eb;
    --surface:    #ffffff;
    --bg:         #f3f4f6;
    --success:    #057a55;
    --danger:     #c81e1e;
    --warning:    #9f580a;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); }

/* ─── SIDEBAR ─── */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: width .25s;
    overflow: hidden;
}
.sidebar.collapsed { width: 0; }
.sidebar-brand {
    display: flex; align-items: center; justify-content: center;
    padding: 12px 14px;
    border-bottom: 1px solid #1f2937;
    background: #fff;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-label {
    font-size: .6rem; letter-spacing: .08em;
    color: var(--text-muted); text-transform: uppercase;
    padding: 10px 20px 2px;
    white-space: nowrap;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 20px;
    color: #d1d5db;
    text-decoration: none;
    font-size: .85rem;
    border-left: 3px solid transparent;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.nav-item:hover { background: #1f2937; color: #fff; }
.nav-item.active { background: #1e3a6e; color: #fff; border-color: var(--primary); }
.nav-item.sub { padding-left: 36px; font-size: .8rem; padding-top: 5px; padding-bottom: 5px; }
.sidebar-footer {
    border-top: 1px solid #1f2937;
    padding: 12px 20px;
}
.sidebar-footer a {
    display: flex; align-items: center; gap: 8px;
    color: #9ca3af; font-size: .85rem;
    text-decoration: none; padding: 4px 0;
    white-space: nowrap;
}
.sidebar-footer a:hover { color: #fff; }

/* ─── MAIN CONTENT ─── */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    transition: margin-left .25s;
    display: flex; flex-direction: column;
}
.main-content.expanded { margin-left: 0; }
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 16px;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 50;
}
.topbar h5 { color: #374151; }
.page-content { padding: 28px 28px; flex: 1; }

/* ─── CARDS ─── */
.card {
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    border-radius: 10px 10px 0 0 !important;
    font-weight: 600;
    color: #374151;
}
.stat-card {
    border-radius: 10px;
    padding: 20px;
    color: #fff;
    display: flex; align-items: center; gap: 16px;
}
.stat-card .icon { font-size: 2.2rem; opacity: .8; }
.stat-card .label { font-size: .8rem; opacity: .85; }
.stat-card .value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.bg-primary-custom { background: linear-gradient(135deg, #1a56db, #3b82f6); }
.bg-success-custom { background: linear-gradient(135deg, #057a55, #10b981); }
.bg-warning-custom { background: linear-gradient(135deg, #9f580a, #f59e0b); }
.bg-info-custom    { background: linear-gradient(135deg, #1e40af, #6366f1); }

/* ─── BADGES ─── */
.badge-status-aberto      { background: #dbeafe; color: #1e40af; }
.badge-status-transmitido { background: #d1fae5; color: #065f46; }
.badge-status-fechado     { background: #f3f4f6; color: #374151; }
.badge-status-retificado  { background: #fef3c7; color: #92400e; }

/* ─── TABLES ─── */
.table th { background: #f9fafb; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; }
.table td { vertical-align: middle; font-size: .9rem; }

/* ─── ALERT FLASH ─── */
.flash-alert { border-radius: 8px; margin-bottom: 20px; }

/* ─── LOGIN ─── */
.login-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1a56db 0%, #111827 100%);
}
.login-card {
    width: 380px;
    max-width: calc(100vw - 32px);
    background: #fff;
    border-radius: 14px;
    padding: 40px 36px;
    box-shadow: 0 20px 50px rgba(0,0,0,.3);
    overflow: hidden;
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .login-brand-logo {
    display: block !important;
    width: 180px !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 48px !important;
    margin: 0 auto 10px !important;
    object-fit: contain !important;
}
.login-logo p { color: #6b7280; font-size: .9rem; margin: 0; }

.sidebar-brand .brand-logo {
    display: block !important;
    width: 160px !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 40px !important;
    object-fit: contain !important;
}

/* ─── RESPONSIVO ─── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .45);
    z-index: 90;
    border: 0;
    padding: 0;
    cursor: pointer;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-w);
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 8px 0 24px rgba(0,0,0,.25);
    }
    .sidebar.collapsed {
        width: var(--sidebar-w);
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content,
    .main-content.expanded {
        margin-left: 0;
    }
    .page-content { padding: 16px; }
    .topbar { padding: 0 12px; gap: 10px; }
    .topbar h5 { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .page-header {
        flex-wrap: wrap;
        gap: 10px;
        align-items: flex-start;
    }
    .page-header .d-flex { flex-wrap: wrap; }
    .stat-card .value { font-size: 1.4rem; }
    .login-card { padding: 28px 20px; }
}

/* ─── BTN CUSTOM ─── */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dk); border-color: var(--primary-dk); }

/* ─── FORM ─── */
.form-label { font-weight: 500; font-size: .88rem; color: #374151; }
.form-control, .form-select {
    border-radius: 7px;
    border-color: var(--border);
    font-size: .9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}

/* ─── PAGE HEADER ─── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.page-header h5 { margin: 0; font-weight: 700; color: #111827; }
