/* ==================================================
   METRICVIEWER COMPACT BOXY DESIGN
   Minimal / technical / no rounded app style
================================================== */
:root {
    --mv-primary: #0d6efd;
    --mv-secondary: #1f2937;
    --mv-success: #198754;
    --mv-warning: #f59e0b;
    --mv-danger: #dc3545;

    --mv-bg: #f3f5f8;
    --mv-surface: #ffffff;
    --mv-surface-soft: #f8fafc;

    --mv-text: #18212f;
    --mv-muted: #64748b;
    --mv-border: #cfd6df;
    --mv-border-dark: #aeb8c5;

    --mv-radius-sm: 0;
    --mv-radius: 0;
    --mv-radius-lg: 0;

    --mv-shadow-sm: none;
    --mv-shadow: none;
    --mv-gradient: linear-gradient(90deg, #0d6efd, #1f2937);
}

/* ==================================================
   GLOBAL COMPACT BASE
================================================== */
html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--mv-bg);
    color: var(--mv-text);
    font-size: 13px;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(15, 23, 42, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, .035) 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: .55;
    z-index: -1;
}

#app122.container-fluid {
    padding: .65rem .8rem !important;
}

.tab-content {
    margin-top: .55rem !important;
}

.row.g-3 {
    --bs-gutter-x: .65rem;
    --bs-gutter-y: .65rem;
}

.row.g-2 {
    --bs-gutter-x: .45rem;
    --bs-gutter-y: .45rem;
}

.mb-3 {
    margin-bottom: .65rem !important;
}

.mt-3 {
    margin-top: .65rem !important;
}

.mt-2 {
    margin-top: .45rem !important;
}

.p-3 {
    padding: .65rem !important;
}

.py-3 {
    padding-top: .55rem !important;
    padding-bottom: .55rem !important;
}

.py-2 {
    padding-top: .38rem !important;
    padding-bottom: .38rem !important;
}

/* ==================================================
   BOOTSTRAP COMPACT OVERRIDES
================================================== */
.card,
.mv-card,
.mv-stat-card {
    background: var(--mv-surface);
    border: 1px solid var(--mv-border);
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: hidden;
}

.card-body {
    padding: .55rem .65rem;
}

.card-header,
.mv-card-header {
    min-height: 34px;
    padding: .38rem .6rem !important;
    background: #eef2f7;
    border-bottom: 1px solid var(--mv-border);
    border-radius: 0 !important;
}

.card-footer {
    padding: .38rem .6rem;
    border-top: 1px solid var(--mv-border);
    border-radius: 0 !important;
}

.btn,
.form-control,
.form-select,
.alert,
.badge,
.dropdown-menu,
.input-group-text {
    border-radius: 0 !important;
}

.btn {
    padding: .25rem .55rem;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.25;
}

.btn-sm,
.btn-group-sm>.btn {
    padding: .18rem .42rem;
    font-size: .72rem;
}

.form-control,
.form-select {
    min-height: 28px;
    padding: .22rem .45rem;
    font-size: .78rem;
    border-color: var(--mv-border-dark);
}

.form-select-sm,
.form-control-sm {
    min-height: 26px;
    padding-top: .16rem;
    padding-bottom: .16rem;
    font-size: .74rem;
}

.form-check-input {
    border-radius: 0 !important;
}

.form-switch .form-check-input {
    border-radius: 0 !important;
}

.alert {
    padding: .45rem .6rem;
    margin-bottom: .6rem;
    border-width: 1px;
}

.badge {
    padding: .22rem .38rem;
    font-size: .65rem;
    font-weight: 800;
}

/* ==================================================
   HEADER
================================================== */
.app-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: .75rem;
    padding: .45rem .65rem;
    background: #ffffff;
    border: 1px solid var(--mv-border-dark);
    border-left: 4px solid var(--mv-primary);
    border-radius: 0;
    box-shadow: none;
    position: relative;
    overflow: hidden;
}

.app-header::before {
    display: none;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-width: 0;
}

.app-logo-sm {
    height: 22px;
    width: auto;
    display: block;
}

.app-title-sm {
    font-size: .96rem;
    font-weight: 900;
    line-height: 1;
    letter-spacing: .02em;
    color: var(--mv-text);
    background: none;
    -webkit-text-fill-color: initial;
}

