:root {
    --bg: #f5f7fb;
    --panel: #fff;
    --text: #172033;
    --muted: #667085;
    --line: #e6eaf2;
    --primary: #1e5bff;
    --primary2: #0f2f87;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    --radius: 20px
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text)
}

a {
    text-decoration: none;
    color: inherit
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 285px;
    background: #071225;
    color: #dce7ff;
    padding: 22px 18px;
    z-index: 30;
    overflow: auto
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px
}

.brand.big {
    margin-bottom: 30px
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2f6bff, #0ea5e9);
    display: grid;
    place-items: center;
    color: white;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(30, 91, 255, .3)
}

.brand strong {
    display: block;
    font-size: 18px
}

.brand span {
    display: block;
    color: #97a6c4;
    font-size: 12px
}

.sidebar nav {
    display: grid;
    gap: 5px
}

.sidebar nav a {
    padding: 12px 13px;
    border-radius: 13px;
    color: #d7e3fb;
    font-size: 14px
}

.sidebar nav a:hover {
    background: rgba(255, 255, 255, .08)
}

.topbar {
    position: fixed;
    left: 285px;
    right: 0;
    top: 0;
    height: 76px;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 20
}

.topbar strong {
    display: block;
    font-size: 19px
}

.topbar small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px
}

.content {
    margin-left: 285px;
    padding: 100px 28px 38px
}

.auth-content {
    min-height: 100vh
}

.user-pill {
    display: flex;
    gap: 10px;
    align-items: center;
    background: #f2f5fb;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 10px 8px 16px
}

.user-pill span {
    font-weight: 700
}

.user-pill small {
    margin: 0
}

.user-pill a {
    background: #fff;
    border: 1px solid var(--line);
    padding: 7px 12px;
    border-radius: 999px;
    color: var(--primary);
    font-weight: 700
}

.mobile-menu {
    display: none;
    border: 0;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    padding: 9px 12px
}

.grid {
    display: grid;
    gap: 18px
}

.grid.cards {
    grid-template-columns: repeat(4, minmax(0, 1fr))
}

.grid.two {
    grid-template-columns: 1.35fr .8fr
}

.grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr))
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px
}

.metric {
    position: relative;
    overflow: hidden
}

.metric:after {
    content: "";
    position: absolute;
    right: -35px;
    top: -35px;
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, rgba(30, 91, 255, .12), rgba(14, 165, 233, .06));
    border-radius: 50%
}

.metric span {
    color: var(--muted);
    font-size: 13px
}

.metric strong {
    display: block;
    font-size: 28px;
    margin-top: 9px
}

.metric small {
    display: block;
    color: var(--muted);
    margin-top: 8px
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 8px 0 16px
}

.section-head h2,
.section-head h1 {
    margin: 0
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap
}

.btn,
button {
    border: 0;
    border-radius: 13px;
    padding: 10px 14px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    justify-content: center
}

.btn.primary,
button.primary {
    background: var(--primary);
    color: white
}

.btn.ghost {
    background: #eef3ff;
    color: var(--primary)
}

.btn.danger {
    background: #fee2e2;
    color: var(--danger)
}

.btn.success {
    background: #dcfce7;
    color: var(--success)
}

.btn.full {
    width: 100%
}

.table-wrap {
    overflow: auto
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 16px;
    overflow: hidden
}

.table th {
    background: #f8fafc;
    color: #475467;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em
}

.table th,
.table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    vertical-align: middle
}

.table tr:hover td {
    background: #fafcff
}

.badge {
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    background: #eef2ff;
    color: #3444b5
}

.badge.paga,
.badge.ativo,
.badge.finalizada {
    background: #dcfce7;
    color: #15803d
}

.badge.vencida,
.badge.inadimplente {
    background: #fee2e2;
    color: #b91c1c
}

.badge.aberto,
.badge.em {
    background: #fef3c7;
    color: #a16207
}

.form {
    display: grid;
    gap: 14px
}

.form.grid2 {
    grid-template-columns: repeat(2, minmax(0, 1fr))
}

.form.grid3 {
    grid-template-columns: repeat(3, minmax(0, 1fr))
}

.form label {
    display: grid;
    gap: 6px;
    color: #344054;
    font-size: 13px;
    font-weight: 700
}

.form input,
.form select,
.form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
    color: var(--text)
}

.form textarea {
    min-height: 88px;
    resize: vertical
}

.stack {
    display: grid;
    gap: 14px
}

.filters {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px
}

.filters input,
.filters select {
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 10px 12px
}

.alert-list {
    display: grid;
    gap: 10px
}

.alert-item {
    padding: 12px;
    border-radius: 15px;
    border: 1px solid var(--line);
    background: #fbfcff;
    display: flex;
    justify-content: space-between;
    gap: 12px
}

.alert-item strong {
    display: block
}

.alert-item small {
    color: var(--muted)
}

.flash-wrap {
    display: grid;
    gap: 10px;
    margin-bottom: 16px
}

.flash {
    padding: 13px 15px;
    border-radius: 14px;
    font-weight: 700
}

.flash.success {
    background: #dcfce7;
    color: #166534
}

.flash.danger {
    background: #fee2e2;
    color: #991b1b
}

.flash.warning {
    background: #fef3c7;
    color: #92400e
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 20% 20%, rgba(30, 91, 255, .22), transparent 32%), linear-gradient(135deg, #071225, #111827)
}

.login-card {
    width: min(440px, calc(100% - 30px));
    background: white;
    border-radius: 28px;
    padding: 34px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .3)
}

.login-card h1 {
    font-size: 30px;
    margin: 0 0 8px
}

.login-card p,
.muted {
    color: var(--muted)
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px
}

.report-item {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center
}

.receipt-frame {
    width: 100%;
    height: 80vh;
    border: 1px solid var(--line);
    border-radius: 16px
}

.item-row {
    display: grid;
    grid-template-columns: 1fr 2fr 100px 120px 44px;
    gap: 10px;
    align-items: end;
    margin-bottom: 10px
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px
}

.mini-card {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 15px
}

@media(max-width:1100px) {
    .grid.cards {
        grid-template-columns: repeat(2, 1fr)
    }

    .grid.two,
    .grid.three {
        grid-template-columns: 1fr
    }

    .form.grid3 {
        grid-template-columns: 1fr 1fr
    }
}

@media(max-width:800px) {
    .sidebar {
        transform: translateX(-105%);
        transition: .2s
    }

    .menu-open .sidebar {
        transform: translateX(0)
    }

    .topbar {
        left: 0
    }

    .content {
        margin-left: 0;
        padding: 95px 15px 28px
    }

    .mobile-menu {
        display: block
    }

    .grid.cards,
    .form.grid2,
    .form.grid3,
    .report-grid {
        grid-template-columns: 1fr
    }

    .topbar {
        padding: 0 14px
    }

    .user-pill small {
        display: none
    }

    .item-row {
        grid-template-columns: 1fr
    }

    .card {
        padding: 16px
    }
}

.text-center {
    text-align: center
}

.green {
    color: #169b62 !important
}

.orange {
    color: #d97706 !important
}

.red {
    color: #dc2626 !important
}

.dark {
    color: #1f2937 !important
}

.clickable {
    text-decoration: none;
    color: inherit;
    transition: .15s
}

.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(15, 23, 42, .12)
}

.dashboard-filter {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
    margin-bottom: 18px
}

.dashboard-filter label {
    font-size: 12px;
    color: #64748b
}

.dashboard-filter input {
    display: block;
    margin-top: 6px
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    min-height: 26px;
    padding: 4px 10px;
    white-space: nowrap;
    text-align: center;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700
}

.badge.vencida,
.badge.inadimplente {
    background: #fee2e2;
    color: #991b1b
}

.badge.emaberto,
.badge.parcial,
.badge.pendente {
    background: #fef3c7;
    color: #92400e
}

.badge.paga,
.badge.ativo,
.badge.entrada {
    background: #dcfce7;
    color: #166534
}

.badge.saida,
.badge.inativo {
    background: #ffedd5;
    color: #9a3412
}

.badge.cancelada {
    background: #e5e7eb;
    color: #374151
}

.alert-item {
    align-items: center;
    gap: 10px
}

.checkline {
    display: flex !important;
    align-items: center;
    gap: 10px;
    min-height: 44px
}

.checkline input {
    width: auto !important
}

.collapsible summary {
    cursor: pointer;
    font-weight: 800;
    font-size: 18px;
    list-style: none
}

.collapsible summary:before {
    content: '+';
    display: inline-flex;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    border-radius: 8px;
    background: #eef2ff;
    color: #1d4ed8
}

.collapsible[open] summary:before {
    content: '–'
}

body.sidebar-collapsed .sidebar {
    width: 76px
}

body.sidebar-collapsed .sidebar .brand span,
body.sidebar-collapsed .sidebar .brand strong,
body.sidebar-collapsed .sidebar nav a {
    font-size: 0
}

body.sidebar-collapsed .sidebar nav a::first-letter {
    font-size: 20px
}

body.sidebar-collapsed .content,
body.sidebar-collapsed .topbar {
    margin-left: 76px
}

.user-menu {
    position: relative
}

.user-name {
    border: 0;
    background: #fff;
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .08)
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 42px;
    background: #fff;
    box-shadow: 0 18px 38px rgba(15, 23, 42, .16);
    border-radius: 14px;
    min-width: 190px;
    z-index: 20;
    padding: 8px
}

.user-dropdown a {
    display: block;
    padding: 10px 12px;
    color: #0f172a;
    text-decoration: none;
    border-radius: 10px
}

.user-dropdown a:hover {
    background: #f1f5f9
}

.user-menu:hover .user-dropdown {
    display: block
}

.mini-edit {
    position: relative
}

.mini-edit summary {
    list-style: none
}

.mini-edit form {
    position: absolute;
    right: 0;
    top: 36px;
    background: #fff;
    z-index: 30;
    width: 300px;
    box-shadow: 0 22px 50px rgba(15, 23, 42, .2);
    padding: 14px;
    border-radius: 16px
}

.profile-row {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 12px
}

.profile-row summary {
    cursor: pointer;
    display: flex;
    justify-content: space-between
}

.chart-compact {
    max-height: 280px !important
}

@media(max-width:900px) {

    body.sidebar-collapsed .content,
    body.sidebar-collapsed .topbar {
        margin-left: 0
    }

    .mini-edit form {
        position: static;
        width: auto
    }
}

/* V3 layout refinements */
.sidebar {
    transition: width .2s ease;
    padding-bottom: 82px
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    position: relative
}

.nav-icon {
    width: 25px;
    text-align: center;
    font-size: 18px;
    flex: 0 0 25px
}

.nav-text {
    white-space: nowrap
}

.sidebar-toggle {
    position: fixed;
    left: 18px;
    bottom: 18px;
    width: 48px;
    height: 44px;
    background: rgba(255, 255, 255, .09);
    color: #dce7ff;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 14px
}

.expand-icon {
    display: none
}

.brand-text {
    min-width: 0
}

.brand-text strong {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.topbar {
    transition: left .2s ease
}

.content {
    transition: margin-left .2s ease
}

body.sidebar-collapsed .sidebar {
    width: 78px;
    padding-left: 14px;
    padding-right: 14px;
    overflow: visible
}

body.sidebar-collapsed .brand {
    justify-content: center
}

body.sidebar-collapsed .brand-text {
    display: none
}

body.sidebar-collapsed .sidebar nav a {
    justify-content: center;
    padding: 12px 10px
}

body.sidebar-collapsed .nav-text {
    display: none
}

body.sidebar-collapsed .sidebar nav a:hover::after {
    content: attr(data-title);
    position: absolute;
    left: 64px;
    top: 50%;
    transform: translateY(-50%);
    background: #0f172a;
    color: #fff;
    padding: 8px 10px;
    border-radius: 10px;
    white-space: nowrap;
    font-size: 12px;
    box-shadow: 0 14px 30px rgba(15, 23, 42, .25);
    z-index: 1000
}

body.sidebar-collapsed .topbar {
    left: 78px;
    margin-left: 0
}

body.sidebar-collapsed .content {
    margin-left: 78px
}

body.sidebar-collapsed .collapse-icon {
    display: none
}

body.sidebar-collapsed .expand-icon {
    display: inline
}

.user-dropdown.is-open {
    display: block
}

.user-menu:hover .user-dropdown {
    display: block
}

.action-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px
}

.create-panel {
    margin-bottom: 18px
}

.create-panel>summary {
    list-style: none;
    display: inline-flex
}

.create-panel>summary::-webkit-details-marker {
    display: none
}

.modal-card {
    margin-top: 14px
}

.select-search {
    position: relative
}

.select-search-results {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 18px 38px rgba(15, 23, 42, .16);
    border-radius: 14px;
    margin-top: 6px;
    z-index: 50;
    max-height: 240px;
    overflow: auto
}

.select-search-results.open {
    display: block
}

.select-search-results button {
    display: block;
    width: 100%;
    text-align: left;
    background: #fff;
    color: #172033;
    border-radius: 0;
    padding: 10px 12px;
    font-weight: 600
}

.select-search-results button:hover {
    background: #f1f5f9
}

.chart-card canvas {
    max-height: 285px
}

.chart-card {
    min-height: 365px
}

.profile-summary-row {
    display: grid;
    grid-template-columns: 1.2fr 2fr 180px 120px 110px;
    gap: 10px;
    align-items: center
}

@media(max-width:900px) {

    body.sidebar-collapsed .content,
    body.sidebar-collapsed .topbar {
        margin-left: 0;
        left: 0
    }

    .profile-summary-row {
        grid-template-columns: 1fr
    }

    .create-panel>summary {
        width: 100%
    }
}

/* V4 - ajustes finos */
.dashboard-finance-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px
}

.dashboard-finance-grid .chart-wide {
    grid-column: 1/-1
}

.dashboard-finance-grid .chart-category {
    min-height: 365px
}

.dashboard-finance-grid .chart-category canvas {
    height: 270px !important;
    max-height: 270px !important
}

.dashboard-finance-grid .chart-wide canvas {
    height: 285px !important;
    max-height: 285px !important
}

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .48);
    z-index: 100;
    align-items: flex-start;
    justify-content: center;
    padding: 7vh 18px 28px;
    overflow: auto
}

.modal-backdrop.open {
    display: flex
}

.modal-box {
    width: min(920px, 100%);
    box-shadow: 0 28px 80px rgba(0, 0, 0, .28)
}

.modal-wide {
    width: min(1180px, 100%)
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px
}

.modal-head h2 {
    margin: 0
}

.btn.small {
    padding: 7px 10px;
    font-size: 12px
}

.form input[data-mask],
.form input[name="documento"],
.form input[name="cnpj"],
.form input[name="telefone"],
.form input[name="whatsapp"],
.form input[name="cep"] {
    letter-spacing: .01em
}

@media(max-width:900px) {
    .dashboard-finance-grid {
        grid-template-columns: 1fr
    }

    .dashboard-finance-grid .chart-category,
    .dashboard-finance-grid .chart-wide {
        grid-column: auto
    }

    .modal-backdrop {
        padding-top: 12px
    }

    .modal-head {
        align-items: flex-start
    }
}

/* V5 - dropdowns pesquisáveis, responsividade mobile refinada e modo escuro */
.top-actions {
    display: flex;
    align-items: center;
    gap: 10px
}

.theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
    padding: 0;
    font-size: 18px
}

.theme-toggle .theme-sun {
    display: inline
}

.theme-toggle .theme-moon {
    display: none
}

.dark-mode .theme-toggle .theme-sun {
    display: none
}

.dark-mode .theme-toggle .theme-moon {
    display: inline
}

.native-select-hidden {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important
}

.search-select {
    position: relative;
    width: 100%
}

.search-select-button {
    width: 100%;
    min-height: 43px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-align: left;
    justify-content: flex-start;
    padding: 11px 38px 11px 12px;
    position: relative
}

.search-select-button:after {
    content: '⌄';
    position: absolute;
    right: 12px;
    color: var(--muted);
    font-weight: 800
}

