/* ============================================================
   Mobile Pro Systems Solar Calculator — v1.1.0
   All rules scoped under #mpsc-calculator to prevent
   WordPress theme styles from overriding the calculator.
   ============================================================ */

/* ── Wrapper reset ── */
#mpsc-calculator,
#mpsc-calculator * {
    box-sizing: border-box;
}

#mpsc-calculator {
    font-family: inherit;
    line-height: 1.5;
    background: #ffffff !important;
    background-color: #ffffff !important;
    background-image: none !important;
    padding: 32px !important;
    border-radius: 10px;
}

/* Strip theme decorations from headings (backgrounds, borders, shadows)
   but leave font-size, font-weight, and color to the active theme. */
#mpsc-calculator h2,
#mpsc-calculator h3,
#mpsc-calculator h4 {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border: none !important;
    border-bottom: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

/* Hard reset for labels — themes sometimes style label with brand colors */
#mpsc-calculator label {
    background: transparent !important;
    background-color: transparent !important;
    color: inherit !important;
    display: block;
    margin: 0;
    padding: 0;
}

/* ── Step labels ── */
#mpsc-calculator .mpsc-step-label {
    margin-bottom: 12px !important;
    padding-bottom: 6px !important;
    border-bottom: 2px solid #333 !important;
    opacity: 0.85;
}

#mpsc-calculator .mpsc-section {
    margin-bottom: 28px;
}

/* ── Trailer Cards ── */
#mpsc-calculator .mpsc-trailer-cards {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

#mpsc-calculator .mpsc-trailer-card {
    flex: 1 1 280px;
    cursor: pointer;
    border: 2px solid #ccc !important;
    border-radius: 8px;
    padding: 0 !important;
    transition: border-color 0.2s, box-shadow 0.2s;
    position: relative;
    background: #fff !important;
    background-color: #fff !important;
}

#mpsc-calculator .mpsc-trailer-card:hover {
    border-color: #555 !important;
}

#mpsc-calculator .mpsc-trailer-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

#mpsc-calculator .mpsc-trailer-card input[type="radio"]:checked + .mpsc-card-inner {
    background-color: rgba(0, 100, 200, 0.06) !important;
    border-radius: 6px;
}

#mpsc-calculator .mpsc-trailer-card:has(input:checked) {
    border-color: #0064c8 !important;
    box-shadow: 0 0 0 3px rgba(0, 100, 200, 0.18);
}

#mpsc-calculator .mpsc-card-inner {
    padding: 20px 24px;
    border-radius: 6px;
    height: 100%;
    background: transparent !important;
}

#mpsc-calculator .mpsc-card-title {
    margin-bottom: 12px;
    background: transparent !important;
}

#mpsc-calculator .mpsc-card-specs {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
}

#mpsc-calculator .mpsc-card-specs li {
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
}

/* ── Step 2 grid: 3-column (zip | days | button), 3-row (label | input | hint) ── */
#mpsc-calculator .mpsc-step2-fields {
    display: grid;
    grid-template-columns: auto auto auto;
    grid-template-rows: auto auto auto;
    column-gap: 20px;
    row-gap: 4px;
    align-items: center;
}

#mpsc-calculator .mpsc-step2-label {
    font-size: 0.85em;
    font-weight: 600;
    opacity: 0.8;
    align-self: end;
}

#mpsc-calculator .mpsc-step2-hint {
    font-size: 0.78em;
    opacity: 0.65;
    margin: 0;
    align-self: start;
}

#mpsc-calculator #mpsc-deploy-days {
    padding: 9px 10px;
    border: 2px solid #ccc;
    border-radius: 6px;
    width: 90px;
    transition: border-color 0.2s;
    background: #fff;
    color: #333;
}

#mpsc-calculator #mpsc-deploy-days:focus {
    outline: none;
    border-color: #0064c8;
}

/* ── ZIP Row (legacy — keep for backwards compat) ── */
#mpsc-calculator .mpsc-zip-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

