:root{--bg:#f5f7fb;--panel:#fff;--ink:#142033;--muted:#687386;--line:#e4e8ef;--brand:#3157d5;--brand-soft:#eef2ff;--good:#147a44;--warn:#ad6b00;--bad:#bf3a32;--sidebar:#17213a}
*{box-sizing:border-box}html,body{margin:0;min-height:100%;font-family:Inter,system-ui,-apple-system,Segoe UI,Arial,sans-serif;background:var(--bg);color:var(--ink)}
button,input,select{font:inherit}button{cursor:pointer}
.shell{min-height:100vh;display:grid;grid-template-columns:248px 1fr}
.sidebar{background:var(--sidebar);color:#fff;padding:24px 18px;display:flex;flex-direction:column;position:sticky;top:0;height:100vh}
.logo{display:flex;align-items:center;gap:11px;padding:0 8px 24px;font-weight:800;font-size:18px}
.logo-mark{width:34px;height:34px;border-radius:10px;background:#fff;color:var(--brand);display:grid;place-items:center;font-weight:900}
.nav-label{font-size:11px;text-transform:uppercase;letter-spacing:.12em;color:#94a0ba;padding:12px 12px 8px}
.side-nav{display:flex;flex-direction:column;gap:5px}
.tab{border:0;background:transparent;color:#cdd5e5;text-align:left;padding:11px 12px;border-radius:10px;font-weight:680;display:flex;gap:10px;align-items:center}
.tab:hover{background:rgba(255,255,255,.07)}.tab.active{background:#fff;color:#17213a}
.side-footer{margin-top:auto;padding:16px 10px 0;border-top:1px solid rgba(255,255,255,.12);color:#aeb8ca;font-size:12px;line-height:1.5}
.main{min-width:0}.topbar{height:72px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 28px;position:sticky;top:0;z-index:50}
.topbar h1{font-size:20px;margin:0}.top-actions{display:flex;align-items:center;gap:12px}.balance-chip{background:var(--brand-soft);color:#223e9d;border-radius:999px;padding:8px 12px;font-weight:750;font-size:13px}
.menu-btn{display:none;border:1px solid var(--line);background:#fff;border-radius:9px;padding:8px 10px}
.content{max-width:1240px;margin:auto;padding:28px}.page.hidden{display:none}
.hero{display:flex;justify-content:space-between;align-items:flex-end;gap:20px;margin-bottom:20px}.hero h2{font-size:29px;margin:0 0 6px}.hero p{margin:0;color:var(--muted);max-width:680px;line-height:1.55}
.grid{display:grid;gap:15px}.kpis{grid-template-columns:repeat(4,minmax(0,1fr))}.two{grid-template-columns:minmax(0,1.3fr) minmax(320px,.7fr)}.three{grid-template-columns:repeat(3,minmax(0,1fr))}
.card{background:var(--panel);border:1px solid var(--line);border-radius:16px;padding:19px;box-shadow:0 1px 2px rgba(17,24,39,.03)}.card.soft{background:#fbfcff}
.label{font-size:12px;color:var(--muted);font-weight:700;text-transform:uppercase;letter-spacing:.045em}.value{font-size:29px;font-weight:800;margin-top:8px}.small{font-size:13px;color:var(--muted);margin-top:5px;line-height:1.45}
.section-title{font-size:18px;font-weight:800;margin:0 0 14px}.section-head{display:flex;justify-content:space-between;gap:15px;align-items:center;margin-bottom:14px}
.good{color:var(--good)}.warn{color:var(--warn)}.bad{color:var(--bad)}
.alert{padding:14px 15px;border-radius:12px;margin-bottom:15px;background:#ecf9f1;color:#176a3b;line-height:1.45}.alert.bad{background:#fff0ef;color:#942d27}.alert.warn{background:#fff7e8;color:#875900}
.controls{display:flex;gap:10px;flex-wrap:wrap;align-items:end}.field{display:flex;flex-direction:column;gap:6px}.field label{font-size:12px;color:var(--muted);font-weight:700}.field input,.field select{padding:10px 11px;border:1px solid var(--line);border-radius:9px;background:#fff;min-width:145px;color:var(--ink)}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.btn{border:0;border-radius:9px;padding:10px 13px;font-weight:750;background:var(--brand);color:#fff}.btn.secondary{background:var(--brand-soft);color:#2946ad}.btn.ghost{background:#fff;border:1px solid var(--line);color:var(--ink)}.btn.danger{background:#fff0ef;color:#a03028}.btn.wide{width:100%}
.chart{height:270px;display:flex;align-items:end;gap:2px;border-bottom:1px solid var(--line);padding-top:12px;overflow:hidden}.bar{flex:1;min-width:2px;border-radius:4px 4px 0 0;background:#6a82ea;opacity:.82;position:relative}.bar.neg{background:#d5554c}.bar:hover:after{
  content:attr(data-tip);
  position:absolute;
  bottom:calc(100% + 6px);
  left:50%;
  transform:translateX(-50%);
  background:#111827;
  color:#fff;
  padding:5px 7px;
  border-radius:6px;
  font-size:11px;
  white-space:nowrap;
  z-index:100;
  pointer-events:none;
}
table{width:100%;border-collapse:collapse}th,td{padding:11px 8px;border-bottom:1px solid var(--line);text-align:left;font-size:14px}th{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.05em}.right{text-align:right}.pill{display:inline-block;border-radius:999px;padding:4px 8px;font-size:11px;background:var(--brand-soft);color:#2946ad;text-transform:capitalize}.row-actions{display:flex;gap:6px}
.category-row td{
  background:#eef2f8;
  border-top:2px solid #d7deea;
  border-bottom:1px solid #d7deea;
  padding:12px 10px;
  font-weight:800;
}
.category-row .category-name{
  font-size:14px;
  color:#20304a;
}
.category-row .category-meta{
  margin-left:8px;
  font-size:12px;
  color:var(--muted);
  font-weight:650;
}
.category-row .category-total{
  font-size:15px;
  color:#20304a;
}
.category-row{
  cursor:pointer;
}
.category-row:hover td{
  background:#e7edf6;
}
.category-toggle{
  display:inline-block;
  width:18px;
  margin-right:4px;
  color:#52627c;
  font-weight:900;
}
.category-actions{
  display:flex;
  justify-content:flex-end;
  gap:7px;
  align-items:center;
}
.category-add{
  border:1px solid #cfd8e6;
  background:#fff;
  color:#2946ad;
  border-radius:8px;
  padding:6px 9px;
  font-size:12px;
  font-weight:800;
}
.category-add:hover{
  background:#f5f7ff;
}
.category-item-row.hidden-row{
  display:none;
}
.plan-summary{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-bottom:15px}.summary-box{padding:15px;border:1px solid var(--line);border-radius:13px;background:#fbfcff}.summary-box strong{display:block;font-size:22px;margin-top:4px}.summary-box.net-positive strong{color:var(--good)}.summary-box.net-negative strong{color:var(--bad)}
.question-card{border-left:4px solid var(--brand)}.question-card h3{margin:0 0 7px;font-size:17px}.question-card p{margin:0;color:var(--muted);font-size:13px;line-height:1.45}
.result{font-size:15px;line-height:1.6;padding:14px;border-radius:12px;background:#f8fafc;margin-top:14px}
.settings-list{display:grid;gap:14px}.setting-row{display:flex;justify-content:space-between;gap:25px;align-items:center;padding:4px 0 17px;border-bottom:1px solid var(--line)}.setting-row:last-child{border-bottom:0}.setting-copy strong{display:block;margin-bottom:4px}.setting-copy span{font-size:13px;color:var(--muted)}
.modal{position:fixed;inset:0;background:rgba(15,23,42,.48);display:flex;align-items:center;justify-content:center;padding:20px;z-index:20}.modal.hidden{display:none}.modal-box{background:#fff;border-radius:16px;max-width:560px;width:100%;padding:20px}
.mobile-note{display:none}
@media(max-width:980px){.shell{grid-template-columns:1fr}.sidebar{position:fixed;z-index:20;left:-270px;width:248px;transition:.2s}.sidebar.open{left:0}.menu-btn{display:block}.topbar{padding:0 18px}.content{padding:20px}.kpis{grid-template-columns:1fr 1fr}.two{grid-template-columns:1fr}}
@media(max-width:620px){.kpis,.three,.form-grid,.plan-summary{grid-template-columns:1fr}.content{padding:14px}.hero{align-items:flex-start;flex-direction:column}.top-actions .balance-chip{display:none}.setting-row{align-items:flex-start;flex-direction:column}.field input,.field select{width:100%;min-width:0}.mobile-note{display:block}}

.forecast-table-scroll{
  max-height:560px;
  overflow-y:auto;
  overflow-x:auto;
  border:1px solid #e1e6ef;
  border-radius:12px;
  background:#fff;
}
.forecast-table-scroll table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
}
.forecast-table-scroll thead th{
  position:sticky;
  top:0;
  z-index:5;
  background:#f4f6fa;
  box-shadow:0 1px 0 #dce2eb;
}
.forecast-table-scroll tbody tr:hover td{
  background:#f8faff;
}


.forecast-table-scroll tbody tr.chart-linked-row{
  transition:background .12s ease, box-shadow .12s ease;
}
.forecast-table-scroll tbody tr.chart-row-highlight td{
  background:#fff3c8 !important;
  box-shadow:inset 0 1px 0 #e4bd42,inset 0 -1px 0 #e4bd42;
}
.forecast-table-scroll tbody tr.chart-row-highlight td:first-child{
  box-shadow:inset 3px 0 0 #c99900,inset 0 1px 0 #e4bd42,inset 0 -1px 0 #e4bd42;
}
.chart .bar{
  cursor:pointer;
  transition:opacity .12s ease, transform .12s ease, filter .12s ease;
}
.chart .bar:hover,
.chart .bar.active-chart-bar{
  opacity:1;
  transform:scaleX(1.35);
  filter:brightness(.82);
  z-index:50;
}


/* Forecast chart and approximately ten table rows remain visible together. */
#forecast .forecast-layout{
  display:flex;
  flex-direction:column;
  gap:15px;
}
#forecast #chart{
  height:220px;
  min-height:220px;
}
#forecast .forecast-table-scroll{
  height:430px;
  max-height:430px;
  overflow-y:auto;
  overflow-x:auto;
}
#forecast .forecast-table-scroll tbody tr{
  height:39px;
  cursor:pointer;
}
#forecast .forecast-table-scroll tbody tr:focus{
  outline:2px solid var(--accent);
  outline-offset:-2px;
}
.forecast-table-scroll tbody tr.forecast-selected-row td{
  background:#fff3c8 !important;
  box-shadow:inset 0 1px 0 #e4bd42,inset 0 -1px 0 #e4bd42;
}
.forecast-table-scroll tbody tr.forecast-selected-row td:first-child{
  box-shadow:inset 4px 0 0 #c99900,inset 0 1px 0 #e4bd42,inset 0 -1px 0 #e4bd42;
}
.chart .bar.selected-chart-bar{
  opacity:1;
  transform:scaleX(1.45);
  filter:brightness(.72);
  z-index:3;
}
.chart .bar:not(.selected-chart-bar){
  opacity:.72;
}


#forecast{
  padding-top:18px;
}
#forecast .forecast-compact-heading{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:10px;
}
#forecast .forecast-compact-heading h2{
  margin:0;
  font-size:26px;
}
#forecast .forecast-compact-heading p{
  margin:3px 0 0;
  color:var(--muted);
  font-size:13px;
}
#forecast .forecast-layout{
  gap:10px;
}
#forecast .forecast-chart-card{
  padding:16px 20px 12px;
}
#forecast .forecast-chart-card .section-head{
  margin-bottom:4px;
}
#forecast .forecast-chart-card .section-title{
  font-size:18px;
}
#forecast .forecast-chart-card .small{
  font-size:12px;
}
#forecast #chart{
  height:190px;
  min-height:190px;
  margin-top:2px;
}
#forecast .forecast-controls-card{
  padding:12px 20px;
}
#forecast .forecast-controls-card .controls{
  align-items:flex-end;
  gap:10px;
}
#forecast .forecast-controls-card .field{
  min-width:165px;
}
#forecast .forecast-controls-card label{
  font-size:11px;
}
#forecast .forecast-controls-card input,
#forecast .forecast-controls-card select{
  min-height:42px;
}
#forecast .forecast-controls-card .btn{
  min-height:42px;
}
#forecast .forecast-table-card{
  padding:12px 20px 14px;
}
#forecast .forecast-table-card .section-head{
  margin-bottom:7px;
}
#forecast .forecast-table-scroll{
  height:408px;
  max-height:408px;
  border-radius:9px;
}
#forecast .forecast-table-scroll thead th{
  padding-top:9px;
  padding-bottom:9px;
}
#forecast .forecast-table-scroll tbody tr{
  height:36px;
}
#forecast .forecast-table-scroll td{
  padding-top:7px;
  padding-bottom:7px;
}
@media (max-height:850px){
  #forecast #chart{
    height:160px;
    min-height:160px;
  }
  #forecast .forecast-table-scroll{
    height:360px;
    max-height:360px;
  }
}


#forecast{
  padding-top:0 !important;
}
#forecast .forecast-layout{
  gap:9px;
  margin-top:0;
}
#forecast .forecast-chart-card{
  margin-top:0;
  border-top-left-radius:0;
  border-top-right-radius:0;
  padding-top:14px;
}


.topbar-period{
  display:flex;
  align-items:center;
  gap:8px;
}
.topbar-period label{
  font-size:11px;
  color:var(--muted);
  font-weight:750;
  white-space:nowrap;
}
.topbar-period select{
  height:38px;
  min-width:112px;
  padding:0 32px 0 11px;
  border:1px solid var(--line);
  border-radius:999px;
  background:#fff;
  color:var(--ink);
  font-weight:750;
}
@media(max-width:760px){
  .topbar-period label{display:none}
  .topbar-period select{min-width:98px}
}
@media(max-width:620px){
  .topbar-period{display:none}
}


#forecast .forecast-layout{
  gap:9px;
}
#forecast .forecast-table-card{
  margin-top:0;
}
#forecast .forecast-table-scroll{
  height:500px;
  max-height:500px;
}
@media(max-height:850px){
  #forecast .forecast-table-scroll{
    height:445px;
    max-height:445px;
  }
}


.topbar-startdate{
 display:flex;
 align-items:center;
 gap:8px;
}
.topbar-startdate label{
 font-size:11px;
 color:var(--muted);
 font-weight:700;
 white-space:nowrap;
}
.topbar-startdate input[type="date"]{
 height:38px;
 border:1px solid var(--line);
 border-radius:999px;
 padding:0 12px;
 font-weight:700;
 background:#fff;
}


.chart{position:relative;overflow:visible}
.chart-zero-line{position:absolute;left:0;right:0;height:1px;background:#aeb8c8;z-index:1;pointer-events:none}
.chart-zero-label{position:absolute;left:4px;transform:translateY(-50%);font-size:10px;color:var(--muted);background:#fff;padding:0 4px;z-index:2}
.chart-bars{position:absolute;inset:0}
.chart .bar{position:absolute;min-width:0;border:0}
.chart .bar.negative-bar{border-radius:0 0 4px 4px}

.chart-bars{pointer-events:none}
.chart .bar{
  pointer-events:auto;
  cursor:pointer;
  z-index:2;
}
.chart .bar.selected-chart-bar{
  opacity:1 !important;
  transform:scaleX(1.45);
  filter:brightness(.72);
  z-index:4;
}
.forecast-table-scroll tbody tr.forecast-selected-row td{
  background:#fff3c8 !important;
  box-shadow:inset 0 1px 0 #e4bd42,inset 0 -1px 0 #e4bd42;
}
.forecast-table-scroll tbody tr.forecast-selected-row td:first-child{
  box-shadow:inset 4px 0 0 #c99900,inset 0 1px 0 #e4bd42,inset 0 -1px 0 #e4bd42;
}


/* Plan table scrolls beneath a fixed header row */
#items .plan-table-scroll{
  height:520px;
  max-height:520px;
  overflow-y:auto;
  overflow-x:auto;
  position:relative;
  border:1px solid var(--line);
  border-radius:10px;
  background:#fff;
}
#items .plan-table-scroll table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  margin:0;
}
#items .plan-table-scroll thead{
  position:relative;
  z-index:8;
}
#items .plan-table-scroll thead th{
  position:sticky;
  top:0;
  z-index:10;
  background:#f4f6fa;
  box-shadow:0 1px 0 #dce2eb;
}
#items .plan-table-scroll tbody td{
  background:#fff;
}
#items .plan-table-scroll .category-row td{
  background:#eef2f8;
}
@media(max-height:850px){
  #items .plan-table-scroll{
    height:440px;
    max-height:440px;
  }
}


#today.legacy-today{
  display:none !important;
}


.chart-period-control{
  display:flex;
  align-items:center;
  gap:8px;
  flex-shrink:0;
}
.chart-period-control label{
  font-size:11px;
  color:var(--muted);
  font-weight:750;
  white-space:nowrap;
}
.period-wrapper{
  position:relative;
}

.period-button{
  height:38px;
  min-width:112px;
  padding:0 12px;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
  color:var(--ink);
  font:inherit;
  font-weight:750;
  display:flex;
  align-items:center;
  justify-content:space-between;
  cursor:pointer;
}

.period-button:hover{
  background:#f8fafc;
}

.period-button:focus-visible{
  outline:2px solid var(--brand);
  outline-offset:1px;
}

.period-menu{
  display:none;
  position:absolute;
  top:calc(100% + 6px);
  right:0;
  z-index:1000;
  min-width:170px;
  padding:8px;
  background:#fff;
  border:1px solid var(--line);
  border-radius:10px;
  box-shadow:0 10px 30px rgba(0,0,0,.12);
}

.period-menu.show{
  display:block;
}

.period-menu button{
  width:100%;
  padding:9px 10px;
  border:0;
  border-radius:7px;
  background:transparent;
  color:var(--ink);
  font:inherit;
  text-align:left;
  cursor:pointer;
}

