/* Performance per categoria — mobile blu + desktop distinta */
:root {
    --mpc-bg: #0a1628;
    --mpc-bg2: #0f2138;
    --mpc-card: #132a47;
    --mpc-card2: #1a3558;
    --mpc-border: #2a4a6e;
    --mpc-text: #f0f4fa;
    --mpc-muted: #9eb4d0;
    --mpc-accent: #4d9fff;
    --mpc-ok: #4ade80;
    --mpc-warn: #fbbf24;
    --mpc-bad: #f87171;
    --mpc-target: #94a3b8;
    --mpc-radius: 16px;
    --mpc-touch: 48px;
}

body.pagina-margini-categoria {
    background: var(--mpc-bg) !important;
    background-image: radial-gradient(ellipse at 50% -20%, #1a3a5c 0%, var(--mpc-bg) 55%) !important;
    color: var(--mpc-text) !important;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
.pagina-margini-categoria .text-muted { color: var(--mpc-muted) !important; }
.pagina-margini-categoria nav a { color: var(--mpc-muted) !important; }
.pagina-margini-categoria nav strong { color: var(--mpc-text) !important; }

.mpc-main {
    max-width: min(98%, 1600px);
    margin-left: auto;
    margin-right: auto;
}
.mpc-page-title {
    color: var(--mpc-text);
    font-weight: 800;
}
.mpc-page-lead { color: var(--mpc-muted); }

.mpc-btn-back {
    background: var(--mpc-card);
    color: var(--mpc-text);
    border: 1px solid var(--mpc-border);
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 0.45rem 0.75rem;
    min-height: var(--mpc-touch);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.mpc-btn-back:hover {
    background: var(--mpc-card2);
    color: #fff;
    border-color: var(--mpc-accent);
}

.mpc-info-box {
    background: var(--mpc-card);
    border: 1px solid var(--mpc-border);
    border-left: 4px solid var(--mpc-ok);
    border-radius: var(--mpc-radius);
    padding: 0.75rem 0.85rem;
    font-size: 0.82rem;
    margin-bottom: 1rem;
    color: var(--mpc-text);
}
.pagina-margini-categoria .alert-danger {
    background: rgba(248, 113, 113, 0.12);
    border-color: var(--mpc-bad);
    color: #fecaca;
}

.mpc-perf-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.85rem;
}
.mpc-perf-chip {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    background: var(--mpc-card);
    border: 1px solid var(--mpc-border);
    border-left: 4px solid var(--mpc-target);
    border-radius: 12px;
    padding: 0.55rem 0.65rem;
}
.mpc-perf-chip.is-good {
    border-left-color: var(--mpc-ok);
    background: rgba(74, 222, 128, 0.1);
}
.mpc-perf-chip.is-warn {
    border-left-color: var(--mpc-warn);
    background: rgba(251, 191, 36, 0.1);
}
.mpc-perf-chip.is-bad {
    border-left-color: var(--mpc-bad);
    background: rgba(248, 113, 113, 0.1);
}
.mpc-chip-cat {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--mpc-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mpc-chip-val {
    font-size: 1.2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--mpc-text);
}
.mpc-chip-delta {
    font-size: 0.72rem;
    color: var(--mpc-muted);
}
.mpc-chip-delta.is-over { color: var(--mpc-bad); font-weight: 600; }
.mpc-chip-delta.is-under { color: var(--mpc-ok); font-weight: 600; }

.mpc-chart-panel {
    background: var(--mpc-card);
    border: 1px solid var(--mpc-border);
    border-radius: var(--mpc-radius);
    padding: 0.75rem 0.65rem;
    margin-bottom: 0.85rem;
}
.mpc-chart-label {
    color: var(--mpc-muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}
.mpc-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.75rem;
    font-size: 0.72rem;
    color: var(--mpc-muted);
    margin-bottom: 0.55rem;
}
.mpc-chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.mpc-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}
.mpc-legend-line {
    display: inline-block;
    width: 22px;
    height: 0;
    flex-shrink: 0;
    border-top-width: 3px;
    border-top-style: solid;
}
.mpc-legend-line--real {
    border-top-color: var(--mpc-ok);
}
.mpc-legend-line--teorico {
    border-top-color: rgba(255, 255, 255, 0.9);
    border-top-style: dashed;
    border-top-width: 2px;
}
.mpc-legend-line--target {
    border-top-color: var(--mpc-target);
    border-top-style: dashed;
    border-top-width: 2px;
}
.mpc-legend-dot--ok { background: var(--mpc-ok); }
.mpc-legend-dot--warn { background: var(--mpc-warn); }
.mpc-legend-dot--bad { background: var(--mpc-bad); }
.mpc-legend-dot--target {
    width: 14px;
    height: 0;
    border-top: 2px dashed var(--mpc-target);
    border-radius: 0;
}

.mpc-chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 280px;
    overflow: hidden;
}
.mpc-chart-canvas-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-height: 100%;
}

