/* ===========================
   Net Worth Page - Simulation/Calendar Design System
=========================== */

/* Hero */
.nw-hero {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-top: 3px solid var(--brand-purple);
    border-radius: 0;
    padding: 24px;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.nw-hero:hover {
    box-shadow: var(--card-hover-shadow);
    border-color: rgba(180, 100, 255, 0.3);
}

.nw-hero-main {
    text-align: center;
    padding: 12px 0 20px;
    border-bottom: 1px solid var(--border-primary);
    margin-bottom: 20px;
}

.nw-hero-amount {
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
    color: var(--brand-purple);
}

.nw-hero-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.nw-hero-change {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 0;
    margin-top: 8px;
    display: inline-block;
}

.nw-hero-change--pos {
    background-color: rgba(5, 150, 105, 0.12);
    color: var(--success-green);
}

.nw-hero-change--neg {
    background-color: rgba(220, 38, 38, 0.12);
    color: var(--error-red);
}

.nw-hero-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.nw-stat-box {
    background-color: var(--bg-tertiary);
    border-radius: 0;
    padding: 12px;
}

.nw-stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.nw-stat-value {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 3px;
}

.nw-stat-value--green {
    color: var(--success-green);
}

.nw-stat-value--red {
    color: var(--error-red);
}

/* Timerange buttons */
.nw-timerange-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.nw-timerange-btn {
    font-size: 10px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 0;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid transparent;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.nw-timerange-btn:hover {
    background-color: rgba(180, 100, 255, 0.1);
    color: var(--brand-purple);
}

.nw-timerange-btn--active {
    background-color: rgba(180, 100, 255, 0.15);
    color: var(--brand-purple);
}

/* Section cards (Assets / Liabilities) */
.nw-section-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle, var(--border-primary));
    border-radius: 0;
    overflow: hidden;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.nw-section-card:hover {
    box-shadow: var(--card-hover-shadow);
    border-color: rgba(180, 100, 255, 0.3);
}

.nw-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-primary);
}

.nw-section-title {
    font-size: var(--font-size-base);
    font-weight: 700;
    color: var(--text-primary);
}

.nw-section-badge {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 0;
    box-shadow: none;
}

.nw-section-badge--lg {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
}

.nw-section-badge--green {
    background: color-mix(in srgb, var(--success-green) 14%, transparent);
    color: var(--success-green);
}

.nw-section-badge--red {
    background: color-mix(in srgb, var(--error-red) 14%, transparent);
    color: var(--error-red);
}

.nw-section-body {
    flex: 1;
    overflow-y: auto;
    max-height: 280px;
}

.nw-section-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
}

.nw-section-total-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.nw-section-total-value {
    font-size: var(--font-size-lg);
    font-weight: 700;
}

.nw-category-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 8px 12px 4px;
}

/* Item rows */
.nw-item-row {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-primary);
    min-height: 48px;
    position: relative;
}

.nw-item-row:last-child {
    border-bottom: none;
}

.nw-item-row:hover .nw-item-actions {
    opacity: 1;
}

.nw-item-bar {
    width: 2px;
    min-height: 32px;
    flex-shrink: 0;
    margin-right: 12px;
}

.nw-item-bar--asset {
    background: var(--success-green);
}

.nw-item-bar--liability {
    background: var(--error-red);
}

.nw-item-info {
    flex: 1;
    min-width: 0;
}

.nw-item-name {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.nw-item-institution {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.nw-item-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nw-item-value {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-primary);
}

.nw-item-synced {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 0;
    background-color: rgba(180, 100, 255, 0.15);
    color: var(--brand-purple);
}

/* Sleek link style - no blue underline */
.nw-edit-savings-link {
    color: var(--brand-purple);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--font-size-xs);
    transition: opacity 0.2s ease;
}
.nw-edit-savings-link:hover {
    opacity: 0.8;
}

.nw-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.nw-item-actions .btn {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 0;
}

/* Add button */
.nw-add-btn {
    width: 100%;
    border: 1.5px dashed var(--border-primary);
    border-radius: 0;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    background: transparent;
    padding: 12px;
    transition: border-color 0.2s, color 0.2s;
}

.nw-add-btn:hover {
    border-color: var(--brand-purple);
    color: var(--brand-purple);
}

.nw-section-card .p-2 {
    flex-shrink: 0;
    border-top: 1px solid var(--border-primary);
}

/* Empty state */
.nw-empty-state {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* Metrics row */
.nw-metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.nw-metric-box {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-subtle, var(--border-primary));
    border-radius: 0;
    padding: 12px;
}

.nw-metric-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.nw-metric-value {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 3px;
}

