/* ── Design Tokens (mirrored from onboarding/style.css) ────────────────── */
:root {
    --bg: #FAFAF8;
    --bg-warm:      #FFFFFF;
    --paper:        #FFFFFF;
    --paper-white:  #FFFFFF;
    --ink:          #0F2D21;
    --ink-soft:     #244135;
    --muted:        #5C6E64;
    --rule:         rgba(15, 45, 33, 0.10);
    --rule-soft:    rgba(15, 45, 33, 0.06);
    --accent:       #B8541A;
    --accent-deep:  #8E3F12;
    --accent-soft:  #FDEEE4;
    --accent-light: #FFF2E6;
    --mint-100:     #E6F7F0;
    --mint-600:     #047857;

    --serif:      'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --sans:       'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-title: 'Plus Jakarta Sans', var(--sans);

    --radius-sm:   4px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(15,45,33,0.04);
    --shadow-md: 0 8px 24px rgba(15,45,33,0.07);
    --shadow-lg: 0 16px 48px rgba(15,45,33,0.10);

    --transition: all 0.3s cubic-bezier(0.16,1,0.3,1);

    --nav-width: 220px;
    --header-h:  60px;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Paper grain overlay disabled */
body::before {
    display: none;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.profile-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--paper);
    border-bottom: 1px solid var(--rule-soft);
    gap: 16px;
}

.profile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--accent);
    flex-shrink: 0;
}
.profile-logo svg { flex-shrink: 0; }
.profile-logo-text {
    font-family: var(--serif);
    font-size: 20px;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.profile-logo-text span { color: var(--accent); }

.profile-header-center { flex: 1; text-align: center; }
.profile-header-title {
    font-family: var(--font-title);
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
}

.profile-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}
.profile-back-link {
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.2s;
}
.profile-back-link:hover { color: var(--ink); }
.profile-logout-btn {
    font-size: 13px;
    font-family: var(--sans);
    font-weight: 500;
    color: var(--muted);
    background: none;
    border: 1px solid var(--rule);
    border-radius: var(--radius-full);
    padding: 4px 14px;
    cursor: pointer;
    transition: var(--transition);
}
.profile-logout-btn:hover {
    color: var(--ink);
    border-color: var(--ink);
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.profile-layout {
    display: flex;
    min-height: calc(100vh - var(--header-h));
}

/* ── Left Nav ───────────────────────────────────────────────────────────── */
.profile-nav {
    width: var(--nav-width);
    flex-shrink: 0;
    border-right: 1px solid var(--rule-soft);
    background: var(--paper);
    padding: 20px 0;
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
}

.profile-nav-list {
    list-style: none;
}

.profile-nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink-soft);
    border-left: 3px solid transparent;
    transition: var(--transition);
    user-select: none;
}
.profile-nav-item:hover {
    background: var(--bg-warm);
    color: var(--ink);
}
.profile-nav-item.active {
    background: var(--accent-light);
    border-left-color: var(--accent);
    color: var(--accent-deep);
    font-weight: 600;
}
.profile-nav-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--mint-600);
    background: var(--mint-100);
    border-radius: var(--radius-full);
    padding: 2px 6px;
    letter-spacing: 0.02em;
}

/* ── Main Pane ──────────────────────────────────────────────────────────── */
.profile-main {
    flex: 1;
    padding: 32px 40px;
    max-width: 720px;
}

/* Loading state */
.profile-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    min-height: 300px;
    color: var(--muted);
    font-size: 14px;
}
.profile-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--rule);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Section Card ───────────────────────────────────────────────────────── */
.section-card {
    background: var(--paper);
    border: 1px solid var(--rule-soft);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    box-shadow: var(--shadow-sm);
}

.section-title {
    font-family: var(--font-title);
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.section-subtitle {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 28px;
}

/* ── Form Elements ──────────────────────────────────────────────────────── */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.form-row.single { grid-template-columns: 1fr; }
.form-row.triple { grid-template-columns: 1fr 1fr 1fr; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-group.full { grid-column: 1 / -1; }

.form-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    font-family: var(--sans);
    font-size: 14px;
    color: var(--ink);
    background: var(--paper-white);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    padding: 10px 13px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(184,84,26,0.12);
}
.form-input:read-only {
    background: var(--bg-warm);
    color: var(--muted);
    cursor: not-allowed;
}
.form-select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%236F6859' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.form-textarea {
    resize: vertical;
    min-height: 90px;
}

/* Read-only field */
.form-readonly {
    font-size: 14px;
    color: var(--muted);
    background: var(--bg-warm);
    border: 1px solid var(--rule-soft);
    border-radius: var(--radius-md);
    padding: 10px 13px;
}

/* ── Toggle / Checkbox group ────────────────────────────────────────────── */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--rule-soft);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 14px; color: var(--ink-soft); }

.toggle {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
    position: absolute; inset: 0;
    background: var(--rule);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background 0.2s;
}
.toggle-track::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    top: 3px; left: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::before { transform: translateX(18px); }