.period-menu button:hover{
  background:#f5f7fb;
}
@media(max-width:620px){
  .chart-period-control label{display:none}
  .period-button{min-width:96px}
}
.topbar-balance-group {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.start-fresh-button {
  height: 38px;
  padding: 0 13px;
  border: 1px solid #d8dee9;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}

.start-fresh-button:hover {
  background: #fff0ef;
  border-color: #efb4af;
  color: var(--bad);
}

.start-fresh-button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.topbar-balance-input{
  display:flex;
  align-items:center;
  gap:8px;
}
.topbar-balance-input label{
  font-size:11px;
  color:var(--muted);
  font-weight:700;
  white-space:nowrap;
}
.money-input-wrap{
  height:38px;
  display:flex;
  align-items:center;
  gap:3px;
  border:1px solid var(--line);
  border-radius:999px;
  padding:0 11px;
  background:var(--brand-soft);
  color:#223e9d;
  font-weight:750;
}
.money-input-wrap input{
  width:92px;
  border:0;
  outline:0;
  background:transparent;
  color:#223e9d;
  font-weight:750;
  padding:0;
}
.starting-point-row td{
  background:#eef2ff !important;
  font-weight:750;
}
.chart .bar.starting-balance-bar{
  background:#263fa8;
  opacity:1;
}


#test.legacy-test{
  display:none !important;
}


.add-category-menu{
 display:none;
 position:absolute;
 background:#fff;
 border:1px solid var(--line);
 border-radius:10px;
 box-shadow:0 8px 20px rgba(0,0,0,.12);
 padding:6px;
 z-index:50;
}
.add-category-menu.show{display:block;}
.add-category-menu button{
 display:block;
 width:160px;
 padding:10px 12px;
 border:0;
 background:#fff;
 text-align:left;
 cursor:pointer;
 border-radius:8px;
}
.add-category-menu button:hover{
 background:#f3f6fb;
}


.add-category-menu{
  display:none;
  position:absolute;
  width:285px;
  max-height:70vh;
  overflow-y:auto;
  background:#fff;
  border:1px solid var(--line);
  border-radius:12px;
  box-shadow:0 12px 30px rgba(15,23,42,.16);
  padding:8px;
  z-index:50;
}
.add-category-menu.show{display:block}
.category-menu-section{
  padding:5px 0 9px;
  border-bottom:1px solid var(--line);
}
.category-menu-section:last-child{
  border-bottom:0;
  padding-bottom:3px;
}
.category-menu-heading{
  padding:7px 10px 5px;
  color:var(--ink);
  font-size:12px;
  font-weight:850;
  text-transform:uppercase;
  letter-spacing:.045em;
}
.add-category-menu button{
  display:block;
  width:100%;
  padding:8px 11px;
  border:0;
  background:#fff;
  color:var(--ink);
  text-align:left;
  cursor:pointer;
  border-radius:8px;
}
.add-category-menu button:hover{background:#f3f6fb}
.add-category-menu .custom-category-option{
  margin-top:3px;
  color:var(--brand);
  font-weight:750;
}


.pill.goal{background:#fff2d8;color:#8a5a00}
.goal-detail{display:block;font-size:11px;color:var(--muted);margin-top:3px}

.visibility-toggle{width:30px;height:30px;display:inline-grid;place-items:center;border:0;border-radius:8px;background:transparent;color:#40506a;cursor:pointer;padding:0}
.visibility-toggle:hover{background:#eef2f8}
.visibility-toggle svg{width:18px;height:18px}
.category-item-row.item-disabled td{opacity:.46}
.category-item-row.item-disabled td:first-child{opacity:1}
.category-item-row.item-disabled strong{text-decoration:line-through}
.visibility-heading{width:38px;text-align:center}
.account-view-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-view-control > label {
  white-space: nowrap;
}

.account-view-wrapper {
  position: relative;
}

.account-view-button {
  height:38px;
  min-width:150px;
  padding:0 12px;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
  color:var(--ink);
  font:inherit;
  font-weight:700;
  text-align:left;
  cursor:pointer;
}

.account-view-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  padding: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  z-index: 1000;
}

.account-view-menu.show {
  display: block;
}

.account-view-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  transition: background .12s ease;
}

.account-view-option:hover {
  background: #f5f7fb;
}

.account-view-option input {
  margin: 0;
}

.account-view-divider {
  height: 1px;
  background: var(--line);
  margin: 6px 0;
}

.add-account-button {
  width: 100%;
  padding: 10px;
  border: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border-radius: 7px;
}

.add-account-button:hover {
  background: #f5f7fb;
}

#addCategoryButton:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.35);
  box-shadow: none;
}

/* #22 Persistent forecast chart on Plan and Forecast */

#persistentForecastChart{
  margin-bottom:9px;
}

#persistentForecastChart.hidden{
  display:none;
}

#persistentForecastChart .forecast-chart-card{
  margin-top:0;
  border-top-left-radius:0;
  border-top-right-radius:0;
  padding:14px 20px 12px;
}

#persistentForecastChart .forecast-chart-card .section-head{
  margin-bottom:4px;
}

#persistentForecastChart .forecast-chart-card .section-title{
  font-size:18px;
}

#persistentForecastChart .forecast-chart-card .small{
  font-size:12px;
}

#persistentForecastChart #chart{
  height:190px;
  min-height:190px;
  margin-top:2px;
}

@media(max-height:850px){
  #persistentForecastChart #chart{
    height:160px;
    min-height:160px;
  }
}

/* #25 Fixed / Flexible date classification */

.pill.fixed{
  background:#eef2f8;
  color:#52627c;
}

.pill.flexible{
  background:#ecf9f1;
  color:#147a44;
}

/*
  Keep the Plan date-flexibility filter compact
  and aligned with the other Budget breakdown controls.
*/
#dateFlexibilityFilter{
  min-width:125px;
  height:38px;
  padding:0 30px 0 10px;
  border:1px solid var(--line);
  border-radius:9px;
  background:#fff;
  color:var(--ink);
  font-weight:700;
}

/* =========================================================
   #29 — Plan Screen UX & Layout Refinement
   Step 1A — Plan screen structure and hierarchy
   ========================================================= */

/*
  Keep the Plan screen visually compact so the user can see:

  1. Forecast
  2. Monthly position
  3. Budget breakdown

  as one connected planning workspace.
*/

#items{
  padding-top:0;
}


/* ---------- Monthly summary ---------- */

#items .plan-summary{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:12px;
  margin:0 0 12px;
}

#items .summary-box{
  min-height:84px;
  padding:13px 16px;
  border-radius:12px;
  background:#fff;
}

#items .summary-box .label{
  font-size:11px;
}

#items .summary-box strong{
  font-size:21px;
  margin-top:3px;
}

#items .summary-box .small{
  margin-top:2px;
  font-size:12px;
}


/* ---------- Budget breakdown card ---------- */

#items > .card{
  padding:14px 16px 16px;
}

#items > .card > .section-head{
  margin-bottom:10px;
  align-items:flex-end;
}

#items > .card .section-title{
  margin-bottom:2px !important;
  font-size:17px;
}

#items > .card .section-head .small{
  margin-top:2px;
  font-size:12px;
}


/* ---------- Plan table ---------- */

#items .plan-table-scroll{
  height:480px;
  max-height:480px;
}

#items .plan-table-scroll th{
  padding-top:9px;
  padding-bottom:9px;
}

#items .plan-table-scroll td{
  padding-top:8px;
  padding-bottom:8px;
}


/*
  On shorter laptop screens reduce the table height
  so the top of all three Plan sections remains accessible.
*/
@media(max-height:850px){

  #items .plan-table-scroll{
    height:400px;
    max-height:400px;
  }

}


/*
  Preserve the existing single-column summary behaviour
  on narrow screens.
*/
@media(max-width:620px){

  #items .plan-summary{
    grid-template-columns:1fr;
  }

}

/* =========================================================
   #29 — Step 1B
   Budget breakdown toolbar structure
   ========================================================= */

/*
  On the Plan screen the Budget breakdown heading
  sits above its controls.

  This gives the current controls enough room and
  creates a permanent toolbar area for future
  View Tags and Forecast Controls.
*/

#items > .card > .section-head{
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
  align-items:start;
}

#items > .card > .section-head > div:first-child{
  width:100%;
}

#items > .card > .section-head .controls{
  width:100%;
  display:flex;
  align-items:flex-end;
  justify-content:flex-start;
  gap:10px;
  flex-wrap:wrap;
}


/*
  Keep Collapse / Expand together visually.
*/

#items > .card > .section-head .controls .btn{
  min-height:38px;
}


/*
  Give the table a small visual separation
  from the control toolbar.
*/

#items .plan-table-scroll{
  margin-top:2px;
}

/* =========================================================
   #29 — Step 1C
   Compact forecast chart on Plan
   ========================================================= */

/*
  Forecast is the primary analysis screen,
  so it retains the full-size chart.

  On Plan the chart provides context while the
  transaction plan remains the primary workspace.
*/

#persistentForecastChart.plan-chart .forecast-chart-card{
  padding-top:11px;
  padding-bottom:8px;
}

#persistentForecastChart.plan-chart .forecast-chart-card .section-head{
  margin-bottom:0;
}

#persistentForecastChart.plan-chart #chart{
  height:125px;
  min-height:125px;
}

#persistentForecastChart.plan-chart .forecast-chart-card .small{
  margin-top:2px;
}


/*
  Keep the Plan version compact on shorter screens.
*/

@media(max-height:850px){

  #persistentForecastChart.plan-chart #chart{
    height:105px;
    min-height:105px;
  }

}

/* =========================================================
   #29 — Step 3A
   Category row refinement
   ========================================================= */

#items .category-row td{
  background:#f3f6fb;
  border-top:1px solid #d7deea;
  border-bottom:1px solid #d7deea;
  padding-top:10px;
  padding-bottom:10px;
}

#items .category-row:hover td{
  background:#edf2f8;
}

#items .category-row .category-name{
  font-size:14px;
  font-weight:850;
  color:#1d2b43;
}

#items .category-row .category-meta{
  margin-left:8px;
  font-size:11px;
  font-weight:650;
  color:var(--muted);
}

#items .category-row .category-toggle{
  width:16px;
  margin-right:5px;
  color:#5f6f88;
}

#items .category-row .category-total{
  font-size:14px;
  font-weight:850;
  color:#1d2b43;
}

#items .category-row .small{
  font-size:11px;
  color:var(--muted);
  white-space:nowrap;
}

#items .category-add{
  padding:5px 9px;
  font-size:11px;
  border-radius:7px;
  white-space:nowrap;
}

/* =========================================================
   #29 — Step 3E
   Final transaction row hierarchy
   ========================================================= */

/*
  Stable table layout after removal of the
  redundant Category column.
*/
#items .plan-table-scroll table{
  width:100%;
  min-width:0;
  table-layout:fixed;
}


/* Transaction name is the primary identifier. */
#items .category-item-row td:nth-child(3) strong{
  font-size:14px;
  font-weight:800;
  color:var(--ink);
}


/*
  Frequency, date and flexibility are supporting
  information and remain visually quieter.
*/
#items .category-item-row td:nth-child(4),
#items .category-item-row td:nth-child(5),
#items .category-item-row td:nth-child(6){
  color:#35435a;
}


/* Prevent frequency and date wrapping unnecessarily. */
#items .category-item-row td:nth-child(4),
#items .category-item-row td:nth-child(5){
  white-space:nowrap;
}


/*
  Amount is supporting detail.
  Monthly amount is the primary planning figure.
*/
#items .category-item-row td:nth-child(7){
  color:#35435a;
  font-weight:650;
}

#items .category-item-row td:nth-child(8){
  font-weight:850;
  color:var(--ink);
}


/* Keep individual transaction rows subtly separated. */
#items .category-item-row td{
  border-bottom-color:#e8ecf2;
}


/* =========================================================
   #29 — Step 3D
   Simplified Plan columns and compact row actions
   ========================================================= */



#items .plan-action-button{
  width:30px;
  height:30px;
  display:inline-grid;
  place-items:center;
  padding:0;
  border-radius:8px;
  background:#fff;
  border:1px solid var(--line);
  font-size:17px;
  font-weight:800;
  line-height:1;
}

#items .plan-action-button.edit-action{
  color:#35435a;
}

#items .plan-action-button.edit-action:hover{
  background:#f3f6fb;
}

#items .plan-action-button.delete-action{
  color:var(--bad);
  background:#fff7f6;
  border-color:#f2d4d1;
}

#items .plan-action-button.delete-action:hover{
  background:#fff0ef;
}


/*
  Updated Plan table widths after removing
  the redundant Category column.
*/





/* =========================================================
   #29 — Step 4
   Final Plan screen polish
   ========================================================= */


/* ---------- Transaction row feedback ---------- */

#items .category-item-row{
  transition:background .12s ease;
}

#items .category-item-row:hover td{
  background:#fafbfe;
}


/* ---------- Action button accessibility ---------- */

#items .plan-action-button{
  transition:
    background .12s ease,
    border-color .12s ease,
    transform .12s ease;
}

#items .plan-action-button:hover{
  transform:translateY(-1px);
}

#items .plan-action-button:focus-visible{
  outline:2px solid var(--brand);
  outline-offset:2px;
}


/* ---------- Visibility toggle feedback ---------- */

#items .visibility-toggle{
  transition:
    background .12s ease,
    transform .12s ease;
}

#items .visibility-toggle:hover{
  transform:scale(1.05);
}

#items .visibility-toggle:focus-visible{
  outline:2px solid var(--brand);
  outline-offset:2px;
}


/* ---------- Category add button ---------- */

#items .category-add{
  transition:
    background .12s ease,
    border-color .12s ease;
}

#items .category-add:focus-visible{
  outline:2px solid var(--brand);
  outline-offset:2px;
}


/* ---------- Budget toolbar responsiveness ---------- */

@media(max-width:1100px){

  #items > .card > .section-head .controls{
    gap:8px;
  }

  #items > .card > .section-head .controls .btn{
    padding-left:11px;
    padding-right:11px;
  }

}


/* ---------- Table scrollbar ---------- */

#items .plan-table-scroll{
  scrollbar-width:thin;
  scrollbar-color:#aab2c0 transparent;
}

#items .plan-table-scroll::-webkit-scrollbar{
  width:8px;
  height:8px;
}

#items .plan-table-scroll::-webkit-scrollbar-thumb{
  background:#aab2c0;
  border-radius:999px;
}

#items .plan-table-scroll::-webkit-scrollbar-track{
  background:transparent;
}

/* =========================================================
   #29 — Step 5A
   Permanent Plan workspace + right-side summary panel
   ========================================================= */

#items .plan-workspace{
  display:grid;
  grid-template-columns:minmax(0,1fr) 245px;
  gap:14px;
  align-items:start;
}

#items .plan-main{
  min-width:0;
}

#items .plan-summary-panel{
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
}


/* Summary cards are deliberately compact. */

#items .plan-summary-panel .summary-box{
  min-height:82px;
  padding:13px 15px;
  background:#fff;
}

#items .plan-summary-panel .summary-box .label{
  font-size:11px;
}

#items .plan-summary-panel .summary-box strong{
  display:block;
  margin-top:4px;
  font-size:21px;
}

#items .plan-summary-panel .summary-box .small{
  margin-top:3px;
  font-size:11px;
}


/* Today's Balance anchors the summary panel. */

#items .plan-today-summary{
  background:var(--brand-soft);
  border-color:#dce3ff;
}

#items .plan-today-summary strong{
  color:#223e9d;
}


/*
  Allow the main Plan workspace to reclaim the
  full available height now that the horizontal
  summary row has been removed.
*/

#items .plan-table-scroll{
  height:460px;
  max-height:460px;
}


/* Responsive fallback */

@media(max-width:1050px){

  #items .plan-workspace{
    grid-template-columns:1fr;
  }

  #items .plan-summary-panel{
    grid-template-columns:repeat(4,minmax(0,1fr));
  }

}


@media(max-width:760px){

  #items .plan-summary-panel{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

}


@media(max-width:620px){

  #items .plan-summary-panel{
    grid-template-columns:1fr;
  }

}

/* =========================================================
   #29 — Step 5B
   Date Flexibility in permanent top-bar position
   ========================================================= */

.topbar-date-flexibility{
  display:flex;
  align-items:center;
  gap:8px;
}

.topbar-date-flexibility label{
  font-size:11px;
  color:var(--muted);
  font-weight:700;
  white-space:nowrap;
}

.topbar-date-flexibility select{
  height:38px;
  min-width:105px;
  padding:0 30px 0 10px;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
  color:var(--ink);
  font-weight:700;
}

/* =========================================================
   #29 — Step 5C
   Permanent Plan category disclosure control
   ========================================================= */



#items .visibility-heading{
  text-align:center;
}

#items .plan-master-toggle{
  width:24px;
  height:24px;
  display:inline-grid;
  place-items:center;
  padding:0;
  border:0;
  border-radius:6px;
  background:transparent;
  color:#5f6f88;
  font-size:15px;
  font-weight:900;
  line-height:1;
  cursor:pointer;
}

#items .plan-master-toggle:hover{
  background:#e8edf5;
  color:var(--ink);
}

#items .plan-master-toggle:focus-visible{
  outline:2px solid var(--brand);
  outline-offset:1px;
}

/* =========================================================
   #29 — Step 5D
   Compact category add control
   ========================================================= */

#items .category-add-compact{
  width:22px;
  height:22px;
  display:inline-grid;
  place-items:center;
  margin-left:6px;
  padding:0;
  border-radius:6px;
  vertical-align:middle;
  font-size:16px;
  font-weight:800;
  line-height:1;
}

#items .category-add-compact:hover{
  background:var(--brand-soft);
  border-color:#bfcaf0;
}

/* =========================================================
   #29 — Step 5E
   Eye / Edit / Delete transaction controls
   ========================================================= */

#items .plan-row-controls{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:3px;
  white-space:nowrap;
}


/*
  First column now contains:
  eye + edit + delete.
*/



/*
  Give some of the reclaimed action-column width
  back to the transaction name.
*/


/* =========================================================
   #29 — Step 5F
   Start Fresh in View Accounts menu
   ========================================================= */

.account-menu-action{
  width:100%;
  padding:9px 10px;
  border:0;
  border-radius:8px;
  background:transparent;
  color:var(--ink);
  font:inherit;
  font-weight:700;
  text-align:left;
  cursor:pointer;
}

.account-menu-action:hover{
  background:#f3f6fb;
}

.account-menu-action:focus-visible{
  outline:2px solid var(--brand);
  outline-offset:1px;
}

/* =========================================================
   #29 — Step 5F-A
   Compact View Accounts edit control
   ========================================================= */

.account-edit-button{
  width:32px;
  height:32px;
  flex:0 0 32px;
  display:grid;
  place-items:center;
  padding:0;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
  color:var(--ink);
  font-size:15px;
  font-weight:800;
  line-height:1;
  cursor:pointer;
}

.account-edit-button:hover{
  background:#f3f6fb;
  border-color:#cbd5e1;
}

.account-edit-button:focus-visible{
  outline:2px solid var(--brand);
  outline-offset:1px;
}

/* =========================================================
   #29 — Step 5F-B
   Edit Account modal
   ========================================================= */

.account-edit-modal-box{
  max-width:440px;
}

.account-edit-divider{
  height:1px;
  margin:18px 0;
  background:var(--line);
}

.account-edit-actions{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.account-edit-actions .btn{
  min-width:120px;
}

/* #29 — Income type styling */

#items .pill.income{
  background:#ecf9f1;
  color:var(--good);
}

/* =========================================================
   #29 — Step 5H
   Drag transactions between Plan categories
   ========================================================= */

#items .category-item-row[draggable="true"]{
  cursor:grab;
}

#items .category-item-row[draggable="true"]:active{
  cursor:grabbing;
}

#items .category-item-row.plan-item-dragging td{
  opacity:.45;
}

#items .category-row.plan-drop-target td{
  background:#e8eeff !important;
  box-shadow:
    inset 0 2px 0 var(--brand),
    inset 0 -2px 0 var(--brand);
}

#items .category-row.plan-drop-target .category-name{
  color:var(--brand);
}

/* =========================================================
   #29 — Step 6A
   Final Plan table width allocation
   ========================================================= */

#items .plan-table-scroll{
  overflow-x:hidden;
}

#items .plan-table-scroll table{
  width:100%;
  min-width:0;
  table-layout:fixed;
}


/* Eye / pencil / delete */
#items .plan-table-scroll th:nth-child(1),
#items .plan-table-scroll td:nth-child(1){
  width:92px;
}


/* Type */
#items .plan-table-scroll th:nth-child(2),
#items .plan-table-scroll td:nth-child(2){
  width:100px;
}

#items .plan-table-scroll td:nth-child(2) .pill{
  white-space:nowrap;
}

/* Name — flexible column */
#items .plan-table-scroll th:nth-child(3),
#items .plan-table-scroll td:nth-child(3){
  width:auto;
}


/* Frequency */
#items .plan-table-scroll th:nth-child(4),
#items .plan-table-scroll td:nth-child(4){
  width:94px;
}


/* Date */
#items .plan-table-scroll th:nth-child(5),
#items .plan-table-scroll td:nth-child(5){
  width:112px;
}


/* Date flexibility */
#items .plan-table-scroll th:nth-child(6),
#items .plan-table-scroll td:nth-child(6){
  width:104px;
}


