:root {
    --sidebar-width: 240px;
    --topbar-height: 60px;
    --page-bg: #f4f6f9;
    --card-shadow: 0 4px 18px rgba(18, 38, 63, 0.08);
    --content-inline-padding: 12px;
}

body {
    background: var(--page-bg) url("/static/core/Fundo.png") no-repeat center top;
    background-size: cover;
}

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

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    height: 100vh;
    background: #111827;
    color: #e5e7eb;
    padding: 16px 12px;
    overflow: hidden;
}

.sidebar-brand {
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: #9ca3af;
    padding: 12px 12px 20px;
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.app-sidebar .nav-link {
    color: #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.app-sidebar .nav-link i {
    font-size: 1.1rem;
}

.app-sidebar .nav-link.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.sidebar-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(229, 231, 235, 0.12);
}

.app-topbar .btn.btn-outline-secondary {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

.app-topbar .btn.btn-outline-secondary:hover,
.app-topbar .btn.btn-outline-secondary:focus {
    background-color: #0b5ed7;
    border-color: #0b5ed7;
    color: #fff;
}

.app-main {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: transparent;
}

.app-topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    z-index: 10;
    background-image: none;
}

.user-avatar-btn .user-avatar-img {
    display: inline-block;
    object-fit: cover;
}

.user-avatar-btn .user-avatar-icon {
    display: none;
}

.user-avatar-btn {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

.user-avatar-btn:hover,
.user-avatar-btn:focus {
    background-color: #0b5ed7;
    border-color: #0b5ed7;
    color: #fff;
}

.app-content {
    padding: 24px 0 40px;
    flex: 1;
}

.app-content .container-fluid {
    padding-left: var(--content-inline-padding);
    padding-right: var(--content-inline-padding);
}

.card {
    border: none;
    box-shadow: var(--card-shadow);
}

.table thead th {
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
}

.badge-soft {
    background: rgba(13, 110, 253, 0.12);
    color: #0d6efd;
    font-weight: 600;
}

.form-shell {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.18);
    backdrop-filter: blur(4px);
}

.form-shell .card-footer {
    background: rgba(241, 245, 249, 0.88) !important;
    border-top: 1px solid #e2e8f0;
}

.form-section {
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(241, 245, 249, 0.95));
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    padding: 20px;
}

.form-section + .form-section {
    margin-top: 1rem;
}

.form-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 4px;
}

.form-section-subtitle {
    color: #64748b;
    font-size: 0.9rem;
    margin-bottom: 18px;
}

.form-shell .form-control,
.form-shell .form-select {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

.form-shell .form-control:focus,
.form-shell .form-select:focus {
    background-color: #fff;
    border-color: #93c5fd;
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.15);
}

.form-shell .form-text {
    color: #64748b;
}

.empresa-grid-empty-row td {
    background: rgba(248, 250, 252, 0.9);
}

.form-shell .invalid-feedback,
.form-shell .text-danger {
    display: block;
    font-size: 0.85rem;
}

.page-intro-card {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 64, 175, 0.82));
    color: #fff;
    border: 0;
}

.page-intro-card .text-muted {
    color: rgba(255, 255, 255, 0.78) !important;
}

.page-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.9rem;
}

.page-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.nexus-filter-form {
    background: linear-gradient(180deg, #fff4d6 0%, #ffe8b3 100%);
    border: 1px solid #f1d48a;
    border-radius: 0.85rem;
    padding: 1rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.nexus-filter-form .form-label {
    color: #704d00;
    font-weight: 600;
    margin-bottom: 0.35rem;
    line-height: 1.15;
}

.nexus-filter-form .form-control,
.nexus-filter-form .form-select {
    background-color: #fffdfa;
    border-color: #e4c46f;
}

.nexus-filter-form .form-control:focus,
.nexus-filter-form .form-select:focus {
    background-color: #ffffff;
    border-color: #cc9a06;
    box-shadow: 0 0 0 0.2rem rgba(204, 154, 6, 0.18);
}

.nexus-filter-form .form-text {
    color: #7a5b12;
}

.nexus-filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.nexus-results-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.1rem;
}

.nexus-table-card .table-responsive {
    overflow-x: auto;
}

.nexus-table-card .table td,
.nexus-table-card .table th {
    vertical-align: middle;
}

.nexus-table-card .btn {
    white-space: nowrap;
}

.fiscal-doc-table .doc-party-cell strong {
    display: inline-block;
    line-height: 1.2;
}

.fiscal-doc-table .doc-party-meta,
.fiscal-doc-table .doc-extra-meta {
    display: block;
}

.fiscal-doc-table .doc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

@media (max-width: 1499px) {
    :root {
        --sidebar-width: 216px;
        --content-inline-padding: 10px;
    }

    .app-topbar {
        padding: 0 18px;
    }

    .app-content {
        padding: 20px 0 32px;
    }

    .sidebar-brand {
        font-size: 0.8rem;
        padding: 10px 10px 16px;
    }

    .app-sidebar .nav-link {
        padding: 9px 10px;
        gap: 8px;
        font-size: 0.95rem;
    }

    .app-sidebar .nav-link i {
        font-size: 1rem;
    }

    .display-6 {
        font-size: 1.95rem;
    }

    .table thead th {
        font-size: 0.68rem;
    }

    .table {
        font-size: 0.93rem;
    }

    .card .card-body {
        padding: 1rem;
    }

    .fiscal-doc-table {
        font-size: 0.88rem;
    }
}

@media (max-width: 1279px) {
    :root {
        --sidebar-width: 188px;
        --topbar-height: 54px;
        --content-inline-padding: 8px;
    }

    .app-sidebar {
        padding: 12px 10px;
    }

    .sidebar-brand {
        font-size: 0.76rem;
        letter-spacing: 0.05em;
        padding: 8px 8px 14px;
    }

    .app-sidebar .nav-link {
        padding: 8px 9px;
        gap: 7px;
        font-size: 0.9rem;
        border-radius: 8px;
    }

    .app-topbar {
        padding: 0 14px;
    }

    .user-avatar-btn .user-avatar-img {
        width: 34px;
        height: 34px;
    }

    .app-content {
        padding: 16px 0 24px;
    }

    .display-6 {
        font-size: 1.7rem;
    }

    .breadcrumb {
        row-gap: 0.2rem;
    }

    .form-label,
    .form-text,
    .btn,
    .form-control,
    .form-select {
        font-size: 0.92rem;
    }

    .table {
        font-size: 0.88rem;
    }

    .table thead th {
        font-size: 0.64rem;
    }

    .card .card-header,
    .card .card-body {
        padding-left: 0.9rem;
        padding-right: 0.9rem;
    }

    .page-toolbar-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .nexus-results-meta {
        width: 100%;
        align-items: flex-start;
    }

    .nexus-filter-actions {
        justify-content: flex-start;
    }

    .fiscal-doc-table {
        font-size: 0.84rem;
    }

    .fiscal-doc-table .doc-party-meta,
    .fiscal-doc-table .doc-extra-meta {
        display: none;
    }

    .fiscal-doc-table .doc-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .fiscal-doc-table .doc-actions .btn {
        padding-inline: 0.55rem;
        font-size: 0.82rem;
    }

    .fiscal-doc-table .doc-col-secondary {
        display: none;
    }
}

@media (max-width: 991px) {
    .app-sidebar {
        position: static;
        width: 100%;
        height: auto;
        overflow: visible;
    }

    .sidebar-nav {
        overflow: visible;
        padding-right: 0;
    }

    .app-main {
        margin-left: 0;
        width: 100%;
    }
}