.nw-metric-sub {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.nw-metric-sub--green {
    color: var(--success-green);
}

.nw-metric-sub--red {
    color: var(--error-red);
}

.nw-prog-wrap {
    margin-top: 8px;
}

.nw-prog-track {
    height: 6px;
    background-color: var(--bg-primary);
    border-radius: 0;
    overflow: hidden;
}

.nw-prog-fill {
    height: 100%;
    border-radius: 0;
    transition: width 0.6s ease;
}

.nw-prog-fill--green {
    background-color: var(--success-green);
}

.nw-prog-fill--amber {
    background-color: var(--warning-yellow);
}

/* Value History Modal - card-based design (mirrors csv-mapper-card) */
#nw-history-modal .modal-body {
    overflow: visible;
}

.nw-history-table-container {
    margin-bottom: var(--spacing-md, 16px);
}

/* Card container - mirrors .csv-mapper-card */
.nw-history-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-subtle, var(--border-primary));
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
    margin-bottom: var(--spacing-md, 16px);
}

.nw-history-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 2px;
    background: var(--brand-purple);
}

.nw-history-card:hover {
    box-shadow: var(--card-hover-shadow);
    border-color: rgba(180, 100, 255, 0.3);
}

/* Card header - mirrors .csv-mapper-card-header */
.nw-history-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--spacing-sm, 8px);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-subtle, var(--border-primary));
    background-color: var(--bg-primary);
}

/* Card body - mirrors .csv-mapper-card-body */
.nw-history-card-body {
    padding: 10px 12px 12px;
}

/* Value table - mirrors .csv-mapper-before-table */
.nw-history-value-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
}

.nw-history-value-table thead {
    background: var(--bg-secondary);
}

.nw-history-value-table th {
    padding: 9px 10px;
    text-align: left;
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-xs);
    border-bottom: 1px solid var(--border-subtle, var(--border-primary));
    white-space: nowrap;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.nw-history-value-table td {
    padding: 8px 10px;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    border-bottom: 1px solid var(--border-subtle, var(--border-primary));
}

.nw-history-value-table tbody tr:last-child td {
    border-bottom: none;
}

.nw-history-table-scroll {
    max-height: 280px;
    overflow-y: auto;
}

.nw-history-row:hover {
    background-color: var(--bg-tertiary);
}

.nw-history-row--current {
    background-color: var(--bg-tertiary);
}

.nw-history-row-actions {
    display: flex;
    gap: 4px;
}

.nw-history-pending-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.nw-history-add-row-btn {
    font-size: 0.9rem;
    color: var(--brand-purple) !important;
    text-decoration: none !important;
    font-weight: 500;
    transition: opacity 0.2s ease;
}
.nw-history-add-row-btn:hover {
    opacity: 0.8;
    color: var(--brand-purple) !important;
    text-decoration: none !important;
}

.nw-history-pending-delete {
    cursor: pointer;
}

.nw-history-edit-form-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 576px) {
    .nw-history-add-row,
    .nw-history-pending-row {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Add/Edit Modal - Category info banner and mortgage section */
.nw-modal-category-info {
    display: none;
    padding: 12px;
    margin-top: 12px;
    background-color: rgba(180, 100, 255, 0.08);
    border: 1px solid rgba(180, 100, 255, 0.25);
    border-radius: 0;
}

.nw-modal-go-savings-btn {
    font-size: var(--font-size-sm);
}

.nw-modal-mortgage-section {
    padding: 12px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-subtle, var(--border-primary));
    border-radius: 0;
}

.nw-modal-equity-value {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--success-green);
}

.nw-modal-mortgage-error {
    font-size: var(--font-size-sm);
    color: var(--error-red);
}

/* Responsive */
@media (max-width: 768px) {
    .nw-hero-amount {
        font-size: 36px;
    }

    .nw-hero-stats {
        grid-template-columns: 1fr;
    }

    .nw-metrics-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .nw-item-actions {
        opacity: 1;
    }

    .nw-section-body {
        max-height: 220px;
    }

    /* Net Worth chart cards: prevent compression on mobile (donut + line) */
    .net-worth-page-content .col-12:has(#nw-expand-donut) .metric-card,
    .net-worth-page-content .col-12:has(#nw-expand-line) .metric-card {
        min-height: 400px !important;
    }
    .net-worth-page-content .col-12:has(#nw-expand-donut) .metric-card .card-body > div,
    .net-worth-page-content .col-12:has(#nw-expand-line) .metric-card .card-body > div {
        min-height: 350px !important;
        flex: none !important;
    }
    .net-worth-page-content .col-12:has(#nw-expand-donut) .dash-graph,
    .net-worth-page-content .col-12:has(#nw-expand-line) .dash-graph {
        min-height: 350px !important;
        flex: none !important;
    }
}

@media (max-width: 576px) {
    .nw-metrics-row {
        grid-template-columns: 1fr;
    }

    .nw-hero {
        padding: 16px;
    }
}