/* Checkbox group (investments) */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    margin-top: 4px;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 13.5px;
    color: var(--ink-soft);
    transition: var(--transition);
    user-select: none;
}
.checkbox-item:hover { border-color: var(--accent-soft); background: var(--accent-light); }
.checkbox-item.checked {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent-deep);
    font-weight: 600;
}
.checkbox-item input { display: none; }

/* Radio pill group */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}
.radio-pill {
    padding: 7px 16px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-full);
    font-size: 13.5px;
    color: var(--ink-soft);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}
.radio-pill:hover { border-color: var(--accent-soft); background: var(--accent-light); }
.radio-pill.selected {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent-deep);
    font-weight: 600;
}
.radio-pill input { display: none; }

/* ── Asset Mix Sliders ──────────────────────────────────────────────────── */
.asset-mix-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.asset-mix-label {
    width: 90px;
    font-size: 13px;
    color: var(--ink-soft);
    font-weight: 500;
    flex-shrink: 0;
}
.asset-mix-slider {
    flex: 1;
    accent-color: var(--accent);
    cursor: pointer;
}
.asset-mix-value {
    width: 38px;
    text-align: right;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    flex-shrink: 0;
}
.asset-mix-total {
    margin-top: 8px;
    font-size: 13px;
    color: var(--muted);
}
.asset-mix-total.error { color: #c0392b; font-weight: 600; }

/* ── Loan section ───────────────────────────────────────────────────────── */
.loan-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

/* ── Goals repeater ─────────────────────────────────────────────────────── */
.goal-row {
    display: grid;
    grid-template-columns: 1fr 140px 100px 32px;
    gap: 8px;
    align-items: end;
    margin-bottom: 10px;
}
.goal-row-remove {
    height: 38px;
    width: 32px;
    background: none;
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.goal-row-remove:hover { border-color: #c0392b; color: #c0392b; }
.add-goal-btn {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    background: none;
    border: 1px dashed var(--accent-soft);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 4px;
}
.add-goal-btn:hover { background: var(--accent-light); border-style: solid; }

/* ── Save Button ────────────────────────────────────────────────────────── */
.save-row {
    margin-top: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.btn-save {
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 700;
    color: white;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-md);
    padding: 11px 28px;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.01em;
}
.btn-save:hover { background: var(--accent-deep); }
.btn-save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.save-status {
    font-size: 13px;
    color: var(--muted);
}

/* ── Nav: account-actions divider ──────────────────────────────────────── */
.profile-nav-divider {
    height: 1px;
    margin: 10px 20px;
    background: var(--rule-soft);
    list-style: none;
}

/* ── Settings section ───────────────────────────────────────────────────── */
.settings-card {
    background: var(--paper-white, #FFFFFF);
    border: 1px solid var(--rule-soft);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
}
.settings-card-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--ink);
    margin-bottom: 6px;
}
.settings-card-sub {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
    margin-bottom: 14px;
}
.btn-settings-danger {
    font-family: var(--sans);
    font-size: 13.5px;
    font-weight: 700;
    color: #B3261E;
    background: rgba(179, 38, 30, 0.08);
    border: 1px solid rgba(179, 38, 30, 0.25);
    border-radius: var(--radius-md);
    padding: 9px 18px;
    cursor: pointer;
    transition: var(--transition);
}
.btn-settings-danger:hover { background: rgba(179, 38, 30, 0.14); }
.btn-settings-danger:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Settings confirm modal ─────────────────────────────────────────────── */
.settings-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(21, 23, 28, 0.45);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.settings-modal-sheet {
    background: var(--paper-white, #FFFFFF);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}
.settings-modal-title {
    font-family: var(--font-title);
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 10px;
}
.settings-modal-body {
    font-size: 13.5px;
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 22px;
}
.settings-modal-actions {
    display: flex;
    gap: 10px;
}
.btn-settings-cancel {
    font-family: var(--sans);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: var(--radius-md);
    padding: 9px 18px;
    cursor: pointer;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.profile-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast-msg {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    opacity: 1;
    transition: opacity 0.4s;
    pointer-events: auto;
}
.toast-msg.success {
    background: var(--mint-100);
    color: var(--mint-600);
    border: 1px solid rgba(19,115,51,0.2);
}
.toast-msg.error {
    background: #fdecea;
    color: #c0392b;
    border: 1px solid rgba(192,57,43,0.2);
}
.toast-msg.fade-out { opacity: 0; }

/* ── Mobile (accordion) ─────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .profile-header { padding: 0 16px; }
    .profile-header-center { display: none; }
    .profile-back-link { display: none; }

    .profile-layout { flex-direction: column; }

    .profile-nav {
        position: static;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--rule-soft);
        padding: 0;
    }
    .profile-nav-item {
        border-left: none;
        border-bottom: 1px solid var(--rule-soft);
        padding: 14px 20px;
    }
    .profile-nav-item.active { border-left: none; }

    .profile-main { padding: 20px 16px; max-width: 100%; }

    .form-row { grid-template-columns: 1fr; }
    .form-row.triple { grid-template-columns: 1fr; }

    .loan-grid { grid-template-columns: 1fr; }

    .goal-row {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }
    .goal-row-remove { grid-column: 2; grid-row: 2; }
}

@media (max-width: 480px) {
    .section-card { padding: 20px 16px; }
}
