/* ═══════════════════════════════════════════════
   ROOT & RESET
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --brand:       #37517e;
    --brand-dark:  #2a3e61;
    --brand-light: #4a6699;
    --brand-pale:  #eef1f6;
    --brand-muted: rgba(55,81,126,0.10);
    --surface:     #ffffff;
    --bg:          #f4f6fb;
    --text:        #1a2742;
    --text-muted:  #6b7a99;
    --border:      rgba(55,81,126,0.14);
    --success:     #059669;
    --radius-lg:   18px;
    --radius-md:   12px;
    --radius-sm:   8px;
    --shadow-card: 0 4px 28px rgba(55,81,126,0.10);
    --shadow-hover:0 12px 36px rgba(55,81,126,0.16);
    --transition:  all 0.22s ease;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ═══════════════════════════════════════════════
   TOP NAV
═══════════════════════════════════════════════ */
.topnav {
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%);
    padding: .9rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 20px rgba(26,39,66,0.18);
}
.topnav .brand {
    font-family: 'DM Serif Display', serif;
    font-size: 1.15rem;
    color: #fff;
    letter-spacing: .01em;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.topnav .brand i { font-size: 1.3rem; opacity: .85; }
.home-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,0.22);
    border-radius: var(--radius-sm);
    padding: .38rem .9rem;
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}
.home-btn:hover {
    background: rgba(255,255,255,0.22);
    color: #fff;
    transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════
   PAGE WRAPPER
═══════════════════════════════════════════════ */
.page-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

.page-intro {
    margin-bottom: 2rem;
}
.page-intro h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.75rem;
    color: var(--brand-dark);
    margin-bottom: .3rem;
}
.page-intro p {
    color: var(--text-muted);
    font-size: .9rem;
    max-width: 560px;
}

/* ═══════════════════════════════════════════════
   TAB NAVIGATION
═══════════════════════════════════════════════ */
.calc-tabs {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: 1.75rem;
}
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem 1.05rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.tab-btn i { font-size: 1rem; }
.tab-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
    transform: translateY(-1px);
}
.tab-btn.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    box-shadow: 0 4px 14px rgba(55,81,126,0.25);
}

/* ═══════════════════════════════════════════════
   CALCULATOR PANELS
═══════════════════════════════════════════════ */
.calc-panel { display: none; }
.calc-panel.active { display: block; animation: fadeUp .28s ease; }

@keyframes fadeUp {
    from { opacity:0; transform: translateY(10px); }
    to   { opacity:1; transform: translateY(0); }
}

.calc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 720px) {
    .calc-grid { grid-template-columns: 1fr; }
}

/* ─── Input card ─── */
.input-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 1.75rem;
    border: 1px solid var(--border);
}
.input-card h3 {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--brand);
    border-left: 3px solid var(--brand);
    padding-left: .6rem;
    margin-bottom: 1.3rem;
}

.field { margin-bottom: 1.1rem; }
.field label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: .35rem;
}
.field label span {
    font-size: .75rem;
    color: var(--brand-light);
    font-weight: 700;
}

.input-wrap { position: relative; }
.input-wrap .prefix {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    font-size: .82rem;
    font-weight: 700;
    color: var(--brand);
    pointer-events: none;
    z-index: 2;
}
.input-wrap .suffix {
    position: absolute;
    right: 12px; top: 50%;
    transform: translateY(-50%);
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
}
.input-wrap input[type="number"],
.input-wrap input[type="text"] {
    width: 100%;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: .6rem .6rem .6rem 2.2rem;
    font-size: .95rem;
    font-weight: 600;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    transition: border-color .15s, box-shadow .15s;
    background: #fff;
    appearance: none;
    -moz-appearance: textfield;
}
.input-wrap input::-webkit-inner-spin-button,
.input-wrap input::-webkit-outer-spin-button { -webkit-appearance: none; }
.input-wrap input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(55,81,126,0.14);
}
.input-wrap.no-prefix input { padding-left: .75rem; }
.input-wrap.has-suffix input { padding-right: 2.4rem; }

/* Slider */
.range-wrap { margin-top: .5rem; }
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 99px;
    background: linear-gradient(to right, var(--brand) var(--pct, 0%), #e2e8f0 var(--pct, 0%));
    outline: none;
    cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--brand);
    border: 2.5px solid #fff;
    box-shadow: 0 2px 8px rgba(55,81,126,0.30);
    cursor: pointer;
}

/* ─── Result card ─── */
.result-card {
    background: linear-gradient(145deg, var(--brand-dark), var(--brand));
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hover);
    padding: 1.75rem;
    color: #fff;
    position: sticky;
    top: 80px;
}
.result-card .result-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
    opacity: .65;
    margin-bottom: .2rem;
}
.result-card .result-main {
    font-family: 'DM Serif Display', serif;
    font-size: 2.5rem;
    line-height: 1.1;
    margin-bottom: 1.2rem;
    letter-spacing: -.01em;
}
.result-card .result-main small {
    font-family: 'DM Sans', sans-serif;
    font-size: .9rem;
    opacity: .7;
    font-weight: 400;
}