#mpsc-calculator #mpsc-zipcode {
    font-size: 1.05em;
    padding: 9px 14px;
    border: 2px solid #ccc;
    border-radius: 6px;
    width: 140px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #fff;
    color: #333;
}

#mpsc-calculator #mpsc-zipcode:focus {
    outline: none;
    border-color: #0064c8;
}

/* ── Buttons ── */
#mpsc-calculator .mpsc-btn {
    display: inline-block;
    padding: 10px 22px;
    font-size: 1em;
    font-weight: 600;
    font-family: inherit;
    border: 2px solid transparent !important;
    border-radius: 6px;
    cursor: pointer;
    background-color: #0064c8 !important;
    background-image: none !important;
    color: #fff !important;
    transition: background-color 0.2s, opacity 0.2s;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: none !important;
}

#mpsc-calculator .mpsc-btn:hover {
    background-color: #0052a3 !important;
    color: #fff !important;
}

#mpsc-calculator .mpsc-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#mpsc-calculator .mpsc-btn-secondary {
    background-color: transparent !important;
    color: #0064c8 !important;
    border: 2px solid #0064c8 !important;
    margin-top: 20px;
}

#mpsc-calculator .mpsc-btn-secondary:hover {
    background-color: rgba(0, 100, 200, 0.07) !important;
}

/* ── Error ── */
#mpsc-calculator .mpsc-error {
    color: #c0392b;
    margin-top: 8px;
    min-height: 1.2em;
}

/* ── Loading ── */
#mpsc-calculator .mpsc-loading {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 0;
}

#mpsc-calculator .mpsc-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(0, 100, 200, 0.2);
    border-top-color: #0064c8;
    border-radius: 50%;
    animation: mpsc-spin 0.75s linear infinite;
    flex-shrink: 0;
}

@keyframes mpsc-spin { to { transform: rotate(360deg); } }

/* ── Results section (hidden until JS shows it) ── */
#mpsc-calculator .mpsc-results {
    display: none;
}

#mpsc-calculator .mpsc-results-header {
    margin-bottom: 20px;
}

#mpsc-calculator .mpsc-results-header h2 {
    margin-bottom: 4px !important;
}

#mpsc-calculator .mpsc-location-label {
    margin: 0;
}

/* ── Risk Banner ── */
#mpsc-calculator .mpsc-risk-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-left: 4px solid;
    border-radius: 6px;
    padding: 14px 18px;
    margin-bottom: 24px;
}

#mpsc-calculator .mpsc-risk-icon  { font-size: 1.4em; flex-shrink: 0; margin-top: 1px; }
#mpsc-calculator .mpsc-risk-text  { flex: 1; }
#mpsc-calculator .mpsc-risk-desc  {
    display: block;
    margin-top: 4px;
}

/* ── Summary Cards ── */
#mpsc-calculator .mpsc-summary-cards {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

#mpsc-calculator .mpsc-summary-card {
    flex: 1 1 180px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 16px 20px;
    text-align: center;
    background: #fff;
}

#mpsc-calculator .mpsc-summary-value {
    font-size: 1.6em;
    font-weight: 700;
    color: #0064c8;
    line-height: 1.2;
}

#mpsc-calculator .mpsc-summary-label {
    margin-top: 4px;
}

/* ── Section subtitles ── */
#mpsc-calculator .mpsc-section-subtitle {
    margin: 24px 0 10px !important;
    opacity: 0.85;
}

#mpsc-calculator .mpsc-subtitle-note {
}

#mpsc-calculator .mpsc-subtitle-caption {
    margin: -8px 0 12px;
}

/* ── Depletion detail grid ── */
#mpsc-calculator .mpsc-depletion-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

#mpsc-calculator .mpsc-dep-card {
    flex: 1 1 160px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 14px 16px;
    text-align: center;
    background: #fff;
}

#mpsc-calculator .mpsc-dep-value {
    line-height: 1.3;
    word-break: break-word;
}

