:root {
    --em-primary: #063bb8;
    --em-secondary: #1d4ed8;
    --em-accent: #60a5fa;
    --lte-sidebar-width: 300px;
}

body {
    letter-spacing: 0;
}

.login-box {
    width: min(420px, calc(100% - 32px));
}

.login-logo img {
    vertical-align: middle;
}

.btn-primary,
.text-bg-primary {
    --bs-btn-bg: var(--em-primary);
    --bs-btn-border-color: var(--em-primary);
    --bs-primary-rgb: 6, 59, 184;
}

.card,
.small-box {
    border-radius: 6px;
}

.app-sidebar .brand-link {
    text-decoration: none;
}

.app-content canvas {
    min-height: 240px;
}
.diagram-shell {
    width: 100%;
    min-height: 420px;
    max-height: 72vh;
    overflow: auto;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 6px;
    background: #ffffff;
    padding: 16px;
}

.diagram-shell .mermaid {
    min-width: 960px;
    margin: 0;
}
/* CODEx: readable Mermaid diagram */
.diagram-shell {
    height: 72vh;
    min-height: 560px;
    max-height: none;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 24px;
    scrollbar-gutter: stable both-edges;
}
.diagram-shell .mermaid {
    display: block;
    width: max-content;
    min-width: 100%;
    margin: 0;
}
.diagram-shell .mermaid svg {
    display: block;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    min-width: 1600px;
}
.diagram-shell .entityBox,
.diagram-shell .attributeBoxOdd,
.diagram-shell .attributeBoxEven {
    stroke-width: 1.5px !important;
}
.diagram-shell text { text-rendering: geometricPrecision; }
@media (max-width: 768px) {
    .diagram-shell { height: 68vh; min-height: 480px; padding: 16px; }
}

/* CODEx: compact diagram and top scrollbar */
.diagram-scroll-top {
    width: 100%;
    height: 18px;
    overflow-x: auto;
    overflow-y: hidden;
    margin-bottom: 6px;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 6px 6px 0 0;
    background: #f8f9fa;
}
.diagram-scroll-top-content {
    height: 1px;
}
.diagram-shell {
    overflow-x: hidden;
    padding: 14px;
}
.diagram-shell .mermaid svg {
    min-width: 1200px;
}
.diagram-shell .er.entityBox,
.diagram-shell .entityBox {
    stroke-width: 1px !important;
}
.diagram-shell text,
.diagram-shell .entityLabel,
.diagram-shell .relationshipLabel {
    font-size: 9px !important;
}

/* CODEx: force horizontal scrollbar at top */
.diagram-scroll-top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: block;
    flex: 0 0 auto;
}
.diagram-shell {
    overflow-x: hidden !important;
    overflow-y: auto !important;
}


/* Standard metric toolbar and chart area */
.metric-toolbar {
    border-left: 4px solid var(--em-primary);
}
.metric-toolbar .card-header {
    background: rgba(6, 59, 184, .04);
}
.metric-toolbar .form-label {
    margin-bottom: .35rem;
    font-size: .875rem;
    font-weight: 600;
}
.daily-sales-chart {
    position: relative;
    width: 100%;
    height: 420px;
}
@media (max-width: 768px) {
    .daily-sales-chart { height: 360px; }
}


/* General settings and data scope */
.general-settings-card > .card-header .nav-tabs {
    padding: .75rem .75rem 0;
}
.general-settings-card .tab-pane {
    min-height: 180px;
}
.scope-switch {
    padding: 1rem 1rem 1rem 3.5rem;
    border: 1px solid rgba(0, 0, 0, .09);
    border-radius: 6px;
    background: rgba(6, 59, 184, .025);
}
.scope-switch .form-check-input {
    margin-left: -2.5rem;
}
.scope-option {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    padding: 1rem;
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: 6px;
    background: var(--bs-body-bg);
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}
.scope-option:hover {
    border-color: var(--em-primary);
    background: rgba(6, 59, 184, .035);
}
.scope-option-content {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}
.scope-option-compact {
    padding: .75rem;
}
.scope-company-group + .scope-company-group {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, .09);
}


/* Daily sales totals */
.branch-total-card {
    border-top: 3px solid rgba(6, 59, 184, .55);
}
.branch-total-value {
    color: var(--bs-body-color);
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
}


/* Payment method chart */
.payment-sales-chart {
    position: relative;
    width: 100%;
    height: 480px;
}
@media (max-width: 768px) {
    .payment-sales-chart { height: 440px; }
}