/* Amount */
#items .plan-table-scroll th:nth-child(7),
#items .plan-table-scroll td:nth-child(7){
  width:88px;
  text-align:right;
}


/* Monthly */
#items .plan-table-scroll th:nth-child(8),
#items .plan-table-scroll td:nth-child(8){
  width:96px;
  text-align:right;
}


/* Name may truncate before financial columns do */
#items .plan-table-scroll td:nth-child(3){
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}


/* Keep compact supporting fields on one line */
#items .plan-table-scroll td:nth-child(4),
#items .plan-table-scroll td:nth-child(5),
#items .plan-table-scroll td:nth-child(6),
#items .plan-table-scroll td:nth-child(7),
#items .plan-table-scroll td:nth-child(8){
  white-space:nowrap;
}

/* =========================================================
   #29 — Step 6B
   Editable Current Balance in summary panel
   ========================================================= */

#items .plan-current-balance-wrap{
  display:flex;
  align-items:center;
  gap:3px;
  margin-top:4px;
  color:#223e9d;
  font-size:21px;
  font-weight:800;
}

#items .plan-current-balance-wrap input{
  width:100%;
  min-width:0;
  padding:0;
  border:0;
  outline:0;
  background:transparent;
  color:#223e9d;
  font-size:21px;
  font-weight:800;
}

#items .plan-current-balance-wrap:has(input:disabled){
  color:#7185d6;
  cursor:not-allowed;
}

#items .plan-current-balance-wrap input:disabled{
  opacity:1;
  color:#7185d6;
  -webkit-text-fill-color:#7185d6;
  cursor:not-allowed;
}

/* =========================================================
   #29 — Transfer type styling
   ========================================================= */

#items .pill.transfer-in{
  background:#ecf9f1;
  color:var(--good);
}

#items .pill.transfer-out{
  background:#fff0ef;
  color:var(--bad);
}

/* =========================================================
   #29 — Step 6D
   Forecast date → Plan transaction highlighting
   ========================================================= */

#items .category-item-row.plan-selected-row td{
  background:#fff8dc !important;
  box-shadow:
    inset 0 1px 0 #ead58a,
    inset 0 -1px 0 #ead58a;
}

#items .category-item-row.plan-selected-row td:first-child{
  box-shadow:
    inset 4px 0 0 #d2a900,
    inset 0 1px 0 #ead58a,
    inset 0 -1px 0 #ead58a;
}

/* =========================================================
   #29 — Step 6E
   Plan chart + table left workspace
   ========================================================= */

#items .plan-main{
  display:flex;
  flex-direction:column;
  gap:10px;
}


/*
  The shared chart now lives inside plan-main
  while the Plan page is open.
*/
#items #persistentForecastChart{
  width:100%;
  margin:0;
}


/*
  Keep chart and table visually aligned.
*/
#items #persistentForecastChart .forecast-chart-card,
#items .plan-table-card{
  width:100%;
}

/* =========================================================
   #29 — Step 6F-3
   Cashflow / Plan summary groups
   ========================================================= */

#items .plan-summary-panel{
  display:flex;
  flex-direction:column;
  gap:18px;
}

#items .plan-summary-section{
  display:flex;
  flex-direction:column;
  gap:8px;
}

#items .plan-summary-heading{
  padding:0 2px 3px;
  font-size:11px;
  font-weight:850;
  letter-spacing:.09em;
  color:var(--muted);
}

#items .plan-summary-section + .plan-summary-section{
  padding-top:16px;
  border-top:1px solid var(--line);
}

/* =========================================================
   #29 — Step 6G
   Income portion inside forecast bars
   ========================================================= */

/*
  Positive balance:
  green income begins at the $0 axis,
  with the remaining balance blue above it.
*/
.chart .bar.income-segment-bar:not(.negative-bar){
  background:
    linear-gradient(
      to top,
      #22c55e 0,
      #22c55e var(--income-percent),
      #6a82ea var(--income-percent),
      #6a82ea 100%
    );
}


/*
  Negative balance:
  green income still begins at the $0 axis,
  with the remaining negative balance red
  extending away from zero.
*/
.chart .bar.income-segment-bar.negative-bar{
  background:
    linear-gradient(
      to bottom,
      #22c55e 0,
      #22c55e var(--income-percent),
      #d5554c var(--income-percent),
      #d5554c 100%
    );
}


/*
  Starting balance remains its own distinct
  dark-blue starting position.
*/
.chart .bar.starting-balance-bar{
  background:#263fa8;
}

/* =========================================================
   #29 — Step 6H
   Selected chart date filter
   ========================================================= */

.topbar-selected-date{
  display:flex;
  align-items:center;
  gap:8px;
}

.topbar-selected-date label{
  font-size:11px;
  color:var(--muted);
  font-weight:700;
  white-space:nowrap;
}

/* =========================================================
   #29 — Topbar control consistency
   View Accounts matches filter controls
   ========================================================= */

.account-switcher > span{
  font-size:11px;
  color:var(--muted);
  font-weight:700;
  white-space:nowrap;
}

/* #29 — Match View Accounts label to topbar filters */

.account-view-control > label{
  font-size:11px;
  color:var(--muted);
  font-weight:700;
  white-space:nowrap;
}

/* =========================================================
   #29 — Forecast transaction marker
   ========================================================= */

.chart .bar.has-transaction::before{
  content:'';
  position:absolute;
  left:50%;
  width:4px;
  height:4px;
  border-radius:50%;
  background:#17213a;
  transform:translateX(-50%);
  z-index:6;
  pointer-events:none;
}


/*
  Positive balance bars rise upward from zero,
  so keep the dot just above the zero axis.
*/
.chart .bar.has-transaction:not(.negative-bar)::before{
  bottom:3px;
}


/*
  Negative balance bars fall downward from zero,
  so keep the dot just below the zero axis.
*/
.chart .bar.has-transaction.negative-bar::before{
  top:3px;
}

/* =========================================================
   View Accounts — drag account ordering
   ========================================================= */

.account-view-option[draggable="true"]{
  cursor:default;
}

.account-view-option[draggable="true"] .account-view-name{
  cursor:grab;
}

.account-view-option[draggable="true"] .account-view-name:active{
  cursor:grabbing;
}

.account-view-option.account-dragging{
  opacity:.45;
}

.account-view-option.account-drop-target{
  background:#fff !important;
  box-shadow:
    inset 0 2px 0 var(--brand);
}

/* Add Category — categories already in Plan */

#addCategoryMenu button:disabled{
  opacity:.38;
  cursor:not-allowed;
  background:#f5f6f8;
  color:var(--muted);
}

/* Category row controls */

.category-row-controls{
  display:inline-flex;
  align-items:center;
  gap:4px;
  margin:0 8px 0 4px;
  vertical-align:middle;
}

.category-row-controls .visibility-toggle,
.category-row-controls .plan-action-button,
.category-row-controls .category-add{
  flex:0 0 auto;
}

.category-row-controls .visibility-toggle:disabled{
  opacity:.3;
  cursor:default;
}

/* =========================================================
   Plan drag insertion indicators
   ========================================================= */

/*
  Category reorder:
  show exactly where the category block
  will be inserted.
*/

#items .category-row.plan-category-drop-before td{
  box-shadow:
    inset 0 3px 0 var(--brand);
}

#items .category-row.plan-category-drop-after td{
  box-shadow:
    inset 0 -3px 0 var(--brand);
}


/*
  Dragged category feedback.
*/

#items .category-row.plan-category-dragging td{
  opacity:.5;
}


/*
  Make draggable category rows communicate
  that they can be grabbed and moved.
*/

#items .category-row[draggable="true"]{
  cursor:grab;
}

#items .category-row[draggable="true"]:active{
  cursor:grabbing;
}

.category-item-row.plan-item-drop-line td {
  border-top: 2px solid currentColor;
}

.pill.view-tag-bills {
  background: #dcfce7;
  color: #166534;
}

.pill.view-tag-essentials {
  background: #ffedd5;
  color: #9a3412;
}

.pill.view-tag-non-essentials {
  background: #fee2e2;
  color: #991b1b;
}

.topbar-view-tags {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-view-tags > label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  margin: 0;
}

.view-tags-wrapper {
  position: relative;
}

.view-tags-button {
  height: 38px;
  min-width: 150px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  appearance: none;
}

.view-tags-button:hover {
  background: #f8fafc;
}

.view-tags-button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.view-tags-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1000;
  min-width: 190px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
}

.view-tags-menu.show {
  display: block;
}

.view-tags-menu label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.view-tags-menu label:hover {
  background: #f5f7fb;
}

.view-tags-menu input {
  margin: 0;
}

/* =========================================================
   #J — Master Plan disclosure + visibility controls
   ========================================================= */

#items .visibility-heading{
  text-align:left;
}

#items .plan-header-controls{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:4px;
  white-space:nowrap;
}

/*
  Align the master triangle with the
  category disclosure triangles below.
*/
#items .plan-header-controls .plan-master-toggle{
  flex:0 0 24px;
}

/*
  Align the master eye with the category
  and transaction visibility eyes below.
*/
#items .plan-header-controls .visibility-toggle{
  flex:0 0 30px;
}

/* =========================================================
   Bug fix — Category row hover + controls
   ========================================================= */

/* Subtle whole-row hover feedback */
#items .category-row:hover td{
  background:#e9eef6;
}

/*
  Keep the row draggable, but don't show the
  grab cursor over the triangle or controls.
*/
#items .category-row[draggable="true"]{
  cursor:grab;
}

#items .category-row[draggable="true"]:active{
  cursor:grabbing;
}

/* Category triangle behaves like a clickable control */
#items .category-row .category-toggle{
  display:inline-grid;
  place-items:center;
  width:22px;
  height:22px;
  margin-right:2px;
  border-radius:6px;
  cursor:pointer;
  transition:
    background .12s ease,
    color .12s ease,
    transform .12s ease;
}

#items .category-row .category-toggle:hover{
  background:#dfe6f1;
  color:var(--ink);
  transform:scale(1.05);
}

/* Eye gets the same subtle hover treatment */
#items .category-row .visibility-toggle{
  cursor:pointer;
}

#items .category-row .visibility-toggle:hover{
  background:#dfe6f1;
  transform:scale(1.05);
}

/* =========================================================
   Bug fix — Top control hover consistency
   ========================================================= */

/*
  Match Selected date, View Accounts and Forecast period
  to the View Tags hover behaviour.
*/

.account-view-button{
  transition:
    background .12s ease,
    border-color .12s ease,
    box-shadow .12s ease;
}

.account-view-button:hover{
  background:#f8fafc;
}

.account-view-button:focus{
  background:#f8fafc;
  border-color:#cbd5e1;
  outline:none;
}

.account-view-button:focus-visible{
  outline:2px solid var(--brand);
  outline-offset:1px;
}

/* =========================================================
   Selected Date custom dropdown
   ========================================================= */

.selected-date-wrapper{
  position:relative;
}

.selected-date-button{
  height:38px;
  min-width:112px;
  padding:0 12px;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
  color:var(--ink);
  font:inherit;
  font-weight:750;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  cursor:pointer;
}

.selected-date-button:hover{
  background:#f8fafc;
}

.selected-date-button:focus-visible{
  outline:2px solid var(--brand);
  outline-offset:1px;
}

.selected-date-menu{
  display:none;
  position:absolute;
  top:calc(100% + 6px);
  left:0;
  z-index:1000;
  min-width:170px;
  padding:8px;
  background:#fff;
  border:1px solid var(--line);
  border-radius:10px;
  box-shadow:0 10px 30px rgba(0,0,0,.12);
}

.selected-date-menu.show{
  display:block;
}

.selected-date-menu button{
  width:100%;
  padding:9px 10px;
  border:0;
  border-radius:7px;
  background:transparent;
  color:var(--ink);
  font:inherit;
  text-align:left;
  cursor:pointer;
}

.selected-date-menu button:hover{
  background:#f5f7fb;
}

/* Collapsible left sidebar */
.menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@media (min-width: 981px) {
  .shell.left-sidebar-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .shell.left-sidebar-collapsed > .sidebar {
    display: none;
  }

  .shell.left-sidebar-collapsed .content {
    max-width: none;
  }
}

/* Show the exact position for a dragged transaction. */
.category-item-row.plan-item-drop-line td {
  border-top: 2px solid var(--brand);
}

.category-item-row.plan-item-drop-line[data-drop-after="true"] td {
  border-top: 0;
  border-bottom: 2px solid var(--brand);
}

/* Longer forecast periods: daily balance line */

.forecast-line-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.forecast-line-svg text {
  font-family: inherit;
  font-size: 10px;
  fill: var(--muted);
  pointer-events: none;
}

.forecast-line-svg > path,
.forecast-line-svg > line,
.forecast-line-svg > circle {
  pointer-events: none;
}

.forecast-point {
  cursor: pointer;
}

.forecast-point circle {
  fill: var(--brand);
  stroke: white;
  stroke-width: 2;
  opacity: 0;
  pointer-events: none;
}

.forecast-point:hover circle,
.forecast-point:focus circle,
.forecast-point.selected-chart-bar circle {
  opacity: 1;
}

/* Transfer destination/source shown beneath the transaction name. */
#items .transfer-detail{
  display:block;
  margin-top:3px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:11px;
  font-weight:600;
  color:var(--muted);
}

/* Surplify sign-in */
#cloudAccountCard {
  margin-bottom: 20px;
}

#cloudAccountCard [hidden] {
  display: none !important;
}

.cloud-auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

#cloudAuthStatus,
#cloudAuthMessage {
  overflow-wrap: anywhere;
}

#cloudAuthMessage:empty {
  display: none;
}

#cloudAccountCard button:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Cloud loading and signed-out screen */
#cloudGate {
  display: none;
  width: min(680px, calc(100% - 32px));
  margin: 32px auto;
}

body.cloud-locked #cloudGate {
  display: block;
}

body.cloud-locked .shell,
body.cloud-locked .modal {
  display: none !important;
}

/* Account and save status occupy their own space below the toolbar. */
#cloudSaveBar {
  position: static;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 18px;
  min-width: 0;
  padding: 10px 28px;
  border-bottom: 1px solid #dce3ef;
  background: #fff;
  color: #173052;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

#cloudSaveBar > * {
  min-width: 0;
  max-width: 100%;
}

#cloudRecoveryHint:empty {
  display: none;
}

@media (max-width: 980px) {
  #cloudSaveBar {
    padding: 10px 18px;
  }
}

/* 6A.1 — Allow toolbar controls to wrap at every window width */
.topbar {
  height: auto;
  min-height: 72px;
  padding-top: 12px;
  padding-bottom: 12px;
  gap: 12px 20px;
  flex-wrap: wrap;
}

.topbar > :first-child {
  flex-shrink: 0;
}

.topbar .top-actions {
  flex: 1 1 680px;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 14px;
}

@media (max-width: 980px) {
  .topbar .top-actions {
    flex-basis: 100%;
    justify-content: flex-start;
  }
}

/* Keep the narrow-screen menu below the toolbar */
@media (max-width: 980px) {
  #mobileNav {
    top: var(--toolbar-height, 72px);
    height: calc(100vh - var(--toolbar-height, 72px));
    height: calc(100dvh - var(--toolbar-height, 72px));
    overflow-y: auto;
  }
}

/* MVP — hide the View Tags filter and Plan table column */
.topbar-view-tags {
  display: none;
}

#items .plan-table-scroll thead th:nth-child(6),
#itemsRows > tr:not(.category-row) > td:nth-child(6) {
  display: none;
}

/* =========================================================
   6B.1 — Mobile Plan overview
   Compact, cashflow-first phone layout
   ========================================================= */