.app-subtitle-sm {
    margin-top: .1rem;
    font-size: .61rem;
    color: var(--mv-muted);
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.app-main-menu {
    display: flex;
    align-items: center;
    gap: .25rem;
}

.app-main-menu .nav-link {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .55rem;
    border-radius: 0;
    color: var(--mv-muted);
    font-size: .76rem;
    font-weight: 800;
    background: #f8fafc;
    border: 1px solid var(--mv-border);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.app-main-menu .nav-link:hover {
    color: var(--mv-primary);
    background: #eef5ff;
}

.app-main-menu .nav-link.active {
    color: #fff;
    background: var(--mv-primary);
    border-color: var(--mv-primary);
}

.app-status {
    display: flex;
    align-items: center;
    gap: .3rem;
}

.app-pill,
.app-version,
.pill,
.pill-sm {
    font-size: .66rem;
    font-weight: 800;
    padding: .18rem .42rem;
    border-radius: 0;
    background: #f8fafc;
    color: var(--mv-muted);
    border: 1px solid var(--mv-border);
    white-space: nowrap;
}

.app-version {
    color: var(--mv-primary);
}

/* ==================================================
   CARDS / HEADERS
================================================== */
.mv-card {
    background: #fff;
    border: 1px solid var(--mv-border);
    border-radius: 0;
    box-shadow: none;
}

.mv-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .7rem;
    background: #eef2f7;
    border-bottom: 1px solid var(--mv-border);
}

.mv-card-header::before {
    content: "";
    width: 3px;
    align-self: stretch;
    background: var(--mv-primary);
    margin-right: .5rem;
}

.mv-card-title {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .76rem;
    letter-spacing: .07em;
    text-transform: uppercase;
    font-weight: 900;
    line-height: 1.1;
}

.mv-card-title i {
    color: var(--mv-primary);
    font-size: .78rem;
}

.mv-card-subtitle {
    margin-top: .08rem;
    font-size: .66rem;
    letter-spacing: .02em;
    color: var(--mv-muted);
}

.mv-card-header small {
    padding: .16rem .42rem;
    border-radius: 0;
    background: #fff;
    color: var(--mv-primary);
    font-weight: 800;
    border: 1px solid var(--mv-border);
    white-space: nowrap;
}

/* ==================================================
   TABLES
================================================== */
.my-table,
.table {
    margin: 0;
    width: 100%;
    font-size: .76rem;
}

.table-xs th,
.table-xs td,
.my-table th,
.my-table td {
    padding: .22rem .38rem !important;
    font-size: .75rem !important;
    vertical-align: middle;
    border-color: #e1e7ef;
}

.my-table thead th,
.table thead th {
    background: #eef2f7 !important;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-size: .66rem !important;
    font-weight: 900;
    border-bottom: 1px solid var(--mv-border-dark);
    white-space: nowrap;
}

.my-table tbody tr {
    transition: background .1s ease;
}

.my-table tbody tr:hover {
    background: #f1f7ff;
}

.my-table tbody tr.table-primary {
    --bs-table-bg: #eaf2ff;
    box-shadow: inset 3px 0 0 var(--mv-primary);
}

.my-table tbody tr.table-success {
    --bs-table-bg: #eaf8f1;
    box-shadow: inset 3px 0 0 var(--mv-success);
}

.my-table .btn {
    border-radius: 0;
    font-weight: 800;
}

.truncate-1 {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-responsive {
    border-radius: 0;
}

/* ==================================================
   STATS
================================================== */
.mv-stat-card {
    position: relative;
    background: #fff;
    border: 1px solid var(--mv-border);
    border-left: 4px solid var(--mv-primary);
}

.mv-stat-card::before {
    display: none;
}

.mv-stat-card .card-body {
    padding: .45rem .6rem !important;
}

.mv-stat-card .text-muted {
    color: var(--mv-muted) !important;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: .63rem;
}

.mv-stat-card .fs-4 {
    margin-top: .08rem;
    color: var(--mv-text);
    font-size: 1.25rem !important;
    line-height: 1.05;
}

/* ==================================================
   SOURCE FILTER BAR
================================================== */
.filters-bar {
    padding: .38rem .5rem;
    border-radius: 0;
    border: 1px solid #263241;
    background: #1f2937;
    color: #e5e7eb;
    z-index: 800;
}

.filters-bar a {
    color: #cbd5e1;
    text-decoration: none;
}

.filters-bar a:hover {
    color: #fff;
    text-decoration: underline;
}

.filters-counter {
    font-size: .67rem;
    padding: .15rem .38rem;
    border-radius: 0;
    background: rgba(255, 255, 255, .08);
    color: #e5e7eb;
    border: 1px solid rgba(255, 255, 255, .12);
}

.source-card {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-width: 170px;
    max-width: 235px;
    padding: .32rem .42rem;
    border-radius: 0;
    border: 1px solid #465365;
    background: #111827;
    color: #f8fafc;
    text-align: left;
    transition: background .1s ease, border-color .1s ease, opacity .1s ease;
}

.source-card:hover {
    transform: none;
    box-shadow: none;
    border-color: #94a3b8;
}

.source-card-status {
    width: 7px;
    height: 18px;
    border-radius: 0;
    background: #94a3b8;
    flex: 0 0 auto;
}

.source-card-on {
    border-color: #20c997;
    background: #10251f;
    box-shadow: inset 3px 0 0 var(--mv-success);
}

.source-card-on .source-card-status {
    background: var(--mv-success);
    box-shadow: none;
}

.source-card-off {
    opacity: .48;
    background: #111827;
}

.source-card-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.05;
    flex: 1;
}

.source-card-body strong {
    font-size: .7rem;
    font-weight: 900;
}

.source-card-body small {
    margin-top: .1rem;
    color: #cbd5e1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-card-state {
    font-size: .56rem;
    font-weight: 900;
    letter-spacing: .06em;
    color: #cbd5e1;
}

/* ==================================================
   MAP / CHARTS
================================================== */
#map {
    height: 390px;
    width: 100%;
    background: #e9ecef;
}

