.page-content {
    position: relative;
}

:root {
    --sgc-bg-base: #f1f5f9;
    --sgc-bg-surface: #ffffff;
    --sgc-bg-soft: #f7f9fc;
    --sgc-stroke: #dbe4ef;
    --sgc-text: #223047;
    --sgc-text-muted: #5f6f86;
    --sgc-primary: #0f5ea8;
    --sgc-primary-soft: rgba(15, 94, 168, 0.12);
    --sgc-shadow: 0 10px 30px rgba(28, 43, 70, 0.08);
    --sgc-shadow-hover: 0 16px 34px rgba(18, 35, 60, 0.14);
    --kpi-good: #198754;
    --kpi-warning: #b96b00;
    --kpi-critical: #c92a2a;
    --kpi-neutral: #4a5a73;
}

body {
    background:
        radial-gradient(1200px 420px at 92% -10%, rgba(15, 94, 168, 0.17), transparent 70%),
        radial-gradient(860px 300px at 10% 0%, rgba(13, 148, 136, 0.11), transparent 68%),
        var(--sgc-bg-base);
    color: var(--sgc-text);
}

.page-content::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
    background-size: 28px 28px;
    opacity: 0.35;
}

.container-fluid,
.card,
.macro-section-card,
.macro-chart-panel,
.export-toolbar {
    position: relative;
    z-index: 1;
}

.page-title-box h4 {
    letter-spacing: 0.02em;
    color: #1d304c;
}

