/* ============================================================
   RETIREMENT — PREMIUM DASHBOARD  (scoped to retirement only)
   Page content lives under .rt-page
   Modals inject into #rt-modal-container (a sibling of .rt-page)
   Uses global theme vars: --surface, --primary, --text,
   --text-muted, --border, --shadow, --radius, --success
   ============================================================ */

/* Shared design tokens — defined on BOTH roots so the injected
   modal markup (outside .rt-page) still resolves the variables. */
.rt-page,
#rt-modal-container {
    --rt-radius: 18px;
    --rt-radius-sm: 12px;
    --rt-gap: 18px;
    --rt-primary: var(--primary, #4A6CF7);
    --rt-success: var(--success, #22c55e);
    --rt-danger: #ef4444;
    --rt-warn: #f59e0b;
    --rt-card-border: var(--border, rgba(0,0,0,0.08));
}

.rt-page {
    display: flex;
    flex-direction: column;
    gap: var(--rt-gap);
    padding: 8px 0 32px;
}

/* ---------------- HERO ---------------- */
.rt-page .rt-hero {
    position: relative;
    overflow: hidden;
    border-radius: 22px;
    padding: 28px 28px;
    background: linear-gradient(135deg, #4A6CF7 0%, #6C5CE7 55%, #8B5CF6 100%);
    box-shadow: 0 14px 40px rgba(74,108,247,0.28);
}

.rt-page .rt-hero-glow {
    position: absolute;
    top: -80px;
    right: -40px;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 70%);
    pointer-events: none;
}

.rt-page .rt-hero-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.rt-page .rt-eyebrow {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: rgba(255,255,255,0.82);
    margin-bottom: 6px;
}

.rt-page .rt-hero-text h1 {
    margin: 0;
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.rt-page .rt-hero-text p {
    margin: 6px 0 0;
    color: rgba(255,255,255,0.88);
    font-size: 0.92rem;
    max-width: 46ch;
}

/* ---------------- BUTTONS (page) ---------------- */
.rt-page .rt-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 12px;
    padding: 11px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.rt-page .rt-btn-primary {
    background: #fff;
    color: var(--rt-primary);
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

.rt-page .rt-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}

.rt-page .rt-btn-ghost {
    background: transparent;
    color: var(--rt-primary);
    padding: 6px 12px;
    border: 1px solid var(--rt-card-border);
}

.rt-page .rt-btn-ghost:hover { background: color-mix(in srgb, var(--rt-primary) 10%, transparent); }

.rt-page .rt-btn-ico { font-size: 1.1rem; line-height: 1; }

/* ---------------- KPI CARDS ---------------- */
.rt-page .rt-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--rt-gap);
}

.rt-page .rt-kpi {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--rt-card-border);
    border-radius: var(--rt-radius);
    padding: 18px;
    box-shadow: var(--shadow, 0 4px 20px rgba(0,0,0,0.05));
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rt-page .rt-kpi:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0,0,0,0.10); }

.rt-page .rt-kpi-accent {
    background: linear-gradient(135deg, color-mix(in srgb, var(--rt-primary) 12%, var(--surface)), var(--surface));
    border-color: color-mix(in srgb, var(--rt-primary) 28%, transparent);
}

.rt-page .rt-kpi-ico {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    background: color-mix(in srgb, var(--rt-primary) 12%, transparent);
}

