/* Retirement tools: Retirement fund calculator and How long will my money last? Tokens from /custom/theme.css. */
.rt {
    /* asset classes, in table order: large cap, mid & small cap, international, bonds & FDs, gold, cash */
    --a1: #2a6fc2; --a2: #e0632e; --a3: #8b5cf6; --a4: #16a070; --a5: #d99400; --a6: #0e9fb3;
    --warn-ink: #8a5a00; --warn-soft: rgba(217, 148, 0, .16);
    --good-soft: rgba(11, 122, 62, .11); --bad-soft: rgba(192, 38, 45, .10);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .rt {
        --a1: #3987e5; --a2: #d95926; --a3: #9b7cf4; --a4: #199e70; --a5: #c98500; --a6: #1aa7bb;
        --warn-ink: #e8b44a; --warn-soft: rgba(232, 180, 74, .16);
        --good-soft: rgba(67, 196, 114, .14); --bad-soft: rgba(240, 122, 122, .14);
    }
}
:root[data-theme="dark"] .rt {
    --a1: #3987e5; --a2: #d95926; --a3: #9b7cf4; --a4: #199e70; --a5: #c98500; --a6: #1aa7bb;
    --warn-ink: #e8b44a; --warn-soft: rgba(232, 180, 74, .16);
    --good-soft: rgba(67, 196, 114, .14); --bad-soft: rgba(240, 122, 122, .14);
}
.rt[data-mode="simple"] .rt-pro { display: none !important; }
.rt[data-mode="pro"] .rt-simple-only { display: none !important; }
.rt select.rt-sel.rt-inline { display: inline-block; width: auto; height: 26px; padding: 0 4px; font-size: 13px; font-weight: 600; vertical-align: baseline; }

/* ---------- header and toolbar ---------- */
.rt-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; margin: 0 0 16px; }
.rt-toolbar-l { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.rt-toolbar .tw-muted { font-size: 12.5px; }
.rt-toolbar .btn { margin: 0; }
.rt-crosslink { font-size: 13px; }

/* ---------- layout ---------- */
.rt-grid { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 0 20px; align-items: start; }
/* the script sets rt-stack / rt-two from the page's own width (the sidebar may be open or closed); the media query covers first paint */
@media (max-width: 991px) { .rt-grid { grid-template-columns: minmax(0, 1fr); } }
.rt.rt-stack .rt-grid { grid-template-columns: minmax(0, 1fr); }
.rt.rt-two .rt-col-in { column-count: 2; column-gap: 20px; }
.rt.rt-two .rt-col-in > .tw-card { break-inside: avoid; -webkit-column-break-inside: avoid; }
.rt-col-out { scroll-margin-top: 64px; }
.rt-col-in .tw-card { padding: 14px 16px 10px; }
.rt-card-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 0 0 4px; }
.rt-card-h h2 { font-size: 17px; margin: 0; }
.rt-card-h .tw-seg { flex: none; }
.rt-kick { font: 600 11px/1.2 var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--claret); margin: 0 0 4px; }

/* ---------- fields ---------- */
.rt-f { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 3px 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--grid); }
.rt-f:first-child, .rt-card-h + .rt-f, .rt-sub + .rt-f { border-top: 0; }
.rt-f > label, .rt-f > .rt-l { margin: 0; font-weight: 500; font-size: 13.5px; color: var(--ink); line-height: 1.35; }
.rt-f .rt-h, .rt-h { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.rt-f .rt-echo { grid-column: 2; text-align: right; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 14px; }
.rt-f.rt-wide { grid-template-columns: minmax(0, 1fr); }
.rt-f .rt-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.rt-sub { margin: 10px 0 0; font-size: 12px; font-weight: 600; color: var(--ink2); text-transform: uppercase; letter-spacing: .05em; }
/* an input with its unit: the box carries the border, so a unit of any length sits beside the number, never over it */
.rt-box {
    display: flex; align-items: center; min-width: 0; height: 34px; cursor: text;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.rt-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rt-box:has(input.bad) { border-color: var(--neg); box-shadow: 0 0 0 3px var(--bad-soft); }
.rt .rt-box input {
    flex: 1 1 auto; width: 100%; min-width: 0; height: 100%; margin: 0; padding: 0 10px;
    font: 500 14px var(--font); font-variant-numeric: tabular-nums; text-align: right;
    color: var(--ink); background: transparent; border: 0; border-radius: 8px; box-shadow: none; outline: none;
    -moz-appearance: textfield;
}
.rt .rt-box input.bad { color: var(--neg); }
.rt .rt-box input::-webkit-outer-spin-button, .rt .rt-box input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.rt-box .u { flex: none; margin-left: -5px; padding-right: 10px; font-size: 12px; color: var(--muted); white-space: nowrap; pointer-events: none; }
.rt-box .p { flex: none; padding-left: 10px; margin-right: -6px; font-size: 13px; color: var(--muted); pointer-events: none; }
.rt-box.rt-sm { height: 30px; max-width: 96px; margin-left: auto; }
.rt .rt-box.rt-sm input { font-size: 13px; padding: 0 7px; }
.rt-box.rt-sm .u { padding-right: 7px; }
.rt select.rt-sel {
    width: 100%; height: 34px; margin: 0; padding: 0 8px; font: 500 13px var(--font); text-align: left;
    color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: none;
}
.rt select.rt-sel:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.rt input.rt-cin.bad { border-color: var(--neg) !important; box-shadow: 0 0 0 3px var(--bad-soft) !important; }
.rt .tw-seg.rt-per { margin-top: 4px; }
.rt-check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink2); font-weight: 400; margin: 0; cursor: pointer; }
.rt-check input { margin: 2px 0 0; accent-color: var(--accent); }
.rt-linkbtn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.rt-linkbtn:hover { color: var(--accent-ink); text-decoration: underline; }
.rt-warn { color: var(--warn-ink); }
.rt-actions { display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap; margin: 10px 0 2px; }