@media (max-width: 620px) {

  /* ---------------------------------------------------------
     PLAN TOP TOOLBAR
     menu | month | account
     --------------------------------------------------------- */

  body[data-page="items"] .topbar {
    display: grid;
    grid-template-columns: minmax(52px, 1fr) auto minmax(52px, 1fr);
    align-items: center;
    min-height: 64px;
    padding: 8px 14px;
    gap: 8px;
  }

  body[data-page="items"] .topbar > :first-child {
    grid-column: 1;
    grid-row: 1;
    width: auto;
    min-width: 0;
    justify-self: start;
  }

  /* "Plan" is unnecessary once the Plan tab is active. */
  body[data-page="items"] #pageTitle {
    display: none;
  }

  body[data-page="items"] .menu-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
  }

  /*
    Allow the individual Plan controls to participate
    directly in the toolbar grid.
  */
  body[data-page="items"] .topbar .top-actions {
    display: contents;
  }

  /* Month becomes the primary centred navigation control. */
  body[data-page="items"] .topbar .topbar-budget-month {
    display: block;
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
    width: auto;
    min-width: 0;
  }

  body[data-page="items"] .topbar .topbar-budget-month[hidden] {
    display: none;
  }

  body[data-page="items"] .topbar-budget-month label {
    display: none;
  }

  body[data-page="items"] .topbar-budget-month input {
    width: 158px;
    min-width: 0;
    min-height: 44px;
    padding: 6px 8px;
    border: 0;
    background: transparent;
    text-align: center;
    color: var(--ink);
    font-size: 17px;
    font-weight: 800;
  }

  /* Compact account selector on the right. */
  body[data-page="items"] .topbar .account-view-control {
    display: block;
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    width: auto;
    min-width: 0;
  }

  body[data-page="items"] .account-view-control > label {
    display: none;
  }

  body[data-page="items"] .account-view-wrapper {
    width: auto;
  }

  body[data-page="items"] .account-view-button {
    width: auto;
    max-width: 126px;
    min-width: 44px;
    min-height: 44px;
    padding: 7px 9px;
    border-radius: 12px;
  }

  body[data-page="items"] #accountViewLabel {
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /*
    These are useful desktop controls but should not compete
    with the Plan overview on a phone.
  */
  body[data-page="items"] .mobile-view-options-toggle,
  body[data-page="items"] .topbar-selected-date,
  body[data-page="items"] .topbar-startdate {
    display: none !important;
  }


  /* ---------------------------------------------------------
     PLAN PAGE
     --------------------------------------------------------- */

  body[data-page="items"] .content {
    padding: 10px 14px 90px;
  }

  #items .plan-workspace {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    gap: 10px;
  }

  #items .plan-main,
  #items .plan-summary-panel {
    width: 100%;
    min-width: 0;
  }


  /* ---------------------------------------------------------
     HIDE PLAN CHART ON PHONE
     Forecast remains available on the Forecast screen.
     --------------------------------------------------------- */

  #items #persistentForecastChart {
    display: none !important;
  }


  /* ---------------------------------------------------------
     TODAY'S BALANCE
     Move it above the Plan list.
     --------------------------------------------------------- */

  #items .plan-summary-panel {
    order: -1;
    display: block;
  }

  #items .plan-summary-panel .plan-summary-heading {
    display: none;
  }

  /*
    Only Today's balance is needed in the primary mobile view.

    Minimum / maximum balance and monthly Plan summary remain
    available in the desktop layout and can later be placed
    into a mobile details view.
  */
  #items .plan-summary-panel .plan-summary-section:first-child
    .summary-box:not(:first-of-type),
  #items .plan-summary-panel
    .plan-summary-section:nth-child(2) {
    display: none;
  }

  #items .plan-summary-panel .plan-summary-section:first-child {
    display: block;
    padding: 0;
    border: 0;
  }

  #items .plan-today-summary {
    min-height: 0;
    margin: 0;
    padding: 12px 16px;
    border: 1px solid #dce3ff;
    border-radius: 14px;
    background: var(--brand-soft);
  }

  #items .plan-today-summary .label {
    display: block;
    margin-bottom: 3px;
    font-size: 11px;
    letter-spacing: 0;
    text-transform: none;
  }

  #items .plan-current-balance-wrap {
    margin: 0;
    font-size: 25px;
  }

  #items .plan-current-balance-wrap input {
    font-size: 25px;
  }

  /*
    Keep balance updating available but make it secondary.
  */
  #items .plan-today-summary > button {
    margin-top: 6px !important;
    padding: 5px 0;
    border: 0;
    background: transparent;
    color: var(--brand);
    font-size: 12px;
    font-weight: 750;
  }

  #items #planTodayAccountLabel {
    display: none;
  }


  /* ---------------------------------------------------------
     REMOVE DESKTOP "BUDGET BREAKDOWN" CARD CHROME
     --------------------------------------------------------- */

  #items .plan-table-card {
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible !important;
  }

  /*
    The category list itself is the mobile Plan screen,
    so this desktop heading/tool row is unnecessary here.
  */
  #items .plan-table-card > .section-head {
    display: none;
  }

  #items #monthlyPeriodHint {
    margin: 0 2px 6px;
    font-size: 11px;
  }


  /* ---------------------------------------------------------
     PLAN TABLE → COMPACT MOBILE LIST
     --------------------------------------------------------- */

  #items .plan-table-scroll {
    height: auto;
    max-height: none;
    margin: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  #items .plan-table-scroll table,
  #items .plan-table-scroll tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }

  /*
    Hide the desktop table headings and master controls.
    Mobile group management will get its own treatment later.
  */
  #items .plan-table-scroll thead {
    display: none;
  }


  /* ---------------------------------------------------------
     CATEGORY / GROUP ROWS
     --------------------------------------------------------- */

  #items .plan-table-scroll .category-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
    min-height: 50px;
    margin: 0;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    overflow: visible;
    cursor: pointer;
  }

  #items .plan-table-scroll .category-row:first-child {
    border-top: 1px solid var(--line);
  }

  #items .plan-table-scroll .category-row:hover {
    background: transparent;
  }

  #items .plan-table-scroll .category-row > td {
    display: block;
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent !important;
    box-shadow: none !important;
  }

  /*
    Category name + disclosure triangle.
  */
  #items .plan-table-scroll .category-row > td:first-child {
    grid-column: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 11px 4px 11px 0;
    gap: 5px;
  }

  /*
    The empty desktop spacer cell isn't needed.
  */
  #items .plan-table-scroll .category-row > td:nth-child(2) {
    display: none;
  }

  /*
    Category total sits at the far right.
  */
  #items .plan-table-scroll .category-row > td.category-total {
    grid-column: 2;
    padding: 11px 2px 11px 12px;
    text-align: right;
    white-space: nowrap;
    font-size: 15px;
    font-weight: 800;
    color: var(--ink);
  }

  #items .category-total::before {
    content: none;
  }

  #items .category-row .category-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    margin: 0;
    border-radius: 7px;
    color: var(--ink);
    font-size: 16px;
  }

  #items .category-row .category-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink);
    font-size: 15px;
    font-weight: 750;
  }

  /*
    Remove management clutter from the mobile overview.
  */
  #items .category-row-controls,
  #items .category-row .category-add,
  #items .category-row .category-meta {
    display: none !important;
  }


  /* ---------------------------------------------------------
     EXISTING TRANSACTIONS
     Temporary compact treatment.

     6B.1b will refine expanded transaction rows further.
     --------------------------------------------------------- */

  #items .plan-table-scroll .category-item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
    min-height: 46px;
    margin: 0;
    padding: 0 0 0 33px;
    border: 0;
    border-bottom: 1px solid #edf0f4;
    border-radius: 0;
    background: #fff;
  }

  #items .plan-table-scroll .category-item-row.hidden-row {
    display: none;
  }

  #items .plan-table-scroll .category-item-row > td {
    display: none;
    width: auto;
    min-width: 0;
    padding: 9px 4px;
    border: 0;
    background: transparent;
  }

  /*
    For now show only transaction name and period total.
  */
  #items .plan-table-scroll .category-item-row > td:nth-child(3) {
    display: block;
    grid-column: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #items .plan-table-scroll .category-item-row > td:nth-child(8) {
    display: block;
    grid-column: 2;
    padding-left: 10px;
    text-align: right;
    white-space: nowrap;
    font-weight: 750;
  }

  #items .category-item-row > td::before {
    display: none !important;
    content: none !important;
  }

  #items .category-item-row td:nth-child(3) strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 650;
  }

  #items .transfer-detail,
  #items .goal-detail {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

}

/* 6B.2 — Phone layout for the Forecast table */
@media (max-width: 620px) {

  #forecast .forecast-table-card {
    min-width: 0;
    padding: 12px;
  }

  #forecast .forecast-table-card .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  #forecast .forecast-table-scroll {
    position: relative;
    height: 60vh;
    height: 60dvh;
    max-height: 560px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 0;
    border-radius: 0;
  }

  #forecast .forecast-table-scroll table,
  #forecast .forecast-table-scroll tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }

  #forecast .forecast-table-scroll thead {
    display: none;
  }

  #forecast .forecast-table-scroll tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    height: auto;
    margin: 0 0 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
  }

  #forecast .forecast-table-scroll tbody tr > td {
    display: block;
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
    font-size: 14px;
  }

  /* Date and closing balance across the top. */
  #forecast .forecast-table-scroll td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    font-weight: 700;
  }

  #forecast .forecast-table-scroll td:nth-child(5) {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
    font-size: 16px;
  }

  /* Income and expenses beneath. */
  #forecast .forecast-table-scroll td:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  #forecast .forecast-table-scroll td:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
    text-align: right;
  }

  /* Transaction names use the full card width. */
  #forecast .forecast-table-scroll td:nth-child(4) {
    grid-column: 1 / -1;
    grid-row: 3;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    line-height: 1.5;
  }

  #forecast .forecast-table-scroll td::before {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
  }

  #forecast .forecast-table-scroll td:nth-child(1)::before {
    content: "Date";
  }

  #forecast .forecast-table-scroll td:nth-child(2)::before {
    content: "Income";
  }

  #forecast .forecast-table-scroll td:nth-child(3)::before {
    content: "Expenses";
  }

  #forecast .forecast-table-scroll td:nth-child(4)::before {
    content: "What happens";
  }

  #forecast .forecast-table-scroll td:nth-child(5)::before {
    content: "Closing balance";
  }

  /* Highlight the whole selected card. */
  #forecast .forecast-table-scroll tr.forecast-selected-row,
  #forecast .forecast-table-scroll tr.chart-row-highlight {
    background: #fff3c8;
    border-color: #c99900;
  }

  #forecast .forecast-table-scroll tbody tr > td {
    background: transparent !important;
    box-shadow: none !important;
  }

  #forecast .forecast-table-scroll tbody tr:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
  }
}

/* Month selector in the Plan toolbar */
.topbar-budget-month {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.topbar-budget-month[hidden] {
  display: none;
}

.topbar-budget-month label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.topbar-budget-month input {
  width: 180px;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

/* 6B.3 — Compact phone toolbar */
.mobile-view-options-toggle {
  display: none;
}

@media (max-width: 620px) {

  .topbar {
    padding: 10px 14px;
    gap: 10px;
  }

  .topbar > :first-child {
    width: 100%;
    min-width: 0;
  }

  .topbar .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 10px;
    align-items: end;
  }

  .topbar .account-view-control {
    order: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    min-width: 0;
  }

  .topbar .account-view-control > label,
  .topbar-budget-month label {
    font-size: 11px;
    color: var(--muted);
    font-weight: 700;
  }

  .topbar .account-view-wrapper {
    width: 100%;
    min-width: 0;
  }

  .topbar .account-view-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 8px;
    gap: 6px;
  }

  #accountViewLabel {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .topbar-budget-month {
    order: 2;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    min-width: 0;
  }

  .topbar .topbar-budget-month[hidden] {
    display: none;
  }

  .topbar-budget-month input {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 8px;
    font-size: 16px;
  }

  .topbar .mobile-view-options-toggle {
    display: block;
    order: 3;
    grid-column: 1 / -1;
    justify-self: start;
    min-height: 44px;
  }

  .topbar .topbar-selected-date,
  .topbar .topbar-startdate {
    display: none;
    grid-column: 1 / -1;
    min-width: 0;
    flex-wrap: wrap;
    gap: 8px;
  }

  .topbar .topbar-selected-date {
    order: 4;
  }

  .topbar .topbar-startdate {
    order: 5;
  }

  .topbar.view-options-open .topbar-selected-date,
  .topbar.view-options-open .topbar-startdate {
    display: flex;
  }

  .topbar .selected-date-button {
    min-height: 44px;
  }

  /* Open the account menu toward the available screen space. */
  .topbar .account-view-menu {
    left: 0;
    right: auto;
    width: min(300px, calc(100vw - 28px));
    min-width: 0;
    max-height: 50vh;
    max-height: 50dvh;
    overflow-y: auto;
    overflow-wrap: anywhere;
  }

  .topbar .account-view-option,
  .topbar .account-menu-action,
  .topbar .selected-date-menu button {
    min-height: 44px;
    white-space: normal;
  }
}

/* 6B.4 — Scrollable forms above the toolbar */
.modal {
  z-index: 2000;
}

.modal .modal-box {
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-width: 620px) {

  /* Follow the visible screen when the keyboard opens. */
  .modal {
    inset: auto 0 auto 0;
    top: var(--form-viewport-top, 0px);
    height: var(--form-viewport-height, 100dvh);
    padding: 8px;
    align-items: flex-start;
    overflow: hidden;
  }

  .modal .modal-box {
    width: 100%;
    min-width: 0;
    max-width: none;
    max-height: 100%;
    padding: 16px;
    border-radius: 12px;
    scroll-padding-block: 16px 88px;
  }

  .modal .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .modal .field,
  .modal .transaction-name-wrapper {
    min-width: 0;
  }

  .modal .field input,
  .modal .field select,
  .modal .field textarea {
    min-width: 0;
    max-width: 100%;
    font-size: 16px;
  }

  .modal .field input:not([type="checkbox"]):not([type="radio"]),
  .modal .field select,
  .modal #itemNameButton {
    width: 100%;
    min-height: 44px;
  }

  .modal #itemNameButton {
    min-width: 0;
    height: auto;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* Keep the final Save/Cancel row within reach. */
  .modal .modal-box > .controls:last-child {
    position: sticky;
    bottom: -16px;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--line);
  }

  .modal .modal-box > .controls:last-child .btn {
    flex: 1 1 100px;
    min-height: 44px;
  }

  .modal .account-edit-actions {
    flex-wrap: wrap;
  }

  .modal .account-edit-actions .btn {
    flex: 1 1 140px;
    min-height: 44px;
  }

  .modal #itemNameMenu button {
    min-height: 44px;
  }

  body:has(.modal:not(.hidden)) {
    overflow: hidden;
  }
}

/* =========================================================
   6B.1a refinement — mobile Plan header
   ========================================================= */

@media (max-width: 620px) {

  body[data-page="items"] .topbar {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: 62px !important;
    min-height: 62px !important;
    padding: 8px 12px !important;
  }

  body[data-page="items"] .topbar > div:first-child {
    display: flex !important;
    width: auto !important;
    min-width: 44px !important;
    z-index: 2;
  }

  body[data-page="items"] .topbar .top-actions {
    display: contents !important;
  }

  body[data-page="items"] .topbar-budget-month {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 150px !important;
    z-index: 1;
  }

  body[data-page="items"] #budgetMonth {
    width: 150px !important;
    max-width: 150px !important;
    min-height: 42px !important;
    padding: 4px !important;
    border: 0 !important;
    background: transparent !important;
    text-align: center !important;
    font-size: 16px !important;
    font-weight: 800 !important;
  }

  body[data-page="items"] .account-view-control {
    position: absolute !important;
    top: 10px !important;
    right: 12px !important;
    width: 96px !important;
    z-index: 3;
  }

  body[data-page="items"] .account-view-button {
    width: 96px !important;
    max-width: 96px !important;
    min-width: 0 !important;
    min-height: 42px !important;
    padding: 6px 8px !important;
    border-radius: 10px !important;
  }

  body[data-page="items"] #accountViewLabel {
    max-width: 66px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

}

/* =========================================================
   6B.1a refinement — Today's balance
   ========================================================= */

@media (max-width: 620px) {

  #items .plan-workspace {
    display: flex !important;
    flex-direction: column !important;
  }

  #items .plan-summary-panel {
    display: block !important;
    visibility: visible !important;
    order: -1 !important;
    width: 100% !important;
    margin: 0 0 6px !important;
  }

  #items .plan-summary-panel .plan-summary-section:first-child {
    display: block !important;
    visibility: visible !important;
    padding: 0 !important;
    border: 0 !important;
  }

  #items .plan-summary-panel .plan-summary-section:first-child
 .plan-today-summary {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 8px !important;
    min-height: 54px !important;
    padding: 8px 12px !important;
    margin: 0 !important;
    border-radius: 12px !important;
    background: var(--brand-soft) !important;
    border: 1px solid #dce3ff !important;
  }

  #items .plan-today-summary .label {
    display: block !important;
    margin: 0 !important;
    font-size: 12px !important;
    font-weight: 750 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    white-space: nowrap !important;
  }

  #items .plan-current-balance-wrap {
    justify-self: end !important;
    width: auto !important;
    margin: 0 !important;
    font-size: 21px !important;
  }

  #items .plan-current-balance-wrap input {
    width: 100px !important;
    font-size: 21px !important;
    text-align: right !important;
  }

  #items .plan-today-summary > button {
    grid-column: 3 !important;
    margin: 0 !important;
    padding: 5px 7px !important;
    border: 0 !important;
    background: transparent !important;
    color: var(--brand) !important;
    font-size: 11px !important;
    font-weight: 750 !important;
    white-space: nowrap !important;
  }

  #items #planTodayAccountLabel {
    display: none !important;
  }

  #items .plan-summary-panel
  .plan-summary-section:first-child
  .summary-box:not(.plan-today-summary),
  #items .plan-summary-panel
  .plan-summary-section:nth-child(2) {
    display: none !important;
  }

}

/* =========================================================
   6B.1a refinement — compact mobile save status
   ========================================================= */

@media (max-width: 620px) {

  body[data-page="items"] #cloudSaveBar {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    min-height: 28px !important;
    padding: 4px 12px !important;
    border-bottom: 1px solid var(--line) !important;
    font-size: 10px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
  }

  body[data-page="items"] #cloudSaveAccount {
    max-width: 45% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  body[data-page="items"] #cloudSaveMessage {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  body[data-page="items"] #cloudRecoveryHint {
    display: none !important;
  }

}

@media (max-width: 620px) {

  #items .plan-table-scroll .category-row {
    min-height: 52px !important;
  }

  #items .category-row .category-name {
    font-size: 15px !important;
    font-weight: 800 !important;
  }

  #items .plan-table-scroll
  .category-row > td.category-total {
    font-size: 15px !important;
    font-weight: 800 !important;
  }

}

@media (max-width: 620px) {

  body[data-page="items"] #monthlyPeriodHint {
    display: none !important;
  }

}

/* =========================================================
   6B.1b — Mobile expanded transaction rows
   ========================================================= */

@media (max-width: 620px) {

  #items .plan-table-scroll .category-item-row {
    min-height: 48px !important;
    padding-left: 36px !important;
    cursor: pointer !important;
    background: #fff !important;
  }

  #items .plan-table-scroll .category-item-row:active {
    background: #f5f7fb !important;
  }

  #items .plan-table-scroll .category-item-row > td:nth-child(3) {
    padding: 10px 8px 10px 0 !important;
  }

  #items .plan-table-scroll .category-item-row > td:nth-child(8) {
    padding: 10px 2px 10px 8px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
  }

  #items .category-item-row td:nth-child(3) strong {
    font-size: 14px !important;
    font-weight: 650 !important;
    color: #26354b !important;
  }

  #items .category-item-row .transfer-detail,
  #items .category-item-row .goal-detail {
    margin-top: 2px !important;
    font-size: 10px !important;
    font-weight: 500 !important;
    color: var(--muted) !important;
  }

  /*
    The category remains visually stronger than
    its expanded transactions.
  */
  #items .plan-table-scroll .category-row {
    background: #f4f6fa !important;
  }

  #items .plan-table-scroll .category-item-row {
    background: #fff !important;
  }

}

/* =========================================================
   6B.1c — Mobile Add Transaction
   ========================================================= */

.mobile-add-transaction {
  display: none;
}

@media (max-width: 620px) {

  body[data-page="items"] .mobile-add-transaction {
    position: fixed;
    right: 16px;
    bottom: max(
      18px,
      calc(env(safe-area-inset-bottom) + 10px)
    );
    z-index: 900;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    min-height: 48px;
    padding: 0 17px;

    border: 0;
    border-radius: 999px;

    background: var(--brand);
    color: #fff;

    font-size: 14px;
    font-weight: 800;

    box-shadow:
      0 6px 18px rgba(23, 33, 58, .22);
  }

  body[data-page="items"]
  .mobile-add-transaction > span {
    font-size: 20px;
    line-height: 1;
  }

  body[data-page="items"]
  .mobile-add-transaction:active {
    transform: translateY(1px);
  }

}

/* =========================================================
   6B — Mobile full-screen Accounts panel
   ========================================================= */

.account-view-mobile-label,
.account-view-mobile-header,
.account-view-mobile-footer {
  display: none;
}


@media (max-width: 620px) {

  /* ---------------------------------------------------------
     ACCOUNT BUTTON
     --------------------------------------------------------- */

  .topbar .account-view-button
  #accountViewLabel,
  .topbar .account-view-button
  .account-view-caret {
    display: none !important;
  }

  .topbar .account-view-button
  .account-view-mobile-label {
    display: inline !important;
  }

  .topbar .account-view-button {
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
  }


  /* ---------------------------------------------------------
     FULL-SCREEN ACCOUNT PANEL
     --------------------------------------------------------- */

  .topbar .account-view-menu {

    display: none !important;

    position: fixed !important;

    top: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    left: 8px !important;

    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;

    height: auto !important;
    max-height: none !important;

    padding: 16px !important;

    border: 0 !important;
    border-radius: 12px !important;

    background: #fff !important;

    box-shadow:
      0 0 0 100vmax rgba(15, 23, 42, .48),
      0 18px 60px rgba(15, 23, 42, .20) !important;

    overflow-y: auto !important;
    overscroll-behavior: contain;

    z-index: 2500 !important;
  }

  .topbar .account-view-menu.show {
    display: flex !important;
    flex-direction: column !important;
  }


  /* ---------------------------------------------------------
     HEADER
     --------------------------------------------------------- */

  .account-view-mobile-header {

    position: sticky;
    top: -16px;
    z-index: 2;

    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;

    margin:
      -16px
      -16px
      12px;

    padding:
      16px
      16px
      14px;

    background: #fff;

    border-bottom:
      1px solid var(--line);
  }

  .account-view-mobile-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
  }

  .account-view-mobile-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
  }

  .account-view-mobile-close {

    flex: 0 0 40px;

    width: 40px;
    height: 40px;

    display: grid;
    place-items: center;

    padding: 0;

    border:
      1px solid var(--line);

    border-radius: 10px;

    background: #fff;
    color: var(--ink);

    font-size: 24px;
    line-height: 1;
  }


  /* ---------------------------------------------------------
     ACCOUNT ROWS
     --------------------------------------------------------- */

  .topbar .account-view-option {

    min-height: 56px !important;

    display: flex !important;
    align-items: center !important;

    padding:
      8px
      2px !important;

    border-radius: 0 !important;
    border-bottom:
      1px solid var(--line);
  }

  .topbar .account-view-option label {

    flex: 1;

    display: flex;
    align-items: center;
    gap: 12px;

    min-width: 0;

    font-size: 15px;
  }

  .topbar .account-view-option input {

    width: 20px;
    height: 20px;

    flex: 0 0 20px;

    margin: 0;
  }

  .topbar .account-view-name {

    min-width: 0;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-weight: 700;
  }

  .topbar .account-edit-button {

    width: 40px;
    height: 40px;

    flex: 0 0 40px;
  }

  .topbar .account-view-divider {
    margin: 8px 0;
  }


  /* ---------------------------------------------------------
     ADD ACCOUNT
     --------------------------------------------------------- */

  .topbar .add-account-button {

    min-height: 48px;

    padding:
      11px
      4px;

    color: var(--brand);

    font-size: 15px;
    font-weight: 800;
  }


  /* ---------------------------------------------------------
     DONE BUTTON
     --------------------------------------------------------- */

  .account-view-mobile-footer {

    position: sticky;
    bottom: -16px;

    display: flex;

    margin:
      auto
      -16px
      -16px;

    padding:
      12px
      16px
      max(
        12px,
        env(safe-area-inset-bottom)
      );

    background: #fff;

    border-top:
      1px solid var(--line);
  }

  .account-view-mobile-footer .btn {

    width: 100%;
    min-height: 46px;
  }

}