.insight-card {
    border-left: 4px solid #2c7ac3;
    background: linear-gradient(160deg, #ffffff 0%, #f5f9ff 100%);
    box-shadow: var(--sgc-shadow);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 1.5rem;
}

.met {
    background: var(--color-background-secondary);
    border-radius: var(--border-radius-md);
    padding: .85rem 1rem;
}

.met-label {
    font-size: 11px;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.met-val {
    font-size: 20px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.met-delta {
    font-size: 11px;
    margin-top: 3px;
}

.insight-body {
    color: #495057;
    font-size: 0.95rem;
    line-height: 1.65;
}

.insight-body ul {
    margin-bottom: 0.75rem;
    padding-left: 1rem;
}

.tab-actions .nav-link {
    border: 1px solid #e9ecef;
    color: #495057;
    font-weight: 500;
}

.tab-actions .nav-link.active {
    border-color: #556ee6;
    background: #556ee6;
    color: #ffffff;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2f44;
    letter-spacing: 0.01em;
}

.metric-subtle {
    min-height: 40px;
}

.menu-toggle-item {
    padding: 0.5rem 1.25rem 0.25rem;
}

.side-menu-toggle {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.45rem;
    color: #155188;
    border: 1px solid rgba(15, 94, 168, 0.25);
    background-color: #e8f2ff;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.side-menu-toggle:hover {
    color: #0f3f6a;
    background-color: #dcebff;
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(15, 94, 168, 0.2);
}

body.vertical-collpsed .side-menu-toggle {
    justify-content: center;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

body.vertical-collpsed .side-menu-toggle span {
    display: none;
}

.legend-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.5rem;
    border: 1px solid #eff2f7;
    border-radius: 999px;
    color: #495057;
    background: #f8f9fa;
    font-size: 0.75rem;
}

.legend-item-clickable {
    cursor: pointer;
    user-select: none;
}

.legend-item-inactive {
    opacity: 0.45;
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.chart-box {
    position: relative;
    width: 100%;
    height: 360px;
}

.chart-box-lg {
    height: 430px;
}

.footer-note {
    color: #74788d;
    font-size: 0.8rem;
}

.export-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    background: linear-gradient(160deg, #f8fbff 0%, #f2f7ff 100%);
    border: 1px solid #d9e6f5;
    border-radius: 0.8rem;
    padding: 0.85rem 1rem;
    box-shadow: var(--sgc-shadow);
}

.export-toolbar .btn-group {
    gap: 0.5rem;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 0.75rem;
}

.filters-grid .form-select,
.filters-grid .form-control,
#btn-macro-clear {
    cursor: pointer;
}

.macro-section-card {
    border: 1px solid var(--sgc-stroke);
    border-radius: 0.9rem;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: var(--sgc-shadow);
}

.macro-section-card .card-header {
    border-bottom: 1px solid var(--sgc-stroke);
    background: linear-gradient(125deg, #eef4ff 0%, #f9fcff 55%, #ffffff 100%);
}

.macro-chart-panel {
    height: 100%;
    border: 1px solid #dbe4ef;
    border-radius: 0.5rem;
    padding: 0.75rem;
    background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
    box-shadow: 0 6px 18px rgba(31, 47, 68, 0.07);
}

.macro-chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.65rem;
}

.chart-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.chart-panel-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.btn,
.chart-tool-btn,
#btn-macro-clear,
.export-toolbar .btn {
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.chart-tool-btn:hover,
.export-toolbar .btn:hover,
#btn-macro-clear:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(25, 45, 73, 0.18);
}

.chart-panel-actions .btn.btn-light {
    background: #edf4ff;
    border-color: #ccdff6;
    color: #1f4f7a;
}

.chart-panel-actions .btn.btn-light:hover {
    background: #dcecff;
    border-color: #b4d3f3;
    color: #173d60;
}

.export-toolbar .btn {
    border-width: 1px;
    font-weight: 600;
}

#sidebar-menu .metismenu li a {
    border-radius: 0.65rem;
    margin: 0.2rem 0.55rem;
    padding: 0.58rem 0.8rem;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

#sidebar-menu .metismenu li a:hover {
    background-color: #eaf3ff;
    color: #0f4f86;
    transform: translateX(3px);
}

#sidebar-menu .metismenu li a.active {
    background: linear-gradient(90deg, rgba(15, 94, 168, 0.2) 0%, rgba(15, 94, 168, 0.08) 100%);
    color: #0f4f86;
    font-weight: 700;
}

.mini-stats-wid {
    border: 1px solid #d8e1ed;
    background: linear-gradient(160deg, #ffffff 0%, #f7fbff 100%);
    box-shadow: 0 7px 16px rgba(29, 48, 76, 0.08);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.mini-stats-wid .card-body {
    position: relative;
    padding-top: 1.45rem;
}

.mini-stats-wid:hover {
    transform: translateY(-2px);
    box-shadow: var(--sgc-shadow-hover);
}

.mini-stats-wid::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--kpi-neutral);
    opacity: 0.55;
}

.mini-stats-wid::after {
    content: "Neutro";
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 700;
    color: #4a5a73;
    background: rgba(74, 90, 115, 0.1);
    border: 1px solid rgba(74, 90, 115, 0.2);
    border-radius: 999px;
    padding: 0.14rem 0.5rem;
}

.mini-stats-wid.kpi-tone-good {
    background: linear-gradient(160deg, #ffffff 0%, #f0fff8 100%);
    border-color: rgba(25, 135, 84, 0.28);
}

.mini-stats-wid.kpi-tone-good::before {
    background: var(--kpi-good);
    opacity: 0.9;
}

.mini-stats-wid.kpi-tone-good::after {
    content: "Saudável";
    color: #0f6e44;
    background: rgba(25, 135, 84, 0.12);
    border-color: rgba(25, 135, 84, 0.28);
}

.mini-stats-wid.kpi-tone-warning {
    background: linear-gradient(160deg, #ffffff 0%, #fff9ef 100%);
    border-color: rgba(185, 107, 0, 0.35);
}

.mini-stats-wid.kpi-tone-warning::before {
    background: var(--kpi-warning);
    opacity: 0.92;
}

.mini-stats-wid.kpi-tone-warning::after {
    content: "Atencao";
    color: #8f5100;
    background: rgba(185, 107, 0, 0.12);
    border-color: rgba(185, 107, 0, 0.32);
}

.mini-stats-wid.kpi-tone-critical {
    background: linear-gradient(160deg, #ffffff 0%, #fff2f2 100%);
    border-color: rgba(201, 42, 42, 0.38);
}

.mini-stats-wid.kpi-tone-critical::before {
    background: var(--kpi-critical);
    opacity: 0.95;
}

.mini-stats-wid.kpi-tone-critical::after {
    content: "Crítico";
    color: #a61e1e;
    background: rgba(201, 42, 42, 0.13);
    border-color: rgba(201, 42, 42, 0.34);
}

.mini-stats-wid.kpi-tone-neutral::after {
    content: "Neutro";
}

.mini-stats-wid.kpi-tone-good .metric-value {
    color: #16663f;
}

.mini-stats-wid.kpi-tone-warning .metric-value {
    color: #8b4f02;
}

.mini-stats-wid.kpi-tone-critical .metric-value {
    color: #ad1f1f;
}

.insight-body {
    color: var(--sgc-text-muted);
}

.section-title {
    color: #1d3657;
}

.section-subtitle {
    color: #516a86;
}

.footer {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(226, 235, 247, 0.65) 100%);
}

.chart-panel-actions .btn,
.chart-panel-actions .form-select,
.chart-panel-actions .form-control[type="date"] {
    cursor: pointer;
}

.chart-panel-actions .form-select {
    min-width: 170px;
}

.chart-panel-actions .form-control[type="date"] {
    min-width: 150px;
}

.chart-scroll-y {
    max-height: 540px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.chart-box-dynamic {
    min-height: 360px;
}

.kpi-thresholds-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 0.85rem;
}

.kpi-threshold-card {
    border: 1px solid #dbe4ef;
    border-radius: 0.7rem;
    padding: 0.75rem;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.chart-fullscreen-modal .modal-dialog {
    margin: 0;
}

.chart-fullscreen-modal .modal-content {
    height: 100vh;
    border-radius: 0;
    border: 0;
}

.chart-fullscreen-modal .modal-header {
    border-bottom: 1px solid #dbe4ef;
    background: linear-gradient(125deg, #eef4ff 0%, #f9fcff 55%, #ffffff 100%);
}

.chart-fullscreen-modal .modal-body {
    height: calc(100vh - 72px);
    padding: 0.85rem 1rem 1rem;
    overflow: hidden;
}

#temporal-chart-scroll-fullscreen {
    max-height: 100%;
    height: 100%;
}

#temporal-chart-box-fullscreen {
    min-height: 100%;
}

.stage-fullscreen-body {
    display: flex;
    align-items: stretch;
}

.stage-fullscreen-image-wrap {
    width: 100%;
    height: 100%;
    overflow: auto;
    border: 1px solid #dbe4ef;
    border-radius: 0.8rem;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    padding: 0.75rem;
}

#chart-stage-evolution-fullscreen-image {
    display: block;
    width: 100%;
    height: auto;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1d3657;
}

.section-subtitle {
    color: #516a86;
    font-size: 0.82rem;
}

.chart-box.chart-box-panel {
    height: 320px;
}

.critical-delay-table-scroll {
    max-height: 430px;
    overflow-y: auto;
}

.critical-delay-table-scroll thead th {
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 1;
}

#table-critical-delay-body tr {
    cursor: pointer;
}

#table-critical-delay-body tr:focus-visible {
    outline: 2px solid #556ee6;
    outline-offset: -2px;
}