#mpsc-calculator .mpsc-dep-label {
    margin-top: 4px;
}

/* ── Weekly chart outer layout (y-axis + bars column) ── */
#mpsc-calculator .mpsc-chart-outer {
    display: flex;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 4px;
}

#mpsc-calculator .mpsc-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    width: 44px;
    flex-shrink: 0;
    padding-bottom: 22px; /* room for month/week labels below bars */
    padding-right: 6px;   /* space between labels and the axis line */
    border-right: 2px solid rgba(0,0,0,0.12);
    background: transparent !important;
}

#mpsc-calculator .mpsc-y-top {
    font-size: 0.68em;
    white-space: nowrap;
}

#mpsc-calculator .mpsc-y-unit {
    font-size: 0.62em;
    text-align: right;
    line-height: 1.3;
}

#mpsc-calculator .mpsc-y-bottom {
    font-size: 0.68em;
}

#mpsc-calculator .mpsc-chart-bars-col {
    flex: 1;
    min-width: 0;
}

/* ── Month dividers inside the bar chart ── */
#mpsc-calculator .mpsc-month-div {
    width: 1px;
    background: rgba(0,0,0,0.18);
    align-self: stretch;
    flex-shrink: 0;
    position: relative;
    margin: 0 1px;
}

/* First divider (January) has no line — just the label */
#mpsc-calculator .mpsc-month-div-first {
    background: transparent;
    margin-left: 0;
}

/* Month label sits below the divider line via ::after */
#mpsc-calculator .mpsc-month-div::after {
    content: attr(data-label);
    position: absolute;
    bottom: -20px;
    left: 2px;
    font-size: 0.65em;
    color: rgba(51,51,51,0.65);
    white-space: nowrap;
    font-weight: 500;
}

/* ── Monthly clickable groups in weekly chart ── */
/* One flex block per month; contains 4-5 week bars as children.          */
/* The month label sits below via ::after, matching mpsc-month-div style. */
#mpsc-calculator .mpsc-month-group {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 2px;
    height: 100%;
    flex: 1;
    position: relative;
    cursor: pointer;
    border-radius: 3px 3px 0 0;
    transition: background 0.15s;
}

#mpsc-calculator .mpsc-month-group::after {
    content: attr(data-label);
    position: absolute;
    bottom: -20px;
    left: 0;
    font-size: 0.65em;
    color: rgba(51,51,51,0.65);
    white-space: nowrap;
    font-weight: 500;
    pointer-events: none;
}

#mpsc-calculator .mpsc-month-group:hover {
    background: rgba(0, 100, 200, 0.07) !important;
    outline: 1px solid rgba(0, 100, 200, 0.2);
    outline-offset: 1px;
}

/* Keep a visible gap between month groups (chart-wrap gap already provides 2px;
   add a subtle border-left to visually separate months) */
#mpsc-calculator .mpsc-month-group + .mpsc-month-group {
    border-left: 1px solid rgba(0,0,0,0.10);
}

/* Week separators in daily view ── */
/* Reuses mpsc-month-div styling; the extra class adds click affordance */
#mpsc-calculator .mpsc-week-sep {
    cursor: pointer;
    width: 2px !important;
    background: rgba(0,0,0,0.10) !important;
}
#mpsc-calculator .mpsc-week-sep:hover {
    background: rgba(0, 100, 200, 0.35) !important;
}

/* Daily nav hint (shown in legend below pills area) */
#mpsc-calculator .mpsc-week-nav-hint {
    margin-left: 10px;
    white-space: nowrap;
}

/* ── Weekly chart ── */
#mpsc-calculator .mpsc-chart-wrap {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 160px;
    padding: 8px 0 0;
    margin-bottom: 22px; /* space for month labels */
    background: transparent !important;
    overflow: visible;
    position: relative; /* required for threshold line absolute positioning */
}

/* ── Daily view: breakeven threshold line ── */
#mpsc-calculator .mpsc-threshold-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 2px dashed rgba(230, 81, 0, 0.75);
    pointer-events: none;
    z-index: 10;
}