.search-select-button.placeholder {
    color: var(--muted)
}

.search-select-input {
    display: none !important;
    position: absolute;
    left: 8px;
    right: 8px;
    top: 8px;
    width: calc(100% - 16px) !important;
    z-index: 55;
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 10px 11px;
    font: inherit;
    background: var(--panel);
    color: var(--text)
}

.search-select-list {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    max-height: 260px;
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 0 18px 38px rgba(15, 23, 42, .16);
    border-radius: 15px;
    z-index: 54;
    padding: 58px 6px 6px
}

.search-select.open .search-select-input,
.search-select.open .search-select-list {
    display: block !important
}

.search-select-option {
    width: 100%;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    justify-content: flex-start;
    text-align: left;
    font-weight: 600;
    padding: 10px 11px
}

.search-select-option:hover,
.search-select-option.selected {
    background: #eef3ff;
    color: var(--primary)
}

.search-select-empty {
    padding: 12px;
    color: var(--muted);
    font-size: 13px
}

.form label .search-select {
    margin-top: 0
}

.filters .search-select {
    min-width: 190px
}

.mobile-backdrop {
    display: none
}

.chart-card canvas {
    width: 100% !important
}

.table-wrap {
    max-width: 100%
}

.modal-box {
    max-height: 88vh;
    overflow: auto
}

.btn {
    white-space: nowrap
}

.dashboard-filter input,
.filters input,
.filters select {
    background: var(--panel);
    color: var(--text)
}

.dark-mode {
    --bg: #0b1220;
    --panel: #111827;
    --text: #e5edf8;
    --muted: #94a3b8;
    --line: #263244;
    --primary: #60a5fa;
    --primary2: #2563eb;
    --success: #4ade80;
    --danger: #f87171;
    --warning: #f59e0b;
    --shadow: 0 18px 48px rgba(0, 0, 0, .30)
}

.dark-mode body,
body:has(.dark-mode) {
    background: var(--bg);
    color: var(--text)
}

.dark-mode .topbar {
    background: rgba(15, 23, 42, .88);
    border-color: var(--line)
}

.dark-mode .sidebar {
    background: #050b18
}

.dark-mode .card,
.dark-mode .login-card,
.dark-mode .modal-box,
.dark-mode .mini-card,
.dark-mode .report-item {
    background: var(--panel);
    border-color: var(--line);
    color: var(--text)
}

.dark-mode .table {
    background: var(--panel)
}

.dark-mode .table th {
    background: #0f172a;
    color: #cbd5e1
}

.dark-mode .table td {
    border-color: var(--line)
}

.dark-mode .table tr:hover td {
    background: #182235
}

.dark-mode .form label {
    color: #cbd5e1
}

.dark-mode .form input,
.dark-mode .form select,
.dark-mode .form textarea,
.dark-mode .filters input,
.dark-mode .filters select,
.dark-mode .dashboard-filter input {
    background: #0f172a;
    border-color: #334155;
    color: #e5edf8
}

.dark-mode .form input::placeholder,
.dark-mode .form textarea::placeholder {
    color: #94a3b8
}

.dark-mode .btn.ghost {
    background: #172554;
    color: #bfdbfe
}

.dark-mode .btn.danger {
    background: #451a1a;
    color: #fecaca
}

.dark-mode .btn.success {
    background: #052e16;
    color: #bbf7d0
}

.dark-mode .user-name,
.dark-mode .theme-toggle,
.dark-mode .user-dropdown {
    background: #0f172a;
    color: #e5edf8;
    border: 1px solid #334155
}

.dark-mode .user-dropdown a {
    color: #e5edf8
}

.dark-mode .user-dropdown a:hover {
    background: #1e293b
}

.dark-mode .alert-item {
    background: #0f172a;
    border-color: #334155
}

.dark-mode .flash.success {
    background: #052e16;
    color: #bbf7d0
}

.dark-mode .flash.danger {
    background: #451a1a;
    color: #fecaca
}

.dark-mode .flash.warning {
    background: #422006;
    color: #fde68a
}

.dark-mode .login-shell {
    background: radial-gradient(circle at 20% 20%, rgba(96, 165, 250, .18), transparent 32%), linear-gradient(135deg, #020617, #0f172a)
}

.dark-mode .search-select-button,
.dark-mode .search-select-input,
.dark-mode .search-select-list,
.dark-mode .select-search-results {
    background: #0f172a;
    color: #e5edf8;
    border-color: #334155
}

.dark-mode .search-select-option:hover,
.dark-mode .search-select-option.selected,
.dark-mode .select-search-results button:hover {
    background: #172554;
    color: #bfdbfe
}

.dark-mode .select-search-results button {
    background: #0f172a;
    color: #e5edf8
}

.dark-mode .metric:after {
    background: linear-gradient(135deg, rgba(96, 165, 250, .14), rgba(14, 165, 233, .06))
}

.dark-mode .dark {
    color: #e5edf8 !important
}

.dark-mode .green {
    color: #4ade80 !important
}

.dark-mode .red {
    color: #f87171 !important
}

.dark-mode .orange {
    color: #f59e0b !important
}

.dark-mode .badge.cancelada {
    background: #334155;
    color: #e2e8f0
}

.dark-mode .profile-row {
    border-color: #334155
}

.dark-mode .modal-backdrop {
    background: rgba(2, 6, 23, .70)
}

@media(max-width:800px) {
    body {
        overflow-x: hidden
    }

    .sidebar {
        width: min(86vw, 320px);
        transform: translateX(-105%);
        transition: transform .22s ease;
        width: min(86vw, 320px) !important;
        overflow: auto
    }

    .menu-open .sidebar {
        transform: translateX(0)
    }

    .mobile-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .45);
        z-index: 25
    }

    .menu-open .mobile-backdrop {
        display: block
    }

    .topbar {
        left: 0 !important;
        margin-left: 0 !important;
        height: auto;
        min-height: 70px;
        padding: 10px 12px;
        gap: 10px
    }

    .topbar>div:not(.top-actions) {
        min-width: 0;
        flex: 1
    }

    .topbar strong {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis
    }

    .content {
        margin-left: 0 !important;
        padding: 88px 12px 24px
    }

    .grid.cards {
        grid-template-columns: 1fr
    }

    .grid.two,
    .grid.three,
    .dashboard-finance-grid,
    .kpi-row,
    .form.grid2,
    .form.grid3,
    .report-grid {
        grid-template-columns: 1fr !important
    }

    .section-head,
    .action-head {
        align-items: flex-start;
        flex-direction: column
    }

    .actions,
    .filters,
    .dashboard-filter {
        width: 100%;
        align-items: stretch
    }

    .actions .btn,
    .filters .btn,
    .dashboard-filter .btn,
    .filters input,
    .filters select,
    .dashboard-filter input,
    .dashboard-filter label {
        width: 100%
    }

    .filters .search-select {
        width: 100%;
        min-width: 0
    }

    .metric strong {
        font-size: 24px
    }

    .card {
        padding: 15px;
        border-radius: 17px
    }

    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 16px
    }

    .table {
        min-width: 720px
    }

    .modal-backdrop {
        align-items: flex-start;
        padding: 10px
    }

    .modal-box {
        width: 100%;
        max-height: calc(100vh - 20px);
        overflow: auto;
        border-radius: 18px
    }

    .modal-head {
        position: sticky;
        top: 0;
        background: var(--panel);
        z-index: 3;
        padding-bottom: 10px
    }

    .item-row {
        grid-template-columns: 1fr !important
    }

    .search-select-list {
        max-height: 45vh
    }

    .user-dropdown {
        right: 0
    }

    .login-card {
        padding: 24px;
        border-radius: 22px
    }

    .login-card h1 {
        font-size: 24px
    }

    .brand.big {
        align-items: flex-start
    }

    .brand.big .brand-mark {
        flex: 0 0 44px
    }

    .chart-card {
        min-height: 330px
    }

    .dashboard-finance-grid .chart-category canvas,
    .dashboard-finance-grid .chart-wide canvas {
        height: 235px !important;
        max-height: 235px !important
    }

    body.sidebar-collapsed .sidebar {
        width: min(86vw, 320px) !important
    }

    .sidebar-toggle {
        position: static;
        width: 100%;
        margin-top: 16px
    }

    .sidebar nav a {
        font-size: 14px !important;
        justify-content: flex-start !important
    }

    .nav-text,
    .brand-text {
        display: block !important
    }

    .sidebar .brand {
        justify-content: flex-start !important
    }

    .collapse-icon {
        display: inline !important
    }

    .expand-icon {
        display: none !important
    }
}

    .sidebar-toggle {
  display: none !important;
}

.login-logo-area {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 24px;
}

.login-logo {
  width: 330px;
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.logo-preview-box {
  max-width: 260px;
  width: 260px;
  min-height: auto;
  padding: 12px;
}

.logo-preview-box img {
  width: 100%;
  max-width: 240px;
  max-height: 120px;
  object-fit: contain;
  display: block;
}

.brand-logo-img {
  width: 42px !important;
  height: 42px !important;
  max-width: 42px !important;
  max-height: 42px !important;
  object-fit: contain;
  border-radius: 10px;
  padding: 3px;
}

/* Mantém a tela de login sempre em modo claro */
body.login-light-only {
  background: linear-gradient(135deg, #07162f 0%, #0f2f67 45%, #08111f 100%) !important;
  color: #0f172a !important;
}

body.login-light-only .login-card {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: rgba(15, 23, 42, 0.08) !important;
}

body.login-light-only .login-card h1,
body.login-light-only .login-card label,
body.login-light-only .login-card strong {
  color: #0f172a !important;
}

body.login-light-only .login-card span,
body.login-light-only .login-card .muted {
  color: #64748b !important;
}

body.login-light-only input {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #dbe3ef !important;
}

body.login-light-only input:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
}

/* Força a tela de login a ignorar o modo escuro */
html body.login-light-only,
html[data-theme="dark"] body.login-light-only,
body.dark.login-light-only,
body.dark-mode.login-light-only,
body.theme-dark.login-light-only {
  background: linear-gradient(135deg, #07162f 0%, #0f2f67 45%, #08111f 100%) !important;
  color: #0f172a !important;
}

html body.login-light-only .login-shell,
html[data-theme="dark"] body.login-light-only .login-shell,
body.dark.login-light-only .login-shell,
body.dark-mode.login-light-only .login-shell,
body.theme-dark.login-light-only .login-shell {
  background: transparent !important;
}

html body.login-light-only .login-card,
html[data-theme="dark"] body.login-light-only .login-card,
body.dark.login-light-only .login-card,
body.dark-mode.login-light-only .login-card,
body.theme-dark.login-light-only .login-card {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: rgba(15, 23, 42, 0.08) !important;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28) !important;
}

html body.login-light-only .login-card h1,
html body.login-light-only .login-card label,
html body.login-light-only .login-card strong,
html[data-theme="dark"] body.login-light-only .login-card h1,
html[data-theme="dark"] body.login-light-only .login-card label,
html[data-theme="dark"] body.login-light-only .login-card strong {
  color: #0f172a !important;
}

html body.login-light-only .login-card span,
html body.login-light-only .login-card .muted,
html[data-theme="dark"] body.login-light-only .login-card span,
html[data-theme="dark"] body.login-light-only .login-card .muted {
  color: #64748b !important;
}

html body.login-light-only .login-card input,
html[data-theme="dark"] body.login-light-only .login-card input,
body.dark.login-light-only .login-card input,
body.dark-mode.login-light-only .login-card input,
body.theme-dark.login-light-only .login-card input {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #dbe3ef !important;
}

html body.login-light-only .login-card input:focus,
html[data-theme="dark"] body.login-light-only .login-card input:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
}

html body.login-light-only .login-card .btn.primary,
html[data-theme="dark"] body.login-light-only .login-card .btn.primary {
  background: #2563eb !important;
  color: #ffffff !important;
}

/* =========================================================
   RESPONSIVIDADE MOBILE - EducaGest
   Ajustado para o base.html atual
   ========================================================= */

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

/* O botão mobile já existe no base.html como .mobile-menu */
.mobile-menu {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-size: 22px;
  cursor: pointer;
}

/* Backdrop escuro quando o menu abre no mobile */
.mobile-backdrop {
  display: none;
}

@media (max-width: 900px) {
  body {
    overflow-x: hidden;
  }

  .mobile-menu {
    display: inline-flex !important;
    flex-shrink: 0;
  }

  /* Sidebar vira menu lateral sobreposto */
  .sidebar {
    position: fixed !important;
    top: 0;
    left: -285px;
    width: 270px !important;
    max-width: 82vw;
    height: 100vh;
    z-index: 9999;
    transition: left 0.25s ease;
    overflow-y: auto;
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.35);
  }

  body.menu-open .sidebar {
    left: 0 !important;
  }

  body.sidebar-collapsed .sidebar {
    left: -285px !important;
  }

  body.menu-open .mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(2px);
  }

  /* No mobile, o botão interno de recolher menu não precisa aparecer */
  .sidebar-toggle {
    display: none !important;
  }

  /* Topbar ocupa toda a tela */
  .topbar {
    left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 10px 14px !important;
    gap: 10px;
  }

  .topbar > div:first-of-type {
    min-width: 0;
    flex: 1;
  }

  .topbar strong {
    display: block;
    font-size: 16px !important;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar small {
    display: block;
    font-size: 11px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .top-actions {
    gap: 6px !important;
    flex-shrink: 0;
  }

  .theme-toggle {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
  }

  .user-name {
    max-width: 110px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Conteúdo principal */
  .content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 86px 14px 24px !important;
  }

  body.sidebar-collapsed .content {
    margin-left: 0 !important;
  }

  body.sidebar-collapsed .topbar {
    left: 0 !important;
  }

  /* Títulos */
  .content h1,
  .page-title,
  .section-title {
    font-size: 24px !important;
    line-height: 1.2;
  }

  /* Cards e indicadores em coluna */
  .kpi-grid,
  .cards-grid,
  .dashboard-cards,
  .stats-grid,
  .grid4,
  .grid-4 {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .card,
  .kpi-card,
  .stat-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* Gráficos em uma coluna */
  .chart-grid,
  .dashboard-grid,
  .dashboard-finance-grid,
  .grid2,
  .grid-2,
  .charts-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .chart-card,
  .chart-wide,
  .chart-category {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }

  canvas,
  .chart-card canvas {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Formulários em uma coluna */
  .form.grid,
  .form.grid2,
  .form.grid3,
  .form-grid,
  .grid-form {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  form label,
  .form label,
  input,
  select,
  textarea {
    width: 100% !important;
    max-width: 100% !important;
  }

  textarea {
    min-height: 100px;
  }

  /* Botões */
  .btn,
  button {
    min-height: 42px;
  }

  .form-actions,
  .actions,
  .table-actions {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
  }

  .form-actions .btn,
  .form-actions button {
    width: 100%;
  }

  /* Tabelas com rolagem horizontal */
  .table-wrapper,
  .table-responsive,
  .data-table-wrapper,
  .card:has(table) {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 720px;
  }

  th,
  td {
    white-space: nowrap;
  }

  /* Modais */
  .modal,
  .modal-content,
  .modal-card,
  .dialog,
  .dialog-card {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100vh - 24px) !important;
    overflow-y: auto !important;
  }

  /* Login mobile */
  .auth-content {
    width: 100% !important;
    max-width: 100% !important;
  }

  .login-shell {
    min-height: 100vh;
    padding: 24px 14px !important;
  }

  .login-card {
    width: 100% !important;
    max-width: 420px !important;
    padding: 28px 22px !important;
    border-radius: 24px !important;
  }

  .login-logo {
    width: 230px !important;
    max-width: 100% !important;
    height: auto !important;
  }

  .login-card h1 {
    font-size: 26px !important;
  }
}

@media (max-width: 480px) {
  .content {
    padding: 78px 12px 20px !important;
  }

  .topbar {
    padding: 9px 10px !important;
  }

  .topbar small {
    display: none !important;
  }

  .user-name {
    max-width: 82px;
  }

  .card,
  .chart-card,
  .kpi-card,
  .stat-card {
    border-radius: 18px !important;
    padding: 16px !important;
  }

  table {
    min-width: 660px;
  }

  .login-card {
    padding: 24px 18px !important;
  }

  .login-logo {
    width: 205px !important;
  }
}

/* Item ativo no menu lateral */
.sidebar nav a.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.28), rgba(59, 130, 246, 0.16));
  color: #ffffff !important;
  border-left: 4px solid #3b82f6;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.18);
}