.mpc-val-ok { color: var(--mpc-ok) !important; font-weight: 700; }
.mpc-val-warn { color: var(--mpc-warn) !important; font-weight: 700; }
.mpc-val-bad { color: var(--mpc-bad) !important; font-weight: 700; }
.mpc-muted { color: var(--mpc-muted) !important; }

.mpc-cards { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 0.85rem; }
.mpc-card {
    background: var(--mpc-card);
    border: 1px solid var(--mpc-border);
    border-radius: 12px;
    padding: 0.6rem 0.7rem;
    border-left: 3px solid var(--mpc-ok);
}
.mpc-card.is-warn { border-left-color: var(--mpc-warn); }
.mpc-card.is-bad { border-left-color: var(--mpc-bad); }
.mpc-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}
.mpc-card-cat {
    font-weight: 700;
    font-size: 0.9rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mpc-card-fc {
    font-size: 1.05rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.mpc-card-rows { display: flex; flex-direction: column; gap: 0.25rem; }
.mpc-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
}
.mpc-card-lbl { color: var(--mpc-muted); }
.mpc-card-val {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    text-align: right;
}

.mpc-table-panel {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    overflow: hidden;
}
.mpc-table-head {
    background: #1e1e1e;
    border-bottom: 1px solid #333;
    color: #e0e0e0;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.mpc-table-scroll { max-height: calc(100vh - 320px); overflow: auto; }
.mpc-table {
    --bs-table-bg: transparent;
    --bs-table-color: #f0f0f0;
    --bs-table-border-color: #444;
    --bs-table-striped-color: #f0f0f0;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.06);
    --bs-table-hover-bg: #2d3748;
    --bs-table-hover-color: #ffffff;
    color: #f0f0f0;
}
.mpc-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #2a2a2a;
    color: #22c55e;
    font-size: 0.72rem;
    text-transform: uppercase;
    border-color: #444;
}
.mpc-table tbody td {
    color: #f0f0f0;
}
.mpc-table.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-color-type: #f0f0f0;
    color: #f0f0f0;
}
.mpc-cell-nome { color: #fff; font-weight: 600; }

@media (max-width: 768px) {
    .mpc-hint-desktop { display: none !important; }
    .mpc-tabella-wrap { display: none !important; }
    .mpc-main {
        padding-left: max(0.45rem, env(safe-area-inset-left)) !important;
        padding-right: max(0.45rem, env(safe-area-inset-right)) !important;
    }
}

@media (min-width: 769px) {
    body.pagina-margini-categoria {
        background: #121212 !important;
        background-image: none !important;
        color: #e0e0e0 !important;
    }
    body.pagina-margini-categoria .text-muted { color: #9e9e9e !important; }
    .mpc-page-title { color: #fff; font-size: 1.35rem; }
    .mpc-page-lead { color: #a3a3a3; }
    .mpc-btn-back {
        background: #1e1e1e;
        color: #e0e0e0;
        border-color: #555;
        min-height: auto;
        padding: 8px 14px;
    }
    .mpc-info-box {
        background: #1e1e1e;
        border-color: #333;
        font-size: 0.9rem;
    }
    .mpc-perf-chip {
        flex: 1 1 160px;
        background: #1e1e1e;
        border-color: #333;
    }
    .mpc-chart-panel {
        background: #1e1e1e;
        border-color: #333;
        padding: 1.25rem;
    }
    .mpc-chart-label { color: #9e9e9e; font-size: 0.8rem; }
    .mpc-cards { display: none !important; }
    .mpc-table-panel { display: block; }
}

@media (min-width: 769px) {
    .mpc-hint-mobile { display: none !important; }
}