#mpsc-calculator .mpsc-threshold-label {
    position: absolute;
    right: 4px;
    top: -18px;
    font-size: 0.62em;
    color: #e65100;
    background: rgba(255,255,255,0.85);
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    font-weight: 600;
    pointer-events: none;
}

#mpsc-calculator .mpsc-weekly-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    height: 100%;
    justify-content: flex-end;
}

#mpsc-calculator .mpsc-weekly-stack {
    width: 100%;
    flex: 1;
    position: relative;
    display: flex;
    align-items: flex-end;
}

#mpsc-calculator .mpsc-tmy-bar {
    width: 100%;
    background: linear-gradient(180deg, #38a8ff, #0064c8);
    border-radius: 3px 3px 0 0;
    transition: height 0.5s ease;
    min-height: 2px;
    position: relative;
    z-index: 2;
}

#mpsc-calculator .mpsc-hist-bar {
    width: 100%;
    border-radius: 3px 3px 0 0;
    transition: height 0.5s ease;
    min-height: 3px;
}

#mpsc-calculator .mpsc-chart-label {
    font-size: 0.62em;
    white-space: nowrap;
    margin-top: 2px;
    background: transparent !important;
}

/* ── Year pills ── */
#mpsc-calculator .mpsc-year-selector-wrap {
    margin: 20px 0 24px;
    padding: 16px 20px;
    background: #f5f8ff;
    border: 1px solid #d0e2ff;
    border-radius: 8px;
}

.mpsc-year-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

#mpsc-calculator .mpsc-year-pill {
    display: inline-block;
    padding: 4px 14px;
    font-size: 0.82em;
    font-weight: 600;
    font-family: inherit;
    border: 2px solid #0064c8 !important;
    border-radius: 20px;
    cursor: pointer;
    background: transparent !important;
    color: #0064c8 !important;
    transition: background 0.18s, color 0.18s;
    line-height: 1.4;
}

#mpsc-calculator .mpsc-pill-active {
    background: #0064c8 !important;
    color: #fff !important;
}

#mpsc-calculator .mpsc-year-pill:hover:not(.mpsc-pill-active) {
    background: rgba(0,100,200,0.08) !important;
}

#mpsc-calculator .mpsc-chart-hint {
    margin: 0 0 14px;
}

/* ── Clickable weekly bar groups ── */
#mpsc-calculator .mpsc-week-clickable {
    cursor: pointer;
}

#mpsc-calculator .mpsc-week-clickable:hover .mpsc-tmy-bar {
    opacity: 0.72;
    transition: opacity 0.15s;
}

/* ── Clickable day bars ── */
#mpsc-calculator .mpsc-day-clickable {
    cursor: pointer;
}
#mpsc-calculator .mpsc-day-clickable:hover .mpsc-chart-bar {
    opacity: 0.72;
    transition: opacity 0.12s;
}

/* Day-number label — shown on every bar, very small to fit 31 in a month */
#mpsc-calculator .mpsc-day-label {
    font-size: 0.52em;
    opacity: 0.6;
    min-width: 0;
    overflow: hidden;
    text-align: center;
}
.mpsc-monthly-detail-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.mpsc-monthly-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-left: 4px solid #0064c8;
    border-radius: 4px;
    margin-bottom: 10px;
}
.mpsc-monthly-banner-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.mpsc-monthly-row {
    transition: background 0.12s, box-shadow 0.12s;
}
.mpsc-monthly-row:hover td {
    background: #e8f0fe;
    box-shadow: inset 3px 0 0 #0064c8;
}
.mpsc-monthly-row:hover td:first-child {
    padding-left: 9px;
}
.mpsc-mo-link {
    color: #0064c8;
    font-weight: 600;
}
.mpsc-monthly-row:hover .mpsc-mo-link {
    text-decoration: underline;
    color: #004a99;
}
.mpsc-monthly-day-row {
    cursor: pointer;
    transition: background 0.12s, box-shadow 0.12s;
}
.mpsc-monthly-day-row:hover td {
    background: #e8f0fe;
    box-shadow: inset 3px 0 0 #0064c8;
}
.mpsc-monthly-day-row:hover td:first-child {
    padding-left: 9px;
}
.mpsc-monthly-day-row:hover .mpsc-mo-link {
    text-decoration: underline;
    color: #004a99;
}
.mpsc-net-charge-label {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.48em;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    padding-bottom: 1px;
}

