For a Kentucky worker holding a layoff notice, with about 60 days to make choices that are hard to undo. Bridge works out Kentucky unemployment and its dates, compares Medicaid, KCHIP, kynect and COBRA (including the Jan. 2027 Medicaid work rule), shows what a 401(k) cash-out really costs, ranks which bills to protect, and shows how many weeks the money lasts. Try the example, then clear it to enter your own household. For educational use; needs no key, and nothing leaves the page.
<!-- Copyright (c) 2026 Jack Bolyard. Released under the MIT License. -->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bridge — a layoff plan for Kentucky workers</title>
<meta name="description" content="For a Kentucky worker who just lost a job: estimate Kentucky unemployment, compare Medicaid, KCHIP, kynect and COBRA, see what a 401(k) cash-out really nets, decide which bills come first, and see how many weeks your money lasts.">
<!--
Bridge: a layoff plan for Kentucky workers.
WHO IT'S FOR: a Kentucky worker holding a layoff notice, with about 60 days to
make health, money and retirement decisions that are hard to undo.
FOR EDUCATIONAL USE ONLY. Bridge gives estimates, not financial, investment,
tax, legal or benefits advice. Kentucky's Office of Unemployment Insurance,
kynect and your plan administrator make the real decisions.
Built for the Kentucky PFM Challenge 2026 by Jack Bolyard, with an AI assistant.
Everything runs inside this one file. It makes no network requests,
loads no outside scripts, fonts or images, and sends nothing anywhere.
No third-party code is used.
MIT License
Copyright (c) 2026 Jack Bolyard
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<style>
:root{
--paper:#EDEFEA;
--surface:#FBFBF8;
--ink:#1F2522;
--ink-2:#47504C;
--rule:#C8CEC8;
--river:#24576A;
--river-deep:#173C4A;
--river-soft:#D6E4E6;
--grass:#3B6A37;
--grass-soft:#DCE8D5;
--gold:#E3A72F;
--gold-soft:#F7E6BC;
--ember:#A9343A;
--ember-soft:#F4DCD8;
--display:"Palatino Linotype",Palatino,"Book Antiqua","URW Palladio L",P052,Georgia,serif;
--text:Seravek,"Gill Sans Nova",Ubuntu,Calibri,"Segoe UI","DejaVu Sans",sans-serif;
--radius-s:4px;
--radius-m:10px;
--focus:0 0 0 3px var(--surface),0 0 0 6px var(--river);
}
*{box-sizing:border-box}
[hidden]{display:none!important}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--paper);color:var(--ink);font:400 1.0625rem/1.55 var(--text);font-variant-numeric:tabular-nums}
a{color:var(--river)}
#steps,#plan{scroll-margin-top:64px}
@media (prefers-reduced-motion:no-preference){html{scroll-behavior:smooth}}
a:hover{color:var(--river-deep)}
:focus-visible{outline:none;box-shadow:var(--focus);border-radius:var(--radius-s)}
.visually-hidden{position:absolute!important;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.skip{position:absolute;left:12px;top:-60px;background:var(--surface);padding:8px 12px;z-index:50;border-radius:var(--radius-s)}
.skip:focus{top:12px}
/* ---------- top bar ---------- */
.bar{position:sticky;top:0;z-index:20;background:var(--river-deep);color:#fff}
.bar-inner{max-width:1200px;margin:0 auto;padding:8px 20px;display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.brand{font:600 1.35rem/1 var(--display);letter-spacing:.01em;margin-right:auto;display:flex;align-items:center;gap:10px}
.brand svg{flex:none}
.brand small{font:400 .85rem/1.2 var(--text);opacity:.85}
.tools{display:flex;gap:6px;flex-wrap:wrap}
.tool{font:500 .9rem/1 var(--text);color:#fff;background:transparent;border:1px solid rgba(255,255,255,.45);border-radius:999px;padding:8px 14px;cursor:pointer}
.tool:hover{background:rgba(255,255,255,.12)}
.tool.primary{background:var(--gold);border-color:var(--gold);color:var(--ink);font-weight:600}
.tool.primary:hover{background:#efb94b}
.tool:focus-visible{box-shadow:0 0 0 3px var(--river-deep),0 0 0 6px var(--gold)}
.tool .sm{display:none}
.dirty-dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--gold);margin-left:6px;vertical-align:middle}
.dirty-dot[hidden]{display:none}
/* ---------- hero ---------- */
.hero{position:relative;background:#dfe9e8;overflow:hidden}
.hero svg.scene{display:block;width:100%;height:clamp(150px,19vw,250px)}
.hero-copy .wrap{max-width:1200px;width:100%;margin:0 auto;padding:34px 20px 6px;display:grid;grid-template-columns:minmax(0,1fr);gap:20px 40px;align-items:start}
@media (min-width:900px){.hero-copy .wrap{grid-template-columns:minmax(0,1fr) 360px}}
.hero-card{background:var(--surface);border:1px solid var(--rule);border-top:5px solid var(--gold);border-radius:var(--radius-s);padding:14px 18px 14px;box-shadow:0 2px 0 rgba(23,60,74,.08)}
.hero-card .hc-label{margin:0;font-size:.9rem;color:var(--ink-2);font-weight:600}
.hero-card .hc-weeks{margin:2px 0 0;font-size:1rem}
.hero-card .hc-weeks b{display:block;font:600 2.6rem/1.05 var(--display);color:var(--river-deep)}
.hero-card .hc-weeks b.short{color:var(--ember)}
.hero-card .hc-worth{margin:8px 0;padding:6px 10px;background:var(--grass-soft);border-radius:var(--radius-s);font-size:.93rem}
.hero-card .hc-worth:empty{display:none}
.hero-card ul{list-style:none;margin:6px 0 8px;padding:0;font-size:.92rem}
.hero-card li{display:flex;justify-content:space-between;gap:10px;padding:5px 0;border-top:1px solid #e1e5df}
.hero-card li time{color:var(--ink-2);white-space:nowrap}
.hero-card a{font-weight:600;font-size:.95rem}
.hero h1{font:600 clamp(3rem,6.4vw,4.8rem)/.95 var(--display);margin:0;color:var(--river-deep);letter-spacing:-.01em}
.hero .lede{font:400 clamp(1.05rem,1.8vw,1.3rem)/1.4 var(--display);max-width:34ch;margin:.5rem 0 0;color:var(--ink)}
.for{display:inline;background:var(--gold-soft);box-decoration-break:clone;-webkit-box-decoration-break:clone;padding:2px 6px;font-size:.95rem;line-height:1.9}
.hero .for-wrap{max-width:62ch;margin-top:14px}
.hero .edu{margin:10px 0 0;font-size:.92rem;color:var(--ink-2);max-width:62ch}
.under-hero{max-width:1200px;margin:0 auto;padding:18px 20px 0;display:flex;gap:10px 28px;flex-wrap:wrap;color:var(--ink-2);font-size:.95rem}
.under-hero p{margin:0;display:flex;gap:8px;align-items:flex-start;max-width:60ch}
.under-hero svg{flex:none;margin-top:3px}
/* ---------- example banner ---------- */
.why-ky{max-width:1200px;margin:26px auto 0;padding:0 20px}
.why-ky h2{font:600 1.5rem/1.2 var(--display);margin:0 0 4px}
.why-lede{margin:0 0 14px;color:var(--ink-2);max-width:74ch}
.why-list{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:14px 28px}
.why-list li{border-top:3px solid var(--gold);padding-top:10px;font-size:.97rem;color:var(--ink-2)}
.why-list strong{display:block;color:var(--ink);font:600 1.1rem/1.3 var(--display);margin-bottom:3px}
.notice{max-width:1200px;margin:22px auto 0;padding:0 20px}
.notice-inner{background:var(--surface);border:1px solid var(--rule);border-left:5px solid var(--gold);padding:14px 18px;border-radius:var(--radius-s);display:flex;gap:12px 20px;align-items:center;flex-wrap:wrap}
.notice-inner p{margin:0;flex:1 1 380px}
.btn{font:600 .95rem/1 var(--text);border-radius:999px;padding:10px 16px;cursor:pointer;border:1px solid var(--river);background:var(--surface);color:var(--river)}
.btn:hover{background:var(--river-soft)}
.btn.solid{background:var(--river);color:#fff}
.btn.solid:hover{background:var(--river-deep)}
.btn.small{padding:7px 12px;font-size:.88rem}
.btn.quiet{border-color:transparent;background:transparent;text-decoration:underline;text-underline-offset:3px;padding-left:4px;padding-right:4px}
/* ---------- layout ---------- */
.layout{max-width:1200px;margin:0 auto;padding:24px 20px 40px;display:grid;grid-template-columns:minmax(0,1fr);gap:32px}
@media (min-width:1060px){.layout{grid-template-columns:minmax(0,1fr) 340px;gap:48px}}
.steps{position:relative;min-width:0}
.step{position:relative;padding:0 0 40px 58px}
.step::before{content:"";position:absolute;left:19px;top:44px;bottom:0;width:2px;background:var(--rule)}
.step:last-child::before{display:none}
.step-num{position:absolute;left:0;top:0;width:40px;height:40px;border-radius:50%;background:var(--river-deep);color:#fff;display:grid;place-items:center;font:600 1.15rem/1 var(--display)}
.step h2{font:600 1.65rem/1.15 var(--display);margin:4px 0 6px}
.step .why{margin:0 0 18px;color:var(--ink-2);max-width:62ch}
fieldset{border:0;margin:0;padding:0;min-width:0}
legend{padding:0}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:14px 18px}
.field{display:flex;flex-direction:column;gap:5px;min-width:0}
.field label,.field .label{font-weight:600;font-size:.95rem}
.field .hint{font-size:.85rem;color:var(--ink-2);line-height:1.35}
input[type=number],input[type=date],input[type=text],select{font:inherit;font-size:1rem;color:var(--ink);background:var(--surface);border:1px solid #9aa49f;border-radius:var(--radius-s);padding:9px 10px;min-height:44px;width:100%}
input[type=number]{text-align:right}
input:hover,select:hover{border-color:var(--ink-2)}
input:focus-visible,select:focus-visible{border-color:var(--river)}
.money{position:relative}
.money::before{content:"$";position:absolute;left:10px;top:50%;transform:translateY(-50%);color:var(--ink-2);pointer-events:none}
.money input{padding-left:22px}
.check{display:flex;gap:10px;align-items:flex-start;font-size:.95rem;cursor:pointer}
.check input{width:20px;height:20px;margin:2px 0 0;accent-color:var(--river);flex:none}
.radio-row{display:flex;flex-wrap:wrap;gap:8px}
.chip{position:relative}
.chip input{position:absolute;opacity:0;inset:0;width:100%;height:100%;margin:0;cursor:pointer}
.chip span{display:inline-block;padding:9px 14px;border:1px solid #9aa49f;border-radius:999px;background:var(--surface);font-size:.95rem}
.chip input:checked + span{background:var(--river);border-color:var(--river);color:#fff}
.chip input:focus-visible + span{box-shadow:var(--focus)}
/* answer slips */
.answer{margin-top:18px;background:var(--surface);border:1px solid var(--rule);border-left:5px solid var(--river);border-radius:var(--radius-s);padding:16px 18px}
.answer.warn{border-left-color:var(--ember)}
.answer.good{border-left-color:var(--grass)}
.answer h3{font:600 1.15rem/1.3 var(--display);margin:0 0 6px}
.answer p{margin:.35rem 0;max-width:68ch}
.answer ul{margin:.4rem 0;padding-left:1.2rem}
.answer li{margin:.25rem 0}
.big{font:600 2.1rem/1.1 var(--display);color:var(--river-deep)}
.mark{background:var(--gold-soft);padding:0 4px}
.tag{display:inline-block;font-size:.8rem;font-weight:600;padding:2px 9px;border-radius:999px;background:var(--river-soft);color:var(--river-deep);white-space:nowrap}
.tag.good{background:var(--grass-soft);color:#24461f}
.tag.bad{background:var(--ember-soft);color:#7a2026}
.tag.gold{background:var(--gold-soft);color:#5b4310}
details.opt{margin-top:14px;border:1px dashed #b3bcb6;border-radius:var(--radius-s);padding:0 14px;background:rgba(251,251,248,.6)}
details.opt > summary{cursor:pointer;padding:11px 0;font-weight:600;color:var(--river);font-size:.95rem}
details.opt > summary span{font-weight:400;color:var(--ink-2)}
details.opt[open]{padding-bottom:14px}
details.opt .grid{margin-top:2px}
.limits{margin:0 0 1rem;padding-left:1.2rem;max-width:80ch}
.limits li{margin:.25rem 0}
.print-only{display:none}
details.more{margin-top:10px}
details.more summary{cursor:pointer;color:var(--river);font-weight:600;font-size:.95rem}
details.more[open] summary{margin-bottom:6px}
/* health doors */
.doors{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px;margin-top:16px}
.door{background:var(--surface);border:1px solid var(--rule);border-radius:var(--radius-m) var(--radius-m) var(--radius-s) var(--radius-s);padding:14px 16px 16px;display:flex;flex-direction:column;gap:6px;position:relative;border-top:6px solid var(--rule)}
.door.ok{border-top-color:var(--grass)}
.door.no{border-top-color:#b9c0bb;opacity:.92}
.door.pick{outline:2px solid var(--river);outline-offset:-1px}
.door h3{font:600 1.1rem/1.2 var(--display);margin:0}
.door .cost{font:600 1.6rem/1.1 var(--display);color:var(--river-deep)}
.door .cost small{font:400 .9rem var(--text);color:var(--ink-2)}
.door p{margin:0;font-size:.92rem;color:var(--ink-2)}
.door label.choose{margin-top:auto;padding-top:8px}
.door .status{list-style:none;margin:2px 0;padding:0;font-size:.92rem}
.door .status li{display:flex;justify-content:space-between;gap:8px;padding:3px 0;border-top:1px solid #e4e8e3}
.door .status li:first-child{border-top:0}
.door .status .yes{color:var(--grass);font-weight:600}
.door .status .no{color:var(--ink-2);font-weight:600}
.pick-auto{margin-top:12px}
#switchWrap{margin-top:12px;padding:10px 12px;background:var(--grass-soft);border-radius:var(--radius-s)}
/* bills table */
.bills{width:100%;border-collapse:collapse;margin-top:6px}
.bills th{font-size:.85rem;text-align:left;color:var(--ink-2);font-weight:600;padding:6px 6px;border-bottom:1px solid var(--rule)}
.bills td{padding:6px;border-bottom:1px solid #dde2dc;vertical-align:middle}
.bills td.n{width:122px}
.bills td.cat{width:150px}
.bills td.t{width:86px}
.bills td.x{width:44px;text-align:right}
.bills input[type=text]{min-width:120px}
.iconbtn{width:40px;height:40px;border-radius:50%;border:1px solid transparent;background:transparent;cursor:pointer;color:var(--ink-2);display:inline-grid;place-items:center}
.iconbtn:hover{background:var(--ember-soft);color:var(--ember)}
.bill-total{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:10px;font-weight:600}
@media (max-width:720px){
.bills thead{display:none}
.bills,.bills tbody,.bills tr,.bills td{display:block;width:100%}
.bills tr{border:1px solid var(--rule);border-radius:var(--radius-s);padding:8px;margin-bottom:10px;background:var(--surface);display:grid;grid-template-columns:1fr 1fr 72px;gap:6px 8px}
.bills td{border:0;padding:0}
.bills td.name{grid-column:1 / 3;grid-row:1}
.bills td.x{grid-row:1;grid-column:3;align-self:end}
.bills td.cat{grid-column:1 / 3;grid-row:2}
.bills td.t{grid-column:3;grid-row:2;align-self:end;width:auto}
.bills td.now{grid-column:1;grid-row:3;width:auto}
.bills td.during{grid-column:2 / 4;grid-row:3;width:auto}
.bills td[data-label]::before{content:attr(data-label);display:block;font-size:.8rem;color:var(--ink-2);font-weight:600}
}
.tier-group{padding:12px 0 4px;border-top:1px solid #dde2dc}
.tier-group:first-of-type{border-top:0;padding-top:6px}
.tier-group > h4{display:flex;align-items:center;gap:10px;margin:0 0 4px;font:600 1.08rem/1.2 var(--display)}
.tier-group ul{list-style:none;margin:0;padding:0 0 0 40px}
.tier-group li{margin:8px 0 10px}
.tier-group li b{display:block;font-size:.98rem}
.tier-group li p{margin:2px 0 0;font-size:.94rem;color:var(--ink-2);max-width:66ch}
.tier-group li p.snap{color:var(--ink)}
@media (max-width:640px){.tier-group ul{padding-left:0}}
.order{list-style:none;padding:0;margin:12px 0 0;counter-reset:tier}
.order li{display:grid;grid-template-columns:auto 1fr;gap:4px 14px;padding:12px 0;border-top:1px solid #dde2dc}
.order li:first-child{border-top:0}
.order .tier{font:600 1.05rem/1 var(--display);width:30px;height:30px;border-radius:50%;display:grid;place-items:center;background:var(--river-soft);color:var(--river-deep)}
.order h4{margin:3px 0 2px;font-size:1rem}
.order p{margin:0;font-size:.94rem;color:var(--ink-2);max-width:66ch}
/* retirement */
.cashout{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:2px;margin:12px 0 6px;border-radius:var(--radius-s);overflow:hidden}
.cashout div{background:var(--paper);padding:10px 12px}
.cashout b{display:block;font:600 1.3rem/1.2 var(--display)}
.cashout span{font-size:.85rem;color:var(--ink-2)}
.cashout .keep{background:var(--grass-soft)}
.cashout .lose{background:var(--ember-soft)}
/* side panel */
.panel{align-self:start}
@media (min-width:1060px){.panel{position:sticky;top:76px}.panel-box{max-height:calc(100vh - 92px);overflow:auto}}
.panel .worth{margin:0 0 10px;font-size:.95rem;padding:8px 10px;background:var(--grass-soft);border-radius:var(--radius-s)}
.panel .worth:empty{display:none}
.panel-box{background:var(--surface);border:1px solid var(--rule);border-radius:var(--radius-m);padding:18px 18px 16px;box-shadow:0 1px 0 #d9ddd8}
.panel h2{font:600 1rem/1.2 var(--text);margin:0;color:var(--ink-2)}
.panel .weeks{font:600 3.6rem/1 var(--display);color:var(--river-deep);margin:6px 0 2px}
.panel .weeks.short{color:var(--ember)}
.panel .until{margin:0 0 10px}
.mini{display:block;width:100%;height:56px}
.panel h3{font:600 .98rem/1.3 var(--text);margin:14px 0 6px}
.levers,.next{list-style:none;padding:0;margin:0}
.levers li,.next li{display:flex;justify-content:space-between;gap:10px;padding:6px 0;border-top:1px solid #e1e5df;font-size:.93rem}
.levers li:first-child,.next li:first-child{border-top:0}
.levers b{color:var(--grass);white-space:nowrap}
.next time{color:var(--ink-2);white-space:nowrap;font-size:.88rem}
.panel .jump{display:inline-block;margin-top:12px;font-weight:600}
/* mobile summary bar */
.mbar{position:sticky;bottom:0;z-index:15;background:var(--river-deep);color:#fff;padding:10px 16px;display:flex;justify-content:space-between;align-items:center;gap:12px}
.mbar a{color:#fff;font-weight:600}
@media (min-width:1060px){.mbar{display:none}}
@media (max-width:1059px){.panel{order:-1}.panel .levers-wrap,.panel .next-wrap{display:none}}
/* results */
.results{background:var(--surface);border-top:1px solid var(--rule)}
.results-inner{max-width:1200px;margin:0 auto;padding:40px 20px 30px}
.results h2{font:600 2rem/1.15 var(--display);margin:0 0 6px}
.results .sub{color:var(--ink-2);margin:0 0 18px;max-width:70ch}
.chart-wrap{position:relative;border:1px solid var(--rule);border-radius:var(--radius-m);background:linear-gradient(#f6f8f6,#eef3f2);padding:8px 8px 0;outline:none}
.chart-wrap:focus-visible{box-shadow:var(--focus)}
#bridgeChart{display:block;width:100%;height:340px}
.tip{position:absolute;pointer-events:none;background:var(--ink);color:#fff;font-size:.85rem;line-height:1.35;padding:8px 10px;border-radius:var(--radius-s);max-width:240px;transform:translate(-50%,-100%);white-space:normal;z-index:5}
.tip[hidden]{display:none}
.marklist{font-size:.88rem;color:var(--ink-2);margin:10px 2px 0}
.legend{display:flex;flex-wrap:wrap;gap:8px 18px;font-size:.88rem;color:var(--ink-2);margin:10px 2px 0}
.legend span{display:inline-flex;align-items:center;gap:6px}
.legend i{display:inline-block;width:14px;height:14px;border-radius:2px}
.scenarios{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;margin:22px 0 0}
.scenario{border:1px solid var(--rule);border-radius:var(--radius-s);padding:12px 14px;background:var(--paper)}
.scenario b{font:600 1.5rem/1.1 var(--display);display:block}
.scenario.worth-card{background:var(--grass-soft);border-color:#b9d1b0}
.scenario span{font-size:.9rem;color:var(--ink-2)}
.cols{display:grid;grid-template-columns:minmax(0,1fr);gap:40px;margin-top:44px}
@media (min-width:900px){.cols{grid-template-columns:minmax(0,1.15fr) minmax(0,.85fr)}}
.timeline{list-style:none;margin:0;padding:0}
.timeline li{display:grid;grid-template-columns:96px 1fr;gap:4px 16px;padding:12px 0;border-top:1px solid var(--rule)}
.timeline li.past{opacity:.6}
.timeline time{font:600 1rem/1.3 var(--display);color:var(--river-deep)}
.timeline h4{margin:0;font-size:1rem}
.timeline p{margin:2px 0 0;color:var(--ink-2);font-size:.93rem;max-width:62ch}
.timeline .kind{grid-column:2;margin-top:2px}
table.data{border-collapse:collapse;width:100%;font-size:.9rem}
table.data th,table.data td{text-align:left;padding:7px 8px;border-bottom:1px solid var(--rule);vertical-align:top}
table.data th{color:var(--ink-2);font-weight:600}
table.data td.r,table.data th.r{text-align:right}
.scroll{overflow-x:auto}
.foot{max-width:1200px;margin:0 auto;padding:28px 20px 70px;color:var(--ink-2);font-size:.93rem}
.foot h2{font:600 1.3rem/1.2 var(--display);color:var(--ink);margin:0 0 8px}
.foot p{max-width:80ch}
.disclaimer{background:var(--gold-soft);border-radius:var(--radius-s);padding:14px 16px;color:var(--ink)}
/* toast */
.toast{position:fixed;left:50%;bottom:76px;transform:translateX(-50%);background:var(--ink);color:#fff;padding:12px 16px;border-radius:var(--radius-s);max-width:min(560px,92vw);z-index:60;box-shadow:0 6px 24px rgba(0,0,0,.25);font-size:.95rem}
.toast.error{background:var(--ember)}
.toast[hidden]{display:none}
@media (prefers-reduced-motion:no-preference){
.water-line{animation:drift 9s ease-in-out infinite alternate}
@keyframes drift{from{transform:translateX(-14px)}to{transform:translateX(14px)}}
}
@media (max-width:720px){
.bar{position:static}
.tools{flex-wrap:nowrap;overflow-x:auto;width:100%;padding-bottom:4px}
.tool{white-space:nowrap;padding:8px 12px}
.tool .lg{display:none}
.tool .sm{display:inline}
}
@media (max-width:640px){
.hero-copy .wrap{padding-top:22px}
.step{padding-left:0}
.step::before{display:none}
.step-num{position:static;margin-bottom:8px}
.timeline li{grid-template-columns:1fr}
.timeline .kind{grid-column:1}
}
@media print{
body > :not(#printPlan){display:none!important}
#printPlan{display:block!important;color:#000;font:10.5pt/1.45 var(--text)}
#printPlan h1{font:600 20pt/1.1 var(--display);margin:0 0 2pt}
#printPlan h2{font:600 12.5pt/1.2 var(--display);margin:14pt 0 4pt;border-bottom:1pt solid #999;padding-bottom:2pt}
#printPlan .meta{margin:0 0 8pt;color:#333}
#printPlan table{border-collapse:collapse;width:100%}
#printPlan td,#printPlan th{border-bottom:.5pt solid #bbb;padding:3pt 5pt;text-align:left;vertical-align:top}
#printPlan th{width:34%;font-weight:600}
#printPlan ol,#printPlan ul{margin:0;padding-left:14pt}
#printPlan li{margin:2pt 0;break-inside:avoid}
#printPlan .fine{font-size:8.5pt;color:#333;margin-top:12pt}
@page{margin:14mm}
.bar,.mbar,.notice,.skip,.tools,.btn,.iconbtn,.toast,.hero svg.scene,details.more summary{display:none!important}
.hero{background:none}
body{background:#fff;font-size:11pt}
.layout{display:block}
.panel{position:static}
.answer,.door,.tier-group,.timeline li,.scenario,.why-list li{break-inside:avoid}
.results{break-before:page}
.results{border:0}
input,select{border:0;padding:0;min-height:0;background:none}
.chart-wrap{break-inside:avoid}
}
</style>
</head>
<body>
<a class="skip" href="#steps">Skip to the planner</a>
<header class="bar">
<div class="bar-inner">
<div class="brand">
<svg width="34" height="22" viewBox="0 0 34 22" aria-hidden="true"><path d="M1 15h32" stroke="#E3A72F" stroke-width="2.5"/><path d="M3 15 L9 5 L15 15 L21 5 L27 15 M9 5h12M21 5h6L31 15" fill="none" stroke="#fff" stroke-width="1.8"/><path d="M1 20c4-2 8 2 12 0s8 2 12 0 6 2 8 0" fill="none" stroke="#9ec3cc" stroke-width="1.6"/></svg>
<span>Bridge <small>a layoff plan for Kentucky workers</small></span>
</div>
<div class="tools" role="group" aria-label="Your plan">
<button class="tool primary" type="button" id="saveBtn" aria-label="Save my plan" title="Downloads a file you can open here again (Ctrl+S)">Save<span class="lg"> my plan</span><span class="dirty-dot" id="dirtyDot" hidden title="Unsaved changes"></span></button>
<button class="tool" type="button" id="openBtn" aria-label="Open a saved plan">Open<span class="lg"> a saved plan</span></button>
<button class="tool" type="button" id="icsBtn" aria-label="Add dates to my calendar"><span class="lg">Add dates to my calendar</span><span class="sm">Calendar</span></button>
<button class="tool" type="button" id="printBtn" aria-label="Print my action plan">Print<span class="lg"> my action plan</span></button>
<button class="tool" type="button" id="resetBtn">Start over</button>
</div>
<input type="file" id="fileInput" accept=".json,application/json" class="visually-hidden" tabindex="-1" aria-hidden="true">
</div>
</header>
<main>
<section class="hero" aria-labelledby="title">
<div class="hero-copy">
<div class="wrap">
<div>
<h1 id="title">Bridge</h1>
<p class="lede">A plan for the weeks between a Kentucky layoff and your next paycheck.</p>
<div class="for-wrap"><span class="for">Built for a Kentucky worker holding a layoff notice, with about 60 days to make health, money and retirement decisions that are hard to undo.</span></div>
<p class="edu"><strong>For educational use only.</strong> Estimates, not financial, investment, tax, legal or benefits advice.</p>
</div>
<aside class="hero-card" aria-labelledby="hcLabel">
<p class="hc-label" id="hcLabel">Dana's plan, from the example below</p>
<p class="hc-weeks"><b id="hcWeeks">–</b><span id="hcUntil"></span></p>
<p class="hc-worth" id="hcWorth"></p>
<ul id="hcNext"></ul>
<a href="#steps">See how it's worked out</a>
</aside>
</div>
</div>
<svg class="scene" viewBox="0 118 1440 302" preserveAspectRatio="xMidYMax slice" aria-hidden="true">
<defs>
<linearGradient id="riv" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#3b7180"/><stop offset="1" stop-color="#1d4a58"/></linearGradient>
</defs>
<rect width="1440" height="420" fill="#dfe9e8"/>
<!-- far hills -->
<path d="M0 230 C160 196 300 214 460 200 S760 182 900 196 S1220 176 1440 192 V300 H0Z" fill="#a9bfb4"/>
<!-- left palisade -->
<path d="M0 200 C60 190 120 196 170 204 L232 214 L262 300 L276 420 H0Z" fill="#d9dbd2"/>
<path d="M0 236 H226 M0 262 H236 M0 288 H248 M0 316 H258 M0 346 H266 M0 378 H272" stroke="#b9bdb2" stroke-width="3"/>
<path d="M0 202 C40 176 80 186 104 178 C124 170 148 186 176 186 C200 186 214 198 232 214 C200 214 120 210 0 214Z" fill="#4b7a45"/>
<path d="M18 196 a22 22 0 0 1 40 -8 a18 18 0 0 1 30 2 a20 20 0 0 1 36 4 z" fill="#3b6a37"/>
<!-- right palisade -->
<path d="M1440 196 C1360 190 1300 196 1250 206 L1190 216 L1166 300 L1150 420 H1440Z" fill="#d9dbd2"/>
<path d="M1440 238 H1196 M1440 264 H1186 M1440 290 H1176 M1440 318 H1168 M1440 348 H1160 M1440 380 H1154" stroke="#b9bdb2" stroke-width="3"/>
<path d="M1440 198 C1400 178 1366 186 1336 180 C1312 174 1290 188 1260 190 C1232 192 1210 204 1190 216 C1240 214 1330 212 1440 214Z" fill="#4b7a45"/>
<path d="M1420 194 a22 22 0 0 0 -40 -8 a18 18 0 0 0 -30 2 a20 20 0 0 0 -36 4 z" fill="#3b6a37"/>
<!-- river -->
<path d="M150 356 C420 340 1020 340 1290 356 V420 H150Z" fill="url(#riv)"/>
<g class="water-line" stroke="#9ec3cc" stroke-width="2.5" fill="none" opacity=".7">
<path d="M330 378 c30 -6 60 6 90 0"/><path d="M640 392 c30 -6 60 6 90 0"/><path d="M930 374 c30 -6 60 6 90 0"/><path d="M520 404 c24 -5 48 5 72 0"/><path d="M1080 400 c24 -5 48 5 72 0"/>
</g>
<!-- piers -->
<g fill="#8e9690"><rect x="452" y="214" width="20" height="150"/><rect x="712" y="214" width="20" height="150"/><rect x="972" y="214" width="20" height="150"/></g>
<!-- truss bridge -->
<g stroke="#1f2522" stroke-width="4" fill="none">
<path d="M232 214 H1190"/>
<path d="M232 168 H1190"/>
<path d="M232 214 L272 168 L312 214 L352 168 L392 214 L432 168 L472 214 L512 168 L552 214 L592 168 L632 214 L672 168 L712 214 L752 168 L792 214 L832 168 L872 214 L912 168 L952 214 L992 168 L1032 214 L1072 168 L1112 214 L1152 168 L1190 214"/>
<path d="M232 214 V168 M1190 214 V168" />
</g>
<!-- deck planks in goldenrod -->
<path d="M232 214 H1190" stroke="#E3A72F" stroke-width="7"/>
</svg>
</section>
<div class="under-hero">
<p><svg width="18" height="18" viewBox="0 0 18 18" aria-hidden="true"><rect x="3" y="8" width="12" height="9" rx="2" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M5.5 8V5.5a3.5 3.5 0 0 1 7 0V8" fill="none" stroke="currentColor" stroke-width="1.6"/></svg><span>Nothing you type leaves this page. It makes no internet requests, needs no account and no key, and works offline.</span></p>
<p><svg width="18" height="18" viewBox="0 0 18 18" aria-hidden="true"><circle cx="9" cy="9" r="7.5" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M9 8v5M9 5.2v.1" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg><span>Kentucky's Office of Unemployment Insurance, kynect and your plan administrator make the real decisions. Every number on this page is listed with its source near the bottom.</span></p>
</div>
<section class="why-ky" aria-labelledby="whyH">
<h2 id="whyH">Why a Kentucky layoff needs its own plan</h2>
<p class="why-lede">In 2025, only about 1 in 10 unemployed Kentuckians collected unemployment benefits, compared with about 1 in 4 nationwide. In 2026, about 1,500 people lost their jobs at the BlueOval SK battery plant in Glendale alone. And the usual advice, take COBRA and count on 26 weeks of unemployment, doesn't fit Kentucky in three ways.</p>
<ul class="why-list">
<li><strong>Unemployment runs out sooner.</strong>Kentucky pays 16 weeks right now, while most states pay up to 26.</li>
<li><strong>COBRA is the expensive default.</strong>Family COBRA averages about $2,400 a month in 2026. Medicaid, free KCHIP for kids or a kynect tax credit often cost far less.</li>
<li><strong>The rules change January 1.</strong>Kentucky's new Medicaid work rule starts Jan. 1, 2027, and job hunting on its own doesn't count toward it.</li>
</ul>
</section>
<div class="notice" id="exampleNotice">
<div class="notice-inner">
<p id="noticeText"></p>
<button class="btn solid" type="button" id="clearExample">Clear the example</button>
<button class="btn" type="button" id="loadExample" hidden>Show the example again</button>
</div>
</div>
<div class="layout">
<div class="steps" id="steps">
<!-- STEP 1 -->
<section class="step" aria-labelledby="s1h">
<div class="step-num" aria-hidden="true">1</div>
<h2 id="s1h">The layoff</h2>
<p class="why">Your last day starts every clock on this page: when to file, when health coverage ends, and when the 60-day deadlines close.</p>
<div class="grid">
<div class="field"><label for="lastDay">Last day you were paid as an employee</label><input type="date" id="lastDay" data-path="person.lastDay" data-type="date"><span class="hint">If you got "60 days of pay and benefits" on a WARN notice, use the end of that period.</span></div>
<div class="field"><label for="reason">How did the job end?</label>
<select id="reason" data-path="person.reason">
<option value="layoff">Laid off, plant or job closed</option>
<option value="recall">Temporary layoff with a recall date</option>
<option value="quit">I quit</option>
<option value="fired">I was fired</option>
</select></div>
<div class="field"><label for="age">Your age</label><input type="number" id="age" min="16" max="99" step="1" data-path="person.age" data-type="int"></div>
<div class="field"><label for="filing">How you file taxes</label>
<select id="filing" data-path="person.filing">
<option value="single">Single</option>
<option value="mfj">Married filing jointly</option>
<option value="hoh">Head of household</option>
</select></div>
<div class="field"><label for="hh">People in your household</label><input type="number" id="hh" min="1" max="15" step="1" data-path="person.hh" data-type="int"><span class="hint">Count yourself, a spouse, and everyone you claim on your taxes.</span></div>
<div class="field"><label for="kids">Children under 19</label><input type="number" id="kids" min="0" max="12" step="1" data-path="person.kids" data-type="int"></div>
<div class="field"><label for="youngest">Youngest child's age</label><input type="number" id="youngest" min="0" max="18" step="1" data-path="person.youngest" data-type="int"><span class="hint">Matters for Kentucky's new Medicaid work rule.</span></div>
</div>
<div class="answer" id="out1"></div>
</section>
<!-- STEP 2 -->
<section class="step" aria-labelledby="s2h">
<div class="step-num" aria-hidden="true">2</div>
<h2 id="s2h">Kentucky unemployment</h2>
<p class="why">Kentucky pays 1.1923% of what you earned in your "base period," up to $746 a week, for 16 weeks right now. Most states pay up to 26, so the clock here is short.</p>
<fieldset>
<legend class="label" style="font-weight:600;margin-bottom:6px">What you earned</legend>
<div class="radio-row" role="radiogroup" aria-label="How to enter your pay">
<label class="chip"><input type="radio" name="wageMode" value="annual" data-path="wages.mode"><span>My yearly pay was steady</span></label>
<label class="chip"><input type="radio" name="wageMode" value="quarters" data-path="wages.mode"><span>Enter my pay by quarter</span></label>
</div>
</fieldset>
<div class="grid" style="margin-top:14px" id="annualBox">
<div class="field"><label for="annual">Yearly pay before taxes</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="annual" data-path="wages.annual" data-type="num"></div><span class="hint">Hourly? Rate × hours a week × 52. $24 × 40 × 52 = $49,920.</span></div>
</div>
<div class="grid" style="margin-top:14px" id="quarterBox" hidden>
<div class="field"><label for="q0" id="q0l">Quarter 1</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="q0" data-path="wages.q.0" data-type="num"></div></div>
<div class="field"><label for="q1" id="q1l">Quarter 2</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="q1" data-path="wages.q.1" data-type="num"></div></div>
<div class="field"><label for="q2" id="q2l">Quarter 3</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="q2" data-path="wages.q.2" data-type="num"></div></div>
<div class="field"><label for="q3" id="q3l">Quarter 4</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="q3" data-path="wages.q.3" data-type="num"></div></div>
</div>
<div style="display:flex;flex-direction:column;gap:8px;margin-top:14px">
<label class="check"><input type="checkbox" id="countUI" data-path="wages.count" data-type="bool"><span>Count unemployment in my plan</span></label>
<label class="check"><input type="checkbox" id="fedW" data-path="wages.fedW" data-type="bool"><span>Withhold 10% for federal tax (unemployment is taxable)</span></label>
</div>
<details class="opt"><summary>More details <span>(optional): filing date, part-time pay, weeks, state tax</span></summary>
<div class="grid">
<div class="field"><label for="fileDate">Date you filed, or will file</label><input type="date" id="fileDate" data-path="wages.fileDate" data-type="date"><span class="hint" id="fileHint">Leave blank to use the Sunday after your last day.</span></div>
<div class="field"><label for="weeksAvail">Weeks of benefits</label>
<select id="weeksAvail" data-path="wages.weeks" data-type="int">
<option value="16">16 weeks (Kentucky now)</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option>
</select><span class="hint">Set by the state jobless rate. 16 weeks applies while it's 6.5% or lower.</span></div>
<div class="field"><label for="pt">Part-time or gig pay per week while claiming</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="pt" data-path="wages.pt" data-type="num"></div><span class="hint">Before taxes. Kentucky subtracts 80% of it from your weekly check.</span></div>
<div class="field"><label for="inLieu">"Pay in lieu of notice" lump sum</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="inLieu" data-path="wages.inLieu" data-type="num"></div><span class="hint">Not severance. It can hold up benefits for up to 4 weeks.</span></div>
</div>
<label class="check" style="margin-top:12px"><input type="checkbox" id="stW" data-path="wages.stW" data-type="bool"><span>Withhold 3.5% for Kentucky tax</span></label>
</details>
<div class="answer" id="out2"></div>
</section>
<!-- STEP 3 -->
<section class="step" aria-labelledby="s3h">
<div class="step-num" aria-hidden="true">3</div>
<h2 id="s3h">Money you can count on</h2>
<p class="why">Cash on hand plus anything still coming. Use take-home amounts here, after taxes.</p>
<div class="grid">
<div class="field"><label for="savings">Checking and savings on your last day</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="savings" data-path="money.savings" data-type="num"></div><span class="hint">If that day hasn't come yet, your best guess.</span></div>
<div class="field"><label for="finalPay">Final paycheck and unused vacation</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="finalPay" data-path="money.finalPay" data-type="num"></div><span class="hint">Kentucky requires final wages by your next regular payday or 14 days after you leave, whichever is later.</span></div>
<div class="field"><label for="severance">Severance, after taxes</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="severance" data-path="money.severance" data-type="num"></div></div>
<div class="field"><label for="otherGross">Other household pay per month, before taxes</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="otherGross" data-path="money.otherGross" data-type="num"></div><span class="hint">A spouse's or partner's job. Used for Medicaid and kynect.</span></div>
<div class="field"><label for="otherNet">The same pay, take-home per month</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="otherNet" data-path="money.otherNet" data-type="num"></div><span class="hint">What actually lands in the bank.</span></div>
</div>
<div class="answer" id="out3"></div>
</section>
<!-- STEP 4 -->
<section class="step" aria-labelledby="s4h">
<div class="step-num" aria-hidden="true">4</div>
<h2 id="s4h">Health coverage</h2>
<p class="why">This is usually the biggest decision after a layoff, and the most expensive one to get wrong. You have 60 days from losing work coverage to choose. Kentucky has three doors besides COBRA, and the cheapest is often the one people don't think they qualify for.</p>
<div class="grid">
<div class="field"><label for="covEnds">Work coverage ends</label><input type="date" id="covEnds" data-path="health.coverageEnds" data-type="date"><span class="hint">Often the last day of the month you leave. Check your notice.</span></div>
<div class="field"><label for="who">Who's on your work plan now</label>
<select id="who" data-path="health.who">
<option value="me">Just me</option>
<option value="family">Me and family</option>
</select></div>
<div class="field"><label for="cobra">COBRA price per month</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="cobra" data-path="health.cobra" data-type="num"></div><span class="hint" id="cobraHint">Use the number on your COBRA notice.</span></div>
</div>
<details class="opt"><summary>More details <span>(optional): kynect price, next year's income, a spouse's plan</span></summary>
<div class="grid">
<div class="field"><label for="bench">Benchmark silver price from kynect, per month</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="bench" placeholder="Optional" data-path="health.benchmark" data-type="optnum"></div><span class="hint">From kynect's plan browser, the second-cheapest silver plan for the people you'd enroll.</span></div>
<div class="field"><label for="income27">Household income for 2027, if you know better</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="income27" placeholder="Leave blank to estimate" data-path="health.income2027" data-type="optnum"></div></div>
<div class="field"><label for="returnWeeks">Weeks until you expect to work again</label><input type="number" id="returnWeeks" min="1" max="104" step="1" data-path="health.returnWeeks" data-type="int"><span class="hint">Used for next year's kynect income and a "back at work" scenario. The plan itself assumes no new job.</span></div>
<div class="field"><label for="otherCost">Other option, per month</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="otherCost" data-path="health.otherCost" data-type="num"></div><span class="hint">A spouse's work plan, for example.</span></div>
</div>
</details>
<div class="doors" id="doors"></div>
<div class="pick-auto" id="autoPick"></div>
<label class="check" id="switchWrap" hidden><input type="checkbox" id="switchAfter" data-path="health.switchAfter" data-type="bool"><span id="switchLabel">Move the adults to Medicaid after unemployment ends</span></label>
<div class="answer" id="out4"></div>
</section>
<!-- STEP 5 -->
<section class="step" aria-labelledby="s5h">
<div class="step-num" aria-hidden="true">5</div>
<h2 id="s5h">Bills, in the order to protect them</h2>
<p class="why">List what you pay each month (leave out health insurance; that's step 4). In the second column, put what you'll pay after a few phone calls and cuts. The order below tells you which calls to make first.</p>
<div class="scroll">
<table class="bills" id="billsTable">
<thead><tr><th scope="col">Bill</th><th scope="col">Kind</th><th scope="col">Per month now</th><th scope="col">While job hunting</th><th scope="col">Priority</th><th scope="col"><span class="visually-hidden">Remove</span></th></tr></thead>
<tbody id="billsBody"></tbody>
</table>
</div>
<button class="btn small" type="button" id="addBill" style="margin-top:10px">Add a bill</button>
<div class="bill-total" id="billTotal"></div>
<div class="answer" id="out5"></div>
</section>
<!-- STEP 6 -->
<section class="step" aria-labelledby="s6h">
<div class="step-num" aria-hidden="true">6</div>
<h2 id="s6h">Before you touch your 401(k)</h2>
<p class="why">Cashing out retirement money feels like the fastest fix. Here's what it costs once the IRS, the penalty and Kentucky take their share.</p>
<div class="grid">
<div class="field"><label for="planType">Kind of account</label>
<select id="planType" data-path="retire.plan">
<option value="401k">401(k) or 403(b) from this job</option>
<option value="457">Government 457(b) from this job</option>
<option value="ira">IRA</option>
</select></div>
<div class="field"><label for="balance">Balance</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="balance" data-path="retire.balance" data-type="num"></div></div>
<div class="field"><label for="withdraw">Amount you're thinking of taking out</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="withdraw" data-path="retire.withdraw" data-type="num"></div></div>
</div>
<details class="opt"><summary>More details <span>(optional): 401(k) loan, which year, your tax picture</span></summary>
<div class="grid">
<div class="field"><label for="loan">Unpaid 401(k) loan</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="loan" data-path="retire.loan" data-type="num"></div></div>
<div class="field"><label for="wYear">Year you'd take it out</label>
<select id="wYear" data-path="retire.year" data-type="int"><option value="2026">2026</option><option value="2027">2027</option></select></div>
<div class="field"><label for="taxBase">Taxable income that year without it</label><div class="money"><input type="text" inputmode="decimal" autocomplete="off" id="taxBase" placeholder="Leave blank to estimate" data-path="retire.taxBase" data-type="optnum"></div><span class="hint">After the standard deduction. Blank lets the page estimate it.</span></div>
</div>
</details>
<label class="check" style="margin-top:12px"><input type="checkbox" id="incl" data-path="retire.include" data-type="bool"><span>Add the after-tax cash to my plan</span></label>
<div class="answer" id="out6"></div>
</section>
</div>
<aside class="panel" aria-labelledby="panelH">
<div class="panel-box">
<h2 id="panelH">Your money lasts</h2>
<div class="weeks" id="pWeeks">–</div>
<p class="until" id="pUntil"></p>
<p class="worth" id="pWorth"></p>
<svg class="mini" id="miniChart" role="img" aria-label="Small chart of your balance week by week"></svg>
<div class="levers-wrap"><h3>What's adding weeks</h3><ul class="levers" id="pLevers"></ul></div>
<div class="next-wrap"><h3>Next deadlines</h3><ul class="next" id="pNext"></ul></div>
<a class="jump" href="#plan">See the full week-by-week plan</a>
</div>
</aside>
</div>
<section class="results" id="plan" aria-labelledby="planH">
<div class="results-inner">
<h2 id="planH">Your bridge, week by week</h2>
<p class="sub" id="planSub">Each plank is a week. It stands above the water while you still have money. The week it drops below is the week you run out.</p>
<div class="chart-wrap" id="chartWrap" tabindex="0" aria-describedby="chartHelp">
<svg id="bridgeChart" role="img" aria-labelledby="chartTitle"><title id="chartTitle">Bank balance at the end of each week for 52 weeks</title></svg>
<div class="tip" id="tip" hidden></div>
</div>
<p id="chartHelp" class="visually-hidden">Use the left and right arrow keys to move between weeks.</p>
<p class="visually-hidden" id="chartLive" aria-live="polite"></p>
<p class="marklist" id="markList"></p>
<div class="legend" aria-hidden="true">
<span><i style="background:#24576A"></i>Money left</span>
<span><i style="background:#A9343A"></i>Short</span>
<span><i style="background:#3B6A37"></i>Unemployment paid that week</span>
<span><i style="background:#E3A72F"></i>Deadline or change</span>
</div>
<div class="scenarios" id="scenarios"></div>
<details class="more"><summary>Show the week-by-week table</summary><div class="scroll"><table class="data" id="weekTable"></table></div></details>
<div class="cols">
<div>
<h2 style="font-size:1.6rem">Your dates</h2>
<p class="sub">Every date comes from your last day of work. "Add dates to my calendar" saves them as a file your phone or computer calendar can open.</p>
<ol class="timeline" id="timeline"></ol>
</div>
<div>
<h2 style="font-size:1.6rem">Numbers this page uses</h2>
<p class="sub">Every rate and limit, where it comes from, and when it was checked. If a number changes, this is where to fix it.</p>
<div class="scroll"><table class="data" id="sources"></table></div>
</div>
</div>
</div>
</section>
<footer class="foot">
<h2>Read this before you rely on it</h2>
<p class="disclaimer"><strong>For education only.</strong> Bridge gives estimates, not financial, investment, tax, legal or benefits advice. It does not recommend any investment. Kentucky's Office of Unemployment Insurance decides your benefits, kynect and the Department for Community Based Services decide Medicaid and KCHIP, and your plan administrator handles your 401(k). Rules change; check the numbers in "Numbers this page uses" against the source before acting on them.</p>
<p><strong>Where to get help.</strong> Unemployment: kcc.ky.gov or 502-564-2900. Health coverage, Medicaid, KCHIP and SNAP: kynect.ky.gov or 1-855-459-6328. Utility help and the winter Certificate of Need: your local Community Action agency (capky.org, 1-800-456-3452). Anything else: dial 211.</p>
<p><strong>What Bridge doesn't do.</strong></p>
<ul class="limits">
<li>It assumes no new job, so it shows the worst case you're planning around.</li>
<li>It doesn't cover self-employment or gig-only work, which usually doesn't qualify for Kentucky unemployment, and it only notes federal, military and out-of-state wages.</li>
<li>It can't look up kynect plan prices. Enter the benchmark silver price from kynect for a sharper number.</li>
<li>It checks SNAP and LIHEAP income limits but doesn't estimate the benefit amounts.</li>
<li>It doesn't recommend investments or tell you what to do with your 401(k); it shows what each choice costs.</li>
</ul>
<p><strong>Credits.</strong> Built for the Kentucky PFM Challenge 2026 by Jack Bolyard, with an AI assistant. All code, text and the illustration are original to this page. No third-party code is used. Released under the MIT License; the full license is in the page source. If you publish a changed copy, keep the copyright notice and credit "Based on Bridge by Jack Bolyard."</p>
</footer>
</main>
<div class="mbar" aria-hidden="true"><span id="mText">Your money lasts –</span><a href="#plan" tabindex="-1">See plan</a></div>
<div class="toast" id="toast" role="status" hidden></div>
<section id="printPlan" class="print-only" aria-hidden="true"></section>
<p class="visually-hidden" id="announce" aria-live="polite"></p>
<script>
"use strict";
/* ======================================================================
NUMBERS THIS PAGE USES (rendered into the "Numbers" table too)
====================================================================== */
const C = {
uiRate: 0.011923, uiMin: 39, uiMax: 746, uiWeeksNow: 16,
uiPartialDeduct: 0.80, uiFedW: 0.10, uiStW: 0.035,
uiInLieuMaxWeeks: 4, uiFirstRequestDays: 13,
kyTax: 0.035, kyPensionExclusion: 31110,
fpl2026: [15960,21640,27320,33000,38680,44360,50040,55720], fplAdd: 5680,
// kynect monthly Medicaid limits, April 2026 chart
ky138: [1836,2489,3142,3795,4449,5102,5755,6408], ky138Add: 654,
ky218: [2900,3932,4964,5995,7027,8059,9091,10123], ky218Add: 1032,
ky150: [1995,2705,3415,4125,4835,5545,6255,6965], ky150Add: 710,
// 2027 premium tax credit applicable percentages (Rev. Proc. 2026-26)
ptc2027: [[0,133,2.15,2.15],[133,150,3.23,4.30],[150,200,4.30,6.78],[200,250,6.78,8.66],[250,300,8.66,10.22],[300,400,10.22,10.22]],
kffSingle: 9804, kffFamily: 28303, cobraMarkup: 1.02,
macePerMonthEarnings: 580, maceHours: 80, maceStart: "2027-01-01",
stdDed: {single:16100, mfj:32200, hoh:24150},
brackets: {
single:[[12400,.10],[50400,.12],[105700,.22],[201775,.24],[256225,.32],[640600,.35],[Infinity,.37]],
mfj:[[24800,.10],[100800,.12],[211400,.22],[403550,.24],[512450,.32],[768700,.35],[Infinity,.37]],
hoh:[[17700,.10],[67450,.12],[105700,.22],[201750,.24],[256200,.32],[640600,.35],[Infinity,.37]]
},
earlyPenalty: 0.10, mandatoryW: 0.20
};
const SOURCES = [
["Unemployment: weekly amount","1.1923% of base-period wages, $39 to $746 a week (claims filed on or after July 5, 2026)","Kentucky Career Center, Claimant FAQs (updated June 29, 2026); Claimant Guide PAM-UI-400, rev. 02/26","kcc.ky.gov"],
["Unemployment: weeks","16 weeks while the state average jobless rate is 6.5% or lower, up to 24 weeks; approved training can add up to 5 (24 max). The claim's total is the weekly amount times the weeks, so smaller partial checks stretch it within the 52-week benefit year","Claimant Guide PAM-UI-400, rev. 02/26 (KRS 341.385)","kcc.ky.gov"],
["Unemployment: timing","Weeks run Sunday to Saturday; the effective date is the Sunday of the week you file; one unpaid waiting week; first request 13 days after filing, then every 2 weeks, Sunday to Friday; payment usually 2 to 3 days after a request; the claim system is closed Saturdays","Claimant Guide PAM-UI-400, rev. 02/26","kcc.ky.gov"],
["Unemployment: rules","5 work-search activities a week (3 applications or interviews); 80% of part-time wages deducted; severance and vacation pay not deducted; pay in lieu of notice deducted up to 4 weeks; after 6 weeks, must accept work within 30 miles paying 120% of your weekly amount; optional 10% federal and 3.5% state withholding","Claimant Guide PAM-UI-400, rev. 02/26","kcc.ky.gov"],
["Unemployment: qualifying wages","$1,500 in one quarter; total at least 1.5 times the best quarter; $1,500 outside the best quarter; last two base quarters at least 8 times the weekly amount","Claimant Guide PAM-UI-400, rev. 02/26","kcc.ky.gov"],
["Final paycheck","Due by the next regular payday or 14 days after you leave, whichever is later","KRS 337.055","legislature.ky.gov"],
["Poverty guidelines","2026 HHS guidelines: $15,960 for 1 person, plus $5,680 per person","Federal Register, Jan. 15, 2026 (91 FR 1797)","federalregister.gov"],
["Medicaid and KCHIP limits","Adults 138% of poverty; uninsured children up to 218% (monthly amounts by household size). Unemployment counts as income","kynect FPL chart, 2026 Medicaid table, effective April 1, 2026","khbe.ky.gov"],
["Medicaid work rule","From Jan. 1, 2027, many expansion adults 19 to 64 must show 80 hours of work, job training, school or community service, or $580 of earnings, in the month before applying; job search isn't on the list; parents of a child 13 or younger, pregnant people and others are exempt","kynect Medicaid Work or Community Engagement FAQ (Sept. 15, 2026)","khbe.ky.gov"],
["kynect special enrollment","Losing job coverage opens a window 60 days before and 60 days after the loss; a plan picked on or before the last day of coverage starts the 1st of the next month","Kentucky Health Benefit Exchange, Special Enrollment Details","khbe.ky.gov"],
["kynect premium tax credit, 2027","You pay 2.15% to 10.22% of income for the benchmark silver plan; no credit above 400% of poverty (the enhanced credits expired after 2025)","IRS Rev. Proc. 2026-26; KFF, Oct. 2026","irs.gov"],
["COBRA estimate","102% of the full premium. If you enter no price, the page uses the 2026 national average: $9,804 a year single, $28,303 family","KFF 2026 Employer Health Benefits Survey (Oct. 22, 2026); 29 U.S.C. 1162","kff.org"],
["SNAP","Kentucky uses broad-based categorical eligibility: gross income up to 200% of poverty, no asset test. Federal maximum for 4 people: $1,023 a month (Oct. 2026 to Sept. 2027)","USDA Food and Nutrition Service: BBCE states chart (June 2026); FY2027 cost-of-living adjustment","fns.usda.gov"],
["Federal income tax","2026 brackets and standard deduction: $16,100 single, $32,200 married, $24,150 head of household","IRS Rev. Proc. 2025-32","irs.gov"],
["Kentucky income tax","3.5% flat rate for 2026","KRS 141.020(2)(f)","legislature.ky.gov"],
["Kentucky retirement exclusion","Up to $31,110 a person of pension, 401(k) and IRA income excluded, with no age requirement","Kentucky Schedule P instructions","revenue.ky.gov"],
["Early-withdrawal rules","10% extra tax before 59½, except after leaving an employer plan in or after the year you turn 55, or from a government 457(b); 20% federal withholding on cash paid from an employer plan","IRS Topic 558; 26 U.S.C. 72(t), 3405(c)","irs.gov"],
["Student loans","Unemployment deferment ends for federal loans made on or after July 1, 2027","One Big Beautiful Bill Act (Public Law 119-21)","studentaid.gov"],
["Utility help","LIHEAP fall subsidy (Nov.–Dec.) and crisis help (Jan.–Mar.) at or below 130–150% of poverty; Nov. 1 to Mar. 31 a Community Action Certificate of Need can hold off a shutoff by a state-regulated utility for 30 days","Community Action Kentucky; PSC regulation 807 KAR 5:006","capky.org"],
["Health FSA","Your whole annual election can be spent from the start of the plan year (the uniform coverage rule); money left when you leave is usually lost","Proposed Treas. Reg. §1.125-5(d); IRS Publication 969","irs.gov"],
["Who collects","10.6% of unemployed Kentuckians received unemployment benefits in 2025, against 26.5% nationally","Federal Reserve Bank of Cleveland, Community Development report (July 1, 2026)","clevelandfed.org"],
["Kentucky layoffs","BlueOval SK's WARN notice listed about 1,500 terminations at its Glendale battery plant, starting around Feb. 14, 2026","Louisville Courier Journal (Dec. 2025); Manufacturing Dive (Feb. 2026)","courier-journal.com"]
];
const CHECKED = "Nov. 3, 2026";
const CATS = {
housing:{label:"Housing", tier:1, title:"Keep a roof", text:"Call your landlord or mortgage servicer before you miss a payment, not after. Servicers can offer forbearance or a repayment plan; a landlord who hears from you early is more likely to wait. Dial 211 for local rent help."},
utilities:{label:"Utilities", tier:1, title:"Keep the heat and lights on", text:"From November 1 to March 31, a Certificate of Need from your local Community Action agency can hold off a shutoff by a state-regulated utility for 30 days. LIHEAP pays part of heating bills: the fall subsidy runs in November and December, crisis help January through March."},
food:{label:"Food", tier:1, title:"Keep food on the table", text:"Apply for SNAP at kynect.ky.gov. A food pantry can fill gaps while the application is processed; dial 211 to find one."},
car:{label:"Car", tier:1, title:"Keep the car that gets you to interviews", text:"Kentucky requires insurance on any car you drive, so don't let it lapse. Ask the lender for a one- or two-month payment extension; many will do it once."},
childcare:{label:"Childcare", tier:2, title:"Keep what lets you interview and work", text:"Ask your local DCBS office about the Child Care Assistance Program before dropping care you'll need again when you start a new job."},
phone:{label:"Phone, internet", tier:2, title:"Stay reachable", text:"Employers and the unemployment office will call and email. Drop to a cheaper plan instead of going without, and ask about the federal Lifeline discount."},
student:{label:"Student loan", tier:3, title:"Pause it", text:"Federal loans taken out before July 1, 2027 can be put on unemployment deferment for up to 3 years, or moved to an income-driven plan where the payment can fall to near zero. Call your servicer; private lenders may offer forbearance."},
medical:{label:"Medical bill", tier:3, title:"Ask for financial assistance first", text:"Nonprofit hospitals must have a financial assistance policy. Ask for the application before you pay; with lower income you may owe less or nothing. Payment plans are often interest-free."},
credit:{label:"Card or loan", tier:4, title:"Call each lender", text:"Card issuers have hardship programs that lower the rate or payment for a few months. Pay at least the minimum if you can. Money in a 401(k) is generally protected from creditors; once you withdraw it to pay a card, it isn't."},
other:{label:"Other", tier:5, title:"Cancel or pause extras", text:"Subscriptions, memberships and extras are the first place to find money. You can restart them when you're working again."}
};
const CAT_KEYS = Object.keys(CATS);
const TIERS = {
1:{name:"Protect first", tag:"Protect", cls:"good"},
2:{name:"Keep if you can", tag:"Keep", cls:""},
3:{name:"Pause or lower", tag:"Pause", cls:""},
4:{name:"Ask for a hardship plan", tag:"Hardship plan", cls:"gold"},
5:{name:"Cut for now", tag:"Cut", cls:"gold"}
};
/* ======================================================================
STATE
====================================================================== */
const APP_ID = "ky-layoff-bridge", APP_VERSION = 1;
function blankState(){
return {
person:{lastDay:"", reason:"layoff", age:"", filing:"single", hh:1, kids:0, youngest:""},
wages:{mode:"annual", annual:0, q:[0,0,0,0], weeks:16, pt:0, inLieu:0, count:true, fedW:false, stW:false, fileDate:""},
money:{savings:0, finalPay:0, severance:0, otherGross:0, otherNet:0},
health:{coverageEnds:"", who:"me", cobra:0, returnWeeks:16, income2027:null, benchmark:null, otherCost:0, choice:"auto", switchAfter:true},
bills:[
{name:"Rent or mortgage", cat:"housing", now:0, during:0},
{name:"Electric, gas, water", cat:"utilities", now:0, during:0},
{name:"Groceries", cat:"food", now:0, during:0},
{name:"Car payment", cat:"car", now:0, during:0},
{name:"Car insurance", cat:"car", now:0, during:0},
{name:"Phone and internet", cat:"phone", now:0, during:0},
{name:"Credit card minimums", cat:"credit", now:0, during:0}
],
retire:{plan:"401k", balance:0, withdraw:0, loan:0, year:2026, taxBase:null, include:false}
};
}
/* The example always looks ahead: Dana's last day is the first Friday at least
two weeks from today, so she is always someone holding a layoff notice. */
function exampleDates(){
let d=addDays(today(),14); while(d.getDay()!==5) d=addDays(d,1);
return {last:d, cov:new Date(d.getFullYear(), d.getMonth()+1, 0)};
}
function exampleState(){
const ex=exampleDates();
return {
person:{lastDay:iso(ex.last), reason:"layoff", age:41, filing:"mfj", hh:4, kids:2, youngest:8},
wages:{mode:"annual", annual:49920, q:[12480,12480,12480,12480], weeks:16, pt:0, inLieu:0, count:true, fedW:true, stW:false, fileDate:""},
money:{savings:2100, finalPay:1650, severance:0, otherGross:2250, otherNet:1850},
health:{coverageEnds:iso(ex.cov), who:"family", cobra:2406, returnWeeks:20, income2027:null, benchmark:null, otherCost:0, choice:"auto", switchAfter:true},
bills:[
{name:"Mortgage", cat:"housing", now:1240, during:1240},
{name:"Electric, gas, water", cat:"utilities", now:280, during:280},
{name:"Groceries", cat:"food", now:950, during:850},
{name:"Truck payment", cat:"car", now:430, during:430},
{name:"Car insurance, two cars", cat:"car", now:190, during:190},
{name:"Phone and internet", cat:"phone", now:180, during:130},
{name:"Credit card minimums", cat:"credit", now:220, during:220},
{name:"Federal student loan", cat:"student", now:190, during:0},
{name:"Hospital payment plan", cat:"medical", now:85, during:85},
{name:"After-school care", cat:"childcare", now:320, during:320},
{name:"Streaming and gym", cat:"other", now:75, during:0}
],
retire:{plan:"401k", balance:18500, withdraw:10000, loan:0, year:Math.min(2027,Math.max(2026,ex.last.getFullYear())), taxBase:null, include:false}
};
}
let state;
let isExample = true;
let noticeMode = "example";
let dirty = false;
let lastResult = null;
/* ======================================================================
SMALL HELPERS
====================================================================== */
const $ = id => document.getElementById(id);
const fmt$ = new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0});
const fmt$c = new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2});
const money = n => fmt$.format(Math.round(n||0));
const pct = (n,d=1) => (Math.round(n*Math.pow(10,d))/Math.pow(10,d)).toFixed(d)+"%";
function esc(s){return String(s).replace(/[&<>"']/g,c=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[c]));}
function num(v){const n=Number(v);return Number.isFinite(n)&&n>0?n:0;}
function parseDate(s){ if(typeof s!=="string"||!/^\d{4}-\d{2}-\d{2}$/.test(s)) return null; const [y,m,d]=s.split("-").map(Number); const dt=new Date(y,m-1,d); return (dt.getFullYear()===y&&dt.getMonth()===m-1&&dt.getDate()===d)?dt:null; }
function addDays(d,n){const x=new Date(d.getFullYear(),d.getMonth(),d.getDate());x.setDate(x.getDate()+n);return x;}
function iso(d){return d.getFullYear()+"-"+String(d.getMonth()+1).padStart(2,"0")+"-"+String(d.getDate()).padStart(2,"0");}
const MON=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
function fmtDate(d,withYear=true){return d?MON[d.getMonth()]+" "+d.getDate()+(withYear?", "+d.getFullYear():""):"";}
function daysBetween(a,b){return Math.round((b-a)/86400000);}
function today(){const n=new Date();return new Date(n.getFullYear(),n.getMonth(),n.getDate());}
function byHH(arr,add,n){n=Math.max(1,Math.round(n||1));return n<=arr.length?arr[n-1]:arr[arr.length-1]+(n-arr.length)*add;}
function getPath(o,p){return p.split(".").reduce((a,k)=>a==null?a:a[k],o);}
function setPath(o,p,v){const ks=p.split(".");let a=o;for(let i=0;i<ks.length-1;i++){a=a[ks[i]];}a[ks[ks.length-1]]=v;}
function plural(n,w){if(w==="person")return n+(n===1?" person":" people");return n+" "+w+(n===1?"":"s");}
const DOW=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
function fmtDay(d){return d?DOW[d.getDay()]+", "+fmtDate(d):"";}
function parseMoney(v){ if(v==null) return 0; const n=Number(String(v).replace(/[^0-9.]/g,"")); return Number.isFinite(n)&&n>0?n:0; }
const fmtN = new Intl.NumberFormat("en-US",{maximumFractionDigits:2});
function fmtMoneyInput(v){ if(v===""||v==null) return ""; const n=Number(v); return Number.isFinite(n)?fmtN.format(n):""; }
function sundayAfter(d){ const k=d.getDay(); return addDays(d, k===0?7:7-k); }
function sundayOnOrBefore(d){ return addDays(d,-d.getDay()); }
function firstOfNextMonth(d){ return new Date(d.getFullYear(), d.getMonth()+1, 1); }
function overlapDays(a0,a1,b0,b1){ const st=a0>b0?a0:b0, en=a1<b1?a1:b1; return en<st?0:daysBetween(st,en)+1; }
function round100(n){ return Math.round(n/100)*100; }
/* ======================================================================
CALCULATIONS
====================================================================== */
function baseQuarters(fileDate){
const abs = fileDate.getFullYear()*4 + Math.floor(fileDate.getMonth()/3);
const out=[];
for(let k=5;k>=2;k--){
const a=abs-k, y=Math.floor(a/4), q=a%4;
out.push({y, q:q+1, start:new Date(y,q*3,1), end:new Date(y,q*3+3,0), label:MON[q*3]+"–"+MON[q*3+2]+" "+y});
}
return out;
}
function fedTax(ti,status){
ti=Math.max(0,ti); let tax=0, lo=0;
for(const [hi,r] of C.brackets[status]){ if(ti>lo){tax+=(Math.min(ti,hi)-lo)*r;} lo=hi; if(ti<=hi) break; }
return tax;
}
function marginalRate(ti,status){ for(const [hi,r] of C.brackets[status]){ if(ti<hi) return r; } return .37; }
function applicablePct(fplPct){
for(const [lo,hi,a,b] of C.ptc2027){
if(fplPct>=lo && fplPct<hi){ if(a===b) return a; return a+(b-a)*(fplPct-lo)/(hi-lo); }
}
return fplPct>=400?null:C.ptc2027[0][2];
}
function computeUI(s){
const last = parseDate(s.person.lastDay);
// Kentucky weeks run Sunday to Saturday. The first full week without work is the waiting week.
let firstSunday=null, fileDate=null, effSunday=null, fileDefault=true;
if(last){
firstSunday = sundayAfter(last);
const fd = parseDate(s.wages.fileDate);
if(fd && fd>last){ fileDate=fd; fileDefault=false; } else fileDate=firstSunday;
effSunday = sundayOnOrBefore(fileDate); if(effSunday<firstSunday) effSunday=firstSunday;
}
const bq = effSunday ? baseQuarters(effSunday) : null;
let q = s.wages.mode==="quarters" ? s.wages.q.map(num) : [0,0,0,0].map(()=>num(s.wages.annual)/4);
const total = q.reduce((a,b)=>a+b,0);
const hq = Math.max(...q);
let wba = Math.floor(C.uiRate*total);
wba = Math.min(C.uiMax, Math.max(C.uiMin, wba));
const checks = [
{ok: hq>=1500, text:"At least $1,500 in your best quarter"},
{ok: total>=1.5*hq && total>0, text:"Total at least 1.5 times your best quarter"},
{ok: total-hq>=1500, text:"At least $1,500 outside your best quarter"},
{ok: q[2]+q[3] >= 8*wba, text:"Last two base quarters at least 8 times your weekly amount"}
];
const valid = total>0 && checks.every(c=>c.ok);
const weeks = Math.min(24,Math.max(16,Math.round(num(s.wages.weeks)||16)));
const pt = num(s.wages.pt);
const gross = valid ? Math.max(0, wba - C.uiPartialDeduct*pt) : 0;
const wRate = (s.wages.fedW?C.uiFedW:0)+(s.wages.stW?C.uiStW:0);
const net = gross*(1-wRate);
const weeklyWage = total/52;
const inLieu = num(s.wages.inLieu);
const delay = inLieu>0 && weeklyWage>0 ? Math.min(C.uiInLieuMaxWeeks, Math.ceil(inLieu/weeklyWage)) : 0;
const schedule=[]; // one entry per paid week
let firstRequest=null, firstPay=null, lastWeekEnd=null, sixWeeks=null;
if(last){
// First request: 13 days after filing, once the first two weeks have ended; requests aren't taken on Saturdays.
firstRequest = addDays(fileDate, C.uiFirstRequestDays);
const earliest = addDays(effSunday,14); if(firstRequest<earliest) firstRequest=earliest;
if(firstRequest.getDay()===6) firstRequest=addDays(firstRequest,1);
// The claim's total is the weekly amount times the weeks allowed. Partial checks draw it down
// more slowly, so they can stretch it, but never past the 52-week benefit year.
let remaining = valid ? wba*weeks : 0;
const yearEnd = addDays(effSunday, 52*7-1);
for(let j=1+delay; remaining>0.5 && gross>0; j++){
const weekSun = addDays(effSunday,7*j);
if(weekSun>yearEnd) break;
const g = Math.min(gross, remaining);
const payDate = addDays(firstRequest, 14*Math.floor(j/2) + 3);
schedule.push({j, weekSun, weekEnd:addDays(weekSun,6), payDate, gross:g, net:g*(1-wRate)});
remaining -= g;
}
if(schedule.length){
firstPay = schedule[0].payDate;
lastWeekEnd = schedule[schedule.length-1].weekEnd;
sixWeeks = schedule[Math.min(5,schedule.length-1)].weekEnd;
}
}
return {last, firstSunday, fileDate, fileDefault, effSunday, bq, q, total, hq, wba: valid?wba:0, rawWba:wba, valid, checks, weeks, pt, gross, net, wRate, delay, schedule,
maxBenefit: valid? wba*weeks : 0, paidWeeks: schedule.length, firstRequest, firstPay, lastWeekEnd, sixWeeks, weeklyWage};
}
/* Plan weeks follow Kentucky's Sunday-to-Saturday weeks. Week 1 also takes in
any days between your last day and the first Sunday. */
function simStart(ui,i){ return i===1 ? addDays(ui.last,1) : addDays(ui.firstSunday,7*(i-1)); }
function simEnd(ui,i){ return addDays(ui.firstSunday,7*(i-1)+6); }
function simWeekOf(ui,d){ if(d<ui.firstSunday) return 1; return Math.floor(daysBetween(ui.firstSunday,d)/7)+1; }
function computeHealth(s, ui){
const hh = Math.max(1, Math.round(num(s.person.hh)||1));
const kids = Math.min(hh-1, Math.round(num(s.person.kids)));
const adults = Math.max(1, hh-kids);
const counting = s.wages.count && ui.valid;
const uiMonthly = counting ? ui.gross*52/12 : 0;
const monthly = uiMonthly + num(s.money.otherGross) + ui.pt*52/12;
const lim138 = byHH(C.ky138,C.ky138Add,hh), lim218 = byHH(C.ky218,C.ky218Add,hh), lim150 = byHH(C.ky150,C.ky150Add,hh);
const adultsMedicaid = monthly <= lim138;
const kidsChip = kids>0 && monthly <= lim218;
const fpl = byHH(C.fpl2026,C.fplAdd,hh);
// estimated 2027 household income
let est2027 = num(s.money.otherGross)*12;
const last = ui.last;
let returnDate=null;
if(last){
returnDate = addDays(last, Math.max(1,Math.round(num(s.health.returnWeeks)||16))*7);
const y0=new Date(2027,0,1), y1=new Date(2028,0,1);
if(counting){
for(const w of ui.schedule){
if(w.payDate>=y0 && w.payDate<y1 && w.weekSun<returnDate) est2027 += w.gross;
}
}
const startNew = returnDate>y0?returnDate:y0;
if(startNew<y1){ const annual = ui.total>0 ? ui.total : num(s.wages.annual); est2027 += annual*daysBetween(startNew,y1)/365; }
// part-time pay until the new job
if(ui.pt>0){ const ptEnd = returnDate<y1?returnDate:y1; const ptStart = last>y0?last:y0; if(ptEnd>ptStart) est2027 += ui.pt*daysBetween(ptStart,ptEnd)/7; }
}
const income2027 = s.health.income2027!=null && s.health.income2027!=="" ? num(s.health.income2027) : Math.round(est2027);
const fplPct = fpl>0 ? income2027/fpl*100 : 0;
let ptc = {status:"", pctApplied:null, contribution:null, cost:null, credit:null};
const bench = s.health.benchmark!=null && s.health.benchmark!=="" ? num(s.health.benchmark) : null;
if(adultsMedicaid){ ptc.status="medicaid"; }
else if(fplPct<100){ ptc.status="below"; ptc.cost = bench; }
else if(fplPct>400){ ptc.status="above"; ptc.cost = bench; }
else {
ptc.status="eligible";
ptc.pctApplied = applicablePct(fplPct);
ptc.contribution = income2027*ptc.pctApplied/100/12;
if(bench!=null){ ptc.credit = Math.max(0, bench-ptc.contribution); ptc.cost = Math.min(bench, ptc.contribution); }
else ptc.cost = ptc.contribution;
ptc.csr = fplPct<=250;
}
const cobraDefault = (s.health.who==="family"?C.kffFamily:C.kffSingle)*C.cobraMarkup/12;
const cobra = num(s.health.cobra)>0 ? num(s.health.cobra) : cobraDefault;
const cobraIsDefault = !(num(s.health.cobra)>0);
const other = num(s.health.otherCost);
const options = [];
if(adultsMedicaid) options.push({key:"medicaid", cost:0});
if(ptc.cost!=null && !adultsMedicaid) options.push({key:"kynect", cost:ptc.cost});
options.push({key:"cobra", cost:cobra});
if(other>0) options.push({key:"other", cost:other});
let choice = s.health.choice;
if(choice!=="auto" && !options.find(o=>o.key===choice)) choice="auto";
let picked;
if(choice==="auto"){ picked = options.slice().sort((a,b)=>a.cost-b.cost)[0]; }
else picked = options.find(o=>o.key===choice);
const covEnds = parseDate(s.health.coverageEnds) || (last? new Date(last.getFullYear(), last.getMonth()+1, 0) : null);
const deadline = covEnds ? addDays(covEnds,60) : null;
const kynectStart = covEnds ? firstOfNextMonth(covEnds) : null;
// Medicaid work rule
const youngest = s.person.youngest===""||s.person.youngest==null ? null : Number(s.person.youngest);
const parentExempt = kids>0 && youngest!=null && youngest<=13;
const maceStart = parseDate(C.maceStart);
const age = num(s.person.age);
// When unemployment ends, household income drops. Medicaid counts this month's income.
const uiEnd = counting ? ui.lastWeekEnd : null;
const monthlyAfter = num(s.money.otherGross) + ui.pt*52/12;
const adultsAfter = monthlyAfter <= lim138;
const kidsAfter = kids>0 && monthlyAfter <= lim218;
const switchDate = uiEnd ? firstOfNextMonth(uiEnd) : null;
const canSwitch = !!(uiEnd && !adultsMedicaid && adultsAfter && picked && picked.key!=="medicaid" && (age===0 || age<65));
const switching = canSwitch && s.health.switchAfter!==false;
const ruleAfter = !!(switchDate && switchDate>=maceStart && !parentExempt);
// SNAP: Kentucky's gross income limit is 200% of the poverty line (broad-based categorical eligibility)
const snapLim = fpl*2/12;
const snapNow = monthly <= snapLim, snapAfter = monthlyAfter <= snapLim;
return {hh,kids,adults,monthly,uiMonthly,lim138,lim218,lim150,adultsMedicaid,kidsChip,fpl,income2027,est2027:Math.round(est2027),fplPct,ptc,bench,cobra,cobraIsDefault,cobraDefault,other,options,picked,choice,covEnds,deadline,kynectStart,parentExempt,maceStart,returnDate,
uiEnd,monthlyAfter,adultsAfter,kidsAfter,switchDate,canSwitch,switching,ruleAfter,snapLim,snapNow,snapAfter};
}
function billsTotals(s){
let now=0, during=0;
for(const b of s.bills){ now+=num(b.now); during+=num(b.during===""?b.now:b.during); }
return {now,during};
}
function computeRetire(s, ui){
const r=s.retire, W=num(r.withdraw), status=s.person.filing in C.stdDed ? s.person.filing : "single";
const age = num(s.person.age);
const Y = Number(r.year)||2026;
const last = ui.last;
// estimate taxable income in year Y before the withdrawal
let gross = num(s.money.otherGross)*12;
if(last && last.getFullYear()===Y){ const doy = daysBetween(new Date(Y,0,1), last)+1; gross += ui.total*doy/365; }
else if(last && last.getFullYear()<Y){ /* no wages from this job */ }
if(last && s.wages.count){ for(const w of ui.schedule){ if(w.payDate.getFullYear()===Y) gross+=w.gross; } }
if(last && last.getFullYear()===Y) gross += num(s.money.severance)/0.75; // rough gross-up of after-tax severance
const estBase = Math.max(0, gross - C.stdDed[status]);
const base = r.taxBase!=null && r.taxBase!=="" ? num(r.taxBase) : Math.round(estBase);
const fed = fedTax(base+W,status)-fedTax(base,status);
const employerPlan = r.plan==="401k"||r.plan==="457";
let penaltyReason="", penalty=0;
if(W>0){
if(age>=59.5){ penaltyReason="You're 59½ or older, so there's no early-withdrawal penalty."; }
else if(r.plan==="457"){ penaltyReason="Government 457(b) plans don't have the 10% early-withdrawal penalty."; }
else if(r.plan==="401k" && age>=55){ penaltyReason="You left this employer in or after the year you turned 55, so the 10% penalty doesn't apply to this plan (the \"rule of 55\")."; }
else { penalty = C.earlyPenalty*W; penaltyReason = r.plan==="ira" ? "IRAs don't get the rule-of-55 exception, so the 10% penalty applies before 59½." : (age===54 ? "If you turn 55 during the year you leave, the rule of 55 would apply. Otherwise the 10% penalty does." : "You're under 55, so the 10% early-withdrawal penalty applies."); }
}
const ky = C.kyTax*Math.max(0, W - C.kyPensionExclusion);
const net = Math.max(0, W - fed - penalty - ky);
const withheld = r.plan==="ira" ? 0.10*W : C.mandatoryW*W;
const check = W - withheld;
return {W,base,estBase:Math.round(estBase),fed,penalty,penaltyReason,ky,net,withheld,check,employerPlan,status,Y,
rate: W>0?(W-net)/W:0, marginal: marginalRate(base,status), loan:num(r.loan)};
}
function simulate(s, ui, health, opt){
const last = ui.last; if(!last) return null;
opt = opt||{};
const useUI = opt.noUI ? false : (s.wages.count && ui.valid);
const bills = billsTotals(s);
const billsMonthly = opt.noCuts ? bills.now : bills.during;
const healthMonthly = opt.health!=null ? opt.health : (health.picked?health.picked.cost:0);
const switchOn = opt.health==null && !opt.noSwitch && health.switching;
const covEnds = health.covEnds;
const day = 12/365;
const otherDaily = num(s.money.otherNet)*day;
const ptDaily = ui.pt*0.89/7;
let bal = num(s.money.savings);
const pay = {};
if(useUI) for(const w of ui.schedule){ const k=simWeekOf(ui,w.payDate); pay[k]=(pay[k]||0)+w.net; }
const weeks=[]; let runout=null, healthOut=0, billsOut=0, uiIn=0;
const retireCash = (!opt.noRetire && (s.retire.include || opt.forceRetire)) ? opt.retireNet||0 : 0;
const hStart = covEnds ? addDays(covEnds,1) : addDays(last,1);
for(let i=1;i<=52;i++){
const start=simStart(ui,i), end=simEnd(ui,i), days=daysBetween(start,end)+1;
let inflow = (otherDaily+ptDaily)*days + (pay[i]||0);
if(i===1) inflow += num(s.money.finalPay) + num(s.money.severance) + retireCash;
const b = billsMonthly*day*days;
let h;
if(switchOn && health.switchDate){
h = healthMonthly*day*overlapDays(start,end,hStart,addDays(health.switchDate,-1));
} else h = healthMonthly*day*overlapDays(start,end,hStart,end);
const out=b+h;
bal += inflow-out; healthOut+=h; billsOut+=b; uiIn+=(pay[i]||0);
weeks.push({i,start,end,inflow,out,ui:pay[i]||0,bal});
if(runout===null && bal<0) runout=i;
}
const lasts = runout===null ? 52 : runout-1;
return {weeks, runout, lasts, runoutDate: runout? weeks[runout-1].start : null, billsMonthly, healthMonthly, healthAfter: switchOn?0:healthMonthly, healthOut, billsOut, uiIn};
}
function computeAll(s){
const ui = computeUI(s);
const health = computeHealth(s, ui);
const retire = computeRetire(s, ui);
const plan = simulate(s, ui, health, {retireNet: retire.net});
let levers=[], worst=null, worth=null, retireWeeks=0;
if(plan){
const rn = retire.net;
const noUI = simulate(s, ui, health, {noUI:true, retireNet:rn});
const cobraSim = simulate(s, ui, health, {health: health.cobra, retireNet:rn});
const noSwitch = health.switching ? simulate(s, ui, health, {noSwitch:true, retireNet:rn}) : plan;
const noCuts = simulate(s, ui, health, {noCuts:true, retireNet:rn});
if(s.wages.count && ui.valid) levers.push({label:"Filing for unemployment", d: plan.lasts-noUI.lasts});
if(health.picked && health.picked.key!=="cobra") levers.push({label: health.picked.key==="medicaid"?(health.kids>0?"Medicaid and KCHIP instead of COBRA":"Medicaid instead of COBRA"):(health.picked.key==="kynect"?(health.kidsChip?"kynect and KCHIP instead of COBRA":"kynect instead of COBRA"):"Your other plan instead of COBRA"), d: noSwitch.lasts-cobraSim.lasts});
if(health.switching) levers.push({label:"Medicaid once unemployment ends", d: plan.lasts-noSwitch.lasts});
levers.push({label:"Your calls and cuts to bills", d: plan.lasts-noCuts.lasts});
if(s.retire.include && rn>0){ const noR = simulate(s, ui, health, {noRetire:true}); levers.push({label:"Cashing out retirement money", d: plan.lasts-noR.lasts}); }
worst = simulate(s, ui, health, {noUI:true, noCuts:true, health: health.cobra, noRetire:true});
worth = {ui: plan.uiIn, health: Math.max(0,worst.healthOut-plan.healthOut), bills: Math.max(0,worst.billsOut-plan.billsOut)};
worth.total = worth.ui + worth.health + worth.bills;
if(rn>0){ const withR = simulate(s, ui, health, {retireNet:rn, forceRetire:true}); const noR2 = simulate(s, ui, health, {noRetire:true}); retireWeeks = withR.lasts-noR2.lasts; }
}
return {ui, health, retire, plan, levers, worst, worth, retireWeeks, events: buildEvents(s, ui, health, retire, plan)};
}
/* ======================================================================
DATES
====================================================================== */
function buildEvents(s, ui, health, retire, plan){
const last = ui.last; if(!last) return [];
const ev=[];
const add=(date,title,text,kind)=>{ if(date) ev.push({date,title,text,kind}); };
const counting = ui.valid && s.wages.count;
const t0=today();
if(daysBetween(t0,last)>=3) add(addDays(last,-Math.min(7,daysBetween(t0,last))),"Use your health FSA and book appointments","You can spend your whole year's FSA election before you leave; what's left after your last day is usually lost. Refill prescriptions and get checkups while work coverage lasts. Save your last pay stubs and W-2s for your claim.","Job");
add(last,"Last day of work","Ask for your separation paperwork, the date health coverage ends, and how your final pay and any 401(k) loan will be handled.","Job");
add(ui.fileDate, ui.fileDefault?"File your unemployment claim":"Your unemployment claim is filed",
"File online at kcc.ky.gov or call 502-564-2900. Online filing is open Sunday 10 a.m.–9 p.m. and Monday–Friday 7 a.m.–7 p.m., and closed Saturdays. You'll verify your identity with ID.me first. Your first full week without work, Sunday to Saturday, is the unpaid waiting week, but you still have to claim it.","Unemployment");
if(counting){
add(ui.firstRequest,"Request your first benefit payment","Kentucky won't take a request sooner than 13 days after you file. Then request every two weeks, Sunday to Friday, and log 5 job-search activities each week (at least 3 applications or interviews). Keep proof for a year.","Unemployment");
add(ui.firstPay,"First unemployment payment, roughly","Usually 2 to 3 days after a request is approved. It covers your first paid week; the waiting week is never paid.","Unemployment");
if(ui.firstPay) add(addDays(ui.firstPay,7),"Ask the Kentucky Career Center about approved training","A short credential in a high-demand field can add up to 5 weeks of unemployment, excuses you from the weekly job search, and can count toward Medicaid's new 80-hour rule. Ask for the UI-800 training approval form before your benefits run out.","Unemployment");
add(ui.sixWeeks,"The \"suitable work\" rule starts","After 6 weeks of benefits, you must accept a job within 30 miles (or remote) that pays at least "+money(ui.wba*1.2)+" a week (120% of your benefit), if you're able to do the work, even without experience in it.","Unemployment");
let endText = "That's "+plural(ui.paidWeeks,"paid week")+". Approved training started before then can add up to 5 more weeks (24 total).";
if(health.canSwitch) endText += " Your household income drops to about "+money(health.monthlyAfter)+" a month, under Medicaid's "+money(health.lim138)+" limit, so report the change at kynect.ky.gov to move "+(health.adults>1?"the adults":"yourself")+" to Medicaid"+(health.ruleAfter?". You'll need to show 80 hours of work, job training, school or volunteering, or $580 of earnings, in the month before you apply":"")+".";
if(!health.snapNow && health.snapAfter) endText += " Your income should also be under Kentucky's SNAP limit; apply at kynect.ky.gov.";
add(ui.lastWeekEnd,"Unemployment ends",endText,"Unemployment");
}
if(health.covEnds){
const kText = health.picked && health.picked.key==="kynect" ? " Pick your kynect plan on or before today and it starts "+fmtDate(health.kynectStart,false)+", with no gap." : "";
add(health.covEnds,"Work health coverage ends","From the next day, you need Medicaid, a kynect plan, COBRA or another plan."+kText,"Health");
}
if(health.kidsChip) add(addDays(last,3),"Apply for KCHIP for the kids","Apply at kynect.ky.gov or 1-855-459-6328 so their coverage is ready when work coverage ends"+(health.covEnds?" on "+fmtDate(health.covEnds,false):"")+". Children qualify on current monthly income, and KCHIP has no premiums.","Health");
if(health.snapNow) add(addDays(last,3),"Apply for SNAP","Your household's income is under Kentucky's SNAP limit of "+money(health.snapLim)+" a month. Apply at kynect.ky.gov; the amount depends on your income and housing costs.","Bills");
if(health.adultsMedicaid && !health.parentExempt && last < health.maceStart){
add(addDays(health.maceStart,-1),"Apply for Medicaid before the new work rule","Applications from January 1, 2027 on must show 80 hours of work, training, school or service, or $580 of earnings, in the month before applying. Applying earlier avoids that test at sign-up; renewals will still ask.","Health");
}
if(health.deadline) add(health.deadline,"Health coverage deadline","Last day to choose a kynect plan with your special enrollment period, and about the last day to elect COBRA (60 days from your notice or coverage end, whichever is later). COBRA elected late in the window still covers you back to day one.","Health");
const lowInc = health.monthly <= health.lim150;
if(lowInc){
const m = last.getMonth(), y = last.getFullYear();
const fallText = "LIHEAP's fall subsidy pays part of your heating bill. Apply at your Community Action agency in November or December, while funds last. Your household's income right now looks low enough.";
if(m>=10) add(addDays(last,3),"Apply for LIHEAP heating help", fallText, "Bills");
else if(m>=4) add(new Date(y,10,1),"LIHEAP heating help opens", fallText, "Bills");
const crisisY = m>=10 ? y+1 : y;
const crisis = new Date(crisisY,0,5);
if(m<=2 && crisisY===y) add(addDays(last,3),"Ask about LIHEAP crisis help","For a shutoff notice or an empty fuel tank, January through March, at Community Action.","Bills");
else if(crisis>last && crisis<=addDays(last,300)) add(crisis,"LIHEAP crisis help opens","For a shutoff notice or an empty fuel tank, January through March, at Community Action.","Bills");
}
const jan31 = new Date(last.getFullYear()+1,0,31);
if(counting) add(jan31,"Your 1099-G arrives","Unemployment is taxable income. "+(s.wages.fedW?"You're having 10% withheld for federal tax; check at tax time whether that covers it.":"Nothing is being withheld, so set some aside for April, or turn on withholding in your claim."),"Taxes");
if(retire.loan>0){
add(new Date(last.getFullYear()+1,3,15),"401(k) loan rollover deadline","An unpaid loan becomes a withdrawal when you leave. Put the same amount into an IRA by your tax-filing deadline, including an extension to Oct. 15, and it isn't taxed.","Retirement");
}
if(plan && plan.runout){
const warn = addDays(plan.runoutDate,-28);
const uiOn = counting && ui.lastWeekEnd && warn < ui.lastWeekEnd;
if(warn>last) add(warn,"Four weeks before the money runs out","Revisit this plan. Call any lender you haven't called, ask Community Action and 211 about emergency help, and look at part-time or temporary work"+(uiOn?"; while you're on unemployment, Kentucky only subtracts 80% of what you earn.":"."),"Plan");
add(plan.runoutDate,"The week your money runs out at this pace","Everything above is designed to push this date later.","Plan");
}
ev.sort((a,b)=>a.date-b.date);
return ev;
}
/* ======================================================================
RENDER: inputs
====================================================================== */
function renderInputs(){
document.querySelectorAll("[data-path]").forEach(el=>{
const v = getPath(state, el.dataset.path);
if(el.type==="checkbox") el.checked = !!v;
else if(el.type==="radio") el.checked = (el.value===v);
else if(el.closest(".money")) el.value = (v==null||v==="")?"":fmtMoneyInput(v);
else el.value = (v==null?"":v);
});
renderBillRows();
syncWageMode();
}
function syncWageMode(){
const q = state.wages.mode==="quarters";
$("annualBox").hidden = q; $("quarterBox").hidden = !q;
}
function renderBillRows(){
const body=$("billsBody"); body.innerHTML="";
state.bills.forEach((b,i)=>{
const tr=document.createElement("tr");
const opts = CAT_KEYS.map(k=>`<option value="${k}"${k===b.cat?" selected":""}>${esc(CATS[k].label)}</option>`).join("");
tr.innerHTML =
`<td class="name" data-label="Bill"><input type="text" maxlength="60" aria-label="Bill name" data-bill="${i}" data-f="name" value="${esc(b.name)}"></td>`+
`<td class="cat" data-label="Kind"><select aria-label="Kind of bill for ${esc(b.name||"this bill")}" data-bill="${i}" data-f="cat">${opts}</select></td>`+
`<td class="n now" data-label="Per month now"><div class="money"><input type="text" inputmode="decimal" autocomplete="off" aria-label="${esc(b.name||"Bill")}, per month now" data-bill="${i}" data-f="now" value="${num(b.now)?fmtMoneyInput(b.now):""}"></div></td>`+
`<td class="n during" data-label="While job hunting"><div class="money"><input type="text" inputmode="decimal" autocomplete="off" aria-label="${esc(b.name||"Bill")}, per month while job hunting" data-bill="${i}" data-f="during" value="${b.during===""?"":fmtMoneyInput(num(b.during))}"></div></td>`+
`<td class="t" data-label="Priority"><span class="tag" data-tier="${i}"></span></td>`+
`<td class="x"><button class="iconbtn" type="button" data-remove="${i}" aria-label="Remove ${esc(b.name||"this bill")}"><svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 3l10 10M13 3L3 13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg></button></td>`;
body.appendChild(tr);
});
}
/* ======================================================================
RENDER: outputs
====================================================================== */
function render(){
const R = computeAll(state); lastResult = R;
const a = document.activeElement;
const refocus = a && a.name==="hchoice" ? a.value : null;
renderStep1(R); renderStep2(R); renderStep3(R); renderHealth(R); renderBills(R); renderRetire(R);
renderPanel(R); renderHeroCard(R); renderChart(R); renderScenarios(R); renderWeekTable(R); renderTimeline(R); renderPrintPlan(R);
if(refocus){ const r=document.querySelector(`input[name="hchoice"][value="${refocus}"]`); if(r) r.focus(); }
clearTimeout(render._a); render._a=setTimeout(()=>{ const msg=$("mText").textContent; if($("announce").textContent!==msg) $("announce").textContent=msg; }, 1200);
}
function renderStep1({ui,health}){
const el=$("out1"); const s=state;
if(!ui.last){ el.className="answer warn"; el.innerHTML="<h3>Start with your last day</h3><p>Enter the last day you were paid as an employee. Everything else is counted from it.</p>"; return; }
const r = s.person.reason;
let msg="";
if(r==="layoff") msg="<p>A layoff is the clearest case for Kentucky unemployment: you lost the job through no fault of your own.</p>";
if(r==="recall") msg="<p>With a definite recall date within 16 weeks, you don't have to do the weekly job search, but you'll need to upload proof of the date. If your employer filed a mass claim for you, request benefits weekly, Sunday to Wednesday.</p>";
if(r==="quit") msg="<p><span class=\"tag bad\">Review likely</span> Kentucky reviews every quit. You can still qualify if you had good cause connected to the work, but plan as if benefits might be denied. File anyway and keep requesting benefits while it's reviewed.</p>";
if(r==="fired") msg="<p><span class=\"tag bad\">Review likely</span> Being fired doesn't rule you out; being fired for misconduct does. File anyway, answer the fact-finding questions, and keep requesting benefits while it's decided. You can appeal within 30 days.</p>";
el.className = (r==="quit"||r==="fired")?"answer warn":"answer";
const when = ui.fileDefault
? `<h3>File your unemployment claim on ${fmtDay(ui.fileDate)}</h3><p>That's the Sunday after your last day, the start of your first full week without work. Kentucky's weeks run Sunday to Saturday, and online filing is closed on Saturdays.</p>`
: `<h3>Your claim is filed for ${fmtDay(ui.fileDate)}</h3>`;
let act="";
if(r==="quit"||r==="fired") act = s.wages.count
? `<p><button class="btn small" type="button" data-act="noUI">Plan as if benefits are denied</button></p>`
: `<p>Your plan leaves unemployment out, the safe way to plan while Kentucky reviews your claim. <button class="btn small quiet" type="button" data-act="yesUI">Count it again</button></p>`;
const warns=[];
if(num(s.person.kids)>0 && num(s.person.kids)>=Math.max(1,num(s.person.hh))) warns.push(`A household of ${plural(health.hh,"person")} has to include you, so the page counts ${plural(health.kids,"child")}. Check the numbers above.`);
const covIn=parseDate(s.health.coverageEnds); if(covIn && covIn<ui.last) warns.push("Work coverage usually ends on or after your last day. Check the date in step 4.");
const ahead=daysBetween(today(),ui.last);
if(ahead>365) warns.push("That last day is more than a year away, so the 2026 and 2027 rules on this page may not apply.");
if(ahead<-365) warns.push("That last day was more than a year ago. A claim filed now would use more recent wages, so these numbers won't match.");
const check = warns.map(w=>`<p><span class="tag bad">Check this</span> ${w}</p>`).join("");
let before="";
if(ahead>=0){
before = `<h4 style="margin:14px 0 4px">Before your last day</h4><ul>
<li><strong>Spend your health FSA.</strong> You can use your whole year's election before you leave, even the part you haven't paid in yet. What's left after your last day is usually lost. An HSA stays yours.</li>
<li><strong>Get care while you're covered.</strong> Book checkups and refill prescriptions before work coverage ends${health.covEnds?` on ${fmtDate(health.covEnds,false)}`:""}.</li>
<li><strong>Keep proof of pay.</strong> Save your last pay stubs and W-2s; Kentucky may ask for them.</li>
<li><strong>Ask HR, in writing,</strong> for your severance terms, the exact date coverage ends, the COBRA price, and what happens to any 401(k) loan.</li></ul>`;
}
el.innerHTML = `${when}${msg}${act}${check}<p>Your 60-day window to choose health coverage closes around <span class="mark">${fmtDate(health.deadline)}</span>.</p>${before}`;
}
function renderStep2({ui}){
const el=$("out2"); const s=state;
// quarter labels
if(ui.bq){ ui.bq.forEach((q,i)=>{ $("q"+i+"l").textContent = q.label; }); }
$("fileHint").textContent = ui.last ? `Leave blank to use ${fmtDay(ui.firstSunday)}, the Sunday after your last day.` : "Leave blank to use the Sunday after your last day.";
if(!ui.last){ el.className="answer"; el.innerHTML="<p>Add your last day in step 1 to see your base period and payment dates.</p>"; return; }
const late = ui.fileDefault && today() > addDays(ui.firstSunday,6)
? `<p><span class="tag bad">Haven't filed yet?</span> File today. Kentucky doesn't pay for weeks before you file unless you show good cause. Then enter today's date above to see your real dates.</p>` : "";
const bp = ui.bq ? `${fmtDate(ui.bq[0].start)} to ${fmtDate(ui.bq[3].end)}` : "";
if(ui.total<=0){ el.className="answer"; el.innerHTML=`<h3>Add what you earned</h3><p>If you file on ${fmtDate(ui.fileDate,false)}, your base period is probably <strong>${bp}</strong>. Pay you earned after that doesn't count for this claim.</p>${late}`; return; }
if(!ui.valid){
el.className="answer warn";
el.innerHTML=`<h3>These wages may not qualify</h3><p>Kentucky checks four things about your base period (${bp}):</p><ul>${ui.checks.map(c=>`<li>${c.ok?"Met":"<strong>Not met</strong>"}: ${c.text}</li>`).join("")}</ul><p>If you worked in another state too, Kentucky can combine the wages. File anyway; the state makes the final call and you can ask it to reconsider with pay stubs or W-2s.</p>${late}`;
return;
}
const capped = ui.rawWba>=C.uiMax;
const delayText = ui.delay>0 ? `<p>Your pay in lieu of notice likely holds up benefits for about ${plural(ui.delay,"week")}. Severance does not; in Kentucky it isn't deducted.</p>` : "";
const wText = ui.wRate>0 ? ` After the ${ui.wRate>.11?"federal and state":(state.wages.stW&&!state.wages.fedW?"state":"federal")} withholding you chose, about <strong>${money(ui.net)}</strong> lands each week.` : ` Nothing is withheld for taxes unless you ask, so you may owe at tax time.`;
const ptText = ui.pt>0 ? (ui.gross>0
? `<p>Your ${money(ui.pt)} a week of part-time pay cuts each check by ${money(ui.pt*C.uiPartialDeduct)}, but you still come out ${money(ui.pt*0.2)} ahead before tax, and the smaller checks stretch your ${money(ui.maxBenefit)} total over about ${plural(ui.paidWeeks,"week")} instead of ${ui.weeks}.</p>`
: `<p><span class="tag bad">No check those weeks</span> At ${money(ui.pt)} a week, Kentucky's 80% deduction uses up your whole weekly amount. Your benefits stay available for weeks you earn less.</p>`) : "";
el.className="answer good";
if(ui.gross<=0){
el.className="answer warn";
el.innerHTML=`<h3>No check while you earn ${money(ui.pt)} a week</h3><p>Kentucky subtracts 80% of part-time pay, so ${money(ui.pt)} a week uses up your whole ${money(ui.wba)} weekly amount. Your ${money(ui.maxBenefit)} total stays available for weeks you earn less, within your 52-week benefit year. Keep requesting benefits and reporting your pay every two weeks.</p>${late}`;
return;
}
const timing = ui.firstPay ? `<p>First payment around <span class="mark">${fmtDate(ui.firstPay)}</span>; the last paid week ends around ${fmtDate(ui.lastWeekEnd)}. If Kentucky has questions about your claim, the first payment can take longer, so keep requesting benefits every two weeks while it's reviewed.</p>` : "";
el.innerHTML = `<p class="big">${money(ui.gross)} a week</p>
<p>${ui.pt>0&&ui.gross>0&&ui.paidWeeks>ui.weeks?`For about ${ui.paidWeeks} weeks`:`For ${ui.weeks} weeks`}, up to <strong>${money(ui.maxBenefit)}</strong> in all.${wText}${capped&&!ui.pt?" That's Kentucky's maximum.":""}</p>
${timing}${late}${delayText}${ptText}
<details class="more"><summary>How this was worked out</summary>
<p>Base period: ${bp} (the first four of the last five finished calendar quarters before you file). Wages in it: ${money(ui.total)}. ${fmt$c.format(ui.total)} × 1.1923% = ${fmt$c.format(ui.total*C.uiRate)}${capped?`, capped at ${money(C.uiMax)}`:""}${ui.rawWba<=C.uiMin?`, raised to the ${money(C.uiMin)} minimum`:""}.</p>
<ul>${ui.checks.map(c=>`<li>Met: ${c.text}</li>`).join("")}</ul>
<p>Kentucky sets the weekly amount when you file and keeps it for the whole year. Your official number is on the "Monetary Determination" letter that arrives a few days after you file.</p>
</details>`;
}
function renderStep3({ui}){
const el=$("out3"); const s=state.money;
const start = num(s.savings)+num(s.finalPay)+num(s.severance);
let t = `<p>You start with about <strong>${money(start)}</strong>`;
t += num(s.otherNet)>0 ? `, and ${money(s.otherNet)} a month keeps coming in from other household pay.</p>` : `.</p>`;
const Rr=lastResult;
if(Rr && Rr.health && start>0){ const weekly=(billsTotals(state).during + (Rr.health.picked?Rr.health.picked.cost:0) - num(s.otherNet))*12/52; if(weekly>0) t+=`<p>On its own, that covers about <strong>${plural(Math.max(0,Math.floor(start/weekly)),"week")}</strong> of your bills and health coverage, after other household pay. The rest of this page is about stretching that.</p>`; }
if(num(s.severance)>0) t+=`<p><span class="tag good">Kentucky rule</span> Severance isn't deducted from Kentucky unemployment, and neither is vacation pay you get after you leave. You can collect both.</p>`;
if(num(s.otherGross)>0 && num(s.otherNet)>num(s.otherGross)) t+=`<p><span class="tag bad">Check this</span> Take-home pay is higher than pay before taxes.</p>`;
el.className="answer"; el.innerHTML=t;
}
function renderHealth(R){
const {ui,health}=R; const h=health, s=state;
$("cobraHint").textContent = h.cobraIsDefault ? `No price entered, so the page uses the 2026 average: ${money(h.cobraDefault)} a month. Use the number on your COBRA notice.` : "From your COBRA notice. COBRA is the full premium plus 2%.";
const doors=[];
const sel = h.picked?h.picked.key:"";
const adultWord = h.adults>1?"Adults":"You";
// Medicaid / KCHIP
const rows=[`<li><span>${adultWord}</span>${h.adultsMedicaid?'<span class="yes">Likely eligible</span>':(h.canSwitch?`<span class="no">From ${fmtDate(h.switchDate,false)}</span>`:'<span class="no">Over the limit now</span>')}</li>`];
if(h.kids>0) rows.push(`<li><span>Kids</span>${h.kidsChip?'<span class="yes">Qualify, free</span>':(h.kidsAfter&&h.switchDate?`<span class="no">From ${fmtDate(h.switchDate,false)}</span>`:'<span class="no">Over the limit</span>')}</li>`);
let medText = `<ul class="status">${rows.join("")}</ul>`;
medText += h.adultsMedicaid
? `<p>Your household's income right now, about ${money(h.monthly)} a month with unemployment, is under Kentucky's ${money(h.lim138)} limit for ${plural(h.hh,"person")}. Medicaid counts this month's income, not last year's.</p>`
: `<p>About ${money(h.monthly)} a month with unemployment is over the ${money(h.lim138)} adult limit for ${plural(h.hh,"person")}.${h.kidsChip?` The kids' limit is ${money(h.lim218)}, so they qualify now.`:""}</p>`;
if(h.canSwitch) medText += `<p><strong>After unemployment ends</strong> around ${fmtDate(h.uiEnd,false)}, income drops to about ${money(h.monthlyAfter)} a month, under the limit.</p>`;
const medCost = h.adultsMedicaid ? `${money(0)} <small>a month</small>` : (h.kidsChip ? `$0 <small>for the kids</small>` : `<small>Not eligible right now</small>`);
const medTag = h.adultsMedicaid ? "Likely eligible" : (h.kidsChip ? "Kids qualify" : (h.canSwitch ? "Later" : "Not eligible now"));
doors.push({key:"medicaid", ok:h.adultsMedicaid||h.kidsChip, choosable:h.adultsMedicaid, title:h.kids>0?"Medicaid and KCHIP":"Medicaid", costHtml:medCost, label:medTag, text:medText});
// kynect
let kyText="", kyCost=null, kyOk=false, kyLabel="";
const P=h.ptc;
if(P.status==="medicaid"){ kyText=`<p>With income this low, kynect will send you to Medicaid instead of a discounted plan.</p>`; kyLabel="Medicaid instead"; }
else if(P.status==="below"){ kyText=`<p>Your 2027 income estimate, ${money(h.income2027)}, is under 100% of the poverty line (${money(h.fpl)}), and tax credits start at 100%. Include the pay from a job you expect to start; if you still land here, ask kynect at 1-855-459-6328, because this is a tricky spot.</p>`; kyLabel="No tax credit"; kyCost=P.cost; }
else if(P.status==="above"){ kyText=`<p>Your 2027 income estimate, ${money(h.income2027)}, is over 400% of the poverty line. The extra credits that used to reach this income expired after 2025, so you'd pay full price${h.bench!=null?`: ${money(h.bench)} a month`:". Enter a price from kynect above"}.</p>`; kyLabel="Full price"; kyCost=P.cost; kyOk=P.cost!=null; }
else { kyOk=true; kyCost=P.cost; kyLabel="Tax credit"; kyText = `<p>At ${money(h.income2027)} for 2027 (${Math.round(h.fplPct)}% of the poverty line), you'd pay at most ${pct(P.pctApplied,2)} of income for the benchmark silver plan${h.bench!=null?`; your ${money(h.bench)} quote gets a ${money(P.credit)} monthly credit`:""}.${h.kidsChip?" With the kids on KCHIP, only the adults need a plan.":""}${P.csr?" Silver plans also come with lower deductibles at this income.":""}</p>`; }
doors.push({key:"kynect", ok:kyOk && !h.adultsMedicaid, choosable:kyCost!=null && !h.adultsMedicaid, title:"A kynect plan", costHtml:kyCost==null?"<small>Price unknown</small>":`${money(kyCost)} <small>a month</small>`, label:kyLabel, text:kyText + `<p class="hint">Uses 2027 rules. Estimated 2027 income: ${money(h.est2027)}; type your own above.</p>`});
// COBRA
doors.push({key:"cobra", ok:true, choosable:true, title:"COBRA", costHtml:`${money(h.cobra)} <small>a month</small>`, label:"Same plan, full price", text:`<p>Same doctors and deductible, for up to 18 months. You have 60 days to sign up and 45 more to pay, and it's back-dated, so you can decide last.</p>`});
if(h.other>0) doors.push({key:"other", ok:true, choosable:true, title:"Other plan", costHtml:`${money(h.other)} <small>a month</small>`, label:"Your entry", text:"<p>The plan you entered, such as a spouse's job coverage. Losing coverage also opens a 60-day window to join a spouse's plan.</p>"});
$("doors").innerHTML = doors.map(d=>`
<div class="door ${d.ok?"ok":"no"} ${sel===d.key?"pick":""}">
<span class="tag ${d.ok?"good":""}">${esc(d.label)}</span>
<h3>${d.title}</h3>
<div class="cost">${d.costHtml}</div>
${d.text}
${d.choosable?`<label class="check choose"><input type="radio" name="hchoice" value="${d.key}" ${s.health.choice===d.key?"checked":""}><span>Use this in my plan</span></label>`:""}
</div>`).join("");
const autoOn = s.health.choice==="auto"||!h.options.find(o=>o.key===s.health.choice);
$("autoPick").innerHTML = `<label class="check"><input type="radio" name="hchoice" value="auto" ${autoOn?"checked":""}><span>Let the page pick the cheapest one you qualify for${autoOn&&h.picked?` (now: ${({medicaid:"Medicaid",kynect:"kynect",cobra:"COBRA",other:"your other plan"})[h.picked.key]})`:""}</span></label>`;
$("switchWrap").hidden = !h.canSwitch;
if(h.canSwitch) $("switchLabel").textContent = `In my plan, move ${h.adults>1?"the adults":"me"} to Medicaid on ${fmtDate(h.switchDate)}, the month after unemployment ends`+(h.ruleAfter?" (you'll need to meet the new work rule; see below)":"");
const out=$("out4");
const name = {medicaid:h.kids>0?"Medicaid and KCHIP":"Medicaid", kynect:h.kidsChip?"a kynect plan, with KCHIP for the kids":"a kynect plan", cobra:"COBRA", other:"your other plan"}[sel]||"";
const yearSave = (h.cobra-(h.picked?h.picked.cost:0))*12;
let t = `<h3>Your plan uses ${name}: ${money(h.picked?h.picked.cost:0)} a month</h3>`;
if(sel!=="cobra" && yearSave>0) t+=`<p>That's <strong>${money(yearSave)} a year less than COBRA</strong> for ${h.who==="family"||state.health.who==="family"?"everyone on your work plan":"you"}.</p>`;
const notes=[];
if(sel==="kynect" && h.covEnds){
const midMonth = addDays(h.covEnds,1).getDate()!==1;
notes.push(midMonth
? `Work coverage ends ${fmtDate(h.covEnds,false)}, mid-month, and a kynect plan can't start until ${fmtDate(h.kynectStart,false)}. COBRA can cover the days in between: you can elect it for just that month. Pick your kynect plan by ${fmtDate(h.covEnds,false)}; you can shop up to 60 days early.`
: `Pick your kynect plan on or before ${fmtDate(h.covEnds,false)}, the day work coverage ends, and it starts ${fmtDate(h.kynectStart,false)} with no gap. You can shop up to 60 days early.`);
}
if(h.switching || h.canSwitch){
let n = `When unemployment ends around ${fmtDate(h.uiEnd,false)}, your household's income should fall under Medicaid's ${money(h.lim138)} limit. Report the change at kynect.ky.gov to switch${h.switching?`; your plan below counts $0 for ${h.adults>1?"the adults'":"your"} coverage from ${fmtDate(h.switchDate,false)}`:""}.`;
if(h.parentExempt) n += " As the parent of a child 13 or younger, you're exempt from Kentucky's new Medicaid work rule.";
else if(h.ruleAfter) n += ` Kentucky's new work rule will apply: you'll need 80 hours of work, job training, school or volunteering, or ${money(C.macePerMonthEarnings)} of earnings, in the month before you apply. Job hunting and unemployment checks don't count, but approved job training does.`;
notes.push(n);
}
if(h.adultsMedicaid || h.kidsChip) notes.push("Medicaid and KCHIP look at the month you apply. A severance check or 401(k) withdrawal landing that month can push you over, so apply in a month without one.");
if(h.adultsMedicaid){
if(h.parentExempt) notes.push("Kentucky's new Medicaid work rule starts January 1, 2027. As the parent of a child 13 or younger, you're exempt.");
else notes.push(`Kentucky's new Medicaid work rule starts January 1, 2027. If you apply after that, you'll need to show 80 hours of work, job training, school or volunteering, or ${money(C.macePerMonthEarnings)} of earnings, in the month before you apply. Your last paychecks often cover this if you apply the month after you leave. Job hunting doesn't count; job training does.`);
}
if(notes.length) t += `<ul>${notes.map(n=>`<li>${n}</li>`).join("")}</ul>`;
t+=`<p>Decide by <span class="mark">${fmtDate(h.deadline)}</span>. If you end COBRA early later, that doesn't open a new window; you'd wait for kynect's open enrollment, which starts each November 1.</p>`;
out.className="answer"; out.innerHTML=t;
}
function renderBills({health}){
const tot=billsTotals(state);
state.bills.forEach((b,i)=>{ const tag=document.querySelector(`[data-tier="${i}"]`); if(tag){ const c=CATS[b.cat]||CATS.other; const T=TIERS[c.tier]; tag.textContent = T.tag; tag.className="tag"+(T.cls?" "+T.cls:""); } });
$("billTotal").innerHTML = `<span>Now: ${money(tot.now)} a month</span><span>While job hunting: ${money(tot.during)} a month${tot.now>tot.during?` <span class="tag good">${money(tot.now-tot.during)} less</span>`:""}</span>`;
const present = [...new Set(state.bills.filter(b=>num(b.now)>0||num(b.during)>0).map(b=>b.cat))];
const out=$("out5");
if(!present.length){ out.className="answer"; out.innerHTML="<p>Add your monthly bills to see which to protect first.</p>"; return; }
const h=health;
let snap="";
if(h.snapNow) snap=`Your household's income right now, about ${money(h.monthly)} a month, is under Kentucky's SNAP limit of ${money(h.snapLim)} for ${plural(h.hh,"person")}, and there's no asset test. The amount depends on your income and housing costs.`;
else if(h.snapAfter && h.uiEnd) snap=`Right now your income is over Kentucky's SNAP limit of ${money(h.snapLim)} a month, but when unemployment ends it drops to about ${money(h.monthlyAfter)}, under it. Apply then.`;
else snap=`Your household's income is over Kentucky's SNAP limit of ${money(h.snapLim)} a month right now.`;
const groups=[1,2,3,4,5].map(tier=>{
const cats=present.filter(k=>CATS[k].tier===tier); if(!cats.length) return "";
return `<section class="tier-group"><h4><span class="tier" aria-hidden="true">${tier}</span>${TIERS[tier].name}</h4><ul>${cats.map(k=>{const c=CATS[k];const names=state.bills.filter(b=>b.cat===k).map(b=>b.name).filter(Boolean).join(", ");return `<li><b>${esc(c.title)}${names?`: <span style="font-weight:400">${esc(names)}</span>`:""}</b>${k==="food"?`<p class="snap">${snap}</p>`:""}<p>${c.text}</p></li>`;}).join("")}</ul></section>`;
}).join("");
out.className="answer";
out.innerHTML = `<h3>Who to call, in order</h3>${groups}`;
}
function renderRetire(R){
const r=R.retire, s=state.retire, out=$("out6"), h=R.health, p=R.plan;
let t="";
if(r.W<=0){
t = `<p>Enter an amount to see what a withdrawal would really leave you.</p>`;
} else {
const over = r.W>num(s.balance) && num(s.balance)>0;
t = `<h3>Take out ${money(r.W)}, keep about ${money(r.net)}</h3>
<div class="cashout">
<div class="keep"><b>${money(r.net)}</b><span>Yours to spend</span></div>
<div class="lose"><b>${money(r.fed)}</b><span>Federal income tax, about ${Math.round(r.fed/r.W*100)}% of it</span></div>
<div class="lose"><b>${money(r.penalty)}</b><span>10% early-withdrawal penalty</span></div>
<div class="lose"><b>${money(r.ky)}</b><span>Kentucky tax</span></div>
</div>
<p>You'd lose <strong>${pct(r.rate*100,0)}</strong> of it. ${esc(r.penaltyReason)}</p>
<p><span class="tag good">Kentucky rule</span> Kentucky excludes up to ${money(C.kyPensionExclusion)} a person of 401(k), IRA and pension income from state tax, at any age. ${r.ky>0?"Only the part above that is taxed.":"So this withdrawal owes Kentucky nothing."}</p>
<p>The check you'd actually get is about ${money(r.check)}: ${r.employerPlan?"employer plans must hold back 20% for federal tax":"IRAs usually hold back 10% unless you opt out"}. ${r.withheld>r.fed+r.penalty?"Some of that may come back as a refund.":"You'd likely owe the rest next April."}</p>
${over?`<p><span class="tag bad">Check this</span> That's more than the balance you entered.</p>`:""}
${retireTradeoffs(R)}
<details class="more"><summary>How this was worked out</summary><p>Taxable income in ${r.Y} without the withdrawal: ${money(r.base)}${state.retire.taxBase==null||state.retire.taxBase===""?" (estimated from your wages this year, unemployment paid this year, severance and other household pay, minus the standard deduction)":""}. Federal tax is the difference between tax on that income with and without the withdrawal, using ${r.Y===2027?"2026 brackets (2027 brackets aren't set yet)":"2026 brackets"}.</p></details>`;
}
if(r.loan>0) t+=`<p><span class="tag gold">Your loan</span> An unpaid 401(k) loan is usually treated as a withdrawal when you leave. You can avoid the tax by putting ${money(r.loan)} into an IRA by your tax deadline, extensions included.</p>`;
t+=`<p>Other choices that cost nothing today: leave the money in the plan, or roll it into an IRA. Money in a 401(k) is generally out of creditors' reach; cash in the bank isn't.</p>`;
out.className = r.W>0 && r.rate>.2 ? "answer warn" : "answer";
out.innerHTML=t;
}
function retireTradeoffs(R){
const r=R.retire, h=R.health, p=R.plan, items=[];
if(p && R.retireWeeks>0) items.push(`<strong>Time it buys:</strong> about ${plural(R.retireWeeks,"more week")} before your money runs out${p.runout?"":" (your plan already lasts a year without it)"}.`);
else if(p && R.retireWeeks===0 && p.runout===null) items.push(`<strong>Time it buys:</strong> none needed. Your plan already lasts more than a year without it.`);
if(r.Y===2027 && (h.ptc.status==="eligible" || (h.picked&&h.picked.key==="kynect"))){
const inc2=h.income2027+r.W, f2=inc2/h.fpl*100;
if(h.ptc.status==="eligible" && f2>400) items.push(`<strong>Health cost:</strong> it would push your 2027 income over 400% of the poverty line, and you'd lose the kynect tax credit for the year.`);
else if(h.ptc.status==="eligible"){ const a2=applicablePct(f2); const extra=(inc2*a2-h.income2027*h.ptc.pctApplied)/100/12; if(extra>1){ const all=(r.W-r.net)+extra*12; items.push(`<strong>Health cost:</strong> it counts as 2027 income, so your kynect premium would rise about ${money(extra)} a month, ${money(extra*12)} for the year. Counting that, the withdrawal really costs about ${money(all)}, or ${Math.round(all/r.W*100)}% of it.`); } }
}
if(h.adultsMedicaid || h.kidsChip || h.canSwitch) items.push(`<strong>Medicaid timing:</strong> Medicaid and KCHIP count it as income in the month it's paid, which can put you over the limit that month.`);
const age=num(state.person.age);
if(age>0 && age<65){ const fv=r.W*Math.pow(1.05,65-age); items.push(`<strong>Future cost:</strong> left invested, ${money(r.W)} growing 5% a year would be about ${money(round100(fv))} at age 65. That's an illustration of growth over time, not a prediction.`); }
return items.length?`<ul>${items.map(x=>`<li>${x}</li>`).join("")}</ul>`:"";
}
function renderPanel(R){
const p=R.plan;
const w=$("pWeeks"), u=$("pUntil");
const tot=billsTotals(state);
$("pWorth").innerHTML="";
if(!p){ w.textContent="–"; w.className="weeks"; u.textContent="Enter your last day to start."; $("mText").textContent="Enter your last day to start"; $("pLevers").innerHTML=""; $("pNext").innerHTML=""; drawMini(null); return; }
if(tot.now<=0 && tot.during<=0){ w.textContent="–"; w.className="weeks"; u.textContent="Add your monthly bills in step 5 to see how long your money lasts."; $("mText").textContent="Add your bills to see how long money lasts"; $("pLevers").innerHTML=""; drawMini(null);
const t0=today(); const up=R.events.filter(e=>e.date>=t0 && e.kind!=="Plan").slice(0,3); $("pNext").innerHTML=up.map(e=>`<li><span>${esc(e.title)}</span><time datetime="${iso(e.date)}">${fmtDate(e.date,false)}</time></li>`).join(""); return; }
if(R.worth && R.worth.total>=100) $("pWorth").innerHTML = `Worth about <strong>${money(round100(R.worth.total))}</strong> to you over the next year, compared with doing nothing.`;
if(p.runout===null){ w.textContent="52+ weeks"; w.className="weeks"; u.textContent="Longer than a year at this pace."; $("mText").textContent="Your money lasts more than a year"; }
else { w.textContent=plural(p.lasts,"week"); w.className="weeks"+(p.lasts<12?" short":""); u.innerHTML=`Into the week of <strong>${fmtDate(p.runoutDate)}</strong>, with no new job.`; $("mText").textContent=`Money lasts ${plural(p.lasts,"week")}, to ${fmtDate(p.runoutDate,false)}`; }
$("pLevers").innerHTML = R.levers.filter(l=>l.d!==0).map(l=>`<li><span>${esc(l.label)}</span><b>${l.d>0?"+":""}${plural(l.d,"week")}</b></li>`).join("") || `<li><span>Make the calls in step 5 and pick a cheaper health plan to see weeks added here.</span></li>`;
const t0=today();
const upcoming = R.events.filter(e=>e.date>=t0 && e.kind!=="Plan").slice(0,3);
$("pNext").innerHTML = (upcoming.length?upcoming:R.events.slice(-3)).map(e=>`<li><span>${esc(e.title)}</span><time datetime="${iso(e.date)}">${fmtDate(e.date,false)}</time></li>`).join("");
drawMini(p);
}
function renderHeroCard(R){
const p=R.plan, ex=(noticeMode==="example");
$("hcLabel").textContent = ex ? "Dana's plan, from the example below" : "Your plan so far";
const W=$("hcWeeks"), U=$("hcUntil"), tot=billsTotals(state);
$("hcWorth").innerHTML=""; $("hcNext").innerHTML="";
if(!p || (tot.now<=0 && tot.during<=0)){
W.textContent = p ? "Add bills" : "Start below"; W.className="";
U.textContent = p ? " in step 5 to see how long the money lasts." : " with your last day of work in step 1.";
return;
}
const who = ex ? "Dana's" : "your";
if(p.runout===null){ W.textContent="52+ weeks"; W.className=""; U.textContent=` before ${who} money runs out, with no new job`; }
else { W.textContent=plural(p.lasts,"week"); W.className=p.lasts<12?"short":""; U.textContent=` before ${who} money runs out, with no new job`; }
if(R.worth && R.worth.total>=100) $("hcWorth").innerHTML=`The plan is worth about <strong>${money(round100(R.worth.total))}</strong> over a year, compared with doing nothing.`;
const t0=today();
const up=R.events.filter(e=>e.date>=t0 && e.kind!=="Plan" && e.kind!=="Job").slice(0,2);
$("hcNext").innerHTML = up.map(e=>`<li><span>${esc(e.title)}</span><time datetime="${iso(e.date)}">${MON[e.date.getMonth()]} ${e.date.getDate()}</time></li>`).join("");
}
function renderPrintPlan(R){
const el=$("printPlan"); const p=R.plan, ui=R.ui, h=R.health, r=R.retire;
if(!ui.last){ el.innerHTML=`<h1>Your layoff plan</h1><p>Enter your last day of work in Bridge to build a plan.</p>`; return; }
const rows=[];
const tot=billsTotals(state);
if(p && (tot.now>0||tot.during>0)) rows.push(["Money lasts", p.runout===null?"More than a year, with no new job":`${plural(p.lasts,"week")}, into the week of ${fmtDate(p.runoutDate)}, with no new job`]);
if(R.worth && R.worth.total>=100) rows.push(["What the plan is worth", `About ${money(round100(R.worth.total))} over a year, compared with no unemployment claim, COBRA and the same bills`]);
if(ui.valid && state.wages.count && ui.firstPay) rows.push(["Kentucky unemployment", `${money(ui.gross)} a week (${money(ui.net)} after withholding), up to ${money(ui.maxBenefit)}. File ${fmtDay(ui.fileDate)}; first payment around ${fmtDate(ui.firstPay)}; last paid week ends ${fmtDate(ui.lastWeekEnd)}`]);
else rows.push(["Kentucky unemployment", state.wages.count?"Not counted: these wages may not qualify, or nothing is paid at this part-time pay":"Left out of this plan"]);
if(h.picked){ const nm={medicaid:h.kids>0?"Medicaid and KCHIP":"Medicaid",kynect:h.kidsChip?"kynect plan, with KCHIP for the kids":"kynect plan",cobra:"COBRA",other:"Other plan"}[h.picked.key];
rows.push(["Health coverage", `${nm}: ${money(h.picked.cost)} a month. Decide by ${fmtDate(h.deadline)}.${h.switching?` Switch to Medicaid from ${fmtDate(h.switchDate)}.`:""}`]); }
rows.push(["Monthly bills", `${money(tot.now)} now, ${money(tot.during)} while job hunting`]);
if(p) { const gap=p.billsMonthly+p.healthAfter-num(state.money.otherNet); rows.push(["After unemployment ends", gap>0?`About ${money(gap)} short each month`:"Other household pay covers your costs"]); }
if(r.W>0) rows.push(["401(k) withdrawal", `Taking out ${money(r.W)} leaves about ${money(r.net)} after tax and penalty`]);
const present=[...new Set(state.bills.filter(b=>num(b.now)>0||num(b.during)>0).map(b=>b.cat))];
const calls=[1,2,3,4,5].map(tier=>{ const cats=present.filter(k=>CATS[k].tier===tier); if(!cats.length) return "";
return `<li><strong>${TIERS[tier].name}:</strong> ${cats.map(k=>{const names=state.bills.filter(b=>b.cat===k).map(b=>b.name).filter(Boolean).join(", "); return esc(CATS[k].title)+(names?" ("+esc(names)+")":"");}).join("; ")}</li>`; }).join("");
el.innerHTML = `<h1>Your layoff plan</h1>
<p class="meta">Made with Bridge on ${fmtDate(today())}. Last day of work: ${fmtDay(ui.last)}.</p>
<table>${rows.map(x=>`<tr><th>${x[0]}</th><td>${x[1]}</td></tr>`).join("")}</table>
<h2>Your dates</h2><ol>${R.events.map(e=>`<li><strong>${fmtDate(e.date)}: ${esc(e.title)}.</strong> ${e.text}</li>`).join("")}</ol>
${calls?`<h2>Calls to make, in order</h2><ol>${calls}</ol>`:""}
<h2>Where to get help</h2><p>Unemployment: kcc.ky.gov or 502-564-2900. Medicaid, KCHIP, kynect and SNAP: kynect.ky.gov or 1-855-459-6328. Utility help: your Community Action agency, capky.org or 1-800-456-3452. Anything else: dial 211.</p>
<p class="fine">For education only. These are estimates, not financial, investment, tax, legal or benefits advice. Kentucky's Office of Unemployment Insurance, kynect and your plan administrator make the real decisions. Rates were checked ${CHECKED}.</p>`;
}
function drawMini(p){
const svg=$("miniChart"); const W=300,H=56;
svg.setAttribute("viewBox",`0 0 ${W} ${H}`); svg.setAttribute("preserveAspectRatio","none");
if(!p){svg.innerHTML="";return;}
const pos=Math.max(0,...p.weeks.map(w=>w.bal));
const neg=Math.min(Math.max(pos*1.1,2500), Math.max(1,...p.weeks.map(w=>-w.bal)));
const mid=H*0.6, bw=W/52;
let s=`<line x1="0" x2="${W}" y1="${mid}" y2="${mid}" stroke="#9ec3cc" stroke-width="2"/>`;
p.weeks.forEach((w,i)=>{ const h=w.bal>=0? Math.max(1,w.bal/Math.max(pos,1)*(mid-2)) : Math.max(1,Math.min(1,-w.bal/neg)*(H-mid-2)); const y=w.bal>=0?mid-h:mid; s+=`<rect x="${i*bw+0.6}" y="${y}" width="${bw-1.2}" height="${h}" fill="${w.bal>=0?"#24576A":"#A9343A"}"/>`; });
svg.innerHTML=s;
}
/* ---------- big chart ---------- */
let chartGeom=null, chartSel=null, chartNote="";
function renderChart(R){
const svg=$("bridgeChart"); const p=R.plan;
const W=Math.max(320,$("chartWrap").clientWidth-16), H=340;
svg.setAttribute("viewBox",`0 0 ${W} ${H}`);
const title=`<title id="chartTitle">Bank balance at the end of each week for 52 weeks</title>`;
if(!p){ svg.innerHTML=title+`<text x="${W/2}" y="${H/2}" text-anchor="middle" font-size="15" fill="#47504C">Enter your last day of work to draw your bridge.</text>`; chartGeom=null; $("markList").textContent=""; return; }
const left=58, right=12, top=34, bottom=28;
const vals=p.weeks.map(w=>w.bal);
let max=Math.max(0,...vals), min=Math.min(0,...vals);
const floor=-Math.max(max*1.1, 2500);
const clipped=min<floor; if(clipped) min=floor;
if(max===0&&min===0) max=1;
const span=max-min; max+=span*.06; if(min<0 && !clipped) min-=span*.06;
const y=v=>top+(max-v)/(max-min)*(H-top-bottom);
const iw=(W-left-right)/52;
const x=i=>left+(i-1)*iw;
let s=title;
// gridlines
const step=niceStep((max-min)/4);
for(let v=Math.ceil(min/step)*step; v<=max; v+=step){ s+=`<line x1="${left}" x2="${W-right}" y1="${y(v)}" y2="${y(v)}" stroke="#d3dad5" stroke-width="1"/><text x="${left-8}" y="${y(v)+4}" text-anchor="end" font-size="11" fill="#47504C">${shortMoney(v)}</text>`; }
// water
const y0=y(0);
s+=`<rect x="${left}" y="${y0}" width="${W-left-right}" height="${H-bottom-y0}" fill="#cfe0e3" opacity=".7"/>`;
s+=`<line x1="${left}" x2="${W-right}" y1="${y0}" y2="${y0}" stroke="#24576A" stroke-width="2"/>`;
// planks
p.weeks.forEach(w=>{
const b=Math.max(w.bal,min);
const top_=b>=0?y(b):y0, h=Math.max(1.5,Math.abs(y(b)-y0));
s+=`<rect x="${x(w.i)+iw*.12}" y="${top_}" width="${iw*.76}" height="${h}" fill="${b>=0?"#24576A":"#A9343A"}" rx="1"/>`;
if(w.bal<min) s+=`<path d="M${x(w.i)+iw*.12} ${y(min)-1} l${iw*.19} -5 l${iw*.19} 5 l${iw*.19} -5 l${iw*.19} 5" stroke="#cfe0e3" stroke-width="2.5" fill="none"/>`;
if(w.ui>0) s+=`<rect x="${x(w.i)+iw*.12}" y="${y0+3}" width="${iw*.76}" height="5" fill="#3B6A37"/>`;
});
// markers
const marks=[];
const last=R.ui.last;
const weekOf=d=>simWeekOf(R.ui,d);
const narrow = W<560;
if(R.health.deadline) marks.push({w:weekOf(R.health.deadline),t:"60-day health deadline",d:R.health.deadline});
if(R.ui.valid&&state.wages.count&&R.ui.lastWeekEnd) marks.push({w:weekOf(R.ui.lastWeekEnd),t:"Unemployment ends",d:R.ui.lastWeekEnd});
if(R.ui.valid&&state.wages.count&&R.ui.firstPay) marks.push({w:weekOf(R.ui.firstPay),t:"First payment",d:R.ui.firstPay});
if(R.health.switching) marks.push({w:weekOf(R.health.switchDate),t:"Medicaid starts",d:R.health.switchDate});
const jan1=new Date(last.getFullYear()+1,0,1); marks.push({w:weekOf(jan1),t:"Jan 1"});
marks.sort((a,b)=>a.w-b.w);
const rowsEnd=[-1e9,-1e9];
marks.filter(m=>m.w>=1&&m.w<=52).forEach((m,mi)=>{
const cx=x(m.w)+iw/2;
const tw=m.t.length*6.6;
const anchor = cx+tw/2>W-right?"end":(cx-tw/2<left?"start":"middle");
const x0 = anchor==="end"?cx-tw:(anchor==="start"?cx:cx-tw/2);
let row = narrow ? -1 : rowsEnd.findIndex(e=>x0>e+8);
s+=`<line x1="${cx}" x2="${cx}" y1="${row<0?top:14+row*13+3}" y2="${H-bottom}" stroke="#E3A72F" stroke-width="2" stroke-dasharray="4 3"/>`;
if(row>=0){ rowsEnd[row]=x0+tw; s+=`<text x="${cx}" y="${14+row*13}" text-anchor="${anchor}" font-size="11.5" font-weight="600" fill="#5b4310">${esc(m.t)}</text>`; }
});
$("markList").textContent = chartNote + (marks.length ? " Dashed lines: " + marks.map(m=>m.t+(m.d?" ("+fmtDate(m.d,false)+")":"")).join("; ")+"." : "");
// x labels: month starts
let prevM=-1;
let labEnd=-1e9;
p.weeks.forEach(w=>{ const m=w.start.getMonth(); if(m!==prevM){ prevM=m; const lab=(m===0||w.i===1)?MON[m]+" "+w.start.getFullYear():MON[m]; const lx=x(w.i); if(lx>labEnd+8 && lx+lab.length*6.2<W-right+4){ s+=`<text x="${lx}" y="${H-bottom+18}" font-size="11" fill="#47504C">${lab}</text>`; labEnd=lx+lab.length*6.2; } } });
chartNote = "Week 1 starts "+fmtDate(p.weeks[0].start)+"." + (clipped?" Planks below "+shortMoney(min)+" are cut short; the table has the full shortfall.":"");
// selection
if(chartSel!=null){ const w=p.weeks[chartSel-1]; s+=`<rect x="${x(w.i)}" y="${top-6}" width="${iw}" height="${H-bottom-top+6}" fill="none" stroke="#1F2522" stroke-width="1.5"/>`; }
svg.innerHTML=s;
chartGeom={left,iw,W,H,x,y,p};
}
function niceStep(raw){ const p=Math.pow(10,Math.floor(Math.log10(Math.max(raw,1)))); const n=raw/p; return (n<1.5?1:n<3?2:n<7?5:10)*p; }
function shortMoney(v){ const a=Math.abs(v); const sgn=v<0?"−":""; return a>=1000? sgn+"$"+(Math.round(a/100)/10)+"k" : sgn+"$"+Math.round(a); }
function weekTip(i){
const w=chartGeom.p.weeks[i-1];
return `<strong>Week ${w.i}</strong>, ${fmtDate(w.start,false)} to ${fmtDate(w.end,false)}<br>In: ${money(w.inflow)}${w.ui>0?` (unemployment ${money(w.ui)})`:""}<br>Out: ${money(w.out)}<br>${w.bal>=0?"Left":"Short"}: ${money(Math.abs(w.bal))}`;
}
function showTip(i, px){
const tip=$("tip"); tip.innerHTML=weekTip(i); tip.hidden=false;
const g=chartGeom; const w=g.p.weeks[i-1];
const scale=$("bridgeChart").getBoundingClientRect().width/g.W;
let left=(g.x(i)+g.iw/2)*scale+8, top=Math.max(60,g.y(Math.max(0,w.bal))*scale);
left=Math.min(Math.max(left,130),$("chartWrap").clientWidth-130);
tip.style.left=left+"px"; tip.style.top=top+"px";
}
function renderScenarios(R){
const el=$("scenarios"); const p=R.plan;
if(!p){ el.innerHTML=""; $("planSub").textContent="Each plank is a week. Enter your last day of work to draw it."; return; }
const lastsText = q => q.runout===null?"52+ weeks":plural(q.lasts,"week");
const gap = p.billsMonthly + p.healthAfter - num(state.money.otherNet);
const cards=[`<div class="scenario"><b>${lastsText(p)}</b><span>Your plan, as entered</span></div>`];
if(R.worst) cards.push(`<div class="scenario"><b>${lastsText(R.worst)}</b><span>Doing nothing: no unemployment claim, COBRA, the same bills</span></div>`);
if(R.worth && R.worth.total>=100){
const parts=[]; if(R.worth.ui>=50) parts.push(`${money(round100(R.worth.ui))} in unemployment`); if(R.worth.health>=50) parts.push(`${money(round100(R.worth.health))} less for health coverage`); if(R.worth.bills>=50) parts.push(`${money(round100(R.worth.bills))} from bill changes`);
cards.push(`<div class="scenario worth-card"><b>${money(round100(R.worth.total))}</b><span>What the plan is worth over a year: ${parts.join(", ")}</span></div>`);
}
cards.push(`<div class="scenario"><b>${money(Math.max(0,gap))}</b><span>${gap>0?"Short each month once unemployment ends":"Other pay covers your costs after unemployment ends"}</span></div>`);
const rw=Math.round(num(state.health.returnWeeks));
if(rw>=1 && rw<=52){ const b=p.weeks[rw-1].bal; cards.push(`<div class="scenario"><b>${b<0?"−":""}${money(Math.abs(b))}</b><span>${b>=0?"Left":"Short"} if you're back at work after ${plural(rw,"week")}, your guess in step 4</span></div>`); }
el.innerHTML=cards.join("");
$("planSub").textContent = "Each plank is a week, measured by what's left in the bank at the end of it. Planks stand above the water while money lasts and drop below the week it runs out. This assumes no new job, so it's the worst case you're planning around.";
}
function renderWeekTable(R){
const t=$("weekTable"); const p=R.plan;
if(!p){t.innerHTML="";return;}
t.innerHTML=`<thead><tr><th>Week</th><th>Dates</th><th class="r">Coming in</th><th class="r">Unemployment</th><th class="r">Going out</th><th class="r">Left at week's end</th></tr></thead><tbody>${p.weeks.map(w=>`<tr><td>${w.i}</td><td>${fmtDate(w.start,false)} to ${fmtDate(w.end)}</td><td class="r">${money(w.inflow)}</td><td class="r">${w.ui?money(w.ui):"–"}</td><td class="r">${money(w.out)}</td><td class="r"${w.bal<0?' style="color:#A9343A;font-weight:600"':""}>${w.bal<0?"−":""}${money(Math.abs(w.bal))}</td></tr>`).join("")}</tbody>`;
}
function renderTimeline(R){
const el=$("timeline"); const t0=today();
if(!R.events.length){el.innerHTML=`<li><span></span><p>Enter your last day in step 1 to build your dates.</p></li>`;return;}
el.innerHTML=R.events.map(e=>`<li class="${e.date<t0?"past":""}"><time datetime="${iso(e.date)}">${fmtDate(e.date)}</time><div><h4>${esc(e.title)}</h4><p>${e.text}</p></div><span class="kind"><span class="tag">${e.kind}</span></span></li>`).join("");
}
function renderSources(){
$("sources").innerHTML=`<thead><tr><th>What</th><th>Value used</th><th>Source, checked ${CHECKED}</th></tr></thead><tbody>${SOURCES.map(r=>`<tr><td><strong>${esc(r[0])}</strong></td><td>${esc(r[1])}</td><td>${esc(r[2])} <span style="color:#47504C">(${esc(r[3])})</span></td></tr>`).join("")}</tbody>`;
}
/* ======================================================================
EVENTS: inputs
====================================================================== */
function markDirty(){ dirty=true; $("dirtyDot").hidden=false; if(isExample){ isExample=false; } }
function markClean(){ dirty=false; $("dirtyDot").hidden=true; }
function readInput(el){
const t=el.dataset.type;
if(el.type==="checkbox") return el.checked;
if(t==="num") return parseMoney(el.value);
if(t==="int") return el.value===""?"":Math.max(0,Math.round(Number(el.value)||0));
if(t==="optnum") return el.value.trim()===""?null:parseMoney(el.value);
return el.value;
}
let raf=null;
function scheduleRender(){ if(raf) cancelAnimationFrame(raf); raf=requestAnimationFrame(()=>{raf=null;render();}); }
document.addEventListener("input", e=>{
const el=e.target;
if(el.dataset && el.dataset.path){
setPath(state, el.dataset.path, readInput(el));
if(el.dataset.path==="wages.mode") syncWageMode();
if(el.dataset.path==="person.lastDay" && !state.health.coverageEnds){ const d=parseDate(state.person.lastDay); if(d){ state.health.coverageEnds=iso(new Date(d.getFullYear(),d.getMonth()+1,0)); $("covEnds").value=state.health.coverageEnds; } }
markDirty(); scheduleRender(); return;
}
if(el.dataset && el.dataset.bill!=null){
const i=Number(el.dataset.bill), f=el.dataset.f; const b=state.bills[i]; if(!b) return;
if(f==="name"){ b.name=el.value.slice(0,60); }
else if(f==="cat"){ b.cat = CATS[el.value]?el.value:"other"; }
else if(f==="now"){ const old=num(b.now); b.now=parseMoney(el.value); const d=document.querySelector(`[data-bill="${i}"][data-f="during"]`); if(d && (d.value.trim()===""||parseMoney(d.value)===old)){ b.during=b.now; d.value=b.now?fmtMoneyInput(b.now):""; } }
else if(f==="during"){ b.during = el.value.trim()===""?"":parseMoney(el.value); }
markDirty(); scheduleRender(); return;
}
if(el.name==="hchoice"){ state.health.choice=el.value; markDirty(); scheduleRender(); }
});
document.addEventListener("change", e=>{
const el=e.target;
if(el.name==="hchoice"){ state.health.choice=el.value; markDirty(); scheduleRender(); }
if(el.dataset && el.dataset.bill!=null && el.dataset.f==="cat"){ state.bills[Number(el.dataset.bill)].cat = CATS[el.value]?el.value:"other"; markDirty(); scheduleRender(); }
if(el.dataset && el.dataset.path && (el.tagName==="SELECT"||el.type==="radio"||el.type==="checkbox")){ setPath(state, el.dataset.path, readInput(el)); if(el.dataset.path==="wages.mode") syncWageMode(); markDirty(); scheduleRender(); }
});
$("out1").addEventListener("click", e=>{
const b=e.target.closest("[data-act]"); if(!b) return;
state.wages.count = b.dataset.act==="yesUI"; $("countUI").checked=state.wages.count;
markDirty(); render();
const next=$("out1").querySelector("[data-act]"); if(next) next.focus();
});
document.addEventListener("focusout", e=>{
const el=e.target;
if(el && el.tagName==="INPUT" && el.closest && el.closest(".money")){ const v=el.value.trim(); if(v!=="") el.value=fmtMoneyInput(parseMoney(v)); }
});
$("billsBody").addEventListener("click", e=>{
const btn=e.target.closest("[data-remove]"); if(!btn) return;
const i=Number(btn.dataset.remove); state.bills.splice(i,1); renderBillRows(); markDirty(); render();
const next=document.querySelector(`[data-remove="${Math.min(i,state.bills.length-1)}"]`); (next||$("addBill")).focus();
});
$("addBill").addEventListener("click", ()=>{
if(state.bills.length>=40){ toast("That's the most bills one plan can hold.",true); return; }
state.bills.push({name:"", cat:"other", now:0, during:""}); renderBillRows(); markDirty(); render();
const inp=document.querySelector(`[data-bill="${state.bills.length-1}"][data-f="name"]`); if(inp) inp.focus();
});
/* chart interaction */
const cw=$("chartWrap");
cw.addEventListener("mousemove", e=>{
if(!chartGeom) return;
const r=$("bridgeChart").getBoundingClientRect(); const sx=(e.clientX-r.left)*chartGeom.W/r.width;
const i=Math.floor((sx-chartGeom.left)/chartGeom.iw)+1;
if(i>=1&&i<=52){ showTip(i); } else $("tip").hidden=true;
});
cw.addEventListener("mouseleave", ()=>{ $("tip").hidden=true; });
cw.addEventListener("keydown", e=>{
if(!chartGeom) return;
if(e.key==="ArrowRight"||e.key==="ArrowLeft"||e.key==="Home"||e.key==="End"){
e.preventDefault();
chartSel = chartSel==null?1:chartSel;
if(e.key==="ArrowRight") chartSel=Math.min(52,chartSel+1);
if(e.key==="ArrowLeft") chartSel=Math.max(1,chartSel-1);
if(e.key==="Home") chartSel=1; if(e.key==="End") chartSel=52;
renderChart(lastResult); showTip(chartSel);
const w=chartGeom.p.weeks[chartSel-1];
$("chartLive").textContent=`Week ${w.i}, ${fmtDate(w.start,false)}. ${w.bal>=0?"Left":"Short"} ${money(Math.abs(w.bal))}.`;
}
});
cw.addEventListener("blur", ()=>{ chartSel=null; $("tip").hidden=true; if(lastResult) renderChart(lastResult); });
let rz=null; window.addEventListener("resize", ()=>{ clearTimeout(rz); rz=setTimeout(()=>{ if(lastResult) renderChart(lastResult); },120); });
/* ======================================================================
SAVE / OPEN / CALENDAR / PRINT / RESET
====================================================================== */
function toast(msg, isError){
const t=$("toast"); t.textContent=msg; t.className="toast"+(isError?" error":""); t.hidden=false;
clearTimeout(toast._t); toast._t=setTimeout(()=>{t.hidden=true;}, isError?7000:3500);
}
function download(name, text, type){
const blob=new Blob([text],{type});
const url=URL.createObjectURL(blob);
const a=document.createElement("a"); a.href=url; a.download=name; document.body.appendChild(a); a.click();
setTimeout(()=>{URL.revokeObjectURL(url); a.remove();}, 1500);
}
function savePlan(){
const payload={app:APP_ID, version:APP_VERSION, savedAt:new Date().toISOString(), note:"Saved from Bridge, a layoff plan for Kentucky workers. Open it again with \"Open a saved plan\".", data:state};
download("bridge-plan-"+iso(today())+".json", JSON.stringify(payload,null,2), "application/json");
markClean(); toast("Saved. The file is in your downloads; open it here any time to pick up where you left off.");
}
$("saveBtn").addEventListener("click", savePlan);
document.addEventListener("keydown", e=>{ if((e.ctrlKey||e.metaKey) && (e.key==="s"||e.key==="S")){ e.preventDefault(); savePlan(); } });
$("openBtn").addEventListener("click", ()=>{ $("fileInput").value=""; $("fileInput").click(); });
$("fileInput").addEventListener("change", e=>{
const f=e.target.files&&e.target.files[0]; if(!f) return;
if(f.size>1000000){ toast("That file is too large to be a saved Bridge plan. Nothing was changed.",true); return; }
const rd=new FileReader();
rd.onerror=()=>toast("That file couldn't be read. Nothing was changed.",true);
rd.onload=()=>{
let parsed;
try{ parsed=JSON.parse(rd.result); }catch(err){ toast("That file isn't a saved Bridge plan, so nothing was changed. Your numbers are still here.",true); return; }
const res=validatePlan(parsed);
if(!res.ok){ toast(res.msg+" Nothing was changed. Your numbers are still here.",true); return; }
if(dirty && !confirm("Opening this plan replaces the numbers on screen, and they haven't been saved. Open it anyway?")) return;
state=res.state; isExample=false; setNotice("hidden"); renderInputs(); render(); markClean();
toast("Opened "+f.name+".");
};
rd.readAsText(f);
});
function validatePlan(o){
if(!o || typeof o!=="object" || Array.isArray(o)) return {ok:false,msg:"That file isn't a saved Bridge plan."};
if(o.app!==APP_ID) return {ok:false,msg:"That file wasn't saved from Bridge."};
if(typeof o.version!=="number" || o.version>APP_VERSION) return {ok:false,msg:"That plan was saved by a newer version of Bridge."};
const d=o.data; if(!d||typeof d!=="object") return {ok:false,msg:"That plan file is missing its numbers."};
for(const k of ["person","wages","money","health","retire"]) if(!d[k]||typeof d[k]!=="object"||Array.isArray(d[k])) return {ok:false,msg:"That plan file is damaged or incomplete."};
if(!Array.isArray(d.bills)) return {ok:false,msg:"That plan file is damaged or incomplete."};
const b=blankState();
const n=(v,max=1e8)=>{const x=Number(v);return Number.isFinite(x)&&x>=0?Math.min(x,max):0;};
const on=(v)=> v===null||v===""||v===undefined ? null : n(v);
const intOr=(v,def,lo,hi)=>{ if(v===""||v==null) return def; const x=Math.round(Number(v)); return Number.isFinite(x)?Math.min(hi,Math.max(lo,x)):def; };
const pick=(v,allowed,def)=>allowed.includes(v)?v:def;
const date=(v)=>parseDate(v)?v:"";
const s={
person:{lastDay:date(d.person.lastDay), reason:pick(d.person.reason,["layoff","recall","quit","fired"],"layoff"), age:intOr(d.person.age,"",16,99), filing:pick(d.person.filing,["single","mfj","hoh"],"single"), hh:intOr(d.person.hh,1,1,15), kids:intOr(d.person.kids,0,0,12), youngest:intOr(d.person.youngest,"",0,18)},
wages:{mode:pick(d.wages.mode,["annual","quarters"],"annual"), annual:n(d.wages.annual), q:Array.isArray(d.wages.q)?[0,1,2,3].map(i=>n(d.wages.q[i])):[0,0,0,0], weeks:intOr(d.wages.weeks,16,16,24), pt:n(d.wages.pt), inLieu:n(d.wages.inLieu), count:d.wages.count!==false, fedW:!!d.wages.fedW, stW:!!d.wages.stW, fileDate:date(d.wages.fileDate)},
money:{savings:n(d.money.savings), finalPay:n(d.money.finalPay), severance:n(d.money.severance), otherGross:n(d.money.otherGross), otherNet:n(d.money.otherNet)},
health:{coverageEnds:date(d.health.coverageEnds), who:pick(d.health.who,["me","family"],"me"), cobra:n(d.health.cobra), returnWeeks:intOr(d.health.returnWeeks,16,1,104), income2027:on(d.health.income2027), benchmark:on(d.health.benchmark), otherCost:n(d.health.otherCost), choice:pick(d.health.choice,["auto","medicaid","kynect","cobra","other"],"auto"), switchAfter:d.health.switchAfter!==false},
bills:d.bills.slice(0,40).filter(x=>x&&typeof x==="object").map(x=>({name:String(x.name==null?"":x.name).slice(0,60), cat:pick(x.cat,CAT_KEYS,"other"), now:n(x.now), during: x.during===""?"":n(x.during)})),
retire:{plan:pick(d.retire.plan,["401k","457","ira"],"401k"), balance:n(d.retire.balance), withdraw:n(d.retire.withdraw), loan:n(d.retire.loan), year:pick(Number(d.retire.year),[2026,2027],2026), taxBase:on(d.retire.taxBase), include:!!d.retire.include}
};
return {ok:true,state:s};
}
$("icsBtn").addEventListener("click", ()=>{
const R=lastResult; if(!R||!R.events.length){ toast("Enter your last day of work first, so there are dates to add.",true); return; }
const stamp=new Date().toISOString().replace(/[-:]/g,"").replace(/\.\d+Z$/,"Z");
const escI=s=>String(s).replace(/\\/g,"\\\\").replace(/;/g,"\\;").replace(/,/g,"\\,").replace(/\n/g,"\\n");
const fold=line=>{ const out=[]; let l=line; while(l.length>74){ out.push(l.slice(0,74)); l=" "+l.slice(74); } out.push(l); return out.join("\r\n"); };
const lines=["BEGIN:VCALENDAR","VERSION:2.0","PRODID:-//Bridge//Kentucky layoff plan//EN","CALSCALE:GREGORIAN"];
R.events.forEach((e,i)=>{
const d=iso(e.date).replace(/-/g,""), d2=iso(addDays(e.date,1)).replace(/-/g,"");
lines.push("BEGIN:VEVENT","UID:bridge-"+d+"-"+i+"@bridge.local","DTSTAMP:"+stamp,"DTSTART;VALUE=DATE:"+d,"DTEND;VALUE=DATE:"+d2, fold("SUMMARY:"+escI(e.title)), fold("DESCRIPTION:"+escI(e.text.replace(/<[^>]+>/g,""))),"END:VEVENT");
});
lines.push("END:VCALENDAR");
download("bridge-dates.ics", lines.join("\r\n"), "text/calendar");
toast("Calendar file saved. Open it to add "+plural(R.events.length,"date")+" to your calendar.");
});
$("printBtn").addEventListener("click", ()=>{ if(lastResult) renderPrintPlan(lastResult); window.print(); });
window.addEventListener("beforeprint", ()=>{ if(lastResult) renderPrintPlan(lastResult); });
$("resetBtn").addEventListener("click", ()=>{
if(dirty && !confirm("Start over? This clears every number on the page. Save first if you want to keep them.")) return;
state=blankState(); isExample=false; setNotice("fresh"); renderInputs(); render(); markClean();
toast("Cleared. Start with your last day of work in step 1.");
$("lastDay").focus();
});
$("clearExample").addEventListener("click", ()=>{
state=blankState(); isExample=false; setNotice("fresh"); renderInputs(); render(); markClean();
$("lastDay").focus();
});
$("loadExample").addEventListener("click", ()=>{
if(dirty && !confirm("Show the example? This replaces the numbers on screen, and they haven't been saved.")) return;
state=exampleState(); isExample=true; setNotice("example"); renderInputs(); render(); markClean();
});
function setNotice(mode){
noticeMode = mode;
const box=$("exampleNotice");
if(mode==="hidden"){ box.hidden=true; return; }
box.hidden=false;
if(mode==="example"){
const d=parseDate(state.person.lastDay);
$("noticeText").innerHTML = `<strong>You're looking at an example.</strong> Dana, 41, just got a layoff notice from an auto-parts plant in Hardin County. Her last day is ${fmtDay(d)}. She and her husband have two kids, 8 and 12. Type your own numbers over hers, or clear everything and start from zero.`;
$("clearExample").hidden=false; $("loadExample").hidden=true;
} else {
$("noticeText").innerHTML = `<strong>You're starting from zero.</strong> Begin with your last day of work in step 1. Nothing leaves this page, and nothing is kept until you press Save my plan.`;
$("clearExample").hidden=true; $("loadExample").hidden=false;
}
}
window.addEventListener("beforeunload", e=>{ if(dirty){ e.preventDefault(); e.returnValue=""; return ""; } });
/* ======================================================================
START
====================================================================== */
state = exampleState();
setNotice("example");
renderSources();
renderInputs();
render();
</script>
</body>
</html>
Nothing. This page is entirely self-contained and contacts no other website when it runs.
Published on Globefin under the MIT License. You may copy, change, and reuse this page, including commercially — just keep the notice below with it.
Copyright © 2026 Jack Bolyard. Licensed under the MIT License. Published on Globefin.
Provided as is, without warranty. Any external libraries it loads keep their own licences. Terms →
Scripts run, but the demo has its own throwaway origin. It can't read your session or cookies, can't reach the page around it, and can't navigate your tab. Don't enter real passwords or personal data into any demo.