.rt-page .rt-ico-monthly  { background: color-mix(in srgb, #06b6d4 16%, transparent); }
.rt-page .rt-ico-projected{ background: color-mix(in srgb, #8b5cf6 16%, transparent); }
.rt-page .rt-ico-income   { background: color-mix(in srgb, var(--rt-success) 18%, transparent); }

.rt-page .rt-kpi-body { display: flex; flex-direction: column; min-width: 0; }

.rt-page .rt-kpi-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.rt-page .rt-kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rt-page .rt-kpi-sub { font-size: 0.74rem; color: var(--text-muted); margin-top: 2px; }

/* ---------------- LAYOUT GRIDS ---------------- */
.rt-page .rt-grid-2-3 {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: var(--rt-gap);
    align-items: stretch;
}

.rt-page .rt-grid-bottom { align-items: start; }

/* ---------------- CARDS ---------------- */
.rt-page .rt-card {
    background: var(--surface);
    border: 1px solid var(--rt-card-border);
    border-radius: var(--rt-radius);
    padding: 20px;
    box-shadow: var(--shadow, 0 4px 20px rgba(0,0,0,0.05));
    display: flex;
    flex-direction: column;
}

.rt-page .rt-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 10px;
}

.rt-page .rt-card-head h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.rt-page .rt-card-note { font-size: 0.76rem; color: var(--text-muted); }

.rt-page .rt-card-foot {
    margin: 12px 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.rt-page .rt-card-foot strong { color: var(--text); }

/* ---------------- BADGES ---------------- */
.rt-page .rt-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
}

.rt-page .rt-badge-good { background: color-mix(in srgb, var(--rt-success) 18%, transparent); color: var(--rt-success); }
.rt-page .rt-badge-ok   { background: color-mix(in srgb, var(--rt-primary) 16%, transparent); color: var(--rt-primary); }
.rt-page .rt-badge-warn { background: color-mix(in srgb, var(--rt-warn) 20%, transparent); color: #b45309; }
.rt-page .rt-badge-bad  { background: color-mix(in srgb, var(--rt-danger) 18%, transparent); color: var(--rt-danger); }

/* ---------------- GAUGE ---------------- */
.rt-page .rt-gauge-wrap { position: relative; }

.rt-page .rt-gauge-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.rt-page .rt-gauge-pct { font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1; }
.rt-page .rt-gauge-cap { font-size: 0.74rem; color: var(--text-muted); margin-top: 2px; }

.rt-page .rt-gauge-foot {
    display: flex;
    justify-content: space-around;
    gap: 12px;
    margin-top: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--rt-card-border);
}

.rt-page .rt-gauge-foot > div { display: flex; flex-direction: column; align-items: center; }

.rt-page .rt-mini-label { font-size: 0.72rem; color: var(--text-muted); }
.rt-page .rt-mini-value { font-size: 1rem; font-weight: 700; color: var(--text); }
.rt-page .rt-strong { color: var(--rt-primary); }

/* ---------------- INCOME BANNER ---------------- */
.rt-page .rt-income-banner {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    margin-bottom: 14px;
    border-radius: var(--rt-radius-sm);
    background: linear-gradient(135deg, color-mix(in srgb, var(--rt-success) 12%, var(--surface)), var(--surface));
    border: 1px solid color-mix(in srgb, var(--rt-success) 24%, transparent);
}

.rt-page .rt-income-big { font-size: 1.7rem; font-weight: 800; color: var(--rt-success); line-height: 1.1; display: block; }
.rt-page .rt-income-year { text-align: right; }

/* ---------------- ACCOUNT LIST ---------------- */
.rt-page .rt-accounts-card { gap: 4px; }

.rt-page .rt-account-list { display: flex; flex-direction: column; gap: 12px; }

.rt-page .rt-account {
    border: 1px solid var(--rt-card-border);
    border-radius: var(--rt-radius-sm);
    padding: 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    cursor: pointer;
    background: color-mix(in srgb, var(--rt-primary) 3%, var(--surface));
}

.rt-page .rt-account:hover {
    border-color: color-mix(in srgb, var(--rt-primary) 40%, transparent);
    box-shadow: 0 8px 20px rgba(74,108,247,0.10);
    transform: translateY(-1px);
}

.rt-page .rt-account--active {
    border-color: var(--rt-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--rt-primary) 35%, transparent);
    background: color-mix(in srgb, var(--rt-primary) 8%, var(--surface));
}

.rt-page .rt-account-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.rt-page .rt-account-id { display: flex; align-items: center; gap: 12px; min-width: 0; }

.rt-page .rt-account-avatar {
    flex: 0 0 auto;
    width: 40px; height: 40px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-weight: 700; color: #fff;
    background: linear-gradient(135deg, var(--rt-primary), #8b5cf6);
}

.rt-page .rt-account-meta { display: flex; flex-direction: column; min-width: 0; }
.rt-page .rt-account-name { font-weight: 700; color: var(--text); font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-page .rt-account-provider { font-size: 0.76rem; color: var(--text-muted); }

.rt-page .rt-account-balance { text-align: right; flex: 0 0 auto; }
.rt-page .rt-account-bal-value { display: block; font-weight: 700; color: var(--text); font-size: 1rem; }
.rt-page .rt-account-return { font-size: 0.74rem; color: var(--rt-success); font-weight: 600; }

.rt-page .rt-account-progress { margin-top: 12px; }

.rt-page .rt-account-bar {
    height: 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-muted) 18%, transparent);
    overflow: hidden;
}

.rt-page .rt-account-bar > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--rt-primary), #8b5cf6);
}

.rt-page .rt-account-progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.rt-page .rt-account-progress-meta--solo { margin-top: 12px; }

.rt-page .rt-account-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.rt-page .rt-chip {
    border: 1px solid var(--rt-card-border);
    background: var(--surface);
    color: var(--text);
    border-radius: 9px;
    padding: 6px 10px;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.rt-page .rt-chip:hover { border-color: var(--rt-primary); color: var(--rt-primary); background: color-mix(in srgb, var(--rt-primary) 8%, transparent); }
.rt-page .rt-chip-danger:hover { border-color: var(--rt-danger); color: var(--rt-danger); background: color-mix(in srgb, var(--rt-danger) 8%, transparent); }

.rt-page .rt-accounts-empty { padding: 20px; color: var(--text-muted); text-align: center; }

/* ---------------- PROJECTION DRILL-DOWN ---------------- */
.rt-page .rt-projection-stats { display: flex; gap: 24px; margin-bottom: 8px; }
.rt-page .rt-projection-stats > div { display: flex; flex-direction: column; }

.rt-page .rt-projection-summary { margin: 10px 0 0; font-size: 0.82rem; color: var(--text-muted); line-height: 1.45; }

.rt-page .rt-chart-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 240px;
    color: var(--text-muted);
    font-size: 0.88rem;
    text-align: center;
}