/* Hourly bar group — same layout as daily, no cursor needed */
#mpsc-calculator .mpsc-hourly-bar-group {
    flex: 1;
}

/* ── Daily drill-down ── */
#mpsc-calculator .mpsc-daily-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    height: 100%;
    justify-content: flex-end;
    min-width: 5px;
}

#mpsc-calculator .mpsc-daily-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

#mpsc-calculator .mpsc-back-btn {
    display: inline-block;
    padding: 5px 14px;
    font-size: 0.85em;
    font-weight: 600;
    font-family: inherit;
    border: 2px solid #0064c8 !important;
    border-radius: 6px;
    cursor: pointer;
    background: transparent !important;
    color: #0064c8 !important;
    transition: background 0.18s;
    line-height: 1.4;
}

#mpsc-calculator .mpsc-back-btn:hover {
    background: rgba(0,100,200,0.08) !important;
}

/* ── Prev / next navigation arrows (month and day) ── */
#mpsc-calculator .mpsc-nav-arrow {
    display: inline-block;
    padding: 5px 12px;
    font-size: 0.82em;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid rgba(0,100,200,0.35) !important;
    border-radius: 6px;
    cursor: pointer;
    background: rgba(0,100,200,0.05) !important;
    color: #0064c8 !important;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
    line-height: 1.4;
}
#mpsc-calculator .mpsc-nav-arrow:hover {
    background: rgba(0,100,200,0.14) !important;
    border-color: #0064c8 !important;
}

#mpsc-calculator .mpsc-period-label {
    color: #0064c8;
    background: transparent !important;
}

/* The year / TMY qualifier shown in smaller muted text after the month name */
#mpsc-calculator .mpsc-period-year {
}

/* Daily total badge shown in hourly view nav */
#mpsc-calculator .mpsc-hourly-total {
    font-size: 0.80em;
    font-weight: 600;
    color: #fff;
    background: #0064c8;
    border-radius: 12px;
    padding: 2px 10px;
    white-space: nowrap;
}

/* ── Chart legend ── */
#mpsc-calculator .mpsc-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    background: transparent !important;
}

#mpsc-calculator .mpsc-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    background: transparent !important;
}

#mpsc-calculator .mpsc-legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Histogram ── */
#mpsc-calculator .mpsc-hist-wrap {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 130px;
    margin-bottom: 8px;
    background: transparent !important;
}

#mpsc-calculator .mpsc-hist-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    height: 100%;
    justify-content: flex-end;
    background: transparent !important;
}

#mpsc-calculator .mpsc-hist-bar-wrap {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: flex-end;
    background: transparent !important;
}

#mpsc-calculator .mpsc-hist-low { background-color: #c62828 !important; }
#mpsc-calculator .mpsc-hist-ok  { background-color: #0064c8 !important; }
#mpsc-calculator .mpsc-hist-count { font-size: 0.62em; font-weight: 600; background: transparent !important; }
#mpsc-calculator .mpsc-hist-label { font-size: 0.6em; white-space: nowrap; background: transparent !important; }

#mpsc-calculator .mpsc-histogram-note {
    margin: 6px 0 24px;
    background: transparent !important;
}

/* ── Table ── */
#mpsc-calculator .mpsc-table-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #ddd;
    margin-bottom: 8px;
}

#mpsc-calculator .mpsc-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

#mpsc-calculator .mpsc-table th {
    background-color: rgba(0, 100, 200, 0.07) !important;
    background-image: none !important;
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid #ddd;
}