.breakdown {
    background: rgba(255,255,255,0.08);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .65rem;
}
.breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .82rem;
}
.breakdown-row .bk-label { opacity: .72; }
.breakdown-row .bk-value { font-weight: 700; }
.breakdown-row.highlight .bk-label,
.breakdown-row.highlight .bk-value {
    font-size: .9rem;
    font-weight: 800;
    opacity: 1;
}

.divider { border: none; border-top: 1px solid rgba(255,255,255,0.15); }

/* Progress bar inside result */
.result-bar-wrap { margin-top: 1rem; }
.result-bar-wrap .bar-label {
    display: flex; justify-content: space-between;
    font-size: .72rem; opacity: .7; margin-bottom: .35rem;
}
.result-bar {
    height: 6px;
    background: rgba(255,255,255,0.15);
    border-radius: 99px;
    overflow: hidden;
}
.result-bar-fill {
    height: 100%;
    border-radius: 99px;
    background: rgba(255,255,255,0.75);
    transition: width .5s ease;
}

/* Tip box */
.tip-box {
    background: rgba(255,255,255,0.10);
    border-radius: var(--radius-sm);
    padding: .65rem .9rem;
    font-size: .78rem;
    opacity: .85;
    margin-top: 1rem;
    line-height: 1.5;
    display: flex;
    gap: .4rem;
}
.tip-box i { flex-shrink:0; margin-top: 1px; }

/* ─── JOIN US BUTTON ─── */
.join-us-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    margin-top: 1.1rem;
    padding: .72rem 1.2rem;
    background: rgba(255,255,255,0.18);
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: var(--radius-md);
    color: #fff;
    font-family: 'DM Sans', sans-serif;
    font-size: .85rem;
    font-weight: 700;
    letter-spacing: .04em;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}
.join-us-btn:hover {
    background: rgba(255,255,255,0.30);
    border-color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.20);
    color: #fff;
}
.join-us-btn i { font-size: 1rem; }

/* Networth — multi-section */
.nw-section {
    margin-bottom: 1.2rem;
}
.nw-section-title {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--brand-light);
    margin-bottom: .7rem;
    display: flex;
    align-items: center;
    gap: .4rem;
}
.nw-section-title i { font-size: .9rem; }

.add-row-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .75rem;
    font-weight: 600;
    color: var(--brand);
    background: var(--brand-pale);
    border: none;
    border-radius: var(--radius-sm);
    padding: .3rem .7rem;
    cursor: pointer;
    transition: var(--transition);
    margin-top: .5rem;
}
.add-row-btn:hover { background: var(--brand); color: #fff; }

.dynamic-row {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin-bottom: .5rem;
}
.dynamic-row input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: .5rem .75rem;
    font-size: .85rem;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    color: var(--text);
}
.dynamic-row input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(55,81,126,0.12);
}
.dynamic-row .del-btn {
    background: none;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-sm);
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: #dc3545;
    font-size: .9rem;
    flex-shrink: 0;
    transition: var(--transition);
}
.dynamic-row .del-btn:hover { background: #fff0f0; border-color: #dc3545; }

/* ─── Net-worth result pill colors ─── */
.nw-positive { color: #6ee7b7; }
.nw-negative { color: #fca5a5; }

/* ─── Budget category bars ─── */
.budget-cat-bar {
    height: 4px;
    border-radius: 99px;
    margin-top: 3px;
    transition: width .4s ease;
}

/* ─── Select styling ─── */
.styled-select {
    width: 100%;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: .6rem .75rem;
    font-family: 'DM Sans', sans-serif;
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
    background: #fff;
    appearance: none;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}
.styled-select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(55,81,126,0.14);
}

/* ─── Footer note ─── */
.page-footer {
    text-align: center;
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 2.5rem;
    opacity: .7;
    line-height: 1.6;
}

/* ─── Join Us Modal ─── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26,39,66,0.55);
    backdrop-filter: blur(6px);
    z-index: 999;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; animation: fadeUp .25s ease; }
.modal-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 64px rgba(26,39,66,0.25);
    padding: 2.5rem;
    max-width: 420px;
    width: 90%;
    position: relative;
    text-align: center;
}
.modal-box .modal-icon {
    width: 60px; height: 60px;
    background: var(--brand-pale);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.6rem;
    color: var(--brand);
}
.modal-box h2 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    color: var(--brand-dark);
    margin-bottom: .4rem;
}
.modal-box p {
    font-size: .88rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.4rem;
}
.modal-input {
    width: 100%;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: .65rem 1rem;
    font-family: 'DM Sans', sans-serif;
    font-size: .9rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: .75rem;
    transition: border-color .15s, box-shadow .15s;
}
.modal-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(55,81,126,0.14);
}
.modal-submit {
    width: 100%;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: .78rem;
    font-family: 'DM Sans', sans-serif;
    font-size: .92rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: .02em;
}
.modal-submit:hover { opacity: .9; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(55,81,126,0.28); }
.modal-close {
    position: absolute;
    top: 1rem; right: 1rem;
    background: var(--brand-pale);
    border: none;
    border-radius: 50%;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--brand);
    font-size: 1rem;
    transition: var(--transition);
}
.modal-close:hover { background: var(--brand); color: #fff; }
.modal-success { display: none; }
.modal-success.show { display: block; animation: fadeUp .3s ease; }
.modal-form.hide { display: none; }