/* === calc_npd.css === */
/* NPD calculator: card switchers, mode toggle, progress bar, result cards, expandable sections */

/* ---- Card switchers (payer type / taxpayer status) ---- */
.npd-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 6px 0 2px;
}
.npd-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), transform var(--transition);
    user-select: none;
    text-align: center;
}
.npd-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}
.npd-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.npd-card:has(input:checked),
.npd-card.is-active {
    border-color: var(--primary);
    background: var(--primary-bg, rgba(37, 99, 235, 0.08));
}
.npd-card__icon {
    color: var(--text-muted);
    transition: color var(--transition);
}
.npd-card__icon svg {
    width: 20px;
    height: 20px;
}
.npd-card:has(input:checked) .npd-card__icon,
.npd-card.is-active .npd-card__icon {
    color: var(--primary);
}
.npd-card__title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.2;
}
.npd-card__rate {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.npd-card__sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.2;
}

/* ---- Mode toggle (direct / reverse) ---- */
.npd-mode-toggle {
    margin-bottom: 16px;
}
.npd-mode-toggle .segmented-toggle {
    width: 100%;
    max-width: 400px;
}
.npd-mode-toggle .segmented-toggle__option {
    flex: 1 1 auto;
    justify-content: center;
    font-weight: 500;
}

/* ---- Pro mode section ---- */
.npd-pro-mode {
    margin: 12px 0 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    overflow: hidden;
}
.npd-pro-mode__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    list-style: none;
    user-select: none;
    transition: background var(--transition);
}
.npd-pro-mode__summary:hover {
    background: var(--bg-card-hover);
}
.npd-pro-mode__summary::-webkit-details-marker {
    display: none;
}
.npd-pro-mode__summary::marker {
    display: none;
}
.npd-pro-mode__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}
.npd-pro-mode__title::before {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 6px solid var(--text-muted);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform var(--transition);
}
.npd-pro-mode[open] .npd-pro-mode__title::before {
    transform: rotate(90deg);
}
.npd-pro-mode__badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid var(--border);
}
.npd-pro-mode__content {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border);
}

/* ---- Ex-employer conditional field ---- */
.npd-ex-employer-field {
    margin-top: 8px;
    overflow: hidden;
    transition: max-height var(--transition), opacity var(--transition);
}
.npd-ex-employer-field.is-hidden {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}
.npd-ex-employer-field.is-visible {
    max-height: 200px;
    opacity: 1;
}

/* ---- Progress bar (limit 2.4M) ---- */
.npd-progress {
    margin: 12px 0 4px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.npd-progress__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}