/* help tips: a "?" after a label opens one shared bubble (tips() in retirementui.js) */
.rt-lab { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
.rt-f > .rt-lab > label, .rt-f > .rt-lab > .rt-l { margin: 0; font-weight: 500; font-size: 13.5px; color: var(--ink); line-height: 1.35; }
.rt-card-h > .rt-lab { align-items: center; }
.rt-lab > .rt-wname { flex: 0 1 auto; }
.rt-tip {
    position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; margin: 1px 0 0; padding: 0; border-radius: 50%;
    border: 1px solid currentColor; background: transparent; color: var(--muted);
    font: 600 10.5px/1 var(--font); cursor: help; -webkit-tap-highlight-color: transparent;
}
.rt-card-h .rt-tip { margin: 0; }
.rt-tip::after { content: ''; position: absolute; top: -6px; right: -6px; bottom: -6px; left: -6px; }   /* a bigger target for fingers */
.rt-tip:hover, .rt-tip[aria-describedby] { color: var(--accent); border-color: var(--accent); }
.rt-tip:focus { outline: none; }
.rt-tip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rt-tipbox {
    position: fixed; z-index: 3000; max-width: 320px; max-width: min(320px, calc(100vw - 16px)); padding: 9px 12px; border-radius: 8px;
    background: var(--ink); color: var(--surface); font: 400 12.5px/1.5 var(--font); text-align: left;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .22); pointer-events: none;
}
.rt-tipbox[hidden] { display: none; }
.rt-tipbox::before { content: ''; position: absolute; top: -4px; left: var(--ax, 12px); width: 10px; height: 10px; background: inherit; transform: rotate(45deg); }
.rt-tipbox.up::before { top: auto; bottom: -4px; }

/* one-off expenses */
.rt-lumps { display: grid; gap: 6px; margin: 4px 0 6px; }
.rt-lump { display: grid; grid-template-columns: 84px minmax(0, 1fr) 30px; gap: 6px; align-items: center; }
.rt-lump .rt-x { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; }
.rt-lump .rt-x:hover { background: var(--hover); color: var(--ink); }
.rt-lump .rt-box { height: 32px; }

