/* ── Design tokens ──────────────────────────────────────────────────────── */
:root {
    --green-dark:   #155a35;
    --green-mid:    #1a7a4a;
    --green-light:  #28a745;
    --border:       #dee2e6;
    --bg:           #f0f4f8;
    --card-bg:      #ffffff;
    --text-muted:   #6c757d;
    --radius:       10px;
    --shadow:       0 2px 10px rgba(0,0,0,0.07);
}

/* ── Base ───────────────────────────────────────────────────────────────── */
body {
    font-family: 'Segoe UI', system-ui, Arial, sans-serif;
    background-color: var(--bg);
    color: #333;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-header {
    background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
    color: #fff;
    padding: 1.5rem 0;
    box-shadow: 0 3px 12px rgba(0,0,0,0.18);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.header-logo {
    max-width: 90px;
    max-height: 72px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    flex-shrink: 0;
}

.site-header h1 {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 700;
    margin: 0 0 0.35rem;
}

.header-subtitle {
    margin: 0;
    opacity: 0.85;
    font-size: 0.88rem;
    line-height: 1.5;
}

/* ── Section cards ──────────────────────────────────────────────────────── */
.section-card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--card-bg);
    overflow: hidden;
}

.section-header {
    background: #f8f9fa;
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    color: #333;
}

.header-actions {
    margin-left: auto;
    display: flex;
    gap: 0.35rem;
}

.header-actions .btn {
    font-size: 0.78rem;
    padding: 0.2rem 0.55rem;
}

/* ── Slider labels ──────────────────────────────────────────────────────── */
.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.tip-btn {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    line-height: 1;
}

/* ── Styled range sliders ────────────────────────────────────────────────── */
input[type="range"] {
    --fill-pct: 50%;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--green-mid) var(--fill-pct), #dde3ea var(--fill-pct));
    outline: none;
    cursor: pointer;
    margin: 0.4rem 0 0.2rem;
    transition: background 0.1s;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--green-mid);
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0,0,0,0.22);
    border: 2px solid #fff;
    transition: transform 0.1s, box-shadow 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(26,122,74,0.4);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--green-mid);
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0,0,0,0.22);
    border: 2px solid #fff;
}

input[type="range"]::-moz-range-track {
    height: 5px;
    border-radius: 3px;
    background: #dde3ea;
}

/* ── Roles grid ─────────────────────────────────────────────────────────── */
.roles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
}

.role-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    user-select: none;
}

.role-item:hover {
    background: #f0f7f4;
    border-color: #b8ddc9;
}

.role-item.is-checked {
    background: #e0f2e9;
    border-color: var(--green-mid);
    box-shadow: inset 3px 0 0 var(--green-mid);
}

.role-item input[type="checkbox"] {
    flex-shrink: 0;
    cursor: pointer;
}

.role-label {
    flex: 1;
    font-size: 0.85rem;
    line-height: 1.3;
}

.role-salary {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Roles footer summary */
.roles-summary-badge {
    font-size: 0.8rem;
    color: var(--green-mid);
    font-weight: 600;
    background: #e6f4ed;
    border-radius: 20px;
    padding: 0.2rem 0.7rem;
    display: none;
}

.roles-summary-badge.visible { display: inline-block; }

/* Custom role row */
.custom-role-wrapper {
    flex-wrap: wrap;
}

.custom-role-inputs {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.4rem;
    min-width: 0;
}

/* ── Compliance items ───────────────────────────────────────────────────── */
.compliance-item {
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    user-select: none;
}

.compliance-item:hover {
    background: #f8f9fa;
    border-color: var(--border);
}

.compliance-item.is-checked {
    background: #fff8e1;
    border-color: #ffc107;
}

/* ── Results (sticky sidebar) ───────────────────────────────────────────── */
.results-sticky {
    position: sticky;
    top: 1rem;
}

/* Side-by-side cost comparison row */
.costs-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.costs-row .result-stat { flex: 1; }

.costs-vs {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.result-stat {
    padding: 0.35rem 0;
}

.result-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.15rem;
}

.result-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
    transition: transform 0.15s;
}

.result-stat-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Savings hero block */
.savings-hero {
    background: #f0f4f8;
    border-radius: 8px;
    padding: 0.9rem 1rem;
    text-align: center;
    border: 2px solid transparent;
    transition: background 0.25s, border-color 0.25s;
}