.npd-progress__label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.npd-progress__value {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.npd-progress__track {
    height: 10px;
    background: var(--bg-surface);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.npd-progress__fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.4s ease, background 0.3s ease;
    min-width: 0;
}
.npd-progress__fill--green {
    background: var(--success, #10b981);
}
.npd-progress__fill--yellow {
    background: var(--warning, #f59e0b);
}
.npd-progress__fill--red {
    background: var(--danger, #ef4444);
}
.npd-progress__footer {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ---- Overlimit warning block ---- */
.npd-overlimit {
    margin: 12px 0;
    padding: 12px 16px;
    background: var(--danger-bg, rgba(239, 68, 68, 0.08));
    border: 1px solid var(--danger-border, rgba(239, 68, 68, 0.25));
    border-radius: var(--radius-sm);
}
.npd-overlimit__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--danger, #ef4444);
    font-size: 0.95rem;
    margin-bottom: 4px;
}
.npd-overlimit__text {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.npd-overlimit__split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 10px;
}
.npd-overlimit__part {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
}
.npd-overlimit__part-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.npd-overlimit__part-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}
.npd-overlimit__part--npd .npd-overlimit__part-value {
    color: var(--success, #10b981);
}
.npd-overlimit__part--over .npd-overlimit__part-value {
    color: var(--danger, #ef4444);
}

/* ---- Ex-employer warning ---- */
.npd-ex-employer-warning {
    margin: 12px 0;
    padding: 12px 16px;
    background: var(--warning-bg, rgba(245, 158, 11, 0.08));
    border: 1px solid var(--warning-border, rgba(245, 158, 11, 0.25));
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.npd-ex-employer-warning strong {
    color: var(--warning, #f59e0b);
}

/* ---- Result distribution (63/37) ---- */
.npd-distribution {
    display: flex;
    gap: 16px;
    margin-top: 10px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.npd-distribution__item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.npd-distribution__label {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.npd-distribution__value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ---- Expandable sections ---- */
.npd-expandable {
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    overflow: hidden;
}
.npd-expandable__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    list-style: none;
    user-select: none;
    transition: background var(--transition);
}
.npd-expandable__summary:hover {
    background: var(--bg-card-hover);
}
.npd-expandable__summary::-webkit-details-marker {
    display: none;
}
.npd-expandable__summary::marker {
    display: none;
}
.npd-expandable__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
}
.npd-expandable__title::before {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 6px solid var(--text-muted);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform var(--transition);
}
.npd-expandable[open] .npd-expandable__title::before {
    transform: rotate(90deg);
}
.npd-expandable__badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-surface);
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid var(--border);
}
.npd-expandable__content {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border);
}

/* ---- Comparison table (NPD vs IP) ---- */
.npd-comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.npd-comparison-table th,
.npd-comparison-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.npd-comparison-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.82rem;
}
.npd-comparison-table td {
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}
.npd-comparison-table tr:last-child td {
    border-bottom: none;
}
.npd-comparison-table .npd-comparison-table__highlight {
    font-weight: 700;
    color: var(--primary);
}
.npd-comparison-table .npd-comparison-table__savings {
    font-weight: 700;
    color: var(--success, #10b981);
}
.npd-comparison-table .npd-comparison-table__loss {
    font-weight: 700;
    color: var(--danger, #ef4444);
}

/* ---- Detailed breakdown ---- */
.npd-breakdown {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.npd-breakdown__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px dotted var(--border);
    font-size: 0.88rem;
}
.npd-breakdown__row:last-child {
    border-bottom: none;
}
.npd-breakdown__label {
    color: var(--text-secondary);
}
.npd-breakdown__value {
    font-weight: 600;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}
.npd-breakdown__row--total {
    padding-top: 10px;
    border-top: 2px solid var(--border);
    border-bottom: none;
    font-size: 0.95rem;
}
.npd-breakdown__row--total .npd-breakdown__label {
    font-weight: 700;
    color: var(--text-main);
}
.npd-breakdown__row--total .npd-breakdown__value {
    font-size: 1.1rem;
    color: var(--primary);
}

/* ---- Bonus remaining indicator ---- */
.npd-bonus-bar {
    margin: 10px 0;
    padding: 10px 14px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.npd-bonus-bar__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}
.npd-bonus-bar__label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.npd-bonus-bar__value {
    font-size: 0.85rem;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.npd-bonus-bar__value .copy-hint {
    opacity: 0.6;
    transition: opacity 0.2s ease, color 0.2s ease;
    gap: 3px;
    width: auto;
}
.npd-bonus-bar__value .copy-hint span {
    font-size: 0.72rem;
}
.npd-bonus-bar__value:hover .copy-hint {
    opacity: 1;
    color: var(--primary);
}
.npd-bonus-bar__track {
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.npd-bonus-bar__fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* ---- Pension info block ---- */
.npd-pension-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.npd-pension-info__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 8px 12px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.npd-pension-info__label {
    font-size: 0.88rem;
    color: var(--text-secondary);
}
.npd-pension-info__value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

/* ---- Reverse mode result highlight ---- */
.npd-result-highlight--reverse .result-highlight__label {
    color: var(--text-secondary);
}

/* ---- Dark theme overrides ---- */
[data-theme="dark"] .npd-card {
    background: var(--bg-card);
    border-color: var(--border);
}
[data-theme="dark"] .npd-card:has(input:checked),
[data-theme="dark"] .npd-card.is-active {
    background: var(--primary-bg, rgba(59, 130, 246, 0.15));
    border-color: var(--primary);
}
[data-theme="dark"] .npd-pro-mode {
    background: var(--bg-surface);
    border-color: var(--border);
}
[data-theme="dark"] .npd-pro-mode__summary:hover {
    background: var(--bg-card-hover);
}
[data-theme="dark"] .npd-progress {
    background: var(--bg-card);
    border-color: var(--border);
}
[data-theme="dark"] .npd-progress__track {
    background: var(--bg-surface);
    border-color: var(--border);
}
[data-theme="dark"] .npd-overlimit {
    background: var(--danger-bg, rgba(239, 68, 68, 0.12));
    border-color: var(--danger-border, rgba(239, 68, 68, 0.3));
}
[data-theme="dark"] .npd-overlimit__part {
    background: var(--bg-surface);
    border-color: var(--border);
}
[data-theme="dark"] .npd-ex-employer-warning {
    background: var(--warning-bg, rgba(245, 158, 11, 0.12));
    border-color: var(--warning-border, rgba(245, 158, 11, 0.3));
}
[data-theme="dark"] .npd-expandable {
    background: var(--bg-card);
    border-color: var(--border);
}
[data-theme="dark"] .npd-expandable__summary:hover {
    background: var(--bg-card-hover);
}
[data-theme="dark"] .npd-comparison-table th,
[data-theme="dark"] .npd-comparison-table td {
    border-bottom-color: var(--border);
}
[data-theme="dark"] .npd-bonus-bar {
    background: var(--bg-surface);
    border-color: var(--border);
}
[data-theme="dark"] .npd-bonus-bar__track {
    background: var(--bg-card);
    border-color: var(--border);
}
[data-theme="dark"] .npd-distribution {
    background: var(--bg-surface);
    border-color: var(--border);
}
[data-theme="dark"] .npd-pension-info__row {
    background: var(--bg-surface);
    border-color: var(--border);
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
    .npd-cards {
        gap: 6px;
    }
    .npd-card {
        padding: 8px 6px;
    }
    .npd-card__rate {
        font-size: 0.95rem;
    }
    .npd-card__title {
        font-size: 0.82rem;
    }
    .npd-card__sub {
        font-size: 0.68rem;
    }
    .npd-overlimit__split {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .npd-distribution {
        flex-direction: column;
        gap: 8px;
    }
    .npd-comparison-table {
        font-size: 0.82rem;
    }
    .npd-comparison-table th,
    .npd-comparison-table td {
        padding: 6px 8px;
    }
}

@media (max-width: 480px) {
    .npd-cards {
        grid-template-columns: 1fr;
    }
    .npd-mode-toggle .segmented-toggle {
        max-width: 100%;
    }
    .npd-progress__label,
    .npd-progress__value,
    .npd-progress__footer {
        font-size: 0.76rem;
    }
    .npd-overlimit__text,
    .npd-ex-employer-warning,
    .npd-breakdown__row,
    .npd-comparison-table {
        font-size: 0.8rem;
    }
    .calc-glossary {
        font-size: 0.78rem;
    }
}

/* ---- Side-panel compact styles ---- */
.npd-compact-list {
    margin: 0 0 4px !important;
}
.npd-compact-list li {
    font-size: 0.82rem !important;
    line-height: 1.45 !important;
    margin-bottom: 5px !important;
    padding-left: 14px !important;
}
.npd-compact-list li:last-child {
    margin-bottom: 0 !important;
}
.npd-compact-list li::before {
    width: 5px !important;
    height: 5px !important;
    top: 7px !important;
}
.npd-compact-list strong {
    color: var(--text-main);
}

.npd-info-panel {
    padding: 12px 14px !important;
}
.npd-info-panel__heading {
    font-size: 0.78rem !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin: 0 0 6px !important;
}
.npd-info-panel__text {
    font-size: 0.8rem !important;
    line-height: 1.5 !important;
    color: var(--text-secondary);
    margin: 0;
}
.npd-info-panel__text strong {
    color: var(--text-main);
}

/* ---- Side-panel heading compact ---- */
.side-panel .npd-info-panel + .side-panel__section .side-panel__heading,
.side-panel .side-panel__section .side-panel__heading {
    font-size: 0.88rem;
}

/* === Inline style migration === */

/* NPD expandable badge modifiers */
.npd-expandable__badge--success { color: var(--success); }
.npd-expandable__badge--danger { color: var(--danger); }

/* SVG tooltip in distribution labels (fixup #2) */
.npd-distribution__label .calc-rate-tooltip svg {
    vertical-align: middle;
    margin-left: 3px;
    color: var(--text-muted);
}

/* Info box */
.npd-info-box {
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Side-panel summary cursor (fixup #1 — desktop rule, @media covers 768px only) */
.side-panel .side-panel__collapsible > summary {
    cursor: pointer;
    list-style: none;
}