/* ---------- investment mix ---------- */
.rt-al-mode { margin: 2px 0 10px; }
.rt-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; margin: 0 0 10px; }
.rt-presets button {
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 9px;
    font: inherit; text-align: left; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.rt-presets button b { font-size: 12.5px; font-weight: 600; }
.rt-presets button small { font-size: 11px; color: var(--muted); }
.rt-presets button:hover { border-color: var(--axis); background: var(--hover); }
.rt-presets button.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.rt-segbar { display: flex; gap: 2px; height: 8px; margin: 0 0 8px; border-radius: 999px; overflow: hidden; background: var(--chip); }
.rt-segbar i { display: block; min-width: 2px; }
.rt-wtable { display: grid; gap: 2px; }
.rt-wrow { display: grid; grid-template-columns: 10px minmax(0, 1fr) minmax(70px, 110px) 74px; gap: 4px 10px; align-items: center; padding: 4px 0; }
.rt-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.rt-cma .rt-sw { margin-right: 8px; vertical-align: -1px; }
.rt-wname { margin: 0; font-weight: 400; line-height: 1.25; min-width: 0; }
.rt-wname b { display: block; font-size: 13px; font-weight: 600; color: var(--ink); }
.rt-wname small { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-wrow input[type=range] { width: 100%; margin: 0; accent-color: var(--accent); }
.rt-box.rt-wbox { height: 30px; }
.rt-wtotal { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink2); padding: 6px 0 2px; border-top: 1px solid var(--grid); margin-top: 4px; }
.rt-al-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0 4px; }
.rt-al-stats .tw-tile { padding: 8px 10px; background: var(--surface2); }
.rt-al-stats .tw-tile .tv { font-size: 18px; font-variant-numeric: normal; }
.rt-al-stats .tw-tile .ts { font-size: 11.5px; line-height: 1.35; }
.rt-al-line { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
@media (max-width: 420px) { .rt-wrow { grid-template-columns: 10px minmax(0, 1fr) 70px; } .rt-wrow input[type=range] { display: none; } }

/* assumptions */
.rt-cma { font-size: 13px; margin: 0; }
.rt-cma td { vertical-align: top; }
.rt-hist { font-size: 11.5px; color: var(--muted); line-height: 1.45; margin: 3px 0 0 18px; }
.rt-hist b { color: var(--ink2); font-weight: 600; }
.rt-corr { margin: 10px 0 0; }
.rt-corr summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink); }
.rt-corrt { font-size: 12px; margin: 6px 0 0; }
.rt-corrt th, .rt-corrt td { padding: 4px 5px !important; }
.rt .rt-cin { width: 58px; height: 26px; text-align: right; font-size: 12px; padding: 0 4px; border-radius: 6px; }
.rt-dim { color: var(--muted); }

/* ---------- results ---------- */
.rt-col-out { min-width: 0; }
.rt-col-out.rt-busy .rt-dyn { opacity: .55; transition: opacity .15s; }
.rt-hero { padding: 20px 22px 18px; }
.rt-hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.rt-big { font: 650 50px/1.05 var(--font); letter-spacing: -.025em; color: var(--ink); margin: 2px 0 6px; font-variant-numeric: normal; }
.rt-big small { display: inline-block; white-space: nowrap; font-size: 20px; font-weight: 600; letter-spacing: -.01em; color: var(--ink2); margin-left: 4px; }
.rt-lede { font-size: 15px; line-height: 1.6; color: var(--ink2); margin: 0 0 12px; max-width: 70ch; }
.rt-lede b { color: var(--ink); }
.rt-verdict { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.rt-verdict.good { background: var(--good-soft); color: var(--pos); }
.rt-verdict.warn { background: var(--warn-soft); color: var(--warn-ink); }
.rt-verdict.bad { background: var(--bad-soft); color: var(--neg); }
.rt .tw-tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.rt-hero .tw-tiles { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); margin: 4px 0 0; }
.rt-hero .tw-tile .tv { font-variant-numeric: normal; }
.rt-hero .tw-tile .ts { line-height: 1.4; }
.rt-fix { margin: 14px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); font-size: 13.5px; line-height: 1.55; color: var(--ink2); }
.rt-fix b { color: var(--ink); }
/* shown in the hero when the inputs look like a mistake (income that covers all spending) */
.rt-alert { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 12px; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); font-size: 13.5px; line-height: 1.55; color: var(--ink); max-width: 78ch; }
.rt-alert[hidden] { display: none; }
.rt-alert > .fa { color: var(--warn-ink); font-size: 15px; margin-top: 2px; flex: none; }
.rt-stat { font-size: 12px; color: var(--muted); margin: 10px 0 0; line-height: 1.6; }
.rt-err-card { border-color: var(--neg); }
.rt-err-card p { margin: 0; color: var(--neg); font-weight: 500; }

.rt-chart { width: 100%; height: 300px; }
.rt-chart-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px 12px; flex-wrap: wrap; }
.rt-chart-h h2 { margin: 0 0 2px; }
.rt-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--ink2); margin: 6px 0 4px; }
.rt-legend span { display: inline-flex; align-items: center; gap: 6px; }
.rt-legend i { display: inline-block; width: 16px; flex: none; }
.rt-legend i.ln { height: 0; border-top: 2px solid var(--accent); }
.rt-legend i.dash { height: 0; border-top: 2px dashed var(--ink2); }
.rt-legend i.b1 { height: 10px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 24%, transparent); }
.rt-legend i.b2 { height: 10px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 13%, transparent); }
.rt-legend i.tg { height: 0; border-top: 2px solid var(--claret); }
.rt-note { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; line-height: 1.5; }