#mpsc-calculator .mpsc-table td {
    padding: 9px 14px;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
    background: transparent;
}

#mpsc-calculator .mpsc-table tbody tr:last-child td { border-bottom: none; }
#mpsc-calculator .mpsc-table tbody tr:nth-child(even) td { background-color: rgba(0,0,0,0.02); }
#mpsc-calculator .mpsc-tmy-row td { background-color: rgba(0,100,200,0.04) !important; font-style: italic; }

/* ── Progress bar ── */
#mpsc-calculator .mpsc-bar-cell { min-width: 120px; }

#mpsc-calculator .mpsc-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

#mpsc-calculator .mpsc-bar-track {
    flex: 1;
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
}

#mpsc-calculator .mpsc-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #0064c8, #38a8ff);
    border-radius: 4px;
    transition: width 0.6s ease;
}

#mpsc-calculator .mpsc-bar-pct {
    white-space: nowrap;
    font-weight: 600;
}

/* ── Color helpers ── */
#mpsc-calculator .mpsc-pos { color: #2e7d32 !important; font-weight: 600; }
#mpsc-calculator .mpsc-neg { color: #c62828 !important; font-weight: 600; }

/* ── Disclaimer ── */
#mpsc-calculator .mpsc-disclaimer {
    margin-top: 20px;
    background: transparent !important;
}

/* ── Energy balance (diverging) chart ── */

/* Container: align-items:stretch so bar groups fill full height on both halves */
#mpsc-calculator .mpsc-balance-outer {
    display: flex;
    align-items: stretch;
    gap: 2px;
    height: 200px;
    padding: 0;
    margin-bottom: 22px;
    background: transparent !important;
    overflow: visible;
    position: relative;
}

/* Monthly click groups inside balance chart need stretch, not flex-end */
#mpsc-calculator .mpsc-balance-outer .mpsc-month-group,
#mpsc-calculator .mpsc-balance-month-group {
    align-items: stretch !important;
}

/* One bar = pos half + zero divider + neg half (+ optional day label) */
#mpsc-calculator .mpsc-balance-bar-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    align-self: stretch;
}

/* Top half — bar anchors at the BOTTOM (touching the zero line) */
#mpsc-calculator .mpsc-balance-pos-stack {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 0;
    overflow: hidden;
}

/* Bottom half — bar anchors at the TOP (touching the zero line) */
#mpsc-calculator .mpsc-balance-neg-stack {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 0;
    overflow: hidden;
}

/* The zero baseline */
#mpsc-calculator .mpsc-balance-zero-line {
    height: 2px;
    background: rgba(60, 60, 60, 0.35);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

#mpsc-calculator .mpsc-balance-pos-bar {
    width: 100%;
    min-height: 0;
    border-radius: 2px 2px 0 0;
}

#mpsc-calculator .mpsc-balance-neg-bar {
    width: 100%;
    min-height: 0;
    border-radius: 0 0 2px 2px;
}

/* Day / hour label below neg stack */
#mpsc-calculator .mpsc-balance-label {
    font-size: 0.52em;
    text-align: center;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.4;
    padding-top: 2px;
    overflow: hidden;
    background: transparent !important;
}

/* Clickable day bars in daily balance view */
#mpsc-calculator .mpsc-balance-day-clickable {
    cursor: pointer;
}
#mpsc-calculator .mpsc-balance-day-clickable:hover .mpsc-balance-pos-bar,
#mpsc-calculator .mpsc-balance-day-clickable:hover .mpsc-balance-neg-bar {
    opacity: 0.7;
    transition: opacity 0.12s;
}

/* Hover tint on balance month groups */
#mpsc-calculator .mpsc-balance-outer .mpsc-month-group:hover {
    background: rgba(0, 100, 200, 0.05) !important;
}