/* =========================================================
   Mobile Accounts — touch interaction fix
   ========================================================= */

@media (max-width: 620px) {

  .topbar .account-view-menu {
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch;
  }

  .topbar .account-view-option label,
  .topbar .account-view-option input,
  .topbar .account-edit-button,
  .topbar .add-account-button {
    pointer-events: auto !important;
    touch-action: manipulation;
  }

}

/* =========================================================
   6B.1d — Mobile category-aware Add Transaction
   ========================================================= */

.mobile-transaction-category-field {
  display: none;
}


@media (max-width: 620px) {

  /* ---------------------------------------------------------
     CATEGORY PICKER
     --------------------------------------------------------- */

  .mobile-category-picker-box {
    display: flex;
    flex-direction: column;
    gap: 14px;

    height: 100%;
    max-height: 100% !important;

    overflow: hidden !important;
  }

  .mobile-category-picker-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
  }

  .mobile-category-picker-header
  .section-title {
    margin-bottom: 2px;
    font-size: 20px;
  }

  .mobile-category-picker-header
  .small {
    margin: 0;
  }

  .mobile-category-picker-close {
    flex: 0 0 42px;

    width: 42px;
    height: 42px;

    display: grid;
    place-items: center;

    padding: 0;

    border: 1px solid var(--line);
    border-radius: 11px;

    background: #fff;
    color: var(--ink);

    font-size: 25px;
    line-height: 1;
  }

  .mobile-category-picker-search {
    flex: 0 0 auto;
  }

  .mobile-category-picker-search input {
    width: 100%;
    min-height: 46px;
    font-size: 16px;
  }

  .mobile-category-new-button {
    flex: 0 0 auto;

    width: 100%;
    min-height: 50px;

    padding: 11px 14px;

    border: 1px solid #dce3ff;
    border-radius: 11px;

    background: var(--brand-soft);
    color: var(--brand);

    text-align: left;

    font-size: 15px;
    font-weight: 800;
  }

  .mobile-category-picker-list {
    flex: 1 1 auto;

    min-height: 0;

    overflow-y: auto;
    overscroll-behavior: contain;

    border-top: 1px solid var(--line);

    -webkit-overflow-scrolling: touch;
  }

  .mobile-category-picker-option {
    display: flex;
    align-items: center;

    width: 100%;
    min-height: 56px;

    padding: 10px 4px;

    border: 0;
    border-bottom: 1px solid var(--line);

    background: #fff;
    color: var(--ink);

    text-align: left;

    font-size: 15px;
    font-weight: 700;

    touch-action: manipulation;
  }

  .mobile-category-picker-option::after {
    content: '›';

    margin-left: auto;
    padding-left: 14px;

    color: var(--muted);

    font-size: 25px;
    font-weight: 400;
  }

  .mobile-category-picker-option:active {
    background: #f5f7fb;
  }

  .mobile-category-picker-empty {
    padding: 24px 4px;

    color: var(--muted);

    font-size: 14px;
    text-align: center;
  }


  /* ---------------------------------------------------------
     CATEGORY INSIDE ADD / EDIT TRANSACTION
     --------------------------------------------------------- */

  .modal .mobile-transaction-category-field {
    display: flex;
  }

  .modal .mobile-transaction-category-field
  #itemCategorySelect,
  .modal .mobile-transaction-category-field
  #itemCategoryNew {
    width: 100%;
    min-width: 0;
    min-height: 44px;

    font-size: 16px;
  }

}

/* Mobile account panel and Plan tap controls */
@media (max-width: 620px) {

  /* Raise the whole toolbar layer while Accounts is open. */
  body:has(#accountViewMenu.show) .topbar {
    z-index: 1100 !important;
  }

  /* Keep the page behind the account panel still. */
  body:has(#accountViewMenu.show) {
    overflow: hidden;
  }

  /* The floating action must not overlap an open panel. */
  body:has(#accountViewMenu.show) .mobile-add-transaction,
  body:has(.modal:not(.hidden)) .mobile-add-transaction {
    display: none !important;
  }

  /* Let long account lists scroll without squeezing rows. */
  .topbar #accountViewMenu > * {
    flex-shrink: 0;
  }

  /* Make the account name and checkbox a generous tap area. */
  .topbar .account-view-option label {
    min-height: 44px;
    cursor: pointer;
  }

  #items .plan-table-scroll .category-row,
  #items .plan-table-scroll .category-item-row {
    touch-action: manipulation;
  }
}

/* Compact Plan metrics on phones */
.mobile-plan-metrics {
  display: none;
}

@media (max-width: 620px) {

  #items .mobile-plan-metrics {
    display: block;
    margin-top: 10px;
    padding: 0 2px 8px;
    border-bottom: 1px solid var(--line);
  }

  #items .mobile-metrics-heading {
    margin: 10px 0 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    line-height: 1.4;
  }

  #items .mobile-metrics-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  #items .mobile-metrics-row.forecast-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #items .mobile-metrics-row > div {
    min-width: 0;
  }

  #items .mobile-metrics-row span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
  }

  #items .mobile-metrics-row strong {
    display: block;
    margin-top: 2px;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  #items .mobile-plan-metrics .good {
    color: var(--good);
  }

  #items .mobile-plan-metrics .bad {
    color: var(--bad);
  }
}

@media (max-width: 620px) {

  #items .mobile-forecast-period label {
    display: block;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
  }

  #items .mobile-forecast-period select {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    margin-top: 2px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-size: 16px;
  }
}

/* Tappable forecast value */
#items .mobile-forecast-period .forecast-period-value {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 2px 0 0;
  padding: 0 0 24px;
  border: 0;
  background: transparent;
  color: #223e9d;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
}

.forecast-period-value:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Forecast period card */
.forecast-period-dialog {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 20px;
  overflow-y: auto;
  border: 0;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 18px 60px rgba(15, 23, 42, .2);
}

.forecast-period-dialog::backdrop {
  background: rgba(15, 23, 42, .48);
}

body:has(#planForecastPeriodDialog[open]) {
  overflow: hidden;
}

.forecast-period-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.forecast-period-dialog-header h2 {
  margin: 0;
  font-size: 20px;
}

.forecast-period-dialog-header button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 25px;
}

.forecast-period-choices {
  display: grid;
  gap: 8px;
  margin: 16px 0 20px;
}

.forecast-period-choices button {
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 700;
}

.forecast-period-choices button[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}

.forecast-period-dialog form label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
}

.forecast-period-dialog input {
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 16px;
}

.forecast-period-dialog form .btn {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
}

/* Transaction form heading and close button */
.transaction-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.transaction-modal-header .section-title {
  margin: 0;
}

.transaction-modal-close {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
}

.transaction-category-button {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--brand);
  font: inherit;
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
}

#transactionModalAction.transaction-delete {
  border-color: #f3c7c7;
  background: #fff1f1;
  color: #b42318;
}

/* Mobile Edit Plan controls */
.mobile-plan-tools,
.mobile-category-actions {
  display: none;
}

.mobile-plan-tools [hidden],
.mobile-category-dialog [hidden] {
  display: none !important;
}

@media (max-width: 620px) {
  #items .mobile-plan-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 10px;
  }

  #items .mobile-plan-tools .btn {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 13px;
  }

  #items.mobile-plan-editing .mobile-category-actions {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 2px;
    margin-left: auto;
  }

  #items.mobile-plan-editing .category-name {
    min-width: 0;
    flex: 1 1 auto;
  }

  #items .mobile-category-actions button {
    width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--brand);
    font-size: 24px;
    font-weight: 700;
  }
}

/* Category editing card */
.mobile-category-dialog {
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 20px;
  overflow-y: auto;
  border: 0;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
}

.mobile-category-dialog::backdrop {
  background: rgba(15, 23, 42, .48);
}

body:has(.mobile-category-dialog[open]) {
  overflow: hidden;
}

.mobile-category-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.mobile-category-dialog-header h2 {
  margin: 0;
  font-size: 20px;
}

.mobile-category-dialog-header button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 26px;
}

.mobile-category-dialog label {
  display: block;
  margin: 12px 0 6px;
  font-size: 13px;
  font-weight: 700;
}

.mobile-category-dialog input,
.mobile-category-dialog select {
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}

.mobile-category-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.mobile-category-dialog-actions .btn {
  flex: 1 1 130px;
  min-height: 44px;
}

.mobile-category-dialog [data-delete] {
  background: #fff1f1;
  color: #b42318;
}

/* Compact mobile Plan edit control */
.mobile-plan-edit-toggle {
  display: none;
}

@media (max-width: 620px) {
  body[data-page="items"] .mobile-plan-edit-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
  }

  .mobile-plan-edit-toggle svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  body[data-page="items"]
  .mobile-plan-edit-toggle[aria-pressed="true"] {
    background: var(--brand);
    color: #fff;
  }

  .mobile-plan-edit-toggle:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
  }

  /* No separate toolbar space when not editing. */
  #items:not(.mobile-plan-editing) .mobile-plan-tools {
    display: none !important;
  }

  /* Menu + edit | month | accounts */
  body[data-page="items"] .topbar {
    display: grid !important;
    grid-template-columns: 88px minmax(0, 1fr) 80px !important;
    gap: 4px !important;
  }

  body[data-page="items"] .topbar > div:first-child {
    grid-column: 1;
    grid-row: 1;
    width: 88px !important;
    min-width: 0 !important;
    gap: 0 !important;
  }

  body[data-page="items"] .menu-btn {
    flex: 0 0 44px;
  }

  body[data-page="items"] .topbar .topbar-budget-month {
    position: static !important;
    grid-column: 2;
    grid-row: 1;
    transform: none !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  body[data-page="items"] #budgetMonth {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
  }

  body[data-page="items"] .topbar .account-view-control {
    position: static !important;
    grid-column: 3;
    grid-row: 1;
    width: 80px !important;
    min-width: 0 !important;
  }

  body[data-page="items"] .account-view-button {
    width: 80px !important;
    max-width: 80px !important;
  }
}

@media (max-width: 359px) {
  body[data-page="items"] #budgetMonth {
    font-size: 14px !important;
  }
}

/* Phone drag handles */
.plan-grab {
  display: none;
}

@media (max-width: 620px) {
  #items.plan-reordering .plan-grab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--brand);
    font-size: 28px;
    line-height: 1;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }

  #items.plan-reordering .plan-grab:active {
    cursor: grabbing;
    background: var(--brand-soft);
  }

  #items.plan-reordering .mobile-category-actions,
  #items.plan-reordering .mobile-plan-tools [data-new] {
    display: none !important;
  }

  #items.plan-reordering .plan-table-scroll .category-item-row {
    padding-left: 0 !important;
  }

  #items.plan-reordering .plan-table-scroll
  .category-item-row > td:nth-child(3) {
    position: relative;
    min-height: 44px;
    padding-left: 48px !important;
  }

  #items.plan-reordering .category-item-row .plan-grab {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
  }

  #items .reorder-dragging {
    opacity: 0.45;
  }

  #items .reorder-before {
    box-shadow: inset 0 3px 0 var(--brand) !important;
  }

  #items .reorder-after {
    box-shadow: inset 0 -3px 0 var(--brand) !important;
  }
}

@media (max-width: 620px) {
  /* Remove borders from the menu and Accounts buttons. */
  .topbar #sidebarToggle,
  .topbar .account-view-button {
    border: 0 !important;
    box-shadow: none !important;
  }

  /* Replace the menu's three lines with black dots. */
  .topbar #sidebarToggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    color: #000 !important;
    font-size: 0 !important;
  }

  .topbar #sidebarToggle::before {
    content: "⋯";
    display: block;
    font-family: inherit;
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    color: #000;
  }
}

@media (max-width: 620px) {
  /* Match Today's balance shading. */
  .topbar #sidebarToggle,
  body[data-page="items"] .mobile-plan-edit-toggle,
  .topbar .account-view-button {
    background: var(--brand-soft) !important;
    border: 0 !important;
    border-radius: 12px !important;
    box-shadow: none !important;
    color: #000 !important;
  }

  /* Keep the finish-editing tick clearly highlighted. */
  body[data-page="items"]
  .mobile-plan-edit-toggle[aria-pressed="true"] {
    background: var(--brand) !important;
    color: #fff !important;
  }

  /* Leave room beneath the month text for a small arrow. */
  body[data-page="items"] .topbar .topbar-budget-month {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    height: 44px !important;
  }

  body[data-page="items"] #budgetMonth {
    height: 44px !important;
    min-height: 44px !important;
    padding: 4px 4px 12px !important;
    box-sizing: border-box;
  }

  /* Down arrow overlays the input without blocking taps. */
  body[data-page="items"] .topbar-budget-month::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 4px;
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
    transform: translateX(-50%) rotate(45deg);
    pointer-events: none;
  }
}

@media (max-width: 620px) {
  /* Allow space for two 44px buttons and an 8px gap. */
  body[data-page="items"] .topbar {
    grid-template-columns: 96px minmax(0, 1fr) 80px !important;
  }

  body[data-page="items"] .topbar > div:first-child {
    width: 96px !important;
    gap: 8px !important;
  }

  /* Circular menu and Plan edit buttons. */
  .topbar #sidebarToggle,
  body[data-page="items"] .mobile-plan-edit-toggle {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    flex: 0 0 44px !important;
    border-radius: 50% !important;
    box-sizing: border-box;
  }

  /* Pill-shaped Accounts button. */
  .topbar .account-view-button {
    border-radius: 999px !important;
  }
}

@media (max-width: 620px) {
  /* Override the earlier Accounts corner styling. */
  body[data-page="items"] .topbar .account-view-button {
    border-radius: 999px !important;
  }

  /* Keep the month area aligned with the 44px icon buttons. */
  body[data-page="items"] .topbar .topbar-budget-month {
    height: 44px !important;
    align-self: center !important;
  }

  /* Position the month text at the top of that area. */
  body[data-page="items"] .topbar #budgetMonth {
    display: block !important;
    height: 24px !important;
    min-height: 24px !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 24px !important;
  }

  body[data-page="items"]
  #budgetMonth::-webkit-date-and-time-value {
    margin: 0;
    text-align: center;
  }

  /* Separate the arrow from the month text. */
  body[data-page="items"] .topbar .topbar-budget-month::after {
    bottom: 7px !important;
  }
}

@media (max-width: 620px) {
  body[data-page="items"] .topbar {
    grid-template-columns: 96px minmax(0, 1fr) 104px !important;
  }

  body[data-page="items"] .topbar .account-view-control {
    width: 104px !important;
  }

  body[data-page="items"] .topbar .account-view-button {
    width: 104px !important;
    max-width: 104px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box;
  }
}

@media (max-width: 620px) {
  /* Remove shading from the full Today's balance row. */
  #items .plan-summary-panel
  .plan-summary-section:first-child .plan-today-summary {
    background: transparent !important;
    border: 0 !important;
    padding: 8px 0 !important;
    gap: 0 !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
  }

  #items .plan-today-summary > .label {
    padding-right: 12px;
  }

  /* Left half of the balance pill. */
  #items .plan-today-summary .plan-current-balance-wrap {
    justify-self: stretch !important;
    min-width: 0;
    height: 44px;
    padding: 0 8px 0 14px;
    background: var(--brand-soft);
    border-radius: 999px 0 0 999px;
    box-sizing: border-box;
  }

  #items .plan-today-summary .plan-current-balance-wrap input {
    min-width: 0 !important;
    max-width: 100%;
    flex: 1 1 auto;
  }

  /* Right half: joins the amount without a gap. */
  #items .plan-today-summary > button {
    height: 44px !important;
    margin: 0 !important;
    padding: 0 14px 0 8px !important;
    background: var(--brand-soft) !important;
    border: 0 !important;
    border-radius: 0 999px 999px 0 !important;
    box-sizing: border-box;
  }

  /* Forecast period becomes a clearly tappable pill. */
  #items .mobile-forecast-period #planForecastPeriod {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    max-width: 100%;
    min-height: 44px;
    padding: 8px 14px;
    border: 0;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--ink);
    text-align: center;
    box-sizing: border-box;
  }

  /* Keep the forecast amounts aligned with the pill's text. */
  #items .forecast-metrics > div > strong {
    padding-top: 12px;
  }
}

@media (max-width: 620px) {
  #items .plan-summary-panel {
    background: #fff !important;
  }
}

@media (max-width: 620px) {
  /* Consistent white background behind the mobile Plan screen. */
  body[data-page="items"],
  body[data-page="items"] .main,
  #items,
  #items .plan-workspace,
  #items .plan-summary-panel,
  #items .plan-table-card,
  #items .plan-table-scroll,
  #items .plan-table-scroll table {
    background: #fff !important;
  }

  /* Equal left and right spacing inside the summary. */
  #items .plan-summary-panel {
    box-sizing: border-box;
    padding: 12px !important;
  }

  #items .plan-summary-panel
  .plan-summary-section:first-child .plan-today-summary {
    grid-template-columns: minmax(0, 1fr) minmax(0, 150px) !important;
    column-gap: 12px !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
  }

  #items .plan-today-summary > .label {
    grid-column: 1;
    grid-row: 1;
    padding-right: 0 !important;
    white-space: normal !important;
    line-height: 1.4;
  }

  /* Amount-only pill. */
  #items .plan-today-summary .plan-current-balance-wrap {
    grid-column: 2;
    grid-row: 1;
    justify-self: stretch !important;
    width: 100% !important;
    min-width: 0;
    height: 44px;
    padding: 0 16px !important;
    border-radius: 999px !important;
    background: var(--brand-soft) !important;
    box-sizing: border-box;
    pointer-events: none;
  }

  #items .plan-today-summary .plan-current-balance-wrap input {
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 !important;
    background: transparent !important;
  }

  /* Transparent button covers the amount pill. */
  #items .plan-today-summary > button {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: stretch !important;
    align-self: center;
    position: relative;
    z-index: 1;
    width: 100% !important;
    height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 999px !important;
    background: transparent !important;
    font-size: 0 !important;
    cursor: pointer;
  }

  #items .plan-today-summary > button:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
  }
}

@media (max-width: 620px) {
  /* White across the page and all containers surrounding Plan. */
  body[data-page="items"],
  body[data-page="items"] :has(#items),
  body[data-page="items"] #items,
  body[data-page="items"] #items .plan-workspace,
  body[data-page="items"] #items .plan-summary-panel,
  body[data-page="items"] #items .plan-table-card,
  body[data-page="items"] #items .plan-table-scroll {
    background: #fff !important;
  }
}

