:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;
    --bg-page: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
}

* { box-sizing: border-box; }

html, body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    background: var(--bg-page);
    margin: 0;
    min-height: 100vh;
}

/* ===== APP LAYOUT ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.brand-name { font-weight: 700; font-size: 1.1rem; }
.brand-sub { font-size: 0.75rem; color: #94a3b8; }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.sidebar-nav-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 10px;
    margin-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-nav-section:first-of-type {
    margin-top: 4px;
}

.sidebar-nav-label {
    padding: 4px 16px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    position: relative;
}

.sidebar-user-menu {
    position: relative;
}

.sidebar-user-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #e2e8f0;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.sidebar-user-toggle:hover,
.sidebar-user-toggle[aria-expanded="true"] {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-user-toggle.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-user-avatar--inicial {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
}

.sidebar-user-avatar--logo {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-user-avatar--logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
    background: transparent;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-label {
    font-size: 0.7rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-toggle.active .sidebar-user-label,
.sidebar-user-toggle[aria-expanded="true"] .sidebar-user-label {
    color: rgba(255, 255, 255, 0.75);
}

.sidebar-user-chevron {
    font-size: 0.8rem;
    color: #64748b;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.sidebar-user-toggle:hover .sidebar-user-chevron,
.sidebar-user-toggle[aria-expanded="true"] .sidebar-user-chevron,
.sidebar-user-toggle.active .sidebar-user-chevron {
    color: inherit;
}

.sidebar-user-toggle[aria-expanded="true"] .sidebar-user-chevron {
    transform: rotate(180deg);
}

.sidebar-user-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-user-dropdown[hidden] {
    display: none !important;
}

.sidebar-user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.sidebar-user-dropdown-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-user-dropdown-item.active {
    background: var(--sidebar-active);
    color: #fff;
}

.sidebar-user-dropdown-logout {
    color: #fca5a5;
}

.sidebar-user-dropdown-logout:hover {
    background: rgba(220, 38, 38, 0.15);
    color: #fecaca;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
}

.topbar-title p { font-size: 0.85rem; }

.topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.page-content {
    padding: 28px;
    flex: 1;
}

/* ===== CARDS & STATS ===== */
.stat-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border);
    height: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-bottom: 16px;
}