/* Week separators inside balance daily view — must stretch to full height */
#mpsc-calculator .mpsc-balance-outer .mpsc-week-sep {
    align-self: stretch;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 600px) {
    #mpsc-calculator .mpsc-balance-outer { height: 120px; }
    #mpsc-calculator .mpsc-balance-label { display: none; }
}


/* ── Seasonal risk breakdown ── */
#mpsc-calculator .mpsc-seasonal-risks {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

#mpsc-calculator .mpsc-season-card {
    flex: 1 1 80px;
    text-align: center;
    padding: 10px 8px 8px;
    border-radius: 6px;
    background: rgba(255,255,255,0.55);
    border: 1px solid rgba(0,0,0,0.09);
}

#mpsc-calculator .mpsc-season-name {
    font-size: 0.68em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.55;
    margin-bottom: 4px;
    color: #333;
}

#mpsc-calculator .mpsc-season-icon {
    font-size: 1.2em;
    line-height: 1;
}

#mpsc-calculator .mpsc-season-risk-label {
    font-size: 0.75em;
    font-weight: 700;
    margin-top: 3px;
}

#mpsc-calculator .mpsc-season-pct {
    font-size: 0.63em;
    font-weight: 600;
    margin-top: 4px;
    opacity: 0.85;
}

#mpsc-calculator .mpsc-season-avg {
    font-size: 0.65em;
    margin-top: 6px;
    color: #333;
    line-height: 1.7;
    text-align: left;
}

#mpsc-calculator .mpsc-season-avg div {
    white-space: nowrap;
}

#mpsc-calculator .mpsc-season-avg-lbl {
    opacity: 0.6;
    font-weight: 500;
    display: inline-block;
    min-width: 52px;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    #mpsc-calculator .mpsc-trailer-cards,
    #mpsc-calculator .mpsc-summary-cards,
    #mpsc-calculator .mpsc-depletion-grid { flex-direction: column; }

    #mpsc-calculator .mpsc-chart-wrap,
    #mpsc-calculator .mpsc-hist-wrap      { height: 90px; }

    #mpsc-calculator .mpsc-chart-label,
    #mpsc-calculator .mpsc-hist-label,
    #mpsc-calculator .mpsc-hist-count     { display: none; }
}

/* ══════════════════════════════════════════════════════════════════════════
   PHASE 2 — PLATFORM CARDS + CONFIGURATOR MODAL
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Platform card grid ─────────────────────────────────────────────────── */
.mpsc-platform-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 12px;
}
@media (max-width: 700px) {
    .mpsc-platform-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
    .mpsc-platform-cards { grid-template-columns: 1fr; }
}

.mpsc-platform-radio { display: none; }

.mpsc-platform-card {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fafafa;
    overflow: hidden;
    display: flex;         /* let card-inner fill full card height */
    flex-direction: column;
}
.mpsc-platform-card:hover {
    border-color: #0064c8;
    box-shadow: 0 2px 12px rgba(0,100,200,0.12);
}
.mpsc-platform-card.mpsc-card-selected {
    border-color: #0064c8;
    background: #f0f7ff;
    box-shadow: 0 2px 16px rgba(0,100,200,0.18);
}

.mpsc-platform-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    box-sizing: border-box;
    padding: 18px 12px 14px;
    gap: 6px;
    text-align: center;
}

.mpsc-platform-icon { font-size: 2rem; line-height: 1; }

.mpsc-platform-name {
    font-weight: 700;
    font-size: 1.05em;
    color: #1a1a1a;
}