@media (max-width: 620px) {
  /* Match the table's outer alignment. */
  #items .plan-summary-panel {
    padding: 12px 0 !important;
  }

  #items .mobile-plan-metrics {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Balance label left; amount pill right. */
  #items .plan-today-summary > .label {
    justify-self: start !important;
    text-align: left !important;
  }

  #items .plan-today-summary .plan-current-balance-wrap,
  #items .plan-today-summary > button {
    justify-self: end !important;
  }

  /* Three equally sized metric columns. */
  #items .mobile-metrics-row {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  /* Income and minimum balance. */
  #items .mobile-metrics-row > div:nth-child(1) {
    text-align: left !important;
  }

  /* Outgoings and maximum balance. */
  #items .mobile-metrics-row > div:nth-child(2) {
    text-align: center !important;
  }

  /* Surplus and forecast period. */
  #items .mobile-metrics-row > div:nth-child(3) {
    text-align: right !important;
  }

  #items .mobile-forecast-period #planForecastPeriod {
    margin-left: auto !important;
    margin-right: 0 !important;
  }
}

/* Desktop access to the existing account-aware category editor. */
@media (min-width: 621px) {
  body[data-page="items"] .mobile-plan-edit-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: 0;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--ink);
    cursor: pointer;
  }

  .mobile-plan-edit-toggle svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  body[data-page="items"]
  .mobile-plan-edit-toggle[aria-pressed="true"] {
    background: var(--brand);
    color: #fff;
  }

  .mobile-plan-edit-toggle:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
  }

  #items.mobile-plan-editing .mobile-plan-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
  }

  /* Desktop retains its existing direct category dragging. */
  #items .mobile-plan-tools > button:not([data-new]) {
    display: none !important;
  }

  #items.mobile-plan-editing .mobile-category-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 10px;
    vertical-align: middle;
  }

  #items .mobile-category-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 22px;
    cursor: pointer;
  }

  /* Avoid duplicate edit/add controls while Edit Plan is active. */
  #items.mobile-plan-editing
  .category-row-controls .edit-action,
  #items.mobile-plan-editing
  .category-row-controls .delete-action,
  #items.mobile-plan-editing
  .category-add-compact {
    display: none !important;
  }
}

#items .plan-today-summary #planTodayAccountLabel {
  display: block !important;
  grid-column: 1 / -1 !important;
  grid-row: 2 !important;
  margin-top: 8px !important;
  font-size: 12px !important;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
}

/* Plan balance: daily confirmation status */
#items .plan-today-summary
.plan-current-balance-wrap[data-balance-status="confirmed"] {
  background: #dcfce7 !important;
  border-color: #dcfce7 !important;
  color: #166534 !important;
}

#items .plan-today-summary
.plan-current-balance-wrap[data-balance-status="pending"] {
  background: #fef3c7 !important;
  border-color: #fef3c7 !important;
  color: #92400e !important;
}

#items .plan-today-summary
.plan-current-balance-wrap[data-balance-status] * {
  color: inherit !important;
}

#items .plan-today-summary
.plan-current-balance-wrap[data-balance-status] input {
  background: transparent !important;
  -webkit-text-fill-color: currentColor !important;
}

/* Phone Plan: direct editing and long-press dragging */
@media (max-width: 620px) {
  #items .category-row {
    position: relative;
  }

  #items .category-row .category-name {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Keep the add button at the right of every category. */
  #items .category-row .mobile-category-actions {
    display: inline-flex !important;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    gap: 0;
  }

  #items .category-row .mobile-category-actions
  button:first-child {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    font-size: 22px;
  }

  /* Tapping the header now opens the category card. */
  #items .category-row .mobile-category-actions
  button:not(:first-child) {
    display: none !important;
  }

  #items .plan-table-scroll .category-row
  > td.category-total {
    padding-right: 44px !important;
  }

  #items .category-row,
  #items .category-item-row {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  /* Gradually darken while the finger is held down. */
  #items .plan-table-scroll .plan-holding {
    animation: plan-hold-feedback 450ms linear forwards;
  }

  /* The original rows reserve the drop space. */
  #items .plan-lift-space {
    visibility: hidden !important;
  }

  /* Floating copy of the transaction or category group. */
  #items .plan-touch-ghost {
    overflow: hidden !important;
    max-height: none !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 10px;
    background: #f1f3f6 !important;
    box-shadow:
      0 12px 28px rgba(15, 23, 42, 0.22),
      0 3px 8px rgba(15, 23, 42, 0.15);
  }

  #items .plan-touch-ghost table {
    width: 100%;
    margin: 0;
  }

  #items .plan-touch-ghost .category-row,
  #items .plan-touch-ghost .category-item-row {
    background: #f1f3f6 !important;
  }

  #items .plan-touch-ghost * {
    pointer-events: none !important;
  }
}

@keyframes plan-hold-feedback {
  from {
    background-color: #f1f1f1;
  }
  to {
    background-color: #d4d6da;
  }
}

@media (prefers-reduced-motion: reduce) {
  #items .plan-table-scroll .plan-holding {
    animation: none;
    background: #d4d6da !important;
  }
}

/* Phone category: add button immediately after the name */
@media (max-width: 620px) {
  #items .category-row .category-name {
    flex: 0 1 auto !important;
    min-width: 0;
  }

  #items .category-row .mobile-category-actions {
    position: static !important;
    transform: none !important;
    flex: 0 0 auto;
    margin-left: 8px !important;
  }

  #items .plan-table-scroll .category-row
  > td.category-total {
    padding-right: 2px !important;
  }
}

/* Consistent controls in Add/Edit transaction */
@media (max-width: 620px) {
  #modal #itemType,
  #modal #itemCategoryButton,
  #modal #itemNameButton,
  #modal #itemFrequency,
  #modal #itemAmount,
  #modal #itemDate,
  #modal #itemEndDate {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    padding: 10px 12px !important;
    border: 1px solid var(--line) !important;
    border-radius: 9px !important;
    background-color: #fff !important;
    font-size: 16px !important;
  }

  #modal #itemNameButton {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    white-space: nowrap !important;
  }

  #modal #itemNameLabel {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #modal #itemDate,
  #modal #itemEndDate {
    -webkit-appearance: none;
    appearance: none;
    text-align: left;
  }

  #modal input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
  }
}

/* Compact phone category headers */
@media (max-width: 620px) {
  #items .plan-table-scroll .category-row {
    min-height: 48px !important;
    align-items: center;
  }

  #items .plan-table-scroll .category-row > td:first-child,
  #items .plan-table-scroll .category-row > td.category-total {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
  }
}

/* Plan: selected-month balance chart */
#items .plan-month-chart-card {
  margin-top: 20px;
  margin-bottom: 100px;
  background: #fff;
}

#planMonthChart {
  width: 100%;
  min-width: 0;
}

#planMonthChart svg {
  display: block;
  width: 100%;
  height: auto;
}

#planMonthChart [data-day] {
  cursor: pointer;
}

#planMonthChart [data-day]:focus {
  outline: 2px solid #3153df;
}

#planMonthChartDetail {
  min-height: 2.5em;
  margin-bottom: 0;
}

@media (max-width: 620px) {
  #items .mobile-metrics-row.forecast-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  #items .mobile-metrics-row.forecast-metrics > div:first-child {
    text-align: left !important;
  }

  #items .mobile-metrics-row.forecast-metrics > div:last-child {
    text-align: right !important;
  }

  #items .plan-month-chart-card {
    padding: 16px 8px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Subtle selection without changing a bar's positive/negative colour. */
#planMonthChart [data-day] rect:last-child {
  transition: opacity 120ms ease;
}

#planMonthChart [data-day].is-selected rect:last-child {
  stroke: #17243b;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  opacity: 0.78;
}

/* Phone Plan layout */
@media (max-width: 620px) {
  /* Month replaces the text label beside the balance pill. */
  #items .plan-today-summary > .label {
    display: none !important;
  }

  #items .plan-today-summary #topbarBudgetMonth {
    display: block !important;
    position: relative !important;
    grid-column: 1 !important;
    grid-row: 1 !important;
    justify-self: start !important;
    align-self: center !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    inset: auto !important;
    transform: none !important;
  }

  #items .plan-today-summary #topbarBudgetMonth > label {
    display: none !important;
  }

  #items .plan-today-summary #budgetMonth {
    display: block !important;
    box-sizing: border-box;
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 0 0 12px !important;
    border: 0 !important;
    background: transparent !important;
    color: var(--ink);
    font-size: 16px !important;
    font-weight: 800;
    text-align: left !important;
  }

  #items #budgetMonth::-webkit-date-and-time-value {
    text-align: left !important;
  }

  #items .plan-today-summary #topbarBudgetMonth::after {
    left: 12px !important;
    bottom: 3px !important;
  }

  /* The month heading above the first metrics explains both rows. */
  #items #mobilePlanForecastTitle {
    display: none !important;
  }

  /* Keep maximum balance under Outgoings, in the middle column. */
  #items .mobile-metrics-row.forecast-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    margin-top: 14px;
  }

  #items .mobile-metrics-row.forecast-metrics > div:nth-child(2) {
    text-align: center !important;
  }

  /* Metrics now sit immediately above the chart. */
  #items .plan-monthly-metrics-heading {
    margin-bottom: 8px;
  }

  #items .plan-month-chart-card #mobilePlanMetrics {
    margin: 0 0 24px !important;
    padding: 0 !important;
    border: 0 !important;
  }

  /* Plain category headers, retaining hold feedback during dragging. */
  #items .plan-table-scroll:not(.plan-touch-ghost)
  .category-row:not(.plan-holding):not(.plan-lift-space) {
    background: #fff !important;
  }

  #items .plan-table-scroll:not(.plan-touch-ghost)
  .category-row > td {
    background: transparent !important;
  }

  #items .category-row .mobile-category-actions button {
    color: #000 !important;
  }
}

/* Compact phone Plan header and selected-day metric. */
#planHeaderBalance,
#planFloatingMenu {
  display: none;
}

@media (max-width: 620px) {
  /* Equal outer columns keep the month centred. */
  body[data-page="items"] .topbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 950;
    grid-template-columns:
      104px minmax(0, 1fr) 104px !important;
  }

  body[data-page="items"] .topbar > div:first-child {
    width: 104px !important;
    min-width: 0 !important;
    gap: 0 !important;
  }

  body[data-page="items"] #sidebarToggle {
    display: none !important;
  }

  body[data-page="items"] #planHeaderBalance {
    display: block;
    width: 100%;
    min-width: 0;
    height: 44px;
    margin: 0;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--ink);
    font-size: 16px;
    font-weight: 800;
    line-height: normal;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body[data-page="items"]
  #planHeaderBalance[data-balance-status="confirmed"] {
    background: #dcfce7;
    color: #166534;
  }

  body[data-page="items"]
  #planHeaderBalance[data-balance-status="pending"] {
    background: #fef3c7;
    color: #92400e;
  }

  body[data-page="items"] .topbar .account-view-button {
    font-size: 16px !important;
    font-weight: 800 !important;
  }

  body[data-page="items"] .topbar #budgetMonth {
    text-align: center !important;
  }

  body[data-page="items"]
  .topbar #budgetMonth::-webkit-date-and-time-value {
    text-align: center !important;
  }

  /* Stay immediately below the measured header height. */
  body[data-page="items"] #cloudSaveBar {
    position: sticky;
    top: var(--toolbar-height, 62px);
    z-index: 940;
    background: #fff;
  }

  /* Remove the former balance row from the page content. */
  body[data-page="items"] #items .plan-today-summary {
    display: none !important;
  }

  /* Floating menu, level with Add Transaction. */
  body[data-page="items"] #planFloatingMenu {
    position: fixed;
    left: 16px;
    bottom: max(
      18px,
      calc(env(safe-area-inset-bottom) + 10px)
    );
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--brand-soft);
    color: #000;
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 6px 18px rgba(23, 33, 58, .22);
  }

  body:has(#accountViewMenu.show) #planFloatingMenu,
  body:has(.modal:not(.hidden)) #planFloatingMenu,
  body:has(dialog[open]) #planFloatingMenu {
    display: none !important;
  }

  /* Identical heading-to-number spacing for all six metrics. */
  #items #mobilePlanMetrics .mobile-metrics-row > div > strong {
    display: block;
    margin-top: 2px !important;
    padding-top: 0 !important;
    line-height: 1.3;
  }

  #items .forecast-metrics > div:nth-child(2) {
    text-align: center !important;
  }

  #items .forecast-metrics > div:nth-child(3) {
    text-align: right !important;
  }

  #planSelectedDayDate {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.3;
  }

  /* Keep Monthly metrics; remove the redundant chart heading. */
  #items .plan-month-chart-card >
  .section-title:not(.plan-monthly-metrics-heading),
  #items #planMonthChartNote,
  #items #planMonthChartDetail {
    display: none !important;
  }

  /* Retain a clear explanation when no chart can be shown. */
  #planMonthChart.is-empty::before {
    content: "Historical balances are unavailable for this month.";
    display: block;
    padding: 12px 0;
    color: var(--muted);
    font-size: 12px;
  }
}

/* Preserve space for the centred month on smaller phones. */
@media (max-width: 360px) {
  body[data-page="items"] .topbar {
    grid-template-columns:
      84px minmax(0, 1fr) 84px !important;
  }

  body[data-page="items"] .topbar > div:first-child,
  body[data-page="items"] .topbar .account-view-control {
    width: 84px !important;
  }

  body[data-page="items"] .topbar .account-view-button {
    width: 84px !important;
    max-width: 84px !important;
    padding: 0 8px !important;
  }

  body[data-page="items"] #planHeaderBalance,
  body[data-page="items"] .topbar .account-view-button,
  body[data-page="items"] .topbar #budgetMonth {
    font-size: 13px !important;
  }
}

/* Remove the old phone balance row and its surrounding space. */
@media (max-width: 620px) {
  body[data-page="items"] #items .plan-summary-panel {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }
}

/* Keep side-menu text inside its panel. */
#mobileNav {
  min-width: 0;
}

#mobileNav .side-nav,
#mobileNav .tab {
  width: 100%;
  min-width: 0;
}

#mobileNav .tab span,
#mobileNav .nav-label,
#mobileNav .side-footer {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

#mobileNav .logo-mark {
  flex-shrink: 0;
}

/* Highlight the selected day's full column. */
#planMonthChart [data-day].is-selected rect:first-of-type {
  fill: #dbeafe;
  stroke: #2563eb;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

/* Dim other bars once a day is selected. */
#planMonthChart:has(.is-selected)
[data-day]:not(.is-selected) rect:last-child {
  opacity: 0.45;
}

/* Retain the selected bar's positive or negative colour. */
#planMonthChart [data-day].is-selected rect:last-child {
  opacity: 1;
  stroke: #17243b;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

/* Roomier side menu on phones and tablets. */
@media (max-width: 980px) {
  #mobileNav {
    width: min(300px, 88vw);
    padding: 20px 18px 82px;
  }

  #mobileNav:not(.open) {
    left: -310px;
  }

  #mobileNav.open {
    left: 0;
  }

  #mobileNav .logo {
    font-size: 20px;
    padding: 0 6px 20px;
  }

  #mobileNav .nav-label {
    font-size: 12px;
    line-height: 1.5;
    letter-spacing: 0.06em;
    padding: 14px 10px 8px;
  }

  #mobileNav .side-nav {
    gap: 8px;
  }

  #mobileNav .tab {
    padding: 13px 12px;
    gap: 12px;
    font-size: 16px;
    line-height: 1.4;
  }

  #mobileNav .side-footer {
    padding: 14px 6px 0;
    font-size: 13px;
    line-height: 1.55;
  }
}

.side-menu-close {
  display: none;
}

@media (max-width: 980px) {
  #mobileNav {
    top: 0 !important;
    height: 100vh;
    height: 100dvh;
    z-index: 1200;
    padding-top: 24px;
  }

  #mobileNav .side-menu-close {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 24px;
    line-height: 1;
  }
}

/* Make the month and arrow one full-height tap area. */
@media (max-width: 620px) {
  body[data-page="items"] .topbar #budgetMonth {
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 0 20px !important;
    box-sizing: border-box;
    cursor: pointer;
  }

  body[data-page="items"]
  .topbar .topbar-budget-month::after {
    pointer-events: none;
  }
}

/* Milestone 1: one mobile Financial Outlook above the Plan categories. */
.plan-financial-outlook,
.plan-mobile-section-heading,
.plan-explore-forecast { display: none; }

@media (max-width: 620px) {
  #items .plan-financial-outlook {
    display: block;
    margin: 0 0 16px;
    padding: 12px;
    border: 1px solid #d5d5d5;
    border-radius: 8px;
    background: #f4f4f4;
    color: var(--ink);
    scroll-margin-top: calc(var(--toolbar-height, 62px) + 56px);
  }
  #items .plan-outlook-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 32px;
    margin: 0 0 8px;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 14px;
    color: inherit;
    cursor: pointer;
  }
  #items .plan-outlook-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    align-items: start;
  }
  #items .plan-outlook-metrics > div,
  #items .plan-outlook-minimum {
    min-width: 0;
    text-align: left;
  }
  #items .plan-outlook-minimum {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
  }
  #items .plan-outlook-metrics span {
    display: block;
    font-size: 11px;
    color: var(--muted);
  }
  #items .plan-outlook-metrics strong {
    display: block;
    margin-top: 9px;
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
  }
  #items .plan-outlook-metrics small {
    display: block;
    margin-top: 12px;
    color: var(--muted);
    font-size: 11px;
  }
  #items .plan-financial-outlook .bad { color: var(--bad); }
  #items .plan-financial-outlook .good { color: var(--good); }
  #items .plan-outlook-trend-button {
    display: block;
    width: 100%;
    padding: 0;
    margin-top: 6px;
    border: 0;
    background: transparent;
    cursor: pointer;
    touch-action: pan-y;
  }
  #planOutlookTrend,
  #planOutlookTrend svg { display: block; width: 100%; height: 54px; }
  #planOutlookTrend .outlook-zero { stroke: #ccc; }
  #planOutlookTrend .outlook-line { fill: none; stroke: #5873e3; stroke-width: 2; }
  #planOutlookTrend .outlook-dot { fill: #526bdf; }
  #items .plan-financial-outlook [hidden] { display: none !important; }
  #items .plan-outlook-chart-title {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e1e1e1;
    font-size: 12px;
  }
  #items .plan-financial-outlook .plan-month-chart-card {
    margin: 6px 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
  }
  #items .plan-financial-outlook #planMonthChartDetail {
    display: block !important;
    margin: 6px 0;
    min-height: 0;
    font-size: 11px;
  }
  #items .plan-financial-outlook .plan-month-chart-card:has(.is-selected) #planMonthChartDetail {
    display: none !important;
  }
  #items .plan-outlook-selected {
    margin-top: 10px;
    padding: 12px;
    border-radius: 6px;
    background: #fff;
  }
  #planOutlookSelectedDate { display: block; font-size: 11px; color: var(--muted); }
  #planOutlookSelectedBalance { display: block; margin-top: 8px; font-size: 18px; }
  #items .plan-summary-panel,
  #items #mobilePlanMetrics { display: none !important; }
  /* The approved Plan heading supplies the same Add Transaction action. */
  #items > .mobile-add-transaction { display: none !important; }
  #items .plan-mobile-section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 15px;
  }
  #items .plan-mobile-section-heading button {
    padding: 6px 12px;
    border: 0;
    border-radius: 20px;
    background: #111;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
  }
  #items .plan-explore-forecast {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 9px 12px;
    border: 1px solid #d5d5d5;
    border-radius: 22px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
  }
  #items .plan-outlook-toggle:focus-visible,
  #items .plan-outlook-minimum:focus-visible,
  #items .plan-outlook-trend-button:focus-visible,
  #items .plan-explore-forecast:focus-visible {
    outline: 2px solid #526bdf;
    outline-offset: 3px;
  }
}