.savings-hero-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.savings-hero-value {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1;
    color: #aaa;
    transition: color 0.25s, transform 0.2s;
}

/* Win state — MSP saves money */
#results-card.win .savings-hero {
    background: #e6f4ed;
    border-color: var(--green-light);
}

#results-card.win .savings-hero-value {
    color: var(--green-mid);
}

/* Loss state — in-house is cheaper */
#results-card.loss .savings-hero {
    background: #fff5f5;
    border-color: #f5a0a8;
}

#results-card.loss .savings-hero-value {
    color: #dc3545;
}

/* Pop animation on number update */
@keyframes value-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.value-pop {
    animation: value-pop 0.2s ease-out;
}

/* ── Chart tabs ─────────────────────────────────────────────────────────── */
.chart-tab {
    padding: 0.25rem 0.75rem;
    font-size: 0.82rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: #fff;
    color: #555;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chart-tab.active {
    background: var(--green-mid);
    border-color: var(--green-mid);
    color: #fff;
}

.chart-tab:not(.active):hover {
    background: #f0f7f4;
    border-color: #b8ddc9;
}

/* ── Chart canvas ───────────────────────────────────────────────────────── */
#cost-chart {
    max-height: 260px;
}

/* ── Projection table ───────────────────────────────────────────────────── */
#projection-table th {
    font-size: 0.78rem;
    font-weight: 600;
    color: #555;
}

#projection-table td,
#projection-table th {
    font-size: 0.83rem;
    padding: 0.45rem 0.75rem;
}

#projection-table tfoot tr td {
    border-top: 2px solid var(--border);
}

/* ── Tier modal ─────────────────────────────────────────────────────────── */
.tier-block {
    padding: 0.75rem;
    border-radius: 6px;
    background: #f8f9fa;
}

.tier-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.tier-basic    { color: #0d6efd; }
.tier-standard { color: var(--green-mid); }
.tier-premium  { color: #e67e00; }

/* ── Billing source banner ──────────────────────────────────────────────── */
.billing-banner {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: linear-gradient(135deg, #0d3d26 0%, #1a5c3a 100%);
    border: 1px solid rgba(0,217,163,0.25);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    margin-bottom: 1.25rem;
    color: #e6f4ed;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}

.billing-banner-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.billing-banner-body { flex: 1; min-width: 0; }

.billing-banner-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    margin-bottom: 0.25rem;
}

.billing-banner-title span {
    color: #00d9a3;
}

.billing-banner-sub {
    font-size: 0.82rem;
    color: rgba(230,244,237,0.8);
    line-height: 1.5;
}

.billing-banner-close {
    background: transparent;
    border: none;
    color: rgba(230,244,237,0.5);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 0.2rem;
    flex-shrink: 0;
    line-height: 1;
    transition: color 0.15s;
}

.billing-banner-close:hover { color: #fff; }

/* ── Action buttons ─────────────────────────────────────────────────────── */
.d-flex.gap-2.flex-wrap .btn {
    font-size: 0.85rem;
    min-width: 90px;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 575px) {
    .header-inner      { flex-direction: column; text-align: center; }
    .header-logo       { max-width: 70px; }
    .roles-grid        { grid-template-columns: 1fr; }
    .custom-role-inputs{ grid-template-columns: 1fr 1fr auto; }
    .results-sticky    { position: static; }
    .result-stat-value { font-size: 1.35rem; }
    .result-savings    { font-size: 1.5rem; }
}

@media (max-width: 991px) {
    .results-sticky { position: static; }
}

/* ── Print ──────────────────────────────────────────────────────────────── */
@media print {
    .col-lg-7,
    #btn-share,
    #btn-copy-summary,
    .chart-tab,
    .d-flex.gap-2.flex-wrap {
        display: none !important;
    }

    .col-lg-5 {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }

    .results-sticky { position: static !important; }
    .site-header    { background: #fff !important; color: #000 !important; box-shadow: none !important; }
    .header-logo    { filter: none !important; }
    body            { background: #fff !important; }
    .section-card   { box-shadow: none !important; border: 1px solid var(--border) !important; }
    .result-stat-value { font-size: 1.4rem !important; }

    /* Force show projection table fully */
    #projection-table { font-size: 0.9rem !important; }
}