.stat-icon.blue { background: #dbeafe; color: var(--primary); }
.stat-icon.green { background: #d1fae5; color: var(--success); }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.orange { background: #ffedd5; color: var(--warning); }

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 4px;
    line-height: 1.2;
}

.card-panel {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.card-panel-body { padding: 24px; }

.backup-list-scroll {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.backup-list-scroll .list-group-item:first-child { border-top: none; }
.backup-list-scroll .list-group-item:last-child { border-bottom: none; }

/* ===== TABLES ===== */
.table-modern {
    margin: 0;
}

.table-modern thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 14px 16px;
}

.table-modern tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.table-modern tbody tr:hover {
    background: #f8fafc;
}

/* ===== BADGES ===== */
.badge-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-emitido { background: #d1fae5; color: #065f46; }
.badge-rascunho { background: #fef3c7; color: #92400e; }
.badge-cancelado { background: #fee2e2; color: #991b1b; }
.badge-pendente { background: #fef3c7; color: #92400e; }
.badge-aprovado { background: #d1fae5; color: #065f46; }
.badge-rejeitado { background: #f1f5f9; color: #475569; }

.pagador-sugestoes {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 260px;
    overflow-y: auto;
    margin-top: 2px;
}

.pagador-sugestoes.show {
    display: block;
}

.recibo-doc-avisos {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recibo-doc-aviso-item {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 12px 16px;
}

.recibo-doc-aviso-titulo {
    font-size: 0.75rem;
    font-weight: 700;
    color: #92400e;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.recibo-doc-aviso-texto {
    font-size: 0.88rem;
    color: #78350f;
    margin-top: 4px;
    line-height: 1.5;
}
.badge-ativo { background: #d1fae5; color: #065f46; }
.badge-inativo { background: #f1f5f9; color: #64748b; }

/* ===== BUTTONS ===== */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    font-weight: 500;
    border-radius: 10px;
    padding: 10px 20px;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    border-radius: 10px;
    font-weight: 500;
}

.btn-sm { border-radius: 8px; }

/* ===== FORMS ===== */
.form-control, .form-select {
    border-radius: 10px;
    border-color: var(--border);
    padding: 10px 14px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-main);
}

.form-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
}

/* ===== AUTH PAGES ===== */
.auth-body {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #2563eb 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 440px;
    padding: 40px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo .icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.auth-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.auth-logo p {
    color: var(--text-muted);
    margin: 4px 0 0;
    font-size: 0.9rem;
}

/* ===== LANDING ===== */
.landing-hero {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 40%, #2563eb 100%);
    color: #fff;
    display: flex;
    align-items: center;
}

.landing-hero h1 {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.15;
}

.landing-hero .lead {
    font-size: 1.15rem;
    color: #cbd5e1;
    max-width: 520px;
}

.feature-card {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(8px);
}

.feature-card i {
    font-size: 1.75rem;
    color: #93c5fd;
    margin-bottom: 12px;
}

/* ===== CHART BARS ===== */
.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 160px;
    padding-top: 20px;
}

.chart-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.chart-bar {
    width: 100%;
    max-width: 40px;
    background: linear-gradient(180deg, var(--primary), #7c3aed);
    border-radius: 6px 6px 0 0;
    min-height: 4px;
    transition: height 0.5s ease;
}

.chart-bar-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}

.chart-bar-value {
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* ===== RECIBO DOCUMENTO ===== */
.recibo-doc {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 48px 52px;
    max-width: 800px;
    box-shadow: var(--card-shadow);
    font-size: 0.95rem;
    line-height: 1.7;
    color: #1e293b;
}

.recibo-doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}

.recibo-doc-logo img {
    max-width: 140px;
    max-height: 70px;
    object-fit: contain;
}

.logo-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    max-width: 200px;
}

.logo-preview img {
    max-height: 80px;
    max-width: 100%;
    object-fit: contain;
    background: transparent;
}

.recibo-doc-logo-placeholder {
    width: 64px;
    height: 64px;
    background: #eff6ff;
    color: #1e40af;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
}

.recibo-doc-titulo-text {
    font-size: 1.75rem;
    font-weight: 800;
    color: #1e40af;
    letter-spacing: 0.02em;
}

.recibo-doc-numero {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.recibo-doc-data-emissao {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.recibo-doc-divider {
    height: 3px;
    background: #1e40af;
    margin: 20px 0 24px;
    border-radius: 2px;
}

.recibo-doc-texto {
    font-size: 1rem;
    margin-bottom: 24px;
}

.recibo-doc-valor-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
}

.recibo-doc-valor-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.recibo-doc-valor {
    font-size: 2rem;
    font-weight: 800;
    color: #1e40af;
    margin-top: 4px;
}

.recibo-doc-meta {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.recibo-doc-meta .label {
    color: var(--text-muted);
    display: inline-block;
    min-width: 160px;
}

.recibo-doc-emitente {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px;
    margin-top: 28px;
    background: #fafafa;
}

.recibo-doc-emitente-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #1e40af;
}

.recibo-doc-local-data {
    margin-top: 32px;
    font-style: italic;
    color: var(--text-muted);
}

.recibo-doc-assinatura {
    text-align: center;
    margin-top: 48px;
}

.recibo-doc-assinatura-linha {
    width: 280px;
    border-top: 1px solid #333;
    margin: 0 auto 10px;
}

@media print {
    .recibo-doc {
        box-shadow: none;
        border: none;
        padding: 0;
        max-width: 100%;
    }
}

.info-box {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
}

.disclaimer {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 14px 18px;
    font-size: 0.85rem;
    color: #92400e;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .landing-hero h1 {
        font-size: 2rem;
    }
}

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
}