/* Milestone 2: selected-day investigation inside the same expanded outlook. */
@media (max-width: 620px) {
  #items .plan-financial-outlook .plan-outlook-day-breakdown {
    margin-top: 14px;
    padding-top: 8px;
    border-top: 1px solid #eee;
  }
  #items .plan-outlook-breakdown-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    font-size: 12px;
  }
  #items .plan-outlook-breakdown-row > span:last-child {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
  }
  #items .plan-outlook-transactions-title {
    margin-top: 12px;
    font-size: 12px;
  }
  #items .plan-outlook-transaction {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 12px 0;
    border: 0;
    border-bottom: 1px solid #e1e1e1;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
  }
  #items .plan-outlook-transaction-name { min-width: 0; overflow-wrap: anywhere; }
  #items .plan-outlook-transaction-name small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
  }
  #items .plan-outlook-transaction-amount {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
  }
  #items .plan-outlook-show-all {
    width: 100%;
    min-height: 36px;
    margin-top: 10px;
    padding: 8px 12px;
    border: 1px solid #d5d5d5;
    border-radius: 22px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
  }
  #items .plan-outlook-no-transactions { margin: 12px 0 0; font-size: 12px; }
  #items .plan-outlook-transaction:focus-visible,
  #items .plan-outlook-show-all:focus-visible {
    outline: 2px solid #526bdf;
    outline-offset: 3px;
  }
}

/* Milestone 3: mobile shortcut after the outlook has scrolled out of view. */
#planReturnToOutlook { display: none; }
@media (max-width: 620px) {
  body[data-page="items"] #planReturnToOutlook:not([hidden]) {
    position: fixed;
    right: 16px;
    bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px));
    z-index: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid #d5d5d5;
    border-radius: 24px;
    background: #f4f4f4;
    color: var(--ink);
    font-size: 12px;
    box-shadow: 0 3px 12px rgba(23, 33, 58, .12);
  }
  #planReturnToOutlook[hidden],
  body.cloud-locked #planReturnToOutlook,
  body:has(.modal:not(.hidden)) #planReturnToOutlook,
  body:has(dialog[open]) #planReturnToOutlook,
  body:has(#accountViewMenu.show) #planReturnToOutlook,
  body:has(#mobileNav.open) #planReturnToOutlook {
    display: none !important;
  }
  #planReturnToOutlook:focus-visible {
    outline: 2px solid #526bdf;
    outline-offset: 3px;
  }
}

/* Milestone 5: amount exploration and draft forecast comparison in the existing editor. */
#modal .item-amount-slider-wrap { margin-top: 6px; }
#modal #itemAmountSlider {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 !important;
  margin: 0;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  accent-color: #526bdf;
}
#modal .item-amount-slider-scale {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#modal .item-forecast-impact {
  margin-top: 14px;
  padding: 11px;
  border: 1px solid #d5d5d5;
  border-radius: 7px;
  background: #f4f4f4;
}
#modal .item-impact-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  text-align: left;
}
#modal .item-impact-caption,
#modal .item-impact-period,
#modal .item-impact-date,
#modal .item-impact-legend,
#modal .item-impact-delta,
#modal .item-impact-end {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}
#modal .item-impact-period { margin: 12px 0 8px; }
#modal .item-impact-minimums {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
#modal .item-impact-minimums .item-impact-label { font-size: 11px; color: var(--muted); }
#modal .item-impact-minimums strong {
  display: block;
  margin-top: 6px;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
#modal .item-impact-date { display: block; margin-top: 3px; }
#modal .item-impact-delta { margin-top: 9px; }
#modal .item-impact-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
#modal .item-impact-swatch { display: inline-block; width: 9px; height: 9px; margin-right: 5px; }
#modal .item-impact-swatch.current { background: #a0afe7; }
#modal .item-impact-swatch.proposed { background: #526bdf; }
#modal #itemForecastImpactChart { width: 100%; margin-top: 5px; }
#modal #itemForecastImpactChart svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
#modal #itemForecastImpactChart [data-impact-day] { cursor: pointer; }
#modal #itemForecastImpactChart [data-impact-day]:focus-visible { outline: 2px solid #526bdf; }
#modal .item-impact-day {
  margin-top: 8px;
  padding: 10px;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}
#modal .item-impact-day-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; }
#modal .item-impact-day-row strong { font-variant-numeric: tabular-nums; }
#modal .item-impact-end { margin-top: 10px; }
#modal .item-impact-warning { margin: 10px 0 0; color: var(--bad); font-size: 12px; line-height: 1.5; }
#modal .item-impact-message { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
#modal .item-forecast-impact [hidden],
#modal #itemForecastImpactWarning[hidden] { display: none !important; }
#modal .item-impact-toggle:focus-visible,
#modal #itemAmountSlider:focus-visible { outline: 2px solid #526bdf; outline-offset: 3px; }
@media (max-width: 620px) {
  #modal #itemAmountSlider { min-height: 44px !important; height: 44px !important; }
}

/* Approved compact transaction editor: slider and impact are adjacent. */
#modal .modal-box { padding: 12px; position: relative; }
#modal .transaction-modal-header { position: relative; align-items: center; margin-bottom: 9px; gap: 8px; }
#modal .transaction-modal-header .section-title { font-size: 15px; margin: 0; }
#modal .transaction-header-actions { display: flex; align-items: center; gap: 4px; }
#modal .transaction-modal-close,
#modal .transaction-more-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 22px;
}
#modal .transaction-name-field > label {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
}
#modal .transaction-name-field { min-width: 0; }
#modal #transactionOwnerLabel { margin: 6px 0 10px !important; font-size: 11px; line-height: 1.4; }
#modal .transaction-amount-row,
#modal .transaction-date-row,
#modal .transaction-details-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 10px !important;
}
#modal .transaction-amount-row .field,
#modal .transaction-date-row .field,
#modal .transaction-details-grid .field { min-width: 0; gap: 0; }
#modal .transaction-details-grid .mobile-transaction-category-field {
  display: flex !important; flex-direction: column; grid-column: auto !important;
}
#modal .field > label { margin-bottom: 4px; font-size: 11px; }
#modal #itemNameButton,
#modal #itemAmount,
#modal #itemFrequency,
#modal #itemDate,
#modal #itemEndDate,
#modal #itemType,
#modal #itemCategoryButton,
#modal #itemTransferAccount,
#modal #itemViewTag {
  box-sizing: border-box !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 8px 10px !important;
  border: 1px solid #dde1e8 !important;
  border-radius: 7px !important;
  background: #fff !important;
  color: var(--ink);
  font-size: 14px !important;
}
#modal .item-amount-slider-wrap { margin-top: 2px; }
#modal .item-forecast-impact { margin-top: 8px; padding: 9px; }
#modal .item-impact-toggle { min-height: 28px; }
#modal .item-impact-caption { display: none; }
#modal .item-impact-minimums { margin-top: 6px; }
#modal .item-impact-minimums strong { margin-top: 4px; font-size: 18px; }
#modal .item-impact-date { margin-top: 2px; }
#modal .item-impact-delta { margin-top: 6px; }
#modal .item-impact-legend { justify-content: space-between; align-items: center; margin-top: 7px; gap: 6px; }
#modal .item-impact-period { margin: 0 0 0 auto; }
#modal #itemForecastImpactChart { margin-top: 2px; }
#modal .item-impact-day {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  padding: 7px 0 0;
  margin-top: 0;
  border-top: 1px solid #e0e3ea;
  border-radius: 0;
  background: transparent;
  font-size: 11px;
  color: var(--muted);
}
#modal .item-impact-day strong { display: block; margin-top: 2px; font-size: 13px; font-weight: 500; }
#modal .item-impact-end { margin-top: 7px; }
#modal .item-impact-warning { margin-top: 7px; font-size: 11px; }
#modal .transaction-date-row { margin-top: 12px; }
#modal #transactionDetails { margin-top: 12px; border-top: 1px solid var(--line); }
#modal #transactionDetails > summary {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 40px; cursor: pointer; list-style: none; font-size: 12px;
}
#modal #transactionDetails > summary::-webkit-details-marker { display: none; }
#modal #transactionDetails > summary::after { content: '⌄'; }
#modal #transactionDetails[open] > summary::after { content: '⌃'; }
#modal .transaction-details-grid { padding: 2px 0 8px; }
#modal #transferAccountField,
#modal .transaction-view-tag-field { grid-column: 1 / -1; }
#modal .transaction-editor-actions {
  display: grid !important;
  grid-template-columns: 1fr 1.35fr;
  gap: 8px;
  position: sticky;
  bottom: -12px !important;
  z-index: 2;
  margin: 0 -12px -12px !important;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom)) !important;
  border-top: 1px solid var(--line);
  background: #fff;
}
#modal .transaction-editor-actions .btn { min-height: 42px; padding: 8px 10px; border-radius: 8px; font-size: 13px; }
#modal .transaction-actions-menu {
  position: absolute; top: 40px; right: 40px; z-index: 5;
  padding: 5px; background: #fff; border: 1px solid #d5d9e2;
  border-radius: 8px; box-shadow: 0 5px 16px rgba(20, 32, 51, .13);
}
#modal .transaction-actions-menu button {
  padding: 10px; min-height: 42px; border: 0; background: transparent; color: var(--bad); font-size: 13px;
}
#modal .transaction-delete-confirmation {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 32, 51, .33); padding: 14px;
}
#modal .transaction-delete-dialog { width: min(100%, 340px); padding: 16px; background: #fff; border-radius: 10px; font-size: 13px; }
#modal .transaction-delete-dialog p { margin: 10px 0 14px; color: var(--muted); font-size: 12px; line-height: 1.5; }
#modal .transaction-delete-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#modal .transaction-delete-buttons button { min-height: 42px; padding: 8px; border: 1px solid #d5d9e2; border-radius: 7px; background: #fff; font-size: 12px; }
#modal #transactionConfirmDeleteButton { color: #fff; background: var(--bad); border-color: var(--bad); }
#modal [hidden] { display: none !important; }
#modal .transaction-more-button:focus-visible,
#modal .transaction-actions-menu button:focus-visible,
#modal .transaction-delete-buttons button:focus-visible { outline: 2px solid #526bdf; outline-offset: 3px; }
@media (max-width: 620px) {
  #modal .modal-box { padding: 12px; }
  #modal #itemAmount,
  #modal #itemDate,
  #modal #itemEndDate,
  #modal #itemType,
  #modal #itemFrequency,
  #modal #itemTransferAccount,
  #modal #itemViewTag { font-size: 16px !important; }
}