.chart-panel {
    height: 365px;
    display: flex;
    flex-direction: column;
}

.chart-area {
    flex: 1 1 auto;
    min-height: 0;
}

#metricChart {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.supp-chart-card {
    min-height: 285px;
}

.supp-chart-card h6 {
    margin: 0 0 .35rem;
    font-size: .82rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.supp-chart-box {
    height: 230px;
}

.supp-chart-box canvas {
    width: 100% !important;
    height: 100% !important;
}

.legend {
    font-size: .72rem;
}

.legend-gradient {
    height: 8px;
    border-radius: 0;
    border: 1px solid #b8c1cc;
    background: linear-gradient(90deg, #dc3545, #fd7e14, #ffc107, #20c997, #198754);
}

/* ==================================================
   MINI MAPS / QUALITY CHIPS
================================================== */
.mini-route-map {
    width: 120px;
    height: 42px;
    display: block;
    border-radius: 0;
    background: #eef1f4;
    border: 1px solid var(--mv-border);
}

.quality-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
}

.quality-chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .38rem;
    border: 1px solid var(--mv-border);
    border-radius: 0;
    background: #fff;
    font-size: .67rem;
    line-height: 1.05;
}

.quality-chip strong {
    font-size: .66rem;
}

.quality-chip small {
    color: var(--mv-muted);
}

.quality-dot {
    width: 8px;
    height: 8px;
    border-radius: 0;
}

/* ==================================================
   REPLAY / SELECTED STATES
================================================== */
.replay-panel {
    border-top: 1px solid var(--mv-border);
    background: #f8fafc;
}

.replay-slider {
    min-width: 180px;
}

.mv-table-selected {
    --bs-table-bg: #fff3cd !important;
    outline: 2px solid #f59e0b;
    outline-offset: -2px;
}

.leaflet-interactive.mv-replay-marker {
    filter: drop-shadow(0 0 6px rgba(13, 110, 253, .75));
}

.map-mode-group .btn {
    padding: .16rem .4rem;
    font-size: .7rem;
}

.leaflet-interactive.mv-selected-pulse {
    animation: mvPulse 1.15s ease-out infinite;
}

@keyframes mvPulse {
    0% {
        stroke-opacity: .95;
        stroke-width: 3;
        fill-opacity: .20;
    }

    70% {
        stroke-opacity: .10;
        stroke-width: 12;
        fill-opacity: .03;
    }

    100% {
        stroke-opacity: 0;
        stroke-width: 14;
        fill-opacity: 0;
    }
}

/* ==================================================
   FOOTER
================================================== */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-top: .75rem;
    padding: .32rem .55rem;
    background: #ffffff;
    border: 1px solid var(--mv-border-dark);
    border-radius: 0;
    font-size: .66rem;
    color: var(--mv-muted);
    box-shadow: none;
}

.app-footer span {
    white-space: nowrap;
}

/* ==================================================
   UTILITIES
================================================== */
.bg-purple {
    background-color: #6f42c1 !important;
    color: #fff !important;
}

.min-w-0 {
    min-width: 0;
}

.stat-card {
    border-left: 4px solid var(--mv-primary);
}

/* ==================================================
   RESPONSIVE
================================================== */
@media (max-width: 992px) {
    #map {
        height: 340px;
    }

    .chart-panel {
        height: 330px;
    }

    .supp-chart-box {
        height: 220px;
    }
}

@media (max-width: 768px) {
    #app122.container-fluid {
        padding: .45rem !important;
    }

    .app-header {
        grid-template-columns: 1fr;
        gap: .45rem;
        padding: .45rem;
    }

    .app-brand {
        justify-content: center;
        text-align: center;
    }

    .app-subtitle-sm {
        white-space: normal;
    }

    .app-main-menu {
        justify-content: center;
        width: 100%;
        padding-top: .35rem;
        border-top: 1px solid var(--mv-border);
    }

    .app-main-menu .nav-item {
        flex: 1;
    }

    .app-main-menu .nav-link {
        justify-content: center;
        width: 100%;
        text-align: center;
    }

    .app-status {
        justify-content: center;
        flex-wrap: wrap;
    }

    .source-card {
        min-width: 100%;
        max-width: 100%;
    }

    .filters-bar .btn-group {
        width: 100%;
        margin-left: 0 !important;
    }

    #map {
        height: 310px;
    }

    .chart-panel {
        height: 310px;
    }

    .app-footer {
        flex-wrap: wrap;
        justify-content: center;
    }
}