@media (max-width: 991.98px) {
    .filters-grid {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }
}

@media (max-width: 991.98px) {

    body {
        overflow-x: hidden;
    }

    #page-topbar {
        left: 0 !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .vertical-menu {
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1005;
        box-shadow: 0 12px 28px rgba(18, 38, 63, 0.2);
    }

    body.sidebar-enable .vertical-menu {
        transform: translateX(0);
    }

    .chart-panel-header {
        align-items: flex-start;
    }

    .chart-panel-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .legend-wrap {
        gap: 0.35rem;
    }

    .legend-item {
        font-size: 0.7rem;
        padding: 0.15rem 0.4rem;
    }

    .chart-box.chart-box-panel,
    .chart-box,
    .chart-box-lg {
        height: 300px;
    }
}

@media (max-width: 575.98px) {
    .page-title-box h4 {
        font-size: 1.25rem;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .chart-panel-actions {
        gap: 0.3rem;
    }

    .chart-panel-actions .btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.68rem;
    }

    .chart-panel-actions .form-select,
    .chart-panel-actions .form-control[type="date"] {
        min-width: 130px;
        font-size: 0.74rem;
    }

    .chart-box.chart-box-panel,
    .chart-box,
    .chart-box-lg {
        height: 280px;
    }

    .critical-delay-table-scroll {
        max-height: 280px;
    }

    .mini-stats-wid::after {
        font-size: 0.56rem;
        padding: 0.12rem 0.42rem;
    }

    .kpi-thresholds-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 991.98px) {

    .chart-box,
    .chart-box-lg {
        height: 320px;
    }

    .critical-delay-table-scroll {
        max-height: 320px;
    }
}