.rt-page .rt-placeholder-ico { font-size: 2rem; opacity: 0.7; }

/* ---------------- EMPTY STATE ---------------- */
.rt-page .rt-empty {
    text-align: center;
    padding: 56px 24px;
    background: var(--surface);
    border: 1px dashed var(--rt-card-border);
    border-radius: var(--rt-radius);
}

.rt-page .rt-empty-ico { font-size: 2.6rem; }
.rt-page .rt-empty h3 { margin: 12px 0 6px; color: var(--text); }
.rt-page .rt-empty p { margin: 0 auto 18px; color: var(--text-muted); max-width: 42ch; }

/* ---------------- DISCLAIMER ---------------- */
.rt-page .rt-disclaimer {
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 4px 2px 0;
    opacity: 0.85;
}

/* ============================================================
   MODALS  (injected into #rt-modal-container by retirement.js)
   ============================================================ */
#rt-modal-container.rt-modal-open {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    padding: 16px;
    animation: rt-fade 0.18s ease;
}

@keyframes rt-fade { from { opacity: 0; } to { opacity: 1; } }

#rt-modal-container .rt-modal {
    background: var(--surface);
    color: var(--text);
    border-radius: 24px;
    padding: 24px 26px;
    width: 520px;
    max-width: 95vw;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 24px 60px rgba(0,0,0,0.28);
    animation: rt-pop 0.2s ease;
}

@keyframes rt-pop { from { transform: translateY(12px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }

#rt-modal-container .rt-modal h3 { margin: 0 0 16px; font-size: 1.15rem; font-weight: 700; }

#rt-modal-container .rt-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
    margin-bottom: 18px;
}

#rt-modal-container .rt-form-grid label {
    display: block;
    font-size: 0.78rem;
    margin-bottom: 5px;
    color: var(--text-muted);
    font-weight: 500;
}

#rt-modal-container .rt-field { display: flex; flex-direction: column; }

#rt-modal-container .form-control {
    border-radius: 12px;
    border: 1px solid var(--rt-card-border);
    padding: 10px 12px;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#rt-modal-container .form-control:focus {
    outline: none;
    border-color: var(--rt-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--rt-primary) 18%, transparent);
}

/* ---- Validation (scoped so it never affects other pages' forms) ---- */
#rt-modal-container .rt-field-error,
#rt-modal-container .field-validation-error {
    display: block;
    min-height: 1em;
    margin-top: 5px;
    font-size: 0.74rem;
    font-weight: 500;
    color: var(--rt-danger);
}

#rt-modal-container .field-validation-valid { display: none; }

#rt-modal-container .form-control.input-validation-error,
#rt-modal-container .input-validation-error {
    border-color: var(--rt-danger) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--rt-danger) 16%, transparent) !important;
}

#rt-modal-container .rt-val-summary {
    display: none;
    margin-bottom: 14px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.82rem;
    color: var(--rt-danger);
    background: color-mix(in srgb, var(--rt-danger) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--rt-danger) 30%, transparent);
}

#rt-modal-container .rt-val-summary--show,
#rt-modal-container .rt-val-summary.validation-summary-errors { display: block; }

#rt-modal-container .rt-val-summary ul { margin: 0; padding-left: 18px; }
#rt-modal-container .rt-val-summary.validation-summary-valid { display: none; }

#rt-modal-container .rt-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ---- Save / action buttons (as before) ---- */
#rt-modal-container .sf-btn-primary {
    background: var(--rt-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-weight: 600;
    cursor: pointer;
}
#rt-modal-container .sf-btn-primary:hover { background: var(--primary-hover, #3A56C9); }

#rt-modal-container .sf-btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--rt-card-border);
    border-radius: 10px;
    padding: 10px 18px;
    font-weight: 600;
    cursor: pointer;
}
#rt-modal-container .sf-btn-secondary:hover { border-color: var(--rt-primary); color: var(--rt-primary); }

#rt-modal-container .sf-btn-red {
    background: var(--rt-danger);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-weight: 600;
    cursor: pointer;
}
#rt-modal-container .sf-btn-red:hover { background: #dc2626; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
    .rt-page .rt-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rt-page .rt-grid-2-3 { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .rt-page .rt-kpi-grid { grid-template-columns: 1fr; }
    .rt-page .rt-hero { padding: 22px 20px; }
    .rt-page .rt-hero-text h1 { font-size: 1.6rem; }
    #rt-modal-container .rt-form-grid { grid-template-columns: 1fr; }
}