.sidebar nav a.active .nav-icon,
.sidebar nav a.active .nav-text {
  color: #ffffff !important;
}

.sidebar nav a.active .nav-icon {
  filter: brightness(1.15);
}

/* Quando o menu estiver recolhido, mantém o destaque bonito */
body.sidebar-collapsed .sidebar nav a.active {
  border-left: none;
  border-radius: 14px;
  background: rgba(37, 99, 235, 0.32);
}
/* E-mails automáticos */
.email-config-block {
  border-top: 1px solid rgba(148, 163, 184, .22);
  margin-top: 10px;
  padding-top: 18px;
}
.email-config-block h2,
.email-config-block h3 {
  margin: 0 0 6px;
}
.check-line {
  display: flex !important;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 14px;
  background: rgba(148, 163, 184, .06);
}
.check-line input[type="checkbox"] {
  width: 18px !important;
  height: 18px;
  flex: 0 0 auto;
}
.email-test-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(148, 163, 184, .22);
}
.badge.enviado { background: rgba(16,185,129,.14); color: #059669; }
.badge.falhou { background: rgba(239,68,68,.14); color: #dc2626; }
.badge.pendente { background: rgba(245,158,11,.16); color: #d97706; }
.dark-mode .check-line,
.dark-mode .email-test-form,
.dark-mode .email-config-block { border-color: rgba(148, 163, 184, .18); }

/* =========================
   LOGS / AUDITORIA
========================= */

.audit-log-table tbody tr.audit-row {
  cursor: pointer;
  transition: background 0.18s ease;
}

.audit-log-table tbody tr.audit-row:hover {
  background: rgba(37, 99, 235, 0.08);
}

/* Backdrop do modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 9999;
}

.modal-backdrop.open {
  display: flex;
}

/* Caixa do modal */
.audit-modal-card,
.modal-box.audit-modal-card {
  width: min(1000px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #ffffff;
  color: #0f172a;
}

/* Cabeçalho do modal */
.audit-modal-card .modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.audit-modal-card .modal-head h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  color: #0f172a;
}

.audit-modal-card .modal-head .muted {
  margin-top: 6px;
  color: #64748b;
}

/* Botão fechar */
.audit-modal-card .modal-close {
  border: none;
  background: #f1f5f9;
  color: #0f172a;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.audit-modal-card .modal-close:hover {
  background: #e2e8f0;
}

/* Grid de informações */
.audit-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.audit-detail-grid > div,
.audit-block,
.audit-compare > div {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
}

.audit-detail-grid strong,
.audit-block strong,
.audit-compare strong {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.audit-detail-grid span,
.audit-block p,
.audit-compare pre {
  color: #0f172a;
}

/* Descrição */
.audit-block {
  margin-top: 10px;
}

.audit-block p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

/* Dado antigo x dado novo */
.audit-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.audit-compare pre {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
}

/* Tema escuro */
html.dark-mode .modal-backdrop {
  background: rgba(2, 6, 23, 0.72);
}

html.dark-mode .audit-modal-card,
html.dark-mode .modal-box.audit-modal-card {
  background: #0f172a;
  color: #e5e7eb;
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
}

html.dark-mode .audit-modal-card .modal-head h2 {
  color: #f8fafc;
}

html.dark-mode .audit-modal-card .modal-head .muted {
  color: #94a3b8;
}

html.dark-mode .audit-modal-card .modal-close {
  background: rgba(148, 163, 184, 0.14);
  color: #f8fafc;
}

html.dark-mode .audit-modal-card .modal-close:hover {
  background: rgba(148, 163, 184, 0.22);
}

html.dark-mode .audit-detail-grid > div,
html.dark-mode .audit-block,
html.dark-mode .audit-compare > div {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

html.dark-mode .audit-detail-grid strong,
html.dark-mode .audit-block strong,
html.dark-mode .audit-compare strong {
  color: #94a3b8;
}

html.dark-mode .audit-detail-grid span,
html.dark-mode .audit-block p,
html.dark-mode .audit-compare pre {
  color: #f8fafc;
}

/* Responsivo */
@media (max-width: 900px) {
  .audit-detail-grid,
  .audit-compare {
    grid-template-columns: 1fr;
  }

  .audit-modal-card,
  .modal-box.audit-modal-card {
    width: 100%;
    max-height: 92vh;
    padding: 16px;
    border-radius: 16px;
  }

  .audit-modal-card .modal-head h2 {
    font-size: 22px;
  }
}


/* Modal de edição de produtos */
.product-edit-modal {
  width: min(1050px, 96vw);
  max-height: 92vh;
  overflow-y: auto;
}

.product-edit-modal .modal-head h2 {
  margin: 0;
}

.stock-panel {
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 16px;
  padding: 14px;
  background: rgba(37, 99, 235, 0.06);
  display: grid;
  gap: 10px;
}

.stock-panel input[readonly] {
  background: rgba(148, 163, 184, 0.14);
  cursor: not-allowed;
}

html.dark-mode .stock-panel {
  border-color: rgba(96, 165, 250, 0.22);
  background: rgba(37, 99, 235, 0.10);
}

@media (max-width: 800px) {
  .product-edit-modal {
    width: 100%;
    max-height: 94vh;
  }
}

/* =========================================================
   Correção do modal de edição de produtos - tema claro/escuro
   ========================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55) !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 9999;
}

.modal-backdrop.open {
  display: flex !important;
}

.product-edit-modal,
.modal-box.product-edit-modal,
.modal-wide.product-edit-modal {
  width: min(1050px, 96vw) !important;
  max-height: 92vh !important;
  overflow-y: auto !important;
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 22px !important;
  padding: 28px !important;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.35) !important;
  opacity: 1 !important;
}

.product-edit-modal .modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.product-edit-modal .modal-head h2 {
  margin: 0;
  color: #0f172a !important;
}

.product-edit-modal .modal-head .muted {
  color: #64748b !important;
}

.product-edit-modal label {
  color: #334155 !important;
}

.product-edit-modal input,
.product-edit-modal select,
.product-edit-modal textarea {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 14px !important;
  min-height: 44px !important;
  width: 100% !important;
  max-width: 100% !important;
}

.product-edit-modal textarea {
  min-height: 90px !important;
}

/* Corrige o bloco de estoque para ocupar apenas uma célula da grid */
.product-edit-modal .stock-panel {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  border: 1px solid rgba(37, 99, 235, 0.20) !important;
  border-radius: 16px !important;
  padding: 14px !important;
  background: rgba(37, 99, 235, 0.06) !important;
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 10px !important;
}

.product-edit-modal .stock-panel label {
  width: 100% !important;
  max-width: 100% !important;
}

.product-edit-modal .stock-panel input {
  width: 100% !important;
  max-width: 100% !important;
}

.product-edit-modal .stock-panel input[readonly] {
  background: #f1f5f9 !important;
  color: #475569 !important;
  cursor: not-allowed;
}

/* Garante que estoque mínimo não herde tamanho errado */
.product-edit-modal input[name="estoque_minimo"] {
  width: 100% !important;
  max-width: 100% !important;
  min-height: 44px !important;
}

/* Botão de fechar */
.product-edit-modal .modal-close {
  border: none !important;
  background: #f1f5f9 !important;
  color: #0f172a !important;
  width: 40px !important;
  height: 40px !important;
  border-radius: 12px !important;
  font-size: 24px !important;
  font-weight: 700 !important;
  cursor: pointer;
  flex-shrink: 0;
}

.product-edit-modal .modal-close:hover {
  background: #e2e8f0 !important;
}

/* Tema escuro */
html.dark-mode .modal-backdrop {
  background: rgba(2, 6, 23, 0.72) !important;
}

html.dark-mode .product-edit-modal,
html.dark-mode .modal-box.product-edit-modal,
html.dark-mode .modal-wide.product-edit-modal {
  background: #0f172a !important;
  color: #f8fafc !important;
  border-color: rgba(148, 163, 184, 0.18) !important;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45) !important;
}

html.dark-mode .product-edit-modal .modal-head h2 {
  color: #f8fafc !important;
}

html.dark-mode .product-edit-modal .modal-head .muted,
html.dark-mode .product-edit-modal label {
  color: #cbd5e1 !important;
}

html.dark-mode .product-edit-modal input,
html.dark-mode .product-edit-modal select,
html.dark-mode .product-edit-modal textarea {
  background: #111827 !important;
  color: #f8fafc !important;
  border-color: rgba(148, 163, 184, 0.28) !important;
}

html.dark-mode .product-edit-modal .stock-panel {
  background: rgba(37, 99, 235, 0.10) !important;
  border-color: rgba(96, 165, 250, 0.24) !important;
}

html.dark-mode .product-edit-modal .stock-panel input[readonly] {
  background: rgba(148, 163, 184, 0.12) !important;
  color: #cbd5e1 !important;
}

html.dark-mode .product-edit-modal .modal-close {
  background: rgba(148, 163, 184, 0.14) !important;
  color: #f8fafc !important;
}

html.dark-mode .product-edit-modal .modal-close:hover {
  background: rgba(148, 163, 184, 0.22) !important;
}

/* Mobile */
@media (max-width: 900px) {
  .product-edit-modal,
  .modal-box.product-edit-modal,
  .modal-wide.product-edit-modal {
    width: 96vw !important;
    max-height: 92vh !important;
    padding: 20px !important;
  }

  .product-edit-modal form.grid3 {
    grid-template-columns: 1fr !important;
  }
}

/* Correção específica do campo Estoque mínimo no modal de produto */
.product-edit-modal form.grid3 {
  align-items: start !important;
}

.product-edit-modal .stock-min-field {
  align-self: start !important;
  height: auto !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
}

.product-edit-modal .stock-min-field input {
  height: 44px !important;
  min-height: 44px !important;
  max-height: 44px !important;
  padding: 0 14px !important;
  display: block !important;
  line-height: 44px !important;
}

/* Evita que labels simples estiquem junto com blocos altos no grid */
.product-edit-modal form.grid3 > label {
  align-self: start !important;
}
/* =========================================================
   Portal do Responsável / Calendário / Pedidos / H4LVION
   ========================================================= */
.h4-footer,
.login-h4-footer {
  width: 100%; display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 22px 4px 8px; color: #64748b; font-size: 12px;
}
.h4-footer img,
.login-h4-footer img { width: 22px; height: 22px; object-fit: contain; filter: drop-shadow(0 4px 10px rgba(15,23,42,.18)); }
.h4-footer strong,
.login-h4-footer strong { color: #2563eb; letter-spacing: .4px; }
.login-h4-footer { justify-content: center; color: rgba(226,232,240,.78); }
.login-h4-footer strong { color: #fff; }

.access-choice-card { width: min(860px, calc(100vw - 28px)); background: #fff; border-radius: 28px; padding: 34px; box-shadow: 0 25px 80px rgba(0,0,0,.28); text-align: center; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 22px; }
.choice-card { border: 1px solid #e2e8f0; border-radius: 20px; padding: 22px; text-align: left; background: #f8fafc; display: grid; gap: 12px; }
.choice-card h2 { margin: 0; }

.portal-body { background: #f4f7fb; min-height: 100vh; }
.portal-topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); backdrop-filter: blur(12px); border-bottom: 1px solid #e5e7eb; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.portal-brand { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.portal-brand img { width: 42px; height: 42px; object-fit: contain; }
.portal-brand strong { display:block; font-size: 16px; color:#0f172a; }
.portal-brand span { display:block; font-size:12px; color:#64748b; }
.portal-nav { display:flex; flex-wrap:wrap; gap:8px; justify-content:flex-end; }
.portal-nav a { padding: 9px 12px; border-radius: 999px; background: #eef4ff; color: #1e3a8a; font-weight: 700; font-size: 13px; }
.portal-nav a:hover { background:#dbeafe; }
.portal-content { width: min(1180px, 100%); margin: 0 auto; padding: 28px 18px 34px; }
.portal-hero { border-radius: 28px; padding: 28px; background: linear-gradient(135deg,#0f2f87,#2563eb); color:white; display:flex; justify-content:space-between; gap:18px; align-items:center; margin-bottom:18px; box-shadow: 0 20px 50px rgba(37,99,235,.25); }
.portal-hero h1 { margin:0 0 6px; font-size:32px; }
.portal-hero p { margin:0; color: rgba(255,255,255,.82); }
.portal-grid-2 { display:grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap:16px; margin-top:16px; }
.portal-cards { display:grid; grid-template-columns: repeat(auto-fit,minmax(260px,1fr)); gap:16px; }
.portal-list-item { padding:12px 0; border-bottom:1px solid #e5e7eb; display:grid; gap:4px; }
.portal-list-item:last-child { border-bottom:0; }
.portal-list-item span { color:#64748b; font-size:13px; }
.calendar-list { display:grid; gap:14px; }
.calendar-card { display:grid; grid-template-columns:90px 1fr; gap:14px; border-left:6px solid #2563eb; background:#fff; border-radius:20px; padding:16px; box-shadow: var(--shadow); }
.calendar-card > div { display:grid; place-content:center; text-align:center; background:#f1f5f9; border-radius:16px; color:#0f172a; }
.calendar-card > div strong { font-size:22px; }
.calendar-card h2 { margin:0 0 6px; }
.calendar-card p { margin:0 0 8px; color:#475569; }
.calendar-admin-grid { display:grid; grid-template-columns: repeat(auto-fit,minmax(310px,1fr)); gap:16px; }
.calendar-admin-card { border-left:5px solid #2563eb; }
.order-item-row { display:grid; grid-template-columns: 1fr 160px; gap:12px; align-items:end; }
html.dark-mode .portal-body { background:#071225; color:#e5e7eb; }
html.dark-mode .portal-topbar { background: rgba(15,23,42,.92); border-color: rgba(148,163,184,.16); }
html.dark-mode .portal-brand strong { color:#fff; }
html.dark-mode .portal-brand span, html.dark-mode .portal-list-item span { color:#94a3b8; }
html.dark-mode .portal-nav a { background: rgba(37,99,235,.18); color:#bfdbfe; }
html.dark-mode .calendar-card { background:#0f172a; }
html.dark-mode .calendar-card > div { background:#111827; color:#f8fafc; }
html.dark-mode .calendar-card p { color:#cbd5e1; }
html.dark-mode .h4-footer { color:#94a3b8; }
@media (max-width: 820px) {
  .choice-grid, .portal-grid-2, .order-item-row { grid-template-columns:1fr; }
  .portal-topbar { align-items:flex-start; flex-direction:column; }
  .portal-nav { justify-content:flex-start; }
  .portal-hero { flex-direction:column; align-items:flex-start; }
  .portal-hero h1 { font-size:26px; }
  .calendar-card { grid-template-columns:1fr; }
  .h4-footer { justify-content:center; }
}


/* =========================================================
   Ajustes V8.1 - login, calendário, fornecedor e senha portal
   ========================================================= */
.login-shell {
  min-height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 28px !important;
  padding: 32px 16px !important;
}
.login-card {
  margin: 0 !important;
}
.login-h4-footer {
  position: static !important;
  transform: none !important;
  margin-top: 0 !important;
  opacity: .95;
}
.login-h4-footer img {
  width: 22px !important;
  height: 22px !important;
  object-fit: contain !important;
  filter: none !important;
}
.portal-access-check {
  min-height: 44px;
  align-items: center;
  align-self: start;
  margin-top: 23px;
}
.calendar-event-modal,
.supplier-edit-modal {
  width: min(1120px, 96vw) !important;
  max-height: 92vh !important;
  overflow-y: auto !important;
  background: #fff !important;
  color: #0f172a !important;
  border-radius: 22px !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 30px 90px rgba(15,23,42,.35) !important;
  padding: 24px !important;
}
.calendar-event-modal .modal-head,
.supplier-edit-modal .modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.calendar-event-modal .modal-close,
.supplier-edit-modal .modal-close {
  border: none !important;
  background: #f1f5f9 !important;
  color: #0f172a !important;
  width: 40px !important;
  height: 40px !important;
  border-radius: 12px !important;
  font-size: 24px !important;
  font-weight: 700 !important;
  cursor: pointer;
  flex-shrink: 0;
}
.calendar-event-modal input,
.calendar-event-modal select,
.calendar-event-modal textarea,
.supplier-edit-modal input,
.supplier-edit-modal select,
.supplier-edit-modal textarea {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 14px !important;
  min-height: 44px !important;
  width: 100% !important;
}
.calendar-event-modal textarea,
.supplier-edit-modal textarea { min-height: 96px !important; }
html.dark-mode .calendar-event-modal,
html.dark-mode .supplier-edit-modal {
  background: #0f172a !important;
  color: #f8fafc !important;
  border-color: rgba(148,163,184,.18) !important;
}
html.dark-mode .calendar-event-modal input,
html.dark-mode .calendar-event-modal select,
html.dark-mode .calendar-event-modal textarea,
html.dark-mode .supplier-edit-modal input,
html.dark-mode .supplier-edit-modal select,
html.dark-mode .supplier-edit-modal textarea {
  background: #111827 !important;
  color: #f8fafc !important;
  border-color: rgba(148,163,184,.28) !important;
}
html.dark-mode .calendar-event-modal .modal-close,
html.dark-mode .supplier-edit-modal .modal-close {
  background: rgba(148,163,184,.14) !important;
  color: #f8fafc !important;
}
@media (max-width: 900px) {
  .login-shell { justify-content: center !important; gap: 22px !important; }
  .calendar-event-modal,
  .supplier-edit-modal { width: 96vw !important; padding: 18px !important; }
  .calendar-event-modal form.grid3,
  .supplier-edit-modal form.grid3 { grid-template-columns: 1fr !important; }
  .portal-access-check { margin-top: 0; }
}

/* =========================================================
   Ajustes V8.2 - Pedidos, indicadores, filtros e paginação
   ========================================================= */
.portal-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0;
}
.portal-kpi-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 14px 36px rgba(15,23,42,.08);
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  justify-content: center;
  min-height: 122px;
  gap: 8px;
}
.portal-kpi-card strong {
  font-size: 34px;
  line-height: 1;
  color: #0f172a;
}
.portal-kpi-card span {
  font-size: 13px;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.portal-kpi-blue { border-left: 5px solid #2563eb; }
.portal-kpi-neutral { border-left: 5px solid #334155; }
.portal-kpi-red { border-left: 5px solid #dc2626; }
.portal-kpi-green { border-left: 5px solid #16a34a; }
.portal-kpi-blue strong { color: #2563eb; }
.portal-kpi-red strong { color: #dc2626; }
.portal-kpi-green strong { color: #16a34a; }
html.dark-mode .portal-kpi-card { background:#0f172a; border-color:rgba(148,163,184,.18); }
html.dark-mode .portal-kpi-card strong { color:#f8fafc; }
html.dark-mode .portal-kpi-blue strong { color:#60a5fa; }
html.dark-mode .portal-kpi-red strong { color:#f87171; }
html.dark-mode .portal-kpi-green strong { color:#4ade80; }

.order-status { min-width: 128px; }
.order-novo-pedido { background:#e0f2fe !important; color:#075985 !important; }
.order-em-analise { background:#dbeafe !important; color:#1d4ed8 !important; }
.order-aguardando-pagamento { background:#ffedd5 !important; color:#c2410c !important; }
.order-pago { background:#dcfce7 !important; color:#15803d !important; }
.order-separado { background:#ede9fe !important; color:#6d28d9 !important; }
.order-entregue { background:#bbf7d0 !important; color:#166534 !important; }
.order-cancelado { background:#fee2e2 !important; color:#b91c1c !important; }

.filters-form { margin: 0; }
.filter-actions { display:flex; align-items:end; gap:10px; flex-wrap:wrap; }
.table-pagination {
  display:flex;
  justify-content:flex-end;
  align-items:center;
  gap:8px;
  margin-top:14px;
  flex-wrap:wrap;
}
.table-pagination button,
.table-pagination span {
  min-height: 36px;
  border-radius: 10px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-weight: 800;
}
.table-pagination button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.table-pagination button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

@media(max-width:900px){
  .portal-kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .filter-actions { width:100%; }
  .filter-actions .btn, .filter-actions button { width:100%; }
}
@media(max-width:520px){
  .portal-kpi-grid { grid-template-columns: 1fr; }
}

/* Ajuste final do rodapé H4LVION */
.h4-footer img,
.login-h4-footer img {
  width: 38px !important;
  height: 38px !important;
  min-width: 38px !important;
  object-fit: contain !important;
  opacity: 1 !important;
  filter: none !important;
}

.h4-footer,
.login-h4-footer {
  gap: 10px !important;
  font-size: 13px !important;
}

.h4-footer strong,
.login-h4-footer strong {
  font-size: 13px !important;
  font-weight: 800 !important;
  letter-spacing: 0.5px !important;
}
/* =========================================================
   Ajuste financeiro do Portal do Responsável - V8.2.1
   ========================================================= */
.portal-finance-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 18px;
}

.portal-finance-header h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: #0f172a;
}

.portal-finance-header p {
  margin: 0;
  color: #64748b;
  font-size: 15px;
  line-height: 1.5;
}

.portal-finance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0 22px;
}

.portal-finance-card {
  position: relative;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  padding: 20px;
  min-height: 158px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.portal-finance-card::after {
  content: "";
  position: absolute;
  width: 112px;
  height: 112px;
  right: -42px;
  bottom: -48px;
  border-radius: 999px;
  opacity: 0.16;
  background: currentColor;
}

.portal-finance-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.portal-finance-card-top span {
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.portal-finance-icon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  background: rgba(15, 23, 42, 0.06);
  color: currentColor;
  flex: 0 0 auto;
}

.portal-finance-card strong {
  display: block;
  color: #0f172a;
  font-size: clamp(28px, 2.4vw, 36px);
  line-height: 1;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.portal-finance-card p {
  margin: 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.4;
  max-width: 260px;
}

.portal-finance-open {
  color: #f59e0b;
  border-left: 6px solid #f59e0b;
}

.portal-finance-overdue {
  color: #ef4444;
  border-left: 6px solid #ef4444;
}

.portal-finance-monthly {
  color: #2563eb;
  border-left: 6px solid #2563eb;
}

.portal-finance-titles {
  color: #7c3aed;
  border-left: 6px solid #7c3aed;
}

.portal-finance-table-card {
  margin-top: 4px;
}

.portal-finance-table-card .section-head {
  margin-top: 0;
}

.portal-finance-table-card .section-head p {
  margin: 6px 0 0;
}

html.dark-mode .portal-finance-header h1,
.dark-mode .portal-finance-header h1 {
  color: #f8fafc;
}

html.dark-mode .portal-finance-header p,
.dark-mode .portal-finance-header p,
html.dark-mode .portal-finance-card-top span,
.dark-mode .portal-finance-card-top span,
html.dark-mode .portal-finance-card p,
.dark-mode .portal-finance-card p {
  color: #94a3b8;
}

html.dark-mode .portal-finance-card,
.dark-mode .portal-finance-card {
  background: #0f172a;
  border-color: rgba(148, 163, 184, 0.18);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.26);
}

html.dark-mode .portal-finance-card strong,
.dark-mode .portal-finance-card strong {
  color: #f8fafc;
}

html.dark-mode .portal-finance-icon,
.dark-mode .portal-finance-icon {
  background: rgba(148, 163, 184, 0.12);
}

html.dark-mode .portal-finance-open,
.dark-mode .portal-finance-open { color: #fbbf24; }
html.dark-mode .portal-finance-overdue,
.dark-mode .portal-finance-overdue { color: #f87171; }
html.dark-mode .portal-finance-monthly,
.dark-mode .portal-finance-monthly { color: #60a5fa; }
html.dark-mode .portal-finance-titles,
.dark-mode .portal-finance-titles { color: #a78bfa; }

@media (max-width: 1100px) {
  .portal-finance-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .portal-finance-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .portal-finance-grid {
    grid-template-columns: 1fr;
  }

  .portal-finance-card {
    min-height: 138px;
    padding: 18px;
  }

  .portal-finance-card strong {
    font-size: 30px;
  }
}

/* =========================================================
   V8.3 - Refinamento de filtros, tabelas, impressão e paginação
   ========================================================= */
.filters-form,
form.filters,
.card.filters {
  align-items: end !important;
}
.filters-form label,
form.filters label,
.card.filters label {
  align-self: end !important;
}
.filter-actions {
  display: flex;
  gap: 10px;
  align-items: end;
  align-self: end;
  flex-wrap: wrap;
}
.filter-actions .btn,
form.filters .btn,
.card.filters .btn {
  min-height: 43px;
}
.sortable-th {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 24px !important;
}
.sortable-th:after {
  content: '↕';
  position: absolute;
  right: 8px;
  color: #94a3b8;
  font-size: 12px;
}
.sortable-th.sort-asc:after { content: '↑'; color: var(--primary); }
.sortable-th.sort-desc:after { content: '↓'; color: var(--primary); }
.table-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 2px 0;
  color: var(--muted);
  font-size: 13px;
}
.table-pagination button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 10px;
  background: #eef3ff;
  color: var(--primary);
}
.table-pagination button:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.table-pagination span {
  padding: 0 6px;
  font-weight: 700;
}
.badge.Novo,
.badge.novo,
.badge.Novopedido,
.badge.novopedido { background: #e0f2fe; color: #0369a1; }
.badge.Emanálise,
.badge.emanálise,
.badge.emanalise { background: #dbeafe; color: #1d4ed8; }
.badge.Aguardandopagamento,
.badge.aguardandopagamento { background: #ffedd5; color: #c2410c; }
.badge.Separado,
.badge.separado { background: #ede9fe; color: #6d28d9; }
.badge.Entregue,
.badge.entregue,
.badge.Pago,
.badge.pago { background: #dcfce7; color: #15803d; }
.badge.Cancelado,
.badge.cancelado { background: #fee2e2; color: #b91c1c; }
.dark-mode .table-pagination button { background: #172554; color: #bfdbfe; }
.dark-mode .sortable-th:after { color: #64748b; }
.dark-mode .table-tools { color: #94a3b8; }
@media (max-width: 900px) {
  .filters-form,
  form.filters,
  .card.filters {
    grid-template-columns: 1fr !important;
    align-items: stretch !important;
  }
  .filter-actions,
  .table-tools,
  .table-pagination {
    justify-content: stretch;
  }
  .filter-actions .btn,
  .table-tools .btn,
  form.filters .btn,
  .card.filters .btn {
    width: 100%;
  }
}


/* =========================================================
   V8.3.1 - Padronização global das barras de filtros
   ========================================================= */
.card.filters,
.filters {
  display: flex !important;
  align-items: flex-end !important;
  justify-content: flex-start !important;
  gap: 14px !important;
  flex-wrap: wrap !important;
  padding: 18px 20px !important;
}

.filters label,
.filters-form label {
  display: grid !important;
  grid-template-rows: auto auto;
  align-items: start !important;
  gap: 6px !important;
  margin: 0 !important;
  min-width: 180px;
  max-width: 260px;
  color: #344054 !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
}

.filters label:first-child,
.filters-form label:first-child {
  min-width: 240px;
  flex: 1 1 260px;
}

.filters input,
.filters select,
.filters .search-select-button,
.filters-form input,
.filters-form select,
.filters-form .search-select-button {
  height: 44px !important;
  min-height: 44px !important;
  max-height: 44px !important;
  width: 100% !important;
  border-radius: 14px !important;
  padding: 0 14px !important;
  font-size: 14px !important;
  line-height: 44px !important;
}

.filters .search-select,
.filters-form .search-select {
  width: 100% !important;
  min-width: 0 !important;
}

.filters .btn,
.filters button,
.filters-form .btn,
.filters-form button,
.filter-actions .btn,
.filter-actions button {
  height: 44px !important;
  min-height: 44px !important;
  align-self: end !important;
  white-space: nowrap !important;
}

.filter-actions {
  display: flex !important;
  align-items: flex-end !important;
  gap: 10px !important;
  align-self: end !important;
  min-height: 44px !important;
}

.filters-form {
  align-items: end !important;
}

.filters-form .filter-actions {
  grid-column: auto !important;
}

.dark-mode .filters label,
.dark-mode .filters-form label {
  color: #cbd5e1 !important;
}

@media (max-width: 900px) {
  .card.filters,
  .filters,
  .filters-form {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    padding: 16px !important;
  }

  .filters label,
  .filters-form label,
  .filters label:first-child,
  .filters-form label:first-child {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .filter-actions,
  .filters .btn,
  .filters button,
  .filters-form .btn,
  .filters-form button {
    width: 100% !important;
  }

  .filter-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }
}


/* =========================================================
   V8.4 - Refinamento visual premium, ícones e tema do portal
   ========================================================= */
:root {
  --primary: #2563eb;
  --primary2: #1d4ed8;
  --panel-soft: #f8fbff;
  --ring: rgba(37, 99, 235, .14);
}
.sidebar { background: linear-gradient(180deg, #061225 0%, #08172d 100%) !important; border-right: 1px solid rgba(148,163,184,.12); }
.sidebar nav a { min-height: 44px; transition: background .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease; }
.sidebar nav a:hover { background: rgba(59,130,246,.13) !important; transform: translateX(2px); }
.nav-icon { display: inline-flex !important; align-items: center; justify-content: center; width: 24px; min-width: 24px; height: 24px; font-size: 17px !important; }
.nav-icon i { font-size: 17px; line-height: 1; color: currentColor; }
body.sidebar-collapsed .nav-icon i { font-size: 19px; }
.sidebar nav a.active { background: linear-gradient(135deg, rgba(37,99,235,.36), rgba(14,165,233,.18)) !important; border-left-color: #60a5fa !important; box-shadow: inset 0 0 0 1px rgba(96,165,250,.24), 0 10px 30px rgba(37,99,235,.12); }
.btn, button { border-radius: 14px; transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease; }
.btn:hover, button:hover { transform: translateY(-1px); }
.btn.primary, button.primary { background: linear-gradient(135deg, #2563eb, #1d4ed8) !important; box-shadow: 0 10px 22px rgba(37,99,235,.22), 0 0 0 1px rgba(255,255,255,.08) inset; }
.btn.primary:hover, button.primary:hover { box-shadow: 0 14px 28px rgba(37,99,235,.30), 0 0 0 4px rgba(37,99,235,.10); }
.btn.ghost { background: #eef4ff !important; color: #1d4ed8 !important; border: 1px solid rgba(37,99,235,.08); }
.btn.ghost:hover { background: #dbeafe !important; box-shadow: 0 8px 20px rgba(37,99,235,.10); }
.card, .login-card, .modal-box, .report-item { border-color: rgba(148,163,184,.24); box-shadow: 0 18px 45px rgba(15,23,42,.07); }
.form input:focus, .form select:focus, .form textarea:focus, .filters input:focus, .filters select:focus { outline: none; border-color: rgba(37,99,235,.55) !important; box-shadow: 0 0 0 4px var(--ring); }
.badge { font-weight: 800; letter-spacing: .01em; }
.theme-toggle i { font-size: 17px; }
.h4-footer { color: #64748b; }
.h4-footer img, .login-h4-footer img { width: 38px !important; height: 38px !important; min-width: 38px !important; object-fit: contain !important; opacity: 1 !important; filter: none !important; }
.h4-footer strong, .login-h4-footer strong { font-weight: 900 !important; letter-spacing: .5px; }
.dark-mode .h4-footer, html.dark-mode .h4-footer { color: #e2e8f0 !important; }
.dark-mode .h4-footer strong, html.dark-mode .h4-footer strong { color: #ffffff !important; }
.dark-mode .h4-footer img, html.dark-mode .h4-footer img, html.dark-mode .login-h4-footer img { filter: invert(1) brightness(1.8) contrast(1.08) !important; }
html.dark-mode .login-h4-footer, .dark-mode .login-h4-footer { color: rgba(255,255,255,.88) !important; }
html.dark-mode .login-h4-footer strong, .dark-mode .login-h4-footer strong { color: #ffffff !important; }
/* Login passa a respeitar tema salvo, sem perder o padrão aprovado */
body.login-theme-aware { background: linear-gradient(135deg, #07162f 0%, #0f2f67 45%, #08111f 100%) !important; color: #0f172a; }
body.login-theme-aware .login-shell { background: transparent !important; }
html.dark-mode body.login-theme-aware { background: radial-gradient(circle at 20% 20%, rgba(96,165,250,.20), transparent 32%), linear-gradient(135deg, #020617, #0f172a) !important; color: #e5edf8 !important; }
html.dark-mode body.login-theme-aware .login-card { background: #0f172a !important; color: #f8fafc !important; border: 1px solid rgba(148,163,184,.20) !important; }
html.dark-mode body.login-theme-aware .login-card h1, html.dark-mode body.login-theme-aware .login-card label { color: #f8fafc !important; }
html.dark-mode body.login-theme-aware .login-card input { background: #111827 !important; color: #f8fafc !important; border-color: rgba(148,163,184,.30) !important; }
html.dark-mode body.login-theme-aware .login-logo { filter: brightness(1.12) contrast(1.05); }
/* Dashboard avançado */
.premium-dashboard-filter .filter-row { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; width: 100%; }
.premium-dashboard-filter label { display: grid; gap: 6px; min-width: 180px; font-weight: 700; color: #344054; }
.premium-dashboard-filter .filter-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
/* Portal do responsável com tema escuro */
.portal-topbar { gap: 12px; }
.portal-top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.portal-theme-toggle { flex: 0 0 auto; }
.portal-nav a { display: inline-flex; align-items: center; gap: 6px; transition: transform .15s ease, background .15s ease, box-shadow .15s ease; }
.portal-nav a:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(37,99,235,.12); }
html.dark-mode .portal-body { background: #071225 !important; color: #e5edf8 !important; }
html.dark-mode .portal-topbar { background: rgba(15,23,42,.94) !important; border-color: rgba(148,163,184,.16) !important; }
html.dark-mode .portal-brand strong { color: #ffffff !important; }
html.dark-mode .portal-brand span { color: #94a3b8 !important; }
html.dark-mode .portal-nav a { background: rgba(37,99,235,.18) !important; color: #bfdbfe !important; }
html.dark-mode .portal-nav a:hover { background: rgba(37,99,235,.28) !important; }
html.dark-mode .portal-content .card, html.dark-mode .portal-content .mini-card, html.dark-mode .portal-content .calendar-card, html.dark-mode .portal-content .choice-card { background: #0f172a !important; color: #e5edf8 !important; border-color: rgba(148,163,184,.18) !important; }
html.dark-mode .portal-content .table { background: #0f172a !important; }
html.dark-mode .portal-content .table th { background: #111827 !important; color: #cbd5e1 !important; }
html.dark-mode .portal-content .table td { border-color: rgba(148,163,184,.16) !important; }
html.dark-mode .portal-content input, html.dark-mode .portal-content select, html.dark-mode .portal-content textarea { background: #111827 !important; color: #f8fafc !important; border-color: rgba(148,163,184,.28) !important; }
html.dark-mode .portal-hero { background: linear-gradient(135deg,#0f172a,#1d4ed8) !important; }
@media (max-width: 900px) { .premium-dashboard-filter .filter-row, .premium-dashboard-filter .filter-actions { width: 100%; } .premium-dashboard-filter label, .premium-dashboard-filter .btn { width: 100%; } .portal-top-actions { margin-left: 0; } }


/* =========================================================
   Login sempre em tema claro - correção final
   ========================================================= */
html.dark-mode body.login-light-only,
body.login-light-only,
body.login-light-only.dark-mode {
  background: linear-gradient(135deg, #07162f 0%, #0f2f67 45%, #08111f 100%) !important;
  color: #0f172a !important;
}

html.dark-mode body.login-light-only .login-shell,
body.login-light-only .login-shell {
  background: transparent !important;
}

html.dark-mode body.login-light-only .login-card,
body.login-light-only .login-card {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: rgba(15, 23, 42, 0.08) !important;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28) !important;
}

html.dark-mode body.login-light-only .login-card h1,
html.dark-mode body.login-light-only .login-card label,
html.dark-mode body.login-light-only .login-card strong,
body.login-light-only .login-card h1,
body.login-light-only .login-card label,
body.login-light-only .login-card strong {
  color: #0f172a !important;
}

html.dark-mode body.login-light-only .login-card .muted,
html.dark-mode body.login-light-only .login-card span,
body.login-light-only .login-card .muted,
body.login-light-only .login-card span {
  color: #64748b !important;
}

html.dark-mode body.login-light-only .login-card input,
body.login-light-only .login-card input {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #dbe3ef !important;
}

html.dark-mode body.login-light-only .login-card input:focus,
body.login-light-only .login-card input:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
}

html.dark-mode body.login-light-only .login-card .btn.primary,
body.login-light-only .login-card .btn.primary {
  background: #2563eb !important;
  color: #ffffff !important;
}

/* Rodapé H4LVION no login sempre em branco sobre fundo azul */
html.dark-mode body.login-light-only .login-h4-footer,
body.login-light-only .login-h4-footer {
  color: rgba(255, 255, 255, 0.84) !important;
}

html.dark-mode body.login-light-only .login-h4-footer strong,
body.login-light-only .login-h4-footer strong {
  color: #ffffff !important;
}

html.dark-mode body.login-light-only .login-h4-footer img,
body.login-light-only .login-h4-footer img {
  filter: brightness(0) invert(1) !important;
  opacity: 1 !important;
}

/* =========================================================
   V8.6 - Relatórios com filtros individuais por módulo
   ========================================================= */
.reports-page-head { margin-bottom: 18px; }
.reports-group { margin-bottom: 18px; }
.reports-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.report-card-pro {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 13px;
  align-items: start;
  padding: 18px;
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,250,252,.92));
  box-shadow: 0 14px 34px rgba(15, 23, 42, .06);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.report-card-pro:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, .24);
  box-shadow: 0 20px 44px rgba(15, 23, 42, .10);
}
.report-card-icon {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(37, 99, 235, .10);
  color: #1d4ed8;
  font-size: 22px;
}
.report-card-body h3 {
  margin: 0 0 5px;
  font-size: 16px;
}
.report-card-body p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.report-card-pro .btn {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 6px;
}
.report-filter-modal {
  width: min(1080px, 96vw) !important;
  max-height: 92vh !important;
  overflow-y: auto !important;
  padding: 24px !important;
  border-radius: 22px !important;
  background: #fff !important;
  color: #0f172a !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 30px 90px rgba(15,23,42,.34) !important;
}
.report-filter-modal .modal-head h2 { margin: 0; }
.report-filter-modal .modal-close {
  border: none !important;
  background: #f1f5f9 !important;
  color: #0f172a !important;
  width: 40px !important;
  height: 40px !important;
  border-radius: 12px !important;
  font-size: 24px !important;
  font-weight: 700 !important;
  cursor: pointer;
}
.report-filter-form { align-items: end !important; }
.report-filter-form label {
  display: flex !important;
  flex-direction: column !important;
  gap: 7px !important;
  align-self: end !important;
}
.report-filter-form input,
.report-filter-form select,
.report-filter-form textarea {
  min-height: 44px !important;
  width: 100% !important;
  max-width: 100% !important;
  border-radius: 14px !important;
}
.report-modal-actions {
  justify-content: flex-end;
  padding-top: 6px;
}
html.dark-mode .report-card-pro {
  background: linear-gradient(180deg, rgba(17,24,39,.96), rgba(15,23,42,.92));
  border-color: rgba(148,163,184,.18);
  box-shadow: 0 18px 45px rgba(0,0,0,.25);
}
html.dark-mode .report-card-icon {
  background: rgba(96,165,250,.16);
  color: #bfdbfe;
}
html.dark-mode .report-filter-modal {
  background: #0f172a !important;
  color: #f8fafc !important;
  border-color: rgba(148,163,184,.18) !important;
}
html.dark-mode .report-filter-modal .modal-close {
  background: rgba(148,163,184,.14) !important;
  color: #f8fafc !important;
}
html.dark-mode .report-filter-modal input,
html.dark-mode .report-filter-modal select,
html.dark-mode .report-filter-modal textarea {
  background: #111827 !important;
  color: #f8fafc !important;
  border-color: rgba(148,163,184,.28) !important;
}
@media (max-width: 900px) {
  .reports-card-grid { grid-template-columns: 1fr; }
  .report-filter-modal { width: 96vw !important; padding: 18px !important; }
  .report-filter-form { grid-template-columns: 1fr !important; }
  .report-modal-actions { justify-content: stretch; }
  .report-modal-actions .btn { width: 100%; }
}

/* V9 - correção definitiva dos dropdowns pesquisáveis: remove espaço branco antes da primeira opção */
.search-select.open .search-select-input {
  display: block !important;
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  top: 0 !important;
  width: 100% !important;
  min-height: 43px !important;
  border-radius: 13px !important;
  z-index: 70 !important;
}
.search-select .search-select-list {
  padding: 6px !important;
  top: calc(100% + 6px) !important;
  max-height: 260px !important;
  overflow-y: auto !important;
  z-index: 69 !important;
}
.search-select-option:first-child { margin-top: 0 !important; }
html.dark-mode .master-view-banner,
.master-view-banner {
  margin: 0 0 18px;
  padding: 12px 16px;
  border-radius: 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
html.dark-mode .master-view-banner {
  background: rgba(37, 99, 235, .16);
  border-color: rgba(96, 165, 250, .28);
  color: #dbeafe;
}
.master-stat-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.tenant-code-card .login-logo { max-width: 280px; }
@media (max-width: 760px){ .master-view-banner{ flex-direction: column; align-items:flex-start; } }


/* V9.1 - Dashboards profissionais e responsivos */
.dashboard-grid, .master-dashboard-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; align-items:stretch; }
.dashboard-grid .chart-wide, .master-dashboard-grid .chart-wide { grid-column:1 / -1; }
.chart-card { min-height:360px; }
.chart-box { position:relative; width:100%; height:320px; min-height:260px; }
.chart-box-wide { height:380px; }
.chart-card canvas, .chart-box canvas { width:100% !important; height:100% !important; display:block; }
.dashboard-kpi-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.usage-ranking { display:grid; gap:10px; }
.usage-row { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:12px 14px; border:1px solid rgba(148,163,184,.22); border-radius:16px; background:rgba(248,250,252,.7); }
.usage-row small { display:block; color:#64748b; margin-top:3px; }
.master-table-card .table { min-width:1280px; }
.master-view-banner { display:flex; flex-wrap:wrap; align-items:center; gap:10px; padding:12px 16px; margin-bottom:16px; border-radius:16px; background:rgba(37,99,235,.09); border:1px solid rgba(37,99,235,.18); color:#0f172a; }
.master-view-banner a { margin-left:auto; font-weight:800; color:#2563eb; text-decoration:none; }
.search-select-list { padding-top:0 !important; margin-top:6px !important; }
.search-select-option:first-child { margin-top:0 !important; }
.search-select-input { margin:8px !important; width:calc(100% - 16px) !important; }
html.dark-mode .usage-row { background:rgba(15,23,42,.66); border-color:rgba(148,163,184,.18); }
html.dark-mode .usage-row small { color:#94a3b8; }
html.dark-mode .master-view-banner { background:rgba(96,165,250,.12); border-color:rgba(96,165,250,.24); color:#e5e7eb; }
html.dark-mode .master-view-banner a { color:#93c5fd; }
@media (max-width: 980px){ .dashboard-grid, .master-dashboard-grid { grid-template-columns:1fr; } .chart-box,.chart-box-wide{height:300px;} .chart-card{min-height:330px;} }
@media (max-width: 640px){ .chart-box,.chart-box-wide{height:260px;} .usage-row{align-items:flex-start; flex-direction:column;} .master-view-banner a{margin-left:0;} }


/* V9.2 - Gráficos profissionais, fluidos e responsivos */
.apex-dashboard-grid,
.dashboard-grid,
.master-dashboard-grid,
.dashboard-finance-grid {
  min-width: 0;
}
.premium-chart-card {
  overflow: hidden;
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, .20);
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,250,252,.88));
}
.eg-chart {
  width: 100%;
  min-width: 0;
  height: clamp(280px, 32vw, 360px);
  min-height: 260px;
}
.eg-chart-wide {
  height: clamp(320px, 36vw, 420px);
}
.apexcharts-canvas,
.apexcharts-svg {
  max-width: 100% !important;
}
.apexcharts-tooltip {
  border-radius: 14px !important;
  box-shadow: 0 18px 45px rgba(15,23,42,.20) !important;
  overflow: hidden;
}
.apexcharts-legend {
  gap: 8px !important;
}
.apexcharts-xaxis-label,
.apexcharts-yaxis-label {
  font-weight: 700;
}
.usage-row-clickable { margin: 0; }
.usage-row-clickable button {
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font: inherit;
}
.usage-row-clickable:hover {
  border-color: rgba(37,99,235,.35);
  box-shadow: 0 18px 45px rgba(37,99,235,.10);
  transform: translateY(-1px);
}
html.dark-mode .premium-chart-card {
  background: linear-gradient(180deg, rgba(15,23,42,.95), rgba(15,23,42,.82));
  border-color: rgba(148,163,184,.18);
}
html.dark-mode .apexcharts-tooltip {
  box-shadow: 0 18px 45px rgba(0,0,0,.38) !important;
}
@media (max-width: 980px) {
  .eg-chart, .eg-chart-wide { height: 300px; min-height: 280px; }
}
@media (max-width: 640px) {
  .eg-chart, .eg-chart-wide { height: 270px; min-height: 250px; }
  .usage-row-clickable button { align-items: flex-start; flex-direction: column; }
}

/* =========================================================
   V9.3 - Correção definitiva de dashboards e gráficos
   ========================================================= */
.stat-grid,
.master-stat-grid,
.dashboard-kpi-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)) !important;
  gap: 16px !important;
  align-items: stretch !important;
  width: 100% !important;
  min-width: 0 !important;
}
.master-stat-grid .stat-card,
.dashboard-kpi-grid .stat-card {
  min-height: 118px !important;
  padding: 18px 18px !important;
  border-radius: 20px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  overflow: hidden !important;
}
.master-stat-grid .stat-card span,
.dashboard-kpi-grid .stat-card span {
  font-size: 12px !important;
  line-height: 1.2 !important;
}
.master-stat-grid .stat-card strong,
.dashboard-kpi-grid .stat-card strong {
  font-size: clamp(22px, 2.2vw, 30px) !important;
  line-height: 1.05 !important;
  margin-top: 8px !important;
}
.master-stat-grid .stat-card small,
.dashboard-kpi-grid .stat-card small {
  font-size: 12px !important;
  line-height: 1.25 !important;
  margin-top: 8px !important;
}
.master-stat-grid .metric:after,
.dashboard-kpi-grid .metric:after {
  width: 90px !important;
  height: 90px !important;
  right: -42px !important;
  top: -42px !important;
}

.dashboard-grid,
.master-dashboard-grid,
.apex-dashboard-grid,
.dashboard-finance-grid {
  display: grid !important;
  gap: 20px !important;
  width: 100% !important;
  min-width: 0 !important;
  overflow: visible !important;
}
.dashboard-grid,
.master-dashboard-grid,
.apex-dashboard-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}
.dashboard-finance-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}
.chart-wide,
.dashboard-grid .chart-wide,
.master-dashboard-grid .chart-wide,
.dashboard-finance-grid .chart-wide {
  grid-column: 1 / -1 !important;
}
.premium-chart-card,
.chart-card {
  position: relative !important;
  min-width: 0 !important;
  overflow: hidden !important;
  padding: 22px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
}
.premium-chart-card .section-head,
.chart-card .section-head {
  flex: 0 0 auto !important;
  margin-bottom: 10px !important;
}
.eg-chart,
.eg-chart-wide {
  position: relative !important;
  width: 100% !important;
  min-width: 0 !important;
  overflow: hidden !important;
  flex: 1 1 auto !important;
  display: block !important;
}
.eg-chart {
  height: 320px !important;
  min-height: 320px !important;
  max-height: 320px !important;
}
.eg-chart-wide {
  height: 370px !important;
  min-height: 370px !important;
  max-height: 370px !important;
}
.eg-chart .apexcharts-canvas,
.eg-chart .apexcharts-svg,
.eg-chart-wide .apexcharts-canvas,
.eg-chart-wide .apexcharts-svg {
  max-width: 100% !important;
  width: 100% !important;
  overflow: hidden !important;
}
.apexcharts-canvas {
  margin: 0 auto !important;
}
.apexcharts-toolbar {
  display: none !important;
}
.apexcharts-legend {
  overflow: hidden !important;
}
.apexcharts-tooltip {
  z-index: 30 !important;
}
.master-table-card {
  margin-top: 20px !important;
}
.usage-card {
  overflow: hidden !important;
}

@media (max-width: 1100px) {
  .dashboard-grid,
  .master-dashboard-grid,
  .apex-dashboard-grid,
  .dashboard-finance-grid {
    grid-template-columns: 1fr !important;
  }
  .eg-chart,
  .eg-chart-wide {
    height: 310px !important;
    min-height: 310px !important;
    max-height: 310px !important;
  }
}
@media (max-width: 680px) {
  .stat-grid,
  .master-stat-grid,
  .dashboard-kpi-grid {
    grid-template-columns: 1fr !important;
  }
  .premium-chart-card,
  .chart-card {
    padding: 16px !important;
  }
  .eg-chart,
  .eg-chart-wide {
    height: 280px !important;
    min-height: 280px !important;
    max-height: 280px !important;
  }
  .premium-chart-card .section-head,
  .chart-card .section-head {
    align-items: flex-start !important;
    flex-direction: column !important;
    gap: 8px !important;
  }
}


/* V9.4 - Ajustes finais dos gráficos: tooltips reais e legendas sem corte */
.chart-category {
  min-height: 430px !important;
}
.chart-category .eg-chart {
  height: 365px !important;
  min-height: 365px !important;
  max-height: 365px !important;
  overflow: visible !important;
}
.chart-category .apexcharts-canvas,
.chart-category .apexcharts-svg {
  overflow: visible !important;
}
.chart-category .apexcharts-legend {
  overflow: visible !important;
  max-height: none !important;
  padding-left: 8px !important;
}
.chart-category .apexcharts-legend-series {
  align-items: center !important;
  white-space: normal !important;
  line-height: 1.25 !important;
  margin: 4px 8px !important;
}
.chart-category .apexcharts-legend-text {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  max-width: 170px !important;
}
.apexcharts-tooltip {
  font-size: 12px !important;
  border-radius: 12px !important;
  box-shadow: 0 16px 40px rgba(15,23,42,.18) !important;
}
.apexcharts-tooltip-title {
  font-weight: 800 !important;
}
@media (max-width: 900px) {
  .chart-category {
    min-height: 470px !important;
  }
  .chart-category .eg-chart {
    height: 400px !important;
    min-height: 400px !important;
    max-height: 400px !important;
  }
  .chart-category .apexcharts-legend-text {
    max-width: 240px !important;
  }
}

/* =========================================================
   V9.5 - Motor definitivo de gráficos Chart.js
   ========================================================= */
.chartjs-dashboard-grid .premium-chart-card,
.chartjs-dashboard-grid .chart-card,
.dashboard-finance-grid .premium-chart-card,
.master-dashboard-grid .premium-chart-card {
  overflow: hidden !important;
}
.eg-canvas-box {
  position: relative !important;
  width: 100% !important;
  height: 330px !important;
  min-height: 330px !important;
  max-height: 330px !important;
  min-width: 0 !important;
  overflow: hidden !important;
}
.eg-canvas-wide {
  height: 390px !important;
  min-height: 390px !important;
  max-height: 390px !important;
}
.eg-doughnut-box {
  height: 340px !important;
  min-height: 340px !important;
  max-height: 340px !important;
}
.eg-canvas-box canvas {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
}
.doughnut-chart-layout {
  display: grid !important;
  grid-template-columns: minmax(230px, 1fr) minmax(180px, 220px) !important;
  gap: 16px !important;
  align-items: center !important;
  min-width: 0 !important;
  width: 100% !important;
}
.eg-chart-legend {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  min-width: 0 !important;
  max-height: 330px !important;
  overflow-y: auto !important;
  padding-right: 4px !important;
}
.eg-legend-item {
  width: 100% !important;
  border: 1px solid rgba(148,163,184,.18) !important;
  background: rgba(248,250,252,.76) !important;
  color: #0f172a !important;
  border-radius: 14px !important;
  padding: 9px 10px !important;
  display: grid !important;
  grid-template-columns: 11px 1fr !important;
  grid-template-areas: "dot name" "dot value" !important;
  gap: 1px 8px !important;
  align-items: center !important;
  text-align: left !important;
  cursor: pointer !important;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease !important;
}
.eg-legend-item:hover {
  transform: translateY(-1px) !important;
  border-color: rgba(37,99,235,.32) !important;
  box-shadow: 0 12px 28px rgba(37,99,235,.10) !important;
}
.eg-legend-item span {
  grid-area: dot !important;
  width: 10px !important;
  height: 10px !important;
  border-radius: 999px !important;
}
.eg-legend-item b {
  grid-area: name !important;
  font-size: 12px !important;
  line-height: 1.2 !important;
  white-space: normal !important;
  word-break: break-word !important;
}
.eg-legend-item small {
  grid-area: value !important;
  color: #64748b !important;
  font-size: 11px !important;
  font-weight: 800 !important;
}
html.dark-mode .eg-legend-item {
  background: rgba(15,23,42,.72) !important;
  border-color: rgba(148,163,184,.18) !important;
  color: #e5e7eb !important;
}
html.dark-mode .eg-legend-item small {
  color: #94a3b8 !important;
}
@media (max-width: 1100px) {
  .doughnut-chart-layout {
    grid-template-columns: 1fr !important;
  }
  .eg-chart-legend {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    max-height: none !important;
    overflow: visible !important;
  }
}
@media (max-width: 680px) {
  .eg-canvas-box,
  .eg-canvas-wide,
  .eg-doughnut-box {
    height: 290px !important;
    min-height: 290px !important;
    max-height: 290px !important;
  }
  .eg-chart-legend {
    grid-template-columns: 1fr !important;
  }
}

/* =========================================================
   V9.6 - Gráficos definitivos sem canvas externo
   SVG/HTML nativo: estável, responsivo, sem duplicidade/corte
   ========================================================= */
.stable-dashboard-grid .chart-card,
.stable-dashboard-grid .premium-chart-card,
.dashboard-finance-grid .chart-card,
.dashboard-finance-grid .premium-chart-card,
.chart-card.premium-chart-card {
  overflow: hidden !important;
}
.eg-svg-chart {
  width: 100% !important;
  min-height: 360px !important;
  height: 360px !important;
  position: relative !important;
  overflow: hidden !important;
  border-radius: 18px !important;
}
.eg-svg-chart-wide {
  min-height: 390px !important;
  height: 390px !important;
}
.eg-svg-chart svg {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  overflow: visible !important;
}
.eg-grid-line {
  stroke: rgba(148,163,184,.22);
  stroke-width: 1;
  stroke-dasharray: 5 5;
}
.eg-zero-line {
  stroke: rgba(100,116,139,.28);
  stroke-width: 1.25;
}
.eg-axis-text {
  fill: #334155;
  font-size: 12px;
  font-weight: 700;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.eg-x-label {
  font-size: 13px;
  font-weight: 800;
}
.eg-legend-text {
  font-size: 12px;
  font-weight: 800;
}
.eg-chart-click-bar {
  cursor: pointer;
  opacity: .9;
  transition: opacity .18s ease, filter .18s ease;
}
.eg-chart-click-bar:hover {
  opacity: 1;
  filter: brightness(1.05) drop-shadow(0 6px 12px rgba(15,23,42,.18));
}
.eg-chart-empty {
  min-height: 300px;
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #64748b;
  text-align: center;
  border: 1px dashed rgba(148,163,184,.35);
  border-radius: 18px;
  background: rgba(248,250,252,.66);
}
.eg-chart-empty i {
  font-size: 24px;
  color: #2563eb;
}
.eg-category-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 330px;
  width: 100%;
}
.eg-category-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(37,99,235,.06);
  border: 1px solid rgba(37,99,235,.10);
}
.eg-category-total span {
  color: #64748b;
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.eg-category-total strong {
  color: #0f172a;
  font-size: 20px;
  font-weight: 900;
}
.eg-hbar-item {
  border: 1px solid rgba(148,163,184,.20);
  background: rgba(255,255,255,.78);
  border-radius: 16px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  cursor: pointer;
  text-align: left;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.eg-hbar-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(15,23,42,.10);
  border-color: rgba(37,99,235,.30);
}
.eg-hbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}
.eg-hbar-top b {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: #0f172a;
  font-size: 13px;
  line-height: 1.25;
  white-space: normal;
  word-break: break-word;
}
.eg-hbar-top b i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}
.eg-hbar-top strong {
  color: #1e293b;
  font-weight: 900;
  white-space: nowrap;
  font-size: 13px;
}
.eg-hbar-track {
  height: 10px;
  width: 100%;
  display: block;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148,163,184,.16);
}
.eg-hbar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  min-width: 3px;
}
.eg-hbar-item small {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}
html.dark-mode .eg-axis-text { fill: #dbeafe; }
html.dark-mode .eg-grid-line { stroke: rgba(148,163,184,.16); }
html.dark-mode .eg-zero-line { stroke: rgba(226,232,240,.26); }
html.dark-mode .eg-chart-empty {
  color: #94a3b8;
  background: rgba(15,23,42,.58);
  border-color: rgba(148,163,184,.22);
}
html.dark-mode .eg-category-total {
  background: rgba(37,99,235,.13);
  border-color: rgba(96,165,250,.18);
}
html.dark-mode .eg-category-total strong,
html.dark-mode .eg-hbar-top b,
html.dark-mode .eg-hbar-top strong { color: #e5e7eb; }
html.dark-mode .eg-hbar-item {
  background: rgba(15,23,42,.70);
  border-color: rgba(148,163,184,.18);
}
html.dark-mode .eg-hbar-track { background: rgba(148,163,184,.20); }
html.dark-mode .eg-hbar-item small { color: #94a3b8; }
@media (max-width: 760px) {
  .eg-svg-chart,
  .eg-svg-chart-wide {
    height: 320px !important;
    min-height: 320px !important;
  }
  .eg-category-bars {
    min-height: auto;
  }
  .eg-hbar-top {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

/* Sidebar polish: professional desktop collapse control */
@media (min-width: 901px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px 14px 16px !important;
    overflow: hidden !important;
  }

  .sidebar .brand {
    flex: 0 0 auto;
    min-height: 54px;
    margin: 0 4px 2px !important;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(148, 163, 184, .13);
  }

  .sidebar nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 4px 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, .36) transparent;
  }

  .sidebar nav::-webkit-scrollbar {
    width: 7px;
  }

  .sidebar nav::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, .30);
    border-radius: 999px;
  }

  .sidebar nav a {
    border: 1px solid transparent;
    border-radius: 10px !important;
    line-height: 1.2;
  }

  .sidebar-toggle {
    position: static !important;
    display: grid !important;
    grid-template-columns: 34px minmax(0, 1fr) 24px;
    align-items: center;
    gap: 9px;
    flex: 0 0 auto;
    width: 100% !important;
    height: 46px !important;
    margin: 0 !important;
    padding: 5px 8px !important;
    color: #dbeafe;
    border: 1px solid rgba(148, 163, 184, .18) !important;
    border-radius: 10px !important;
    background: linear-gradient(135deg, rgba(30, 91, 255, .20), rgba(14, 165, 233, .10)) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 12px 28px rgba(2, 6, 23, .18);
    cursor: pointer;
    transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
  }

  .sidebar-toggle:hover {
    transform: translateY(-1px);
    border-color: rgba(96, 165, 250, .42) !important;
    background: linear-gradient(135deg, rgba(37, 99, 235, .30), rgba(14, 165, 233, .16)) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .10), 0 16px 34px rgba(2, 6, 23, .24);
  }

  .sidebar-toggle:focus-visible {
    outline: 3px solid rgba(96, 165, 250, .34);
    outline-offset: 2px;
  }

  .sidebar-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: #eff6ff;
    background: rgba(255, 255, 255, .09);
  }

  .sidebar-toggle-icon i,
  .sidebar-toggle-arrow i {
    font-size: 16px;
    line-height: 1;
  }

  .sidebar-toggle-text {
    min-width: 0;
    color: #eff6ff;
    font-size: 13px;
    font-weight: 800;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar-toggle-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #bfdbfe;
    transition: transform .18s ease;
  }

  body.sidebar-collapsed .sidebar {
    width: 82px !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    overflow: hidden !important;
  }

  body.sidebar-collapsed .sidebar .brand {
    justify-content: center !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  body.sidebar-collapsed .sidebar nav {
    overflow-y: auto;
    overflow-x: hidden;
    padding-left: 0;
    padding-right: 0;
  }

  body.sidebar-collapsed .sidebar nav a {
    width: 46px;
    min-height: 44px;
    margin: 0 auto;
    padding: 10px !important;
  }

  body.sidebar-collapsed .topbar {
    left: 82px !important;
  }

  body.sidebar-collapsed .content {
    margin-left: 82px !important;
  }

  body.sidebar-collapsed .sidebar-toggle {
    grid-template-columns: 1fr;
    justify-items: center;
    width: 46px !important;
    align-self: center;
    padding: 6px !important;
  }

  body.sidebar-collapsed .sidebar-toggle-text {
    display: none;
  }

  body.sidebar-collapsed .sidebar-toggle-arrow {
    display: none;
  }

}

@media (max-width: 900px) {
  .sidebar-toggle {
    display: none !important;
  }
}

/* =========================================================
   Visual cycle 1: premium operational shell
   Global polish only: no workflow or business-rule changes.
   ========================================================= */
:root {
  --eg-bg: #f4f7fb;
  --eg-surface: #ffffff;
  --eg-surface-soft: #f8fafc;
  --eg-text: #111827;
  --eg-muted: #64748b;
  --eg-line: #dbe3ef;
  --eg-line-strong: #c8d3e1;
  --eg-primary: #2563eb;
  --eg-primary-strong: #1d4ed8;
  --eg-info: #0891b2;
  --eg-success: #059669;
  --eg-warning: #b45309;
  --eg-danger: #dc2626;
  --eg-shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --eg-shadow-md: 0 10px 28px rgba(15, 23, 42, .08);
  --eg-shadow-lg: 0 20px 54px rgba(15, 23, 42, .12);
  --eg-radius: 8px;
  --eg-focus: 0 0 0 3px rgba(37, 99, 235, .16);
}

html:not(.dark-mode) body:not(.login-light-only) {
  background:
    linear-gradient(180deg, rgba(238, 242, 247, .95) 0, rgba(244, 247, 251, 1) 320px),
    var(--eg-bg) !important;
  color: var(--eg-text);
}

html:not(.dark-mode) .topbar {
  height: 72px;
  background: rgba(255, 255, 255, .92) !important;
  border-bottom: 1px solid rgba(203, 213, 225, .72) !important;
  box-shadow: 0 8px 28px rgba(15, 23, 42, .05);
}

.topbar strong {
  color: #0f172a;
  font-size: 18px !important;
  font-weight: 850;
  letter-spacing: 0;
}

.topbar small {
  color: #64748b !important;
  font-size: 12px !important;
}

.top-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.user-name,
.theme-toggle,
.mobile-menu {
  border-radius: var(--eg-radius) !important;
  border: 1px solid rgba(203, 213, 225, .84) !important;
  background: #ffffff !important;
  color: #1e293b !important;
  box-shadow: var(--eg-shadow-sm) !important;
}

.user-name:hover,
.theme-toggle:hover,
.mobile-menu:hover {
  border-color: rgba(37, 99, 235, .32) !important;
  box-shadow: 0 8px 18px rgba(15, 23, 42, .08) !important;
}

.user-dropdown {
  border: 1px solid rgba(203, 213, 225, .88);
  border-radius: var(--eg-radius) !important;
  box-shadow: var(--eg-shadow-lg) !important;
}

.content {
  padding-top: 94px !important;
}

.sidebar {
  background: linear-gradient(180deg, #08111f 0%, #0b1728 55%, #0d1b2e 100%) !important;
  border-right: 1px solid rgba(148, 163, 184, .16) !important;
}

.brand-mark,
.brand-logo-img {
  border-radius: var(--eg-radius) !important;
}

.brand strong {
  font-size: 16px !important;
  font-weight: 850;
  letter-spacing: 0;
}

.brand span {
  color: #9aa8bd !important;
}

.sidebar nav {
  gap: 4px !important;
}

.sidebar nav a {
  min-height: 42px !important;
  border-radius: var(--eg-radius) !important;
  color: #d8e4f7 !important;
  font-size: 13px !important;
  font-weight: 750;
}

.sidebar nav a:hover {
  background: rgba(148, 163, 184, .12) !important;
  color: #ffffff !important;
  transform: translateX(1px);
}

.sidebar nav a.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, .28), rgba(8, 145, 178, .16)) !important;
  color: #ffffff !important;
  border-left-color: #38bdf8 !important;
  box-shadow: inset 0 0 0 1px rgba(125, 211, 252, .18) !important;
}

.nav-icon {
  color: #b9c8dd;
}

.sidebar nav a.active .nav-icon,
.sidebar nav a:hover .nav-icon {
  color: #e0f2fe !important;
}

.sidebar-toggle {
  border-radius: var(--eg-radius) !important;
}

.card,
.modal-box,
.modal-card,
.login-card,
.mini-card,
.report-item,
.choice-card,
.calendar-card {
  border-radius: var(--eg-radius) !important;
  border: 1px solid rgba(203, 213, 225, .78) !important;
  background: rgba(255, 255, 255, .96) !important;
  box-shadow: var(--eg-shadow-sm) !important;
}

.card:hover {
  border-color: rgba(148, 163, 184, .82) !important;
}

.action-head,
.section-head {
  gap: 14px;
}

.action-head h1,
.section-head h1,
.section-head h2,
.card h1,
.card h2 {
  color: #0f172a;
  font-weight: 850;
  letter-spacing: 0;
}

.muted,
.card small,
.table small {
  color: #64748b;
}

.btn,
button {
  border-radius: var(--eg-radius) !important;
  min-height: 38px;
  font-weight: 800;
  letter-spacing: 0;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease, border-color .14s ease, color .14s ease;
}

.btn:hover,
button:hover {
  transform: translateY(-1px);
}

.btn.primary,
button.primary {
  background: linear-gradient(135deg, var(--eg-primary), var(--eg-primary-strong)) !important;
  color: #ffffff !important;
  box-shadow: 0 10px 20px rgba(37, 99, 235, .18) !important;
}

.btn.primary:hover,
button.primary:hover {
  box-shadow: 0 14px 28px rgba(37, 99, 235, .24) !important;
}

.btn.ghost {
  background: #f8fafc !important;
  color: #1e40af !important;
  border: 1px solid rgba(203, 213, 225, .92) !important;
  box-shadow: var(--eg-shadow-sm);
}

.btn.ghost:hover {
  background: #eef4ff !important;
  border-color: rgba(37, 99, 235, .24) !important;
}

.btn.danger,
button.danger {
  background: #fee2e2 !important;
  color: #b91c1c !important;
  border: 1px solid rgba(248, 113, 113, .24) !important;
}

.btn.success,
button.success {
  background: #dcfce7 !important;
  color: #047857 !important;
  border: 1px solid rgba(16, 185, 129, .22) !important;
}

.form label {
  color: #334155 !important;
  font-size: 12px !important;
  font-weight: 850 !important;
}

.form input,
.form select,
.form textarea,
.filters input,
.filters select,
.dashboard-filter input,
.dashboard-filter select {
  min-height: 40px;
  border-radius: var(--eg-radius) !important;
  border: 1px solid rgba(203, 213, 225, .92) !important;
  background: #ffffff !important;
  color: #111827 !important;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .035);
}

.form textarea {
  min-height: 98px;
}

.form input:focus,
.form select:focus,
.form textarea:focus,
.filters input:focus,
.filters select:focus,
.dashboard-filter input:focus,
.dashboard-filter select:focus {
  outline: none !important;
  border-color: rgba(37, 99, 235, .58) !important;
  box-shadow: var(--eg-focus), inset 0 1px 2px rgba(15, 23, 42, .035) !important;
}

.form input::placeholder,
.form textarea::placeholder {
  color: #94a3b8;
}

.table-wrap {
  border-radius: var(--eg-radius) !important;
  border: 1px solid rgba(203, 213, 225, .78);
  background: #ffffff;
  box-shadow: var(--eg-shadow-sm);
}

.table {
  background: #ffffff !important;
  border-collapse: separate !important;
  border-spacing: 0;
}

.table th {
  background: #f8fafc !important;
  color: #475569 !important;
  font-size: 11px !important;
  font-weight: 900 !important;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(203, 213, 225, .86) !important;
}

.table td {
  color: #1f2937;
  border-bottom: 1px solid rgba(226, 232, 240, .88) !important;
}

.table tbody tr:last-child td {
  border-bottom: 0 !important;
}

.table tr:hover td {
  background: #f8fbff !important;
}

.badge {
  border-radius: 999px !important;
  padding: 5px 9px !important;
  font-size: 11px !important;
  font-weight: 900 !important;
  letter-spacing: .01em !important;
  border: 1px solid transparent;
}

.badge.ativo,
.badge.paga,
.badge.pago,
.badge.finalizada,
.badge.entrada,
.badge.entregue {
  background: #dcfce7 !important;
  color: #047857 !important;
  border-color: rgba(16, 185, 129, .18);
}

.badge.vencida,
.badge.inadimplente,
.badge.cancelada,
.badge.cancelado,
.badge.falhou {
  background: #fee2e2 !important;
  color: #b91c1c !important;
  border-color: rgba(248, 113, 113, .20);
}

.badge.aberto,
.badge.emaberto,
.badge.parcial,
.badge.pendente,
.badge.Aguardandopagamento,
.badge.aguardandopagamento {
  background: #ffedd5 !important;
  color: #b45309 !important;
  border-color: rgba(251, 146, 60, .20);
}

.badge.inativo {
  background: #e2e8f0 !important;
  color: #475569 !important;
  border-color: rgba(148, 163, 184, .28);
}

.flash {
  border-radius: var(--eg-radius) !important;
  border: 1px solid rgba(203, 213, 225, .84);
  box-shadow: var(--eg-shadow-sm);
}

.metric {
  border-top: 3px solid rgba(37, 99, 235, .54) !important;
}

.metric:after {
  opacity: .55;
}

.metric span {
  color: #64748b !important;
  font-weight: 800;
}

.metric strong {
  color: #0f172a;
  letter-spacing: 0;
}

.h4-footer {
  color: #64748b;
}

html.dark-mode {
  --eg-bg: #0b1120;
  --eg-surface: #101827;
  --eg-surface-soft: #111c2f;
  --eg-text: #e5edf8;
  --eg-muted: #94a3b8;
  --eg-line: rgba(148, 163, 184, .22);
  --eg-line-strong: rgba(148, 163, 184, .34);
}

html.dark-mode body:not(.login-light-only) {
  background: #0b1120 !important;
  color: var(--eg-text);
}

html.dark-mode .topbar {
  background: rgba(15, 23, 42, .92) !important;
  border-bottom-color: rgba(148, 163, 184, .18) !important;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
}

html.dark-mode .topbar strong,
html.dark-mode .action-head h1,
html.dark-mode .section-head h1,
html.dark-mode .section-head h2,
html.dark-mode .card h1,
html.dark-mode .card h2,
html.dark-mode .metric strong {
  color: #e5edf8 !important;
}

html.dark-mode .card,
html.dark-mode .modal-box,
html.dark-mode .modal-card,
html.dark-mode .mini-card,
html.dark-mode .report-item,
html.dark-mode .choice-card,
html.dark-mode .calendar-card {
  background: rgba(15, 23, 42, .92) !important;
  border-color: rgba(148, 163, 184, .18) !important;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .18) !important;
}

html.dark-mode .user-name,
html.dark-mode .theme-toggle,
html.dark-mode .mobile-menu,
html.dark-mode .user-dropdown,
html.dark-mode .table-wrap {
  background: #111c2f !important;
  border-color: rgba(148, 163, 184, .22) !important;
  color: #e5edf8 !important;
}

html.dark-mode .user-dropdown a {
  color: #e5edf8;
}

html.dark-mode .user-dropdown a:hover {
  background: rgba(37, 99, 235, .18);
}

html.dark-mode .btn.ghost {
  background: rgba(37, 99, 235, .14) !important;
  color: #bfdbfe !important;
  border-color: rgba(96, 165, 250, .22) !important;
}

html.dark-mode .form label {
  color: #cbd5e1 !important;
}

html.dark-mode .form input,
html.dark-mode .form select,
html.dark-mode .form textarea,
html.dark-mode .filters input,
html.dark-mode .filters select,
html.dark-mode .dashboard-filter input,
html.dark-mode .dashboard-filter select {
  background: #0f172a !important;
  border-color: rgba(148, 163, 184, .26) !important;
  color: #e5edf8 !important;
}

html.dark-mode .table,
html.dark-mode .table-wrap {
  background: #0f172a !important;
}

html.dark-mode .table th {
  background: #111c2f !important;
  color: #cbd5e1 !important;
  border-bottom-color: rgba(148, 163, 184, .20) !important;
}

html.dark-mode .table td {
  color: #e2e8f0;
  border-bottom-color: rgba(148, 163, 184, .16) !important;
}

html.dark-mode .table tr:hover td {
  background: rgba(37, 99, 235, .10) !important;
}

@media (max-width: 900px) {
  .content {
    padding-top: 86px !important;
  }

  .topbar {
    min-height: 68px !important;
  }

  .card,
  .modal-box,
  .modal-card {
    border-radius: var(--eg-radius) !important;
  }
}

/* =========================================================
   Visual cycle 2: dashboards, filters and operational lists
   ========================================================= */
.dashboard-filter,
.filters,
.filters-form {
  align-items: end;
}

.dashboard-filter,
section.card:has(.filters-form),
form.card.filters {
  position: relative;
  overflow: hidden;
  padding: 16px !important;
  border-color: rgba(186, 199, 214, .78) !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(248, 250, 252, .96)) !important;
}

.dashboard-filter::before,
section.card:has(.filters-form)::before,
form.card.filters::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, #2563eb, #0891b2, #16a34a);
  opacity: .78;
}

.filters-form {
  gap: 12px !important;
}

.filters-form label,
.dashboard-filter label,
form.card.filters label {
  gap: 6px !important;
}

.filter-actions,
.dashboard-filter .filter-actions {
  align-items: end;
  gap: 8px !important;
}

.grid.cards {
  gap: 14px !important;
}

.metric {
  min-height: 128px;
  display: flex !important;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 17px 18px !important;
  isolation: isolate;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.metric.clickable:hover {
  transform: translateY(-3px);
  border-color: rgba(37, 99, 235, .30) !important;
  box-shadow: 0 16px 34px rgba(15, 23, 42, .10) !important;
}

.metric:before {
  content: "\F4E7";
  font-family: "bootstrap-icons";
  position: absolute;
  right: 16px;
  top: 16px;
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: #1d4ed8;
  background: rgba(37, 99, 235, .09);
  z-index: 1;
}

.grid.cards .metric:nth-child(1):before { content: "\F12C"; color: #047857; background: rgba(16, 185, 129, .11); }
.grid.cards .metric:nth-child(2):before { content: "\F130"; color: #b45309; background: rgba(245, 158, 11, .13); }
.grid.cards .metric:nth-child(3):before { content: "\F17D"; color: #1d4ed8; background: rgba(37, 99, 235, .10); }
.grid.cards .metric:nth-child(4):before { content: "\F333"; color: #b91c1c; background: rgba(239, 68, 68, .10); }

.metric span,
.metric small,
.metric strong {
  position: relative;
  z-index: 2;
}

.metric span {
  max-width: calc(100% - 46px);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 11px !important;
}

.metric strong {
  font-size: clamp(22px, 2.2vw, 31px) !important;
  line-height: 1.08;
}

.metric small {
  font-size: 12px;
}

.metric strong.green,
.green {
  color: #059669 !important;
}

.metric strong.orange,
.orange {
  color: #b45309 !important;
}

.metric strong.red,
.red {
  color: #dc2626 !important;
}

.metric strong.dark,
.dark {
  color: #1e293b !important;
}

.premium-chart-card,
.chart-card {
  padding: 18px !important;
}

.premium-chart-card .section-head,
.chart-card .section-head {
  padding-bottom: 12px;
  margin-bottom: 14px !important;
  border-bottom: 1px solid rgba(226, 232, 240, .90);
}

.premium-chart-card .section-head h2,
.chart-card .section-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.premium-chart-card .section-head h2::before,
.chart-card .section-head h2::before {
  content: "";
  width: 9px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2563eb, #0891b2);
}

.eg-svg-chart {
  border-radius: var(--eg-radius);
  background:
    linear-gradient(180deg, rgba(248, 250, 252, .82), rgba(255, 255, 255, .72));
  border: 1px solid rgba(226, 232, 240, .78);
  padding: 4px;
}

.eg-chart-click-bar {
  cursor: pointer;
  filter: drop-shadow(0 6px 8px rgba(15, 23, 42, .10));
  transition: opacity .14s ease;
}

.eg-chart-click-bar:hover {
  opacity: .84;
}

.grid.two {
  gap: 16px !important;
}

.alert-list {
  display: grid;
  gap: 9px !important;
}

.alert-item {
  min-height: 58px;
  padding: 11px 12px !important;
  border: 1px solid rgba(226, 232, 240, .86);
  border-radius: var(--eg-radius) !important;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .035);
}

.alert-item:hover {
  background: #f8fbff;
  border-color: rgba(203, 213, 225, .94);
}

.alert-item strong {
  color: #111827;
  font-weight: 850;
}

.alert-item small {
  margin-top: 3px;
  color: #64748b;
}

.table-wrap {
  overflow: auto;
}

.table-wrap > h2 {
  margin: 0;
  padding: 16px 16px 0;
  font-size: 16px;
}

.table {
  min-width: 760px;
}

.table th,
.table td {
  padding: 12px 14px !important;
  vertical-align: middle;
}

.table td:first-child strong {
  color: #111827;
  font-weight: 850;
}

.table td:last-child {
  white-space: nowrap;
}

.table .actions {
  gap: 6px;
  align-items: center;
}

.table .actions input,
.table .actions select,
.table form input,
.table form select {
  min-height: 34px;
  border-radius: var(--eg-radius);
  border: 1px solid rgba(203, 213, 225, .92);
  background: #fff;
  color: #111827;
  padding: 7px 9px;
}

.table .btn,
.table button {
  min-height: 32px;
  padding: 7px 10px !important;
}

.table-detail-row td {
  background: #f8fafc !important;
}

.table-detail-row details {
  color: #475569;
}

.table-detail-row summary {
  cursor: pointer;
  font-weight: 850;
  color: #1e40af;
}

.section-head,
.action-head {
  padding-bottom: 2px;
}

.section-head h1,
.action-head h1 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.section-head h1::before,
.action-head h1::before {
  content: "";
  width: 8px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2563eb, #0891b2);
}

.create-panel > summary {
  display: none;
}

.create-panel[open] {
  margin-bottom: 14px;
}

.modal-card {
  border-top: 3px solid rgba(37, 99, 235, .58) !important;
}

html.dark-mode .dashboard-filter,
html.dark-mode section.card:has(.filters-form),
html.dark-mode form.card.filters {
  background:
    linear-gradient(180deg, rgba(15, 23, 42, .94), rgba(17, 28, 47, .90)) !important;
  border-color: rgba(148, 163, 184, .20) !important;
}

html.dark-mode .metric.clickable:hover {
  border-color: rgba(96, 165, 250, .35) !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .26) !important;
}

html.dark-mode .metric strong.dark,
html.dark-mode .dark {
  color: #e2e8f0 !important;
}

html.dark-mode .premium-chart-card .section-head,
html.dark-mode .chart-card .section-head {
  border-bottom-color: rgba(148, 163, 184, .18);
}

html.dark-mode .eg-svg-chart {
  background:
    linear-gradient(180deg, rgba(15, 23, 42, .55), rgba(15, 23, 42, .28));
  border-color: rgba(148, 163, 184, .16);
}

html.dark-mode .alert-item {
  background: rgba(15, 23, 42, .74);
  border-color: rgba(148, 163, 184, .16);
}

html.dark-mode .alert-item:hover {
  background: rgba(37, 99, 235, .10);
}

html.dark-mode .alert-item strong,
html.dark-mode .table td:first-child strong {
  color: #e5edf8;
}

html.dark-mode .table .actions input,
html.dark-mode .table .actions select,
html.dark-mode .table form input,
html.dark-mode .table form select {
  background: #0f172a;
  color: #e5edf8;
  border-color: rgba(148, 163, 184, .24);
}

html.dark-mode .table-detail-row td {
  background: rgba(15, 23, 42, .84) !important;
}

html.dark-mode .table-detail-row summary {
  color: #bfdbfe;
}

@media (max-width: 1100px) {
  .grid.cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 760px) {
  .grid.cards,
  .grid.two {
    grid-template-columns: 1fr !important;
  }

  .metric {
    min-height: 112px;
  }

  .dashboard-filter,
  section.card:has(.filters-form),
  form.card.filters {
    padding: 14px !important;
  }

  .table th,
  .table td {
    padding: 10px 11px !important;
  }
}

/* =========================================================
   Visual cycle 3: forms, modals, responsiveness and states
   ========================================================= */
.modal-backdrop {
  padding: 18px !important;
  background: rgba(15, 23, 42, .52) !important;
  backdrop-filter: blur(4px);
}

.modal-box,
.modal-card,
.product-edit-modal,
.supplier-edit-modal,
.calendar-event-modal,
.report-filter-modal,
.audit-modal-card {
  width: min(1040px, calc(100vw - 36px));
  max-height: calc(100vh - 36px) !important;
  overflow: auto !important;
  border-radius: 10px !important;
  border-top: 3px solid rgba(37, 99, 235, .66) !important;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .28) !important;
}

.modal-wide,
.product-edit-modal,
.supplier-edit-modal,
.calendar-event-modal {
  width: min(1180px, calc(100vw - 36px)) !important;
}

.modal-head {
  position: sticky;
  top: -1px;
  z-index: 5;
  margin: -2px -2px 16px;
  padding: 2px 2px 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(255, 255, 255, .94));
  border-bottom: 1px solid rgba(226, 232, 240, .90);
}

.modal-head h2 {
  color: #0f172a;
  font-size: 18px;
  font-weight: 900;
}

.modal-close,
.modal-head .modal-close {
  width: 36px;
  height: 36px;
  border-radius: 8px !important;
  border: 1px solid rgba(203, 213, 225, .82) !important;
  background: #f8fafc !important;
  color: #334155 !important;
  display: inline-grid;
  place-items: center;
  font-size: 20px;
}

.modal-close:hover,
.modal-head .modal-close:hover {
  background: #eef4ff !important;
  color: #1d4ed8 !important;
}

.modal-box .form,
.modal-card .form,
.product-edit-modal .form,
.supplier-edit-modal .form,
.calendar-event-modal .form {
  gap: 14px !important;
}

.modal-box .actions,
.modal-card .actions,
.product-edit-modal .actions,
.supplier-edit-modal .actions,
.calendar-event-modal .actions {
  padding-top: 8px;
  border-top: 1px solid rgba(226, 232, 240, .78);
}

.create-panel {
  margin: 0 0 14px !important;
}

.create-panel[open] .modal-card {
  animation: egPanelIn .18s ease-out;
}

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

.form.grid2,
.form.grid3 {
  align-items: start;
}

.form label {
  min-width: 0;
}

.form label small,
.form .muted {
  line-height: 1.35;
}

.form input[readonly],
.form textarea[readonly] {
  background: #f8fafc !important;
  color: #475569 !important;
}

.form input:disabled,
.form select:disabled,
.form textarea:disabled {
  opacity: .72;
  cursor: not-allowed;
}

.form input:user-invalid,
.form select:user-invalid,
.form textarea:user-invalid,
.form input.is-invalid,
.form select.is-invalid,
.form textarea.is-invalid {
  border-color: rgba(220, 38, 38, .72) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .12) !important;
}

.form input:valid:not(:placeholder-shown)[required],
.form select:valid[required],
.form textarea:valid:not(:placeholder-shown)[required] {
  border-color: rgba(5, 150, 105, .38) !important;
}

.checkline {
  min-height: 42px;
  display: inline-flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 10px 12px !important;
  border: 1px solid rgba(203, 213, 225, .82);
  border-radius: var(--eg-radius);
  background: #f8fafc;
  color: #334155 !important;
}

.checkline input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
  flex: 0 0 auto;
}

.portal-access-check {
  align-self: end;
}

.search-select {
  z-index: 10;
}

.search-select.open {
  z-index: 80;
}

.search-select-button {
  border-radius: var(--eg-radius) !important;
  border-color: rgba(203, 213, 225, .92) !important;
  background: #ffffff !important;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .035);
}

.search-select-button:after {
  content: "\F282" !important;
  font-family: "bootstrap-icons";
  font-size: 12px;
}

.search-select-list,
.select-search-results {
  border-radius: 10px !important;
  border-color: rgba(203, 213, 225, .92) !important;
  box-shadow: 0 20px 48px rgba(15, 23, 42, .16) !important;
}

.search-select-input {
  border-radius: 8px !important;
}

.search-select-option,
.select-search-results button {
  min-height: 38px;
  border-radius: 8px !important;
}

.search-select-option:hover,
.search-select-option.selected,
.select-search-results button:hover {
  background: #eef4ff !important;
  color: #1d4ed8 !important;
}

.flash-wrap {
  position: relative;
  z-index: 12;
}

.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px !important;
  font-weight: 750;
}

.flash::before {
  content: "\F26A";
  font-family: "bootstrap-icons";
  flex: 0 0 auto;
}

.flash.success::before { content: "\F26B"; }
.flash.danger::before { content: "\F33A"; }
.flash.warning::before { content: "\F33B"; }

.btn:focus-visible,
button:focus-visible,
a:focus-visible,
.search-select-button:focus-visible,
.modal-close:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .22) !important;
  outline-offset: 2px;
}

.table-wrap::-webkit-scrollbar,
.modal-box::-webkit-scrollbar,
.modal-card::-webkit-scrollbar,
.sidebar nav::-webkit-scrollbar,
.search-select-list::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

.table-wrap::-webkit-scrollbar-thumb,
.modal-box::-webkit-scrollbar-thumb,
.modal-card::-webkit-scrollbar-thumb,
.sidebar nav::-webkit-scrollbar-thumb,
.search-select-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, .46);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.table-wrap::-webkit-scrollbar-track,
.modal-box::-webkit-scrollbar-track,
.modal-card::-webkit-scrollbar-track,
.sidebar nav::-webkit-scrollbar-track,
.search-select-list::-webkit-scrollbar-track {
  background: transparent;
}

.h4-footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid rgba(203, 213, 225, .70);
}

html.dark-mode .modal-backdrop {
  background: rgba(2, 6, 23, .72) !important;
}

html.dark-mode .modal-head {
  background: linear-gradient(180deg, rgba(15, 23, 42, .98), rgba(15, 23, 42, .94));
  border-bottom-color: rgba(148, 163, 184, .18);
}

html.dark-mode .modal-head h2 {
  color: #e5edf8;
}

html.dark-mode .modal-close,
html.dark-mode .modal-head .modal-close {
  background: #111c2f !important;
  border-color: rgba(148, 163, 184, .24) !important;
  color: #cbd5e1 !important;
}

html.dark-mode .modal-box .actions,
html.dark-mode .modal-card .actions,
html.dark-mode .product-edit-modal .actions,
html.dark-mode .supplier-edit-modal .actions,
html.dark-mode .calendar-event-modal .actions {
  border-top-color: rgba(148, 163, 184, .16);
}

html.dark-mode .form input[readonly],
html.dark-mode .form textarea[readonly],
html.dark-mode .checkline,
html.dark-mode .search-select-button,
html.dark-mode .search-select-list,
html.dark-mode .select-search-results {
  background: #111c2f !important;
  border-color: rgba(148, 163, 184, .22) !important;
  color: #e5edf8 !important;
}

html.dark-mode .search-select-option:hover,
html.dark-mode .search-select-option.selected,
html.dark-mode .select-search-results button:hover {
  background: rgba(37, 99, 235, .18) !important;
  color: #bfdbfe !important;
}

html.dark-mode .h4-footer {
  border-top-color: rgba(148, 163, 184, .16);
}

@media (max-width: 900px) {
  .modal-backdrop {
    align-items: flex-start !important;
    padding: 10px !important;
  }

  .modal-box,
  .modal-card,
  .product-edit-modal,
  .supplier-edit-modal,
  .calendar-event-modal,
  .report-filter-modal,
  .audit-modal-card {
    width: 100% !important;
    max-height: calc(100vh - 20px) !important;
    padding: 16px !important;
  }

  .modal-head {
    margin-bottom: 12px;
  }

  .form.grid2,
  .form.grid3,
  .modal-box .form.grid2,
  .modal-box .form.grid3,
  .modal-card .form.grid2,
  .modal-card .form.grid3 {
    grid-template-columns: 1fr !important;
  }

  .modal-box .actions,
  .modal-card .actions,
  .product-edit-modal .actions,
  .supplier-edit-modal .actions,
  .calendar-event-modal .actions {
    display: grid !important;
    grid-template-columns: 1fr;
  }

  .modal-box .actions .btn,
  .modal-box .actions button,
  .modal-card .actions .btn,
  .modal-card .actions button {
    width: 100%;
  }

  .checkline {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

/* Home KPI cards: top accent follows the value color */
.grid.cards .metric {
  --metric-accent: #2563eb;
  --metric-accent-soft: rgba(37, 99, 235, .10);
  border-top: 3px solid var(--metric-accent) !important;
}

.grid.cards .metric:has(strong.green) {
  --metric-accent: #059669;
  --metric-accent-soft: rgba(5, 150, 105, .12);
}

.grid.cards .metric:has(strong.orange) {
  --metric-accent: #b45309;
  --metric-accent-soft: rgba(180, 83, 9, .13);
}

.grid.cards .metric:has(strong.red) {
  --metric-accent: #dc2626;
  --metric-accent-soft: rgba(220, 38, 38, .12);
}

.grid.cards .metric:has(strong.dark) {
  --metric-accent: #0f172a;
  --metric-accent-soft: rgba(15, 23, 42, .09);
}

.grid.cards .metric:before {
  color: var(--metric-accent) !important;
  background: var(--metric-accent-soft) !important;
}

.grid.cards .metric:after {
  background: var(--metric-accent-soft) !important;
}

html.dark-mode .grid.cards .metric {
  background: rgba(15, 23, 42, .92) !important;
  border-color: rgba(148, 163, 184, .18) !important;
  border-top-color: var(--metric-accent) !important;
}

html.dark-mode .grid.cards .metric:has(strong.dark) {
  --metric-accent: #60a5fa;
  --metric-accent-soft: rgba(96, 165, 250, .13);
}

html.dark-mode .grid.cards .metric strong.green {
  color: #34d399 !important;
}

html.dark-mode .grid.cards .metric strong.orange {
  color: #fbbf24 !important;
}

html.dark-mode .grid.cards .metric strong.red {
  color: #f87171 !important;
}

html.dark-mode .grid.cards .metric strong.dark {
  color: #bfdbfe !important;
}

html.dark-mode .grid.cards .metric span,
html.dark-mode .grid.cards .metric small {
  color: #94a3b8 !important;
}

/* Adaptive brand logo glow */
.brand-logo-frame {
  --brand-logo-rgb: 180, 116, 66;
  position: relative;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: inline-grid;
  place-items: center;
  border-radius: 14px;
  isolation: isolate;
  margin: 0;
  line-height: 0;
  align-self: center;
}

.brand-logo-frame::before {
  content: "";
  position: absolute;
  inset: -8px;
  z-index: -2;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 50%,
      rgba(var(--brand-logo-rgb), .38) 0%,
      rgba(var(--brand-logo-rgb), .18) 42%,
      rgba(var(--brand-logo-rgb), .06) 68%,
      transparent 76%);
  filter: blur(4px);
}

.brand-logo-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.92), rgba(255,248,238,.76)),
    rgba(var(--brand-logo-rgb), .16);
  border: 1px solid rgba(var(--brand-logo-rgb), .42);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.70),
    0 10px 24px rgba(var(--brand-logo-rgb), .20);
}

.brand-logo-frame .brand-logo-img {
  position: absolute;
  inset: 3px;
  width: calc(100% - 6px) !important;
  height: calc(100% - 6px) !important;
  max-width: none !important;
  max-height: none !important;
  display: block;
  object-fit: contain;
  object-position: center center;
  padding: 0 !important;
  border-radius: 12px !important;
  filter:
    drop-shadow(0 1px 0 rgba(255,255,255,.45))
    drop-shadow(0 5px 8px rgba(15,23,42,.18));
}

body.sidebar-collapsed .brand-logo-frame {
  width: 52px;
  height: 52px;
}

html.dark-mode .brand-logo-frame::before {
  background:
    radial-gradient(circle at 50% 50%,
      rgba(var(--brand-logo-rgb), .56) 0%,
      rgba(var(--brand-logo-rgb), .30) 42%,
      rgba(var(--brand-logo-rgb), .10) 68%,
      transparent 78%);
}

html.dark-mode .brand-logo-frame::after {
  background:
    linear-gradient(145deg, rgba(255,255,255,.90), rgba(255,247,235,.72)),
    rgba(var(--brand-logo-rgb), .18);
  border-color: rgba(var(--brand-logo-rgb), .50);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.72),
    0 12px 28px rgba(var(--brand-logo-rgb), .28);
}

@media (min-width: 901px) {
  .sidebar .brand:has(.brand-logo-frame) {
    display: grid !important;
    grid-template-columns: 52px minmax(0, 1fr);
    align-items: center !important;
    column-gap: 12px !important;
  }

  body.sidebar-collapsed .sidebar .brand:has(.brand-logo-frame) {
    display: flex !important;
    justify-content: center !important;
  }
}