.payment-chart-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    width: 100%;
    float: none;
    margin-bottom: 0;
}

.payment-chart-title strong {
    flex: 0 0 auto;
    padding: .25rem .65rem;
    border-radius: 999px;
    background: rgba(6, 59, 184, .08);
    color: var(--em-primary);
    font-size: .86rem;
    font-weight: 900;
    white-space: nowrap;
}

.daily-sales-row .card {
    height: 100%;
}

@media (max-width: 575.98px) {
    .payment-chart-title {
        align-items: flex-start;
        flex-direction: column;
    }
}


/* EletroMoveis image assets */
.login-logo img {
    max-width: min(300px, 82vw);
    height: auto;
    vertical-align: middle;
}

.sidebar-brand .brand-image {
    object-fit: contain;
}


.sidebar-brand .em-brand-logo-link {
    justify-content: flex-start;
    overflow: hidden;
    padding-inline: .75rem;
}

.em-sidebar-logo {
    display: block;
    width: min(205px, 100%);
    max-height: 42px;
    object-fit: contain;
}

.sidebar-collapse .em-sidebar-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    object-position: left center;
}


/* Sidebar navigation: neutral brand palette */
.app-sidebar {
    --em-sidebar-bg: #3b4147;
    --em-sidebar-bg-soft: #454c54;
    --em-sidebar-text: #f5f6f8;
    --em-sidebar-muted: #c8cdd3;
    --em-sidebar-active: #526f94;
    --em-sidebar-active-soft: rgba(82, 111, 148, .45);
    --em-sidebar-guide: rgba(255, 255, 255, .20);
    --em-sidebar-icon: #d99a00;
    display: flex;
    height: 100dvh;
    max-height: 100dvh;
    flex-direction: column;
    overflow: hidden;
    background: var(--em-sidebar-bg) !important;
}

.app-sidebar .sidebar-brand {
    flex: 0 0 auto;
    min-height: 58px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
    background: rgba(0, 0, 0, .12);
}