/* Shared account-goal and transaction funding UI. */
.goal-dialog { box-sizing:border-box; width:min(640px,calc(100vw - 24px)); max-height:92dvh; overflow:auto; border:1px solid #dce1e9; border-radius:18px; padding:20px; color:#182337; background:#fff; }
.goal-dialog::backdrop { background:rgba(18,30,49,.4); }
.goal-dialog * { box-sizing:border-box; }
.goal-dialog header { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:12px; }
.goal-dialog h2 { margin:0; font-size:22px; }
.goal-dialog label { display:flex; flex-direction:column; gap:5px; font-size:13px; color:#58677c; margin:10px 0; }
.goal-dialog input,.goal-dialog select { width:100%; min-width:0; min-height:42px; padding:8px 10px; border:1px solid #cbd4e0; border-radius:9px; background:white; color:#182337; font:inherit; font-size:16px; }
.goal-dialog button { min-height:42px; border-radius:9px; border:1px solid #cbd4e0; background:#fff; color:#243b68; padding:8px 14px; cursor:pointer; font:inherit; }
.goal-dialog button.btn { background:#4267cc; color:white; border-color:#4267cc; }
.goal-dialog button:disabled { opacity:.45; cursor:default; }
.goal-dialog input:focus-visible,.goal-dialog button:focus-visible,.goal-dialog select:focus-visible,[data-bars] [role=button]:focus-visible { outline:3px solid #668df2; outline-offset:2px; }
.goal-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.goal-slider { display:flex; align-items:center; gap:10px; margin:8px 0; }
.goal-slider input { padding:0; accent-color:#4267cc; flex:1; }
.goal-slider button { flex:none; }
.goal-panel { padding:12px; margin:10px 0; border:1px solid #d8e0eb; background:#f6f8fc; border-radius:12px; }
.goal-panel h3 { margin:0 0 10px; font-size:16px; font-weight:600; }
.goal-minimums { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.goal-minimums span,.goal-minimums small { display:block; color:#5e6b7e; font-size:12px; }
.goal-minimums strong { display:block; font-size:22px; font-weight:600; margin:3px 0; }
.goal-panel label.goal-month { display:flex; flex-direction:row; align-items:center; gap:12px; font-size:13px; margin:10px 0; }
.goal-month select { width:auto; flex:1; height:34px; min-height:34px; padding:4px 8px; border:1px solid #cbd4e0; border-radius:7px; background:white; font:inherit; }
.goal-chart-legend,.goal-note,.goal-status { font-size:12px; color:#58677c; line-height:1.45; margin:5px 0; }
.goal-chart-legend b { color:#9b5900; font-weight:600; }
.goal-panel [data-bars] svg { display:block; width:100%; height:auto; }
.goal-panel details { font-size:13px; line-height:1.5; margin-top:8px; }
.goal-dialog summary,.goal-panel summary { cursor:pointer; padding:7px 0; }
.goal-dialog footer,.goal-actions { display:flex; gap:10px; justify-content:flex-end; flex-wrap:wrap; margin-top:14px; }
.goal-dialog footer { position:sticky; bottom:-20px; padding:12px 0; background:#fff; border-top:1px solid #e4e9f0; }
.goal-dialog [data-error] { color:#ad303d; font-size:13px; }
.goal-banner { background:#eaf0ff; border-radius:8px; padding:10px; font-size:13px; }
.goal-dialog .goal-check { flex-direction:row; align-items:center; }
.goal-check input { width:18px; min-height:18px; }
@media(max-width:620px) { .goal-dialog { padding:14px; } .goal-dialog footer { bottom:-14px; } .goal-minimums strong { font-size:20px; } .goal-month select { height:44px; min-height:44px; } .goal-grid { gap:10px; } }


/* All-account warning directly beneath the account controls. */
.account-buffer-warning { grid-column:1 / -1; flex-basis:100%; width:100%; min-width:0; box-sizing:border-box; margin:8px 0 0; border:1px solid #e2ad50; border-radius:10px; background:#fff7e6; color:#754600; font-size:13px; }
.account-buffer-warning[hidden] { display:none !important; }
.account-buffer-warning.has-negative { border-color:#df9ba3; background:#fff0f1; color:#992b3a; }
.account-buffer-warning summary { padding:9px 12px; cursor:pointer; line-height:1.4; }
.account-buffer-first { display:block; margin:2px 0 0 18px; font-size:12px; }
.account-buffer-details { padding:0 12px 10px; max-height:35vh; overflow:auto; }
.account-buffer-details p { margin:4px 0 8px; font-size:12px; }
.account-buffer-details button { display:block; width:100%; text-align:left; white-space:normal; padding:9px; margin:5px 0; background:#fff; border:1px solid currentColor; border-radius:7px; color:inherit; }
.account-buffer-details button span { display:block; margin-top:3px; font-size:12px; }
.goal-progress { margin:12px 0; }
.goal-progress-label { display:flex; justify-content:space-between; flex-wrap:wrap; gap:4px 12px; font-size:13px; }
.goal-progress progress { display:block; appearance:none; width:100%; height:10px; margin:8px 0; border:0; border-radius:999px; overflow:hidden; background:#dce3f1; accent-color:#4267cc; }
.goal-progress progress::-webkit-progress-bar { background:#dce3f1; border-radius:999px; }
.goal-progress progress::-webkit-progress-value { background:#4267cc; border-radius:999px; }
.goal-progress progress::-moz-progress-bar { background:#4267cc; border-radius:999px; }
@media (max-width:620px) {
  body[data-page="items"] .topbar .account-buffer-warning { grid-row:2; margin-top:4px; }
}
.topbar:has(.account-buffer-warning:not([hidden])) { flex-wrap:wrap; height:auto !important; min-height:72px; padding-top:8px; padding-bottom:8px; }

/* Account goals are tracked on Plan, not mixed into transaction types. */
#planAccountGoals { margin:0 0 14px; }
.account-goal-card { padding:16px; margin:0 0 12px; border:1px solid #d8e0eb; border-radius:14px; background:#f6f8fc; }
.account-goal-card header { display:flex; justify-content:space-between; align-items:start; gap:12px; }
.account-goal-card h3 { margin:4px 0 0; font-size:18px; }
.account-goal-card small,.account-goal-setup { color:#526078; }
.account-goal-card button,.account-goal-setup button { border:1px solid #c7d2e4; border-radius:9px; background:white; color:#234174; padding:9px 12px; font:inherit; font-size:13px; }
.account-goal-setup { display:flex; justify-content:space-between; gap:10px; align-items:center; padding:8px 2px; font-size:13px; }
.account-goal-card .goal-actions { justify-content:flex-start; }
.account-goal-card .goal-note { font-size:12px; line-height:1.45; }
.goal-dialog [hidden] { display:none !important; }
@media (max-width:620px) { .account-goal-card { padding:14px; } .account-goal-card header { flex-wrap:wrap; } .account-goal-setup { flex-wrap:wrap; } }

/* Account goal simulator: approved neutral mobile creation layout. */
.goal-simulator { width:min(460px,calc(100vw - 20px)); color:#252525; }
.goal-simulator h2 { font-size:20px; }
.goal-simulator h3 { font-size:16px; margin:0 0 12px; }
.goal-simulator label { color:#656565; }
.goal-simulator input,.goal-simulator select { background:#f2f2f2; border:1px solid #ededed; color:#252525; }
.goal-simulator .gs-money { display:flex; align-items:center; font-weight:600; font-size:18px; }
.goal-simulator .gs-money input { background:transparent; border:0; padding:0 3px; font-size:18px; font-weight:600; min-height:32px; }
.goal-simulator input[type=range] { --gs-fill:0%; appearance:none; -webkit-appearance:none; padding:0; background:transparent; border:0; height:36px; min-height:36px; width:100%; }
.goal-simulator input[type=range]::-webkit-slider-runnable-track { height:5px; border-radius:5px; background:linear-gradient(to right,#222 var(--gs-fill),#e3e3e3 var(--gs-fill)); }
.goal-simulator input[type=range]::-webkit-slider-thumb { appearance:none; -webkit-appearance:none; width:32px; height:24px; margin-top:-10px; background:#fff; border:1px solid #f4f4f4; border-radius:10px; box-shadow:0 1px 9px #0002; }
.goal-simulator input[type=range]::-moz-range-track { height:5px; border-radius:5px; background:#e3e3e3; }
.goal-simulator input[type=range]::-moz-range-progress { height:5px; background:#222; }
.goal-simulator input[type=range]::-moz-range-thumb { width:32px; height:24px; border:0; border-radius:10px; background:#fff; box-shadow:0 1px 9px #0002; }
.goal-simulator .gs-segments { display:flex; gap:6px; margin:4px 0 12px; }
.goal-simulator .gs-segments button { border:0; border-radius:24px; color:#777; padding:6px 14px; min-height:36px; }
.goal-simulator .gs-segments button[aria-pressed=true] { background:#efefef; color:#252525; }
.goal-simulator .gs-frequency { display:flex; justify-content:space-between; gap:6px; flex-wrap:wrap; }
.goal-simulator .gs-frequency label { display:flex; flex-direction:row; gap:5px; align-items:center; color:#252525; margin:0; min-height:44px; }
.goal-simulator .gs-frequency input { width:17px; height:17px; min-height:17px; accent-color:#222; }
.goal-simulator .gs-balance { background:#edf3ff; color:#284571; border-radius:9px; padding:11px 13px; font-size:13px; font-weight:500; }
.goal-simulator .gs-confirm { background:#fff3d6; color:#795000; border-radius:9px; padding:12px 13px; font-size:13px; font-weight:500; }
.goal-simulator .gs-confirm button { margin-top:8px; }
.goal-simulator .gs-section { border-top:1px solid #e5e5e5; margin-top:20px; padding-top:18px; }
.goal-simulator .gs-heading { display:flex; justify-content:space-between; align-items:baseline; gap:8px; flex-wrap:wrap; }
.goal-simulator .gs-heading>span { font-size:11px; padding:3px 7px; background:#ddf5e9; color:#177746; border-radius:20px; }
.goal-simulator .gs-metrics>div { padding:12px; background:#f2f2f2; border-radius:11px; min-width:0; }
.goal-simulator .gs-metrics small { display:block; font-size:12px; color:#707070; }
.goal-simulator .gs-metrics strong { display:block; font-size:18px; font-weight:600; margin-top:5px; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.goal-simulator .gs-impact>div { background:#fff; border:1px solid #e5e5e5; }
.goal-simulator .gs-scale,.goal-simulator .gs-payment { display:flex; justify-content:space-between; gap:10px; font-size:12px; }
.goal-simulator .gs-scale { color:#707070; }
.goal-simulator .gs-payment { padding:10px 0; border-bottom:1px solid #ededed; }
.goal-simulator button.btn { background:#222; color:white; border-color:#222; }
.goal-simulator .goal-note { color:#666; font-size:12px; line-height:1.5; }
.goal-simulator footer { position:static; }
.goal-simulator [data-amount-controls]>div:first-child,.goal-simulator [data-buffer-controls]>div:first-child { display:grid; grid-template-columns:1fr 120px; align-items:center; gap:0 8px; }
.goal-simulator [data-amount-controls] input[type=range],.goal-simulator [data-buffer-controls] input[type=range] { grid-column:1/-1; }
.goal-simulator .goal-grid { align-items:start; }
@media(max-width:360px){.goal-simulator{padding:12px}.goal-simulator .gs-targets label{min-height:36px}.goal-simulator .gs-metrics>div{padding:10px}.goal-simulator footer button{padding:8px 10px}}

/* Account-first redesign. Legacy engine elements remain mounted, not navigable. */
.rd-app #rdChart{scroll-margin-top:80px}
.rd-app .topbar{z-index:50!important}.rd-app #cloudSaveBar{z-index:40!important}.rd-app:has(#modal:not(.hidden)){overflow:hidden}
.rd-app #modal #itemAmountSlider,.rd-app #modal #rdTestDateSlider{appearance:none;-webkit-appearance:none;width:100%;height:40px;background:transparent;--rd-fill:0%}
.rd-app #modal #itemAmountSlider::-webkit-slider-runnable-track,.rd-app #modal #rdTestDateSlider::-webkit-slider-runnable-track{height:5px;border-radius:5px;background:linear-gradient(to right,#252525 var(--rd-fill),#dedede var(--rd-fill))}
.rd-app #modal #itemAmountSlider::-webkit-slider-thumb,.rd-app #modal #rdTestDateSlider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;width:32px;height:24px;border-radius:10px;background:white;border:1px solid #eee;box-shadow:0 1px 8px #0002;margin-top:-10px}
.rd-app #modal #itemAmountSlider::-moz-range-track,.rd-app #modal #rdTestDateSlider::-moz-range-track{height:5px;background:#dedede}.rd-app #modal #itemAmountSlider::-moz-range-progress,.rd-app #modal #rdTestDateSlider::-moz-range-progress{height:5px;background:#252525}.rd-app #modal #itemAmountSlider::-moz-range-thumb,.rd-app #modal #rdTestDateSlider::-moz-range-thumb{width:32px;height:24px;background:white;border:1px solid #eee;border-radius:10px}
body.rd-app{background:#fff;color:#272727;padding-bottom:100px;--brand:#262626;--brand-soft:#f3f3f3;--line:#e5e5e5}
.rd-app .shell{display:block!important;min-height:0}.rd-app .main{margin:0!important;padding:0!important;width:100%}
.rd-app .sidebar,.rd-app #sidebarToggle,.rd-app #planHeaderBalance,.rd-app .top-actions,.rd-app #topbarBudgetMonth,.rd-app .account-view-control,.rd-app #planFloatingMenu,.rd-app #planFinancialOutlook,.rd-app #persistentForecastChart,.rd-app .plan-month-chart-card,.rd-app .plan-summary-panel,.rd-app #planExploreForecast,.rd-app #planReturnToOutlook,.rd-app .mobile-add-transaction{display:none!important}
.rd-app .topbar{display:flex!important;flex-wrap:nowrap;justify-content:space-between;gap:12px;height:auto;min-height:64px;padding:12px max(16px,calc((100vw - 760px)/2));background:#fff;position:sticky;top:0;z-index:50}
.rd-app .topbar>div:first-of-type{flex:1;min-width:0}.rd-app .topbar #pageTitle{display:block!important;font-size:20px;color:#222;margin:0;white-space:normal}.rd-app .rd-settings{order:3}
.rd-app .content{max-width:760px;margin:0 auto;padding:24px 20px 32px;width:100%;box-sizing:border-box}
.rd-app #cloudSaveBar{position:static!important;inset:auto!important;width:100%;font-size:12px;min-height:0}
.rd-app [hidden]{display:none!important}.rd-app .page.hidden{display:none!important}
.rd-app .rd-page h2,.rd-app .rd-editor h2,.rd-app #rdOutlook h2{font-size:24px;letter-spacing:-.5px;margin:0 0 20px}.rd-app h3{font-size:17px;margin:0 0 12px}
.rd-app .rd-page button,.rd-app .rd-editor button,.rd-app .rd-nav button,.rd-app .rd-segment button,.rd-app #rdBack,.rd-app #rdSettings,.rd-app #rdGoalChooser button{font:inherit;cursor:pointer;border:1px solid #e1e1e1;background:#fff;border-radius:12px;color:#292929;padding:11px 14px;min-height:44px}
.rd-app button:focus-visible,.rd-app input:focus-visible,.rd-app select:focus-visible{outline:3px solid #6884e7;outline-offset:3px}
.rd-app .rd-row{display:flex;justify-content:space-between;align-items:center;gap:14px}.rd-app .rd-row>div{min-width:0}.rd-app .rd-row h2{margin-bottom:0}
.rd-app .rd-small,.rd-app .rd-page small,.rd-app .rd-editor small,.rd-app #rdOutlook small,.rd-app .rd-transfer-explore small{font-size:13px;color:#747474;line-height:1.5}
.rd-app small{display:block}.rd-app .rd-section{margin:28px 0}.rd-app .rd-overview{padding:20px;background:#f5f5f5;border-radius:16px;align-items:flex-start;margin:20px 0 12px}.rd-app .rd-overview strong{display:block;font-size:27px;margin:7px 0}
.rd-app button.rd-account{display:block;text-align:left;width:100%;margin:16px 0;padding:20px;border:1px solid #dedede;border-radius:15px;background:#fff;color:#252525;box-shadow:none;white-space:normal}.rd-app .rd-account b{font-size:24px}.rd-app .rd-account>.rd-row>strong{font-size:18px;overflow-wrap:anywhere}.rd-app .rd-account>small{margin-top:9px}
.rd-app .rd-warning{background:#fff8ea!important;color:#765112!important;border:1px solid #e6c98e!important;border-radius:12px;padding:12px}.rd-app .rd-warning small{color:inherit}
.rd-app .rd-progress{padding:16px;background:#f5f5f5;border-radius:12px;margin-top:16px}.rd-app .rd-progress p{margin:9px 0;font-size:14px}.rd-app .rd-track{position:relative;height:12px;background:#e3e3e3;border-radius:20px;margin:18px 0 12px}.rd-app .rd-fill{display:block;height:100%;border-radius:20px;background:#7e98dd}.rd-app .rd-fill.green{background:#58a582}.rd-app .rd-fill.amber{background:#d7a24d}.rd-app .rd-track i{position:absolute;top:-5px;height:22px;width:2px;background:#444;transform:translateX(-1px)}
.rd-app .rd-field{display:flex;flex-direction:column;gap:8px;margin:14px 0;font-size:14px;color:#595959;min-width:0}.rd-app .rd-field input,.rd-app .rd-field select{width:100%;min-width:0;box-sizing:border-box;background:#fff;border:1px solid #d7d7d7;border-radius:10px;font:inherit;font-size:16px;color:#242424;padding:13px;min-height:46px}.rd-app .rd-columns{display:grid;grid-template-columns:1fr 1fr;gap:16px}.rd-app .rd-checkbox{display:flex;gap:12px;align-items:center;font-size:18px;font-weight:600;margin:24px 0 10px}.rd-app .rd-checkbox input{width:22px;height:22px;accent-color:#222}
.rd-app .rd-current{padding:18px;background:#eef3ff;border:1px solid #d4def5;border-radius:14px;margin:22px 0}.rd-app .rd-current strong#rdCurrentBalance{display:block;font-size:28px;margin-top:8px}.rd-app .rd-current p{font-size:13px;line-height:1.55;color:#35496f}.rd-app .rd-current button{white-space:normal;max-width:140px}
.rd-app .rd-actions{display:flex;justify-content:flex-end;gap:10px;margin:22px 0}.rd-app button.rd-primary{background:#222;color:#fff;border-color:#222}.rd-app #rdAccountActions{font-size:13px;color:#777;margin-bottom:26px}.rd-app #rdAccountActions button{margin:12px 0}
.rd-app .rd-chart{width:100%;min-width:0;margin-top:16px}.rd-app .rd-chart svg{width:100%;display:block;overflow:visible}.rd-app .rd-chart text{font:11px system-ui;fill:#777}.rd-app .rd-gridline{stroke:#e5e5e5;stroke-width:1}.rd-app .rd-selection{fill:transparent}.rd-app .rd-selection.selected{fill:#e9effb;stroke:#6886db}.rd-app .rd-bar.blue{fill:#91a5dc}.rd-app .rd-bar.amber{fill:#d3a155}.rd-app .rd-bar.red{fill:#ce6060}.rd-app .rd-buffer-line{stroke:#a47727;stroke-dasharray:4 4}.rd-app .rd-chart g{cursor:pointer}.rd-app .rd-chart g:focus{outline:none}.rd-app .rd-chart g:focus .rd-selection{stroke:#333;stroke-width:2}
.rd-app .rd-day-card{padding:20px;background:#f5f5f5;border-radius:14px;margin:20px 0}.rd-app .rd-balance{font-size:28px;display:block;margin:10px 0 22px}.rd-app .rd-day-card .rd-row{font-size:14px;margin:12px 0}.rd-app button.rd-transaction{display:flex;width:100%;justify-content:space-between;align-items:center;gap:15px;padding:16px 0;border:0;border-bottom:1px solid #eee;border-radius:0;background:none;text-align:left;font:inherit;color:#333;cursor:pointer}.rd-app .rd-transaction small{margin-top:5px}.rd-app .rd-transaction>span{min-width:0;overflow-wrap:anywhere}.rd-app .rd-transaction>strong{white-space:nowrap}
.rd-app #rdNewTransfer,.rd-app #rdAccountFooter button,.rd-app #rdAccountActions button{font:inherit;min-height:44px;padding:10px 14px;border:1px solid #ddd;border-radius:10px;background:#fff;cursor:pointer}.rd-app #rdAccountFooter .rd-primary{background:#222;color:#fff}.rd-app #rdAccountFooter{padding-top:20px;border-top:1px solid #eee}.rd-app dialog input[type=number]{width:100%;box-sizing:border-box;font-size:16px;padding:12px;margin:10px 0;border:1px solid #ccc;border-radius:10px}.rd-app dialog button{font:inherit;min-height:44px;padding:9px 14px;margin-top:10px;border:1px solid #ddd;border-radius:10px;background:#fff}.rd-app dialog button[type=submit]{background:#222;color:white}.rd-app dialog label{line-height:1.5}.rd-app dialog p{font-size:14px;line-height:1.5}
.rd-app .plan-workspace{display:block!important}.rd-app .plan-workspace[hidden]{display:none!important}.rd-app .plan-main{width:100%;min-width:0}.rd-app .plan-table-card{padding:0;border:0;box-shadow:none;overflow:visible}.rd-app .plan-mobile-section-heading{display:flex;margin-top:30px}.rd-app .plan-mobile-section-heading[hidden]{display:none}.rd-app #items>.hero{display:none!important}
.rd-app .rd-nav{position:fixed;bottom:0;left:50%;transform:translateX(-50%);z-index:60;width:min(100%,760px);display:flex;justify-content:space-around;gap:8px;background:rgba(255,255,255,.97);border-top:1px solid #e5e5e5;padding:10px 16px max(12px,env(safe-area-inset-bottom));box-sizing:border-box}.rd-app .rd-nav button{flex:1;font-size:22px;border:0;border-radius:22px;padding:7px 12px;color:#777}.rd-app .rd-nav button span{display:block;font-size:14px;margin-top:3px}.rd-app .rd-nav button.active{background:#f0f0f0;color:#222}
.rd-app .modal{z-index:100;overflow:auto;align-items:flex-start;padding-top:20px}.rd-app .modal-box{margin:auto;max-height:calc(100dvh - 40px);overflow-y:auto}.rd-app dialog{max-width:560px;width:calc(100% - 32px);box-sizing:border-box;border:1px solid #ddd;border-radius:18px;padding:22px;max-height:90dvh;overflow:auto}.rd-app dialog::backdrop{background:#0006}.rd-app #rdGoalChooser .rd-account{margin:12px 0}
.rd-app .rd-transfer-explore{background:#f6f6f6;border:1px solid #e6e6e6;border-radius:14px;padding:16px;margin:18px 0;font-size:14px}.rd-app .rd-transfer-explore strong{display:block;font-size:22px}.rd-app .rd-segment{display:flex;gap:8px;margin:16px 0}.rd-app .rd-segment button{flex:1}.rd-app .rd-segment button[aria-pressed=true]{background:#222;color:#fff}.rd-app #rdTestDateSlider{width:100%;accent-color:#222}.rd-app .item-amount-slider-wrap input{accent-color:#222}
.rd-app.cloud-locked .content,.rd-app.cloud-locked .rd-nav,.rd-app.cloud-locked #rdBack,.rd-app.cloud-locked #rdSettings{display:none!important}
@media(max-width:420px){.rd-app .content{padding:18px 16px 30px}.rd-app .rd-columns{grid-template-columns:1fr;gap:0}.rd-app .rd-account b{font-size:22px}.rd-app .rd-overview strong{font-size:23px}.rd-app .rd-current{padding:14px}.rd-app .rd-current strong#rdCurrentBalance{font-size:24px}.rd-app .rd-row{gap:10px}.rd-app .modal{padding:10px}.rd-app .modal-box{max-height:calc(100dvh - 20px)}}

/* Daily balance confirmation and compact account lists. */
html:has(body.rd-app),body.rd-app{overscroll-behavior-y:none}
.rd-app button.rd-account{padding:14px 16px;margin:10px 0}
.rd-app .rd-account b{font-size:21px}
.rd-app .rd-balance-label{display:inline-flex;align-items:center;gap:8px;flex-shrink:0}
.rd-app .rd-confirm-dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:#3478f6;flex-shrink:0}
.rd-app .rd-current button.rd-confirm-needed{background:#2563eb;color:#fff;border-color:#2563eb;font-weight:600}
.rd-app .rd-tile-progress .rd-track{height:7px;margin:9px 0 3px}
.rd-app .rd-tile-progress .rd-track i{height:15px;top:-4px}
.rd-app .rd-tile-progress>small{margin-top:7px}
.rd-app .rd-goal-outcome{border-top:1px solid #ddd;padding-top:10px}

/* Account planning and settings tabs. */
.rd-app .rd-account-tabs{display:flex;gap:5px;padding:5px;background:#f2f2f2;border-radius:14px;margin:0 0 18px}
.rd-app .rd-account-tabs button{flex:1;min-width:0;min-height:44px;border:0;border-radius:10px;background:transparent;color:#707070;padding:10px 8px;font:inherit;font-size:14px;cursor:pointer}
.rd-app .rd-account-tabs button[aria-selected=true]{background:white;color:#222;font-weight:600;box-shadow:0 1px 4px #0001}
.rd-app #rdPlanningPanel .rd-current{margin:0 0 14px;padding:14px 16px}
.rd-app #rdPlanningPanel .rd-current p{margin:8px 0}
.rd-app #rdPlanningPanel .rd-current strong#rdCurrentBalance{font-size:24px;margin-top:4px}
.rd-app #rdPlanningPanel .rd-progress{margin:0 0 16px;padding:12px 14px}
.rd-app #rdPlanningPanel .rd-progress p{margin:6px 0;font-size:13px}
.rd-app #rdPlanningPanel .rd-track{margin:12px 0 10px;height:9px}
.rd-app #rdPlanningPanel .rd-track i{height:19px}
.rd-app #rdPlanningPanel .rd-section{margin:20px 0}
.rd-app .rd-plan-toolbar{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.rd-app .rd-plan-toolbar h3{margin:0;font-size:20px}
.rd-app .rd-plan-toolbar .rd-field{margin:0;font-size:12px;gap:3px;max-width:100%}
.rd-app .rd-plan-toolbar input{width:170px;max-width:100%;padding:8px 10px;min-height:44px;font-size:14px}
.rd-app .rd-plan-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;margin:12px 0}
.rd-app .rd-plan-actions button{font:inherit;font-size:13px;min-height:44px;padding:9px 12px;background:#fff;border:1px solid #ddd;border-radius:10px;color:#292929;cursor:pointer}
.rd-app .rd-daily-outlook{border:1px solid #e1e1e1;border-radius:14px;margin-top:22px;padding:0 14px}
.rd-app .rd-daily-outlook>summary{font-size:17px;font-weight:600;cursor:pointer;min-height:48px;align-content:center;padding:12px 0;box-sizing:border-box}
.rd-app .rd-daily-outlook .rd-overview{margin-top:6px;padding:12px;gap:8px}
.rd-app .rd-daily-outlook .rd-overview strong{font-size:22px}
.rd-app .rd-daily-outlook #rdOutlookBody{padding-bottom:14px}
.rd-app #rdAccountSettingsPanel .rd-editor h2{font-size:20px}
.rd-app #rdAccountSettingsPanel .rd-progress{margin-top:14px}
.rd-app #items .plan-mobile-section-heading[hidden]{display:none!important}
@media(max-width:350px){.rd-app .rd-plan-toolbar h3{font-size:18px}.rd-app .rd-plan-toolbar input{width:155px}.rd-app .rd-account-tabs button{font-size:13px}}
.rd-app #rdPlanningPanel #rdConfirmBalance{font:inherit;font-size:14px;cursor:pointer;border:1px solid #e1e1e1;background:#fff;border-radius:12px;color:#292929;padding:10px 12px;min-height:44px}
.rd-app #rdPlanningPanel #rdConfirmBalance.rd-confirm-needed{background:#2563eb;color:#fff;border-color:#2563eb;font-weight:600}
.rd-app #rdPlanningPanel .plan-table-scroll{height:auto;max-height:none;min-height:0}

@keyframes surplifyAutofill { from { opacity: .999; } to { opacity: 1; } }
#cloudPassword:-webkit-autofill { animation-name: surplifyAutofill; animation-duration: .01s; }
.rd-spending-summary { margin-top: 12px; text-align: left; }
.rd-allowance { display: block; font-size: 1.9rem; color: #3730a3; margin: 8px 0; }
.rd-allowance small { font-size: .9rem; font-weight: normal; }
.rd-spending-dialog { width: min(520px, 90vw); max-height: 85vh; overflow: auto; border: 0; border-radius: 16px; padding: 24px; }