/* confidence ladder: one bar per confidence level, from a zero baseline */
.rt-ladder-h { font: 600 14px/1.3 var(--font); color: var(--ink); margin: 18px 0 2px; }
.rt-ladder { display: grid; gap: 4px; margin: 8px 0 14px; }
.rt-rung {
    display: grid; grid-template-columns: minmax(120px, 170px) minmax(0, 1fr) minmax(80px, auto); gap: 4px 12px; align-items: center;
    width: 100%; padding: 5px 8px; font: inherit; font-size: 13px; text-align: left; color: var(--ink2);
    background: transparent; border: 0; border-radius: 8px; cursor: pointer;
}
.rt-rung:hover { background: var(--hover); }
.rt-rung .lb b { color: var(--ink); font-weight: 600; }
.rt-rung .lb small { display: block; color: var(--muted); font-size: 11.5px; }
.rt-rung .tr { display: block; height: 12px; }
.rt-rung .bar { display: block; height: 12px; border-radius: 0 4px 4px 0; background: var(--axis); min-width: 2px; }
.rt-rung .v { text-align: right; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rt-rung .v small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; }
.rt-rung.on { background: var(--accent-soft); }
.rt-rung.on .bar { background: var(--accent); }
@media (max-width: 560px) { .rt-rung { grid-template-columns: minmax(0, 1fr) auto; } .rt-rung .tr { grid-column: 1 / -1; grid-row: 2; } }

/* what-if table */
.rt-whatif { font-size: 13px; margin: 0; }
.rt-whatif td, .rt-whatif th { vertical-align: middle; }
.rt-whatif td:first-child { color: var(--ink); }
.rt-whatif tr.base td { font-weight: 600; background: var(--surface2); }
.rt-whatif .meter { display: inline-block; width: 70px; height: 6px; border-radius: 999px; background: var(--chip); vertical-align: middle; margin-right: 8px; overflow: hidden; }
.rt-whatif .meter i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.rt-whatif .d { font-size: 11.5px; margin-left: 6px; }
.rt-whatif tr.grp td { background: transparent; color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding-top: 12px; }
@media (max-width: 560px) {   /* phones: values above their change, no meter, so the table fits without much sideways scrolling */
    .rt-whatif { font-size: 12.5px; }
    .rt-whatif td, .rt-whatif th { padding: 6px 5px !important; }
    .rt-whatif td:first-child { min-width: 112px; }
    .rt-whatif .meter { display: none; }
    .rt-whatif .d { display: block; margin-left: 0; }
}

/* year-by-year table */
.rt-ytable-wrap { max-height: 460px; overflow: auto; border: 1px solid var(--grid); border-radius: 8px; }
.rt-ytable { font-size: 12.5px; margin: 0; }
.rt-ytable th { position: sticky; top: 0; z-index: 1; background: var(--surface) !important; }
.rt-ytable td, .rt-ytable th { text-align: right; white-space: nowrap; }
.rt-ytable td:first-child, .rt-ytable th:first-child { text-align: left; }
.rt-ytable tr.plan td { background: var(--accent-soft); font-weight: 600; }
.rt-ytable tr.gone td { color: var(--muted); }

/* method notes */
.rt-method summary { cursor: pointer; font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--ink); }
.rt-method h3 { font-size: 14px; margin: 14px 0 4px; }
.rt-method p, .rt-method li { font-size: 13px; line-height: 1.6; }
.rt-method ul { padding-left: 18px; margin: 0 0 6px; }

/* stacked layout: keep the answer in view while editing inputs (hidden once the results are on screen) */
.rt-sticky { display: none; }
.rt.rt-stack .rt-sticky {
    display: flex; position: sticky; bottom: 10px; z-index: 15; gap: 10px; align-items: center; justify-content: space-between;
    margin: 0 0 10px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .18); font-size: 13px; color: var(--ink2); transition: opacity .15s, visibility .15s;
}
.rt.rt-stack .rt-sticky.off { opacity: 0; visibility: hidden; }
.rt-sticky b { color: var(--ink); }
.rt-sticky a { white-space: nowrap; font-weight: 600; }
@media (max-width: 991px) { .rt-big { font-size: 42px; } }
@media print { .rt-sticky, .rt-toolbar .btn { display: none !important; } }