.mpsc-platform-badge {
    display: inline-block;
    margin: 2px auto 4px;
    padding: 2px 8px;
    border-radius: 20px;
    background: #e8f4e8;
    border: 1px solid #a5d6a7;
    color: #2e7d32;
    font-size: 0.72em;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.mpsc-platform-specs {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.78em;
    color: #555;
    margin-bottom: 4px;
}

.mpsc-configure-btn {
    margin-top: auto;
    padding: 6px 14px;
    border: 1px solid #0064c8;
    border-radius: 6px;
    background: #fff;
    color: #0064c8;
    font-size: 0.82em;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.mpsc-configure-btn:hover,
.mpsc-card-selected .mpsc-configure-btn {
    background: #0064c8;
    color: #fff;
}

.mpsc-config-summary {
    margin-top: 10px;
    font-size: 0.88em;
    color: #2e7d32;
    font-weight: 600;
    padding: 6px 10px;
    background: #e8f5e9;
    border-radius: 6px;
    border-left: 3px solid #2e7d32;
}

/* ── Modal overlay ──────────────────────────────────────────────────────── */
.mpsc-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

body.mpsc-modal-open { overflow: hidden; }

.mpsc-modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,0.22);
    overflow: hidden;
}

.mpsc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.mpsc-modal-title {
    font-weight: 700;
    font-size: 1.1em;
    color: #1a1a1a;
}

.mpsc-modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.12s;
}
.mpsc-modal-close:hover { background: #f0f0f0; color: #333; }

.mpsc-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.mpsc-modal-footer {
    border-top: 1px solid #e8e8e8;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.mpsc-load-preview {
    font-size: 0.88em;
    color: #444;
    font-style: italic;
    flex: 1;
}

.mpsc-btn-apply {
    flex-shrink: 0;
    padding: 10px 22px;
    background: #0064c8;
    color: #fff;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: background 0.12s;
}
.mpsc-btn-apply:hover { background: #0052a3; }

/* ── Base build toggle ──────────────────────────────────────────────────── */
.mpsc-base-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f5f9ff;
    border: 1px solid #c8dff8;
    border-radius: 8px;
    margin-bottom: 16px;
}

.mpsc-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.mpsc-base-hint {
    font-size: 0.8em;
    color: #666;
}

/* ── Tab navigation ─────────────────────────────────────────────────────── */
.mpsc-tab-nav {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e8e8e8;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.mpsc-tab-btn {
    padding: 8px 14px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: #555;
    cursor: pointer;
    font-size: 0.88em;
    font-weight: 500;
    margin-bottom: -2px;
    transition: color 0.12s, border-color 0.12s;
    border-radius: 4px 4px 0 0;
}
.mpsc-tab-btn:hover { color: #0064c8; }
.mpsc-tab-btn.active {
    color: #0064c8;
    border-bottom-color: #0064c8;
    font-weight: 700;
}

/* ── Tab panels ─────────────────────────────────────────────────────────── */
.mpsc-tab-panel { display: none; }
.mpsc-tab-panel.active { display: block; }

/* ── Vertical field layout (theme-controlled text) ──────────────────────── */
.mpsc-cfg-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 14px;
}

/* Label inherits theme — no font-size/color override */
.mpsc-cfg-field-lbl {
    display: block;
}

/* Full-width input / select — structural only, theme controls text */
.mpsc-cfg-input,
.mpsc-cfg-select {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
}
.mpsc-cfg-input:focus,
.mpsc-cfg-select:focus { outline: 2px solid #0064c8; border-color: #0064c8; }
.mpsc-cfg-input.mpsc-field-error,
.mpsc-cfg-input.mpsc-field-error:focus { border-color: #c62828; outline: 2px solid #c62828; }

/* Radio group sits below the number input */
.mpsc-cfg-radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    padding: 2px 0;
}
.mpsc-cfg-radio-lbl {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.mpsc-cfg-radio-lbl input { cursor: pointer; margin: 0; }

/* Checkboxes */
.mpsc-cfg-checks {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mpsc-cfg-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.mpsc-cfg-check input { cursor: pointer; }

/* Hint text below field — structural only */
.mpsc-cfg-hint {
    opacity: 0.7;
}

.mpsc-req { color: #c62828; }

/* Legacy _row() helper — used only inside branded tab panels (kept for compat) */
.mpsc-cfg-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 14px;
}
.mpsc-cfg-label { display: block; }

/* Other form wrapper */
.mpsc-cfg-other { padding-top: 4px; }

/* Custom system extras merged into main form CSS above */