.app-sidebar .sidebar-wrapper {
    min-height: 0;
    height: auto;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

.app-sidebar .sidebar-menu {
    gap: 3px;
    padding-inline: 8px;
    padding-bottom: 1rem;
}

.app-sidebar .sidebar-menu .nav-link {
    min-height: 38px;
    border-radius: 6px;
    color: var(--em-sidebar-text);
    font-size: .95rem;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}


.app-sidebar .sidebar-menu .nav-icon,
.app-sidebar .sidebar-menu .nav-arrow {
    color: var(--em-sidebar-icon);
}

.app-sidebar .sidebar-menu .nav-link:hover {
    background: rgba(255, 255, 255, .09);
    color: #fff;
}

.app-sidebar .sidebar-menu .nav-link.active {
    background: linear-gradient(90deg, var(--em-sidebar-active), #435f83);
    color: #fff;
    box-shadow: inset 3px 0 0 rgba(218, 32, 39, .72);
}

.app-sidebar .sidebar-menu > .nav-item.menu-open > .nav-link:not(.active) {
    background: var(--em-sidebar-bg-soft);
    color: #fff;
}

.app-sidebar .nav-treeview {
    position: relative;
    margin: 2px 0 6px 13px;
    padding-left: 12px;
}

.app-sidebar .nav-treeview::before {
    content: "";
    position: absolute;
    top: 5px;
    bottom: 5px;
    left: 0;
    width: 1px;
    background: var(--em-sidebar-guide);
}

.app-sidebar .nav-treeview .nav-link {
    min-height: 32px;
    padding-top: .38rem;
    padding-bottom: .38rem;
    padding-left: .7rem;
    color: var(--em-sidebar-muted);
    font-size: .875rem;
}

.app-sidebar .nav-treeview .nav-icon {
    width: 1.15rem;
    margin-right: .35rem;
    font-size: .86rem;
    opacity: .82;
}

.app-sidebar .nav-treeview .nav-link.active {
    background: var(--em-sidebar-active-soft);
    color: #fff;
    box-shadow: inset 2px 0 0 rgba(218, 32, 39, .62);
}

.app-sidebar .nav-treeview .nav-treeview {
    margin-left: 16px;
}

/* Seller and sales timing charts */
.seller-sales-chart {
    position: relative;
    width: 100%;
    height: 420px;
}

.sales-heatmap-scroll {
    overflow-x: auto;
    padding-bottom: .35rem;
}

.sales-heatmap {
    display: grid;
    grid-template-columns: 52px repeat(24, minmax(28px, 1fr));
    gap: 4px;
    min-width: 860px;
    align-items: center;
}

.sales-heatmap-hour,
.sales-heatmap-day {
    color: #64748b;
    font-size: .72rem;
    font-weight: 600;
    text-align: center;
}

.sales-heatmap-day {
    padding-right: .35rem;
    text-align: right;
}

.sales-heatmap-cell {
    display: grid;
    aspect-ratio: 1.08;
    place-items: center;
    border: 1px solid rgba(6, 59, 184, .08);
    border-radius: 3px;
    background: var(--heat-color);
    color: var(--heat-text);
    font-size: .68rem;
    font-weight: 700;
}

.sales-heatmap-cell.is-empty {
    color: transparent;
}

.sales-heatmap--sellers {
    grid-template-columns: 130px repeat(24, minmax(28px, 1fr));
}

.sales-heatmap-seller {
    overflow: hidden;
    padding-right: .5rem;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .7rem;
}

.sales-heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: .65rem;
    color: #64748b;
    font-size: .72rem;
}

.sales-heatmap-legend i {
    width: 128px;
    height: 8px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, .08);
    background: linear-gradient(90deg, #dbeafe 0%, #063bb8 100%);
}

.sales-hourly-distribution {
    margin-top: 1.35rem;
    padding-top: 1.15rem;
    border-top: 1px solid rgba(0, 0, 0, .09);
}

.sales-hourly-distribution h4 {
    margin: 0 0 .75rem;
    font-size: 1rem;
    font-weight: 600;
}

.sales-hourly-chart {
    position: relative;
    width: 100%;
    height: 280px;
}

.export-center {
    --export-center-color: var(--bs-secondary-color);
}
.export-center-toggle {
    align-items: center;
    color: var(--export-center-color);
    display: flex;
    justify-content: center;
    min-width: 2.75rem;
    position: relative;
}
.export-center.is-working {
    --export-center-color: var(--bs-primary);
}
.export-center.is-ready {
    --export-center-color: var(--bs-success);
}
.export-center.is-working .export-center-icon {
    animation: export-center-pulse 1.1s ease-in-out infinite;
}
.export-center-dot {
    align-items: center;
    background: var(--export-center-color);
    border: 2px solid var(--bs-body-bg);
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: .58rem;
    font-weight: 800;
    height: 1rem;
    justify-content: center;
    min-width: 1rem;
    padding: 0 .16rem;
    position: absolute;
    right: .15rem;
    top: .2rem;
}
.export-center-menu {
    max-width: calc(100vw - 1rem);
    overflow: hidden;
    width: 390px;
}
.export-center-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    padding: .85rem 1rem;
}
.export-center-header > i {
    color: var(--export-center-color);
    font-size: 1.25rem;
}
.export-center-list {
    border-top: 1px solid var(--bs-border-color);
    max-height: 390px;
    overflow-y: auto;
}
.export-center-item {
    align-items: flex-start;
    color: var(--bs-body-color);
    display: flex;
    gap: .75rem;
    padding: .8rem 1rem;
    text-decoration: none;
}
.export-center-item + .export-center-item {
    border-top: 1px solid var(--bs-border-color);
}
.export-center-item:hover {
    background: var(--bs-tertiary-bg);
}
.export-center-item-icon {
    align-items: center;
    background: var(--bs-tertiary-bg);
    border-radius: 50%;
    display: inline-flex;
    flex: 0 0 auto;
    height: 2.2rem;
    justify-content: center;
    width: 2.2rem;
}
.export-center-item.is-processing .export-center-item-icon { color: var(--bs-primary); }
.export-center-item.is-ready .export-center-item-icon { color: var(--bs-success); }
.export-center-item.is-failed .export-center-item-icon { color: var(--bs-danger); }
.export-center-item-copy {
    min-width: 0;
}
.export-center-item-title {
    display: block;
    font-size: .86rem;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.export-center-item-meta {
    color: var(--bs-secondary-color);
    display: block;
    font-size: .73rem;
    margin-top: .1rem;
}
.export-center-empty {
    align-items: center;
    color: var(--bs-secondary-color);
    display: flex;
    flex-direction: column;
    gap: .35rem;
    padding: 2rem 1rem;
}
.export-center-empty i {
    font-size: 1.65rem;
}
@keyframes export-center-pulse {
    0%, 100% { opacity: .35; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(2px); }
}
@media (prefers-reduced-motion: reduce) {
    .export-center.is-working .export-center-icon { animation: none; }
}
