/* ---------- General ---------- */
:root{
  --blue:#003366;
  --blue-2:#002244;
  --light-bg:#f7f9fb;
  --card:#f0f4f8;
  --shadow:rgba(0,0,0,0.1);

  --pill-red-bg:#ffe5e5;
  --pill-red-fg:#b22222;
  --pill-green-bg:#e5ffe9;
  --pill-green-fg:#0a7f2e;
  --pill-yellow-bg:#fff8d5;
  --pill-yellow-fg:#9a7b00;
  --pill-blue-bg:#e5f0ff;
  --pill-blue-fg:#003366;

  --loan-light:#ff9aa2;      /* light red for loans */
  --freq-weekly:#6aa9ff;     /* light blue */
  --freq-monthly:#b59cff;    /* light purple */
  --freq-quarterly:#7bd88a;  /* light green */
  --freq-yearly:#777;        /* grey */
}

* { box-sizing: border-box; }

html, body {
  background: var(--light-bg);
  color: #000;
  font-family: Arial, sans-serif;
}

h1 {
  color: var(--blue);
  font-size: 2em;
  margin: 0 0 14px;
}

section {
  margin-bottom: 24px;
  padding: 14px;
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 2px 5px var(--shadow);
}

.hidden { display: none !important; }
.visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px; overflow: hidden;
  clip: rect(1px,1px,1px,1px); white-space: nowrap;
  border: 0; padding: 0; margin: -1px;
}

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
}
thead {
  background: var(--blue);
  color: #fff;
}
thead th {
  position: sticky;
  top: 0;
  padding: 6px 8px;           /* tighter header */
  border-bottom: 2px solid var(--blue-2);
  text-align: left;
  white-space: nowrap;        /* prevent header wrap */
}

tbody td {
  padding: 4px 6px;           /* compact rows */
  border-bottom: 1px solid #ccc;
  line-height: 1.15;
  vertical-align: middle;
}
tbody tr:nth-child(even) { background: #e8edf2; }
tfoot th {
  background: var(--blue);
  color: #fff;
  padding: 8px;
  text-align: left;
}

/* Bold content across all tables */
#budget-body td,
#universe-body td,
#savings-body td,
#loans-body td { font-weight: 700; }

/* Name columns: no wrap + ellipsis */
#universe-table td:first-child,
#savings-table td:first-child,
#loans-table td:first-child,
#budget-table td:first-child {
  white-space: nowrap;
  max-width: 20ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Smaller action buttons on lower tables to free space for names */
.actions-cell .btn { white-space: nowrap; }
#universe-table .actions-cell .btn,
#savings-table .actions-cell .btn,
#loans-table .actions-cell .btn { padding: 3px 6px; font-size: 0.9em; }

/* Actions cell alignment: Pay button to the far right */
.actions-cell {
  display: flex;
  align-items: center;
  gap: 4px;
}
.actions-cell .btn.pay { margin-left: auto; }

/* Loans table header in dark red */
#loans-table thead { background: darkred; }

/* ---------- Inputs ---------- */
input[type="number"],
input[type="text"],
input[type="date"],
select {
  padding: 5px;
  border: 1px solid #ccc;
  border-radius: 6px;
  width: 100%;
  font: inherit;
}

/* Compact inline select (for in-row editing) */
.inline-select {
  width: auto;
  min-width: 10ch;
}

/* ---------- Buttons ---------- */
button {
  padding: 5px 10px;
  margin: 1px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: bold;
}
button.btn.pay     { background: #228b22; color: #fff; }
button.btn.adjust  { background: var(--blue); color: #fff; }
button.btn.delete  { background: #b22222; color: #fff; }
button.btn.edit    { background: #87cefa; color: #000; }
button:disabled    { background: #aaa; cursor: not-allowed; }

/* Budget Day button (pink) */
.btn.budget-day { background: #ffc0cb; color: #7a0033; }

/* ---------- Pills ---------- */
.pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: bold;
  background: #ddd;
}
.pill.red    { background: var(--pill-red-bg);    color: var(--pill-red-fg); }
.pill.green  { background: var(--pill-green-bg);  color: var(--pill-green-fg); }
.pill.yellow { background: var(--pill-yellow-bg); color: var(--pill-yellow-fg); }
.pill.blue   { background: var(--pill-blue-bg);   color: var(--pill-blue-fg); }

/* ---------- Undo/Redo Buttons ---------- */
.undo-redo-container {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}
.undo-redo-container button { background: orange; color: #fff; }

/* ---------- Accounts Grid (Universe / Savings / Loans) ---------- */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}
.accounts-grid section h1 {
  font-size: 1.6em;
  white-space: nowrap;
  text-align: center;
  margin-bottom: 6px;
}
.section-total { margin: 2px 0 10px; font-weight: bold; }
.section-total.loans { color: darkred; }

/* ---------- Budget table wrapper ---------- */
.budget-table-wrap { overflow-x: auto; }

/* ---------- Budget Totals banner (values only) ---------- */
#budget-totals-banner {
  position: relative;
  height: 24px;
  margin: 6px 0 4px 0;
}
#budget-totals-banner .tot {
  position: absolute; /* left offsets are computed by JS (if used) */
  top: 0;
  font-weight: bold;
  white-space: nowrap;
}

/* ---------- Frequency colors (light/pastel) ---------- */
tr.loan-row td,
tr.loan-row input,
tr.loan-row select { color: var(--loan-light) !important; }  /* loans override */

tr.freq-weekly td,
tr.freq-weekly input,
tr.freq-weekly select { color: var(--freq-weekly); }

tr.freq-monthly td,
tr.freq-monthly input,
tr.freq-monthly select { color: var(--freq-monthly); }

tr.freq-quarterly td,
tr.freq-quarterly input,
tr.freq-quarterly select { color: var(--freq-quarterly); }

tr.freq-yearly td,
tr.freq-yearly input,
tr.freq-yearly select { color: var(--freq-yearly); }

/* ---------- Toolbar (single-line) ---------- */
.budget-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;  /* spread items */
  gap: 8px;
  padding: 6px 8px;
  white-space: nowrap;             /* NEVER wrap */
  overflow: hidden;                /* stay on one line */
  border-radius: 8px;
}
.budget-toolbar .toolbar-item {
  flex: 0 0 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 2px; /* tight internal spacing for grouped items */
}

/* Hug the "Total Borrowed" pill up to the Borrow button */
.budget-toolbar .toolbar-item button[onclick*="showBudgetForm('borrow')"]{
  margin-right: 0;
}
.budget-toolbar .toolbar-item button[onclick*="showBudgetForm('borrow')"] + .pill{
  margin-left: 0;
}


/* Buffer trio kept together */
.buffer-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;                      /* very tight spacing between linked elements */
}
.buffer-chip .label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--pill-yellow-bg);
  color: #000;
  padding: 2px 6px;              /* slimmer pill so it hugs the input */
  border-radius: 6px;
  border: 1px solid #cfcfcf;
  font-weight: 400;
}
#buffer-weeks {
  width: 4ch;              /* ~3 digits + padding */
  min-width: 3.5ch;
  padding: 3px 8px;
  height: auto;            /* let it match button height */
  border-radius: 6px;
  border: 1px solid #cfcfcf;
  text-align: right;
}
.target-dollar {
  background: #ddc6ff;     /* slightly deeper purple highlight */
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 700;
  display: inline-block;
  min-width: 6ch;          /* tighter, still enough for large numbers */
  text-align: right;
}
.buffer-percent {
  font-weight: 700;
  margin-left: 2px;
}

/* Sim Date chip */
.sim-date-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sim-date-chip .label {
  background: var(--pill-blue-bg);
  color: var(--pill-blue-fg);
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 700;
}
.sim-date-chip input[type="date"] {
  width: auto;
}

/* ---------- Universe controls row ---------- */
.section-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#universe-deposit {
  width: 9ch;     /* small box for $ amount */
  text-align: right;
}

/* ---------- Regular Income dropdown panel ---------- */
.dropdown summary.btn {
  list-style: none;  /* hide default triangle */
}
.dropdown summary::-webkit-details-marker { display: none; }

.dropdown-panel {
  width: min(1200px, 96vw);
  margin: 10px auto;
  padding: 12px;
  background: #fff;
  border: 1px solid #d9e2ef;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  color: #000;
}
#income-table thead th {
  position: static;
  background: #f3f6fb;
  color: #222;
  border-bottom: 1px solid #d9e2ef;
}
#income-table tbody td { background: #fff; }

/* Inputs inside the income panel */
.ri-input { width: 22ch; }
.ri-source { width: 28ch; }
.ri-amount-wrap { display: inline-flex; align-items: center; gap: 4px; }
.ri-dollar-prefix { font-weight: 800; }
.ri-freq-wrap { display: inline-flex; align-items: center; gap: 6px; }
.ri-select, .ri-monthly-mode { width: auto; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(28px, 48px));
  gap: 4px;
  justify-content: center;
}

/* ---------- Misc ---------- */
.muted { color: #666; }

/* Keep the toolbar readable on narrow screens without wrapping */
@media (max-width: 1100px) {
  .budget-toolbar { gap: 6px; font-size: clamp(12px, 1.4vw, 14px); }
  .ri-input { width: 20ch; }
  .ri-source { width: 24ch; }
}
@media (max-width: 860px) {
  .budget-toolbar { gap: 4px; font-size: clamp(11px, 1.2vw, 13px); }
}



/* === Restored baseline fixes (20250903-221133) === */
#income-details > summary.btn {
  background: #c8e6c9;
  color: #0b3d0b;
  border-color: #9ccc9c;
}

/* Center the Regular Income dropdown */
#regular-income-panel {
  position: fixed !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  top: clamp(72px, 14vh, 160px) !important;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 70vh;
  overflow: auto;
}

/* Done button to the right in income panel */
#regular-income-panel #ri-done { margin-left: auto; }

/* Pay to the left of Edit in budget actions */
#budget-table .actions-cell .btn.pay   { margin-left: 0 !important; order: 0; }
#budget-table .actions-cell .btn.edit  { order: 1; }
#budget-table .actions-cell .btn.delete{ order: 2; }

/* Budget toolbar Undo/Redo on the far right */
#budget-undo-btn { margin-left: auto; order: 999; }
#budget-redo-btn { order: 1000; }

/* Name input sizing: exactly 20 characters */
#universe-table td:first-child input[type="text"],
#savings-table  td:first-child input[type="text"],
#loans-table    td:first-child input[type="text"] {
  width: 20ch;
  max-width: 20ch;
  font-size: 0.95em;
  box-sizing: content-box;
}

/* Loans & Liabilities account text -> dark red (not linked to budget light red) */
#loans-table tr.loan-row td,
#loans-table tr.loan-row input,
#loans-table tr.loan-row select {
  color: darkred !important;
}

/* Right-justify undo/redo for account sections */
#universe-section .undo-redo-container,
#savings-section  .undo-redo-container,
#loans-section    .undo-redo-container {
  justify-content: flex-end;
}


/* === Independent table scrollbars (SAFE) === */
:root { --row-h: 30px; } /* approximate single-row height */
.table-scroll {
  height: calc(var(--rows, 10) * var(--row-h));
  overflow-y: scroll;  /* always-visible track */
  overflow-x: hidden;
  scrollbar-gutter: stable both-edges;
  padding-right: 6px;
}
.budget-scroll  { --rows: 14; }  /* Budget */
.account-scroll { --rows: 8;  }  /* Universe, Savings, Loans */



/* === Sticky header compatibility (SAFE) === */
.table-scroll table { border-collapse: separate; border-spacing: 0; }
/* Keep header on top and themed */
.table-scroll thead th {
  position: sticky; top: 0; z-index: 5;
  background: inherit; color: inherit;
}
.table-scroll thead { position: sticky; top: 0; z-index: 60; }



/* === Account tables: fit beside scrollbars (SAFE) === */
#universe-table, #savings-table, #loans-table { table-layout: fixed; width: 100%; }

/* Name column: one line + ellipsis */
#universe-table th:nth-child(1), #universe-table td:nth-child(1),
#savings-table th:nth-child(1), #savings-table td:nth-child(1),
#loans-table   th:nth-child(1), #loans-table   td:nth-child(1) {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Balance column */
#universe-table th:nth-child(2), #universe-table td:nth-child(2),
#savings-table th:nth-child(2), #savings-table td:nth-child(2),
#loans-table   th:nth-child(2), #loans-table   td:nth-child(2) { width: 10ch; white-space: nowrap; }
#universe-table td:nth-child(2) input[type="number"],
#savings-table td:nth-child(2) input[type="number"],
#loans-table   td:nth-child(2) input[type="number"] { max-width: 10ch; text-align: right; }

/* Percent column */
#universe-table th:nth-child(3), #universe-table td:nth-child(3),
#savings-table th:nth-child(3), #savings-table td:nth-child(3),
#loans-table   th:nth-child(3), #loans-table   td:nth-child(3) { width: 6ch; white-space: nowrap; }
#universe-table td:nth-child(3) input[type="number"],
#savings-table td:nth-child(3) input[type="number"],
#loans-table   td:nth-child(3) input[type="number"] { max-width: 5ch; text-align: right; }

/* Actions column */
#universe-table th:last-child, #universe-table td:last-child,
#savings-table th:last-child, #savings-table td:last-child,
#loans-table   th:last-child, #loans-table   td:last-child { width: 160px; min-width: 160px; }



/* === Budget toolbar: compact single-line (toolbar-only) === */
.budget-toolbar { gap: 6px; font-size: 0.92rem; flex-wrap: nowrap; }
.budget-toolbar .btn, .budget-toolbar .pill { padding: 3px 8px; }
.budget-toolbar .toolbar-item { flex: 0 1 auto; min-width: 0; }
.budget-toolbar details > summary.btn { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; }




/* ===================== Budget History Panel & Table ===================== */
#history-details[open] > #history-panel {
  display: block;
}
#history-panel {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: clamp(72px, 14vh, 160px);
  width: min(1100px, 96vw);
  max-height: 85vh;
  padding: 14px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  z-index: 1200;
  overflow: hidden;
}
#history-panel .panel-title {
  margin: 0 0 10px 0;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
}
/* Scroll container for history table: 6 visible rows */
#history-section { overflow: visible !important; }
#history-section .table-scroll {
  display: block !important;
  overflow-y: scroll !important;
  overflow-x: hidden !important;
  scrollbar-gutter: stable;
  height: calc(6 * var(--row-h, 42px)) !important;
}
#history-section .table-scroll thead th {
  position: sticky !important;
  top: 0;
  z-index: 60;
}
/* Dark green header bar with white text */
#history-table thead th {
  background: #1b5e20;
  color: #ffffff;
}
/* Light grey Budget History button */
.btn.history-btn {
  background: #e6e6e6;
  color: #333333;
  border-color: #cfcfcf;
}


/* ===================== Budget Day Panel (Centered) ===================== */
#budget-day-details[open] > #budget-day-panel { display: block; }
/* === Budget Day: width fixes (scoped) === */
#budget-day-panel #regular-budget-day.inline-select { 
  width: auto !important; 
  min-width: 12.1ch; 
  max-width: 13.2ch;
}
#budget-day-panel #sim-date { 
  width: 16ch; 
}

/* === Budget Day (panel-scoped) updates === */
#budget-day-panel #regular-budget-day.inline-select { width: auto; min-width: 12.1ch; } /* fits "Wednesdays" */
#budget-day-panel .no-wrap { flex-wrap: nowrap !important; }
#budget-day-panel input[type="date"] { width: 13ch; } /* slightly wider */
#budget-day-panel .test-note { color: #c00; font-style: normal; margin-left: 6px; white-space: nowrap; }
#budget-day-panel #sim-reset.btn { background: #e53935; color: #fff; } /* red Reset */
#budget-day-panel #sim-reset.btn:hover { filter: brightness(0.95); }

/* Next Budget Day pill styles */
#budget-day-panel .pill { padding: 4px 8px; border-radius: 999px; display:inline-block; font-weight:600; }
#budget-day-panel .pill.green { background:#d9f7d9; }
#budget-day-panel .pill.mauve { background:#f0d9f7; }

/* === Budget Day: highlight selected weekday and date width tweak === */
#budget-day-panel #regular-budget-day,
#budget-day-panel .yellow-pick {
  background: #fff6a6; /* soft yellow */
}
#budget-day-panel input[type="date"] {
  width: 12ch; /* slightly wider */
}

#budget-day-panel {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: clamp(72px, 14vh, 160px);
  width: min( 792px, 96vw);
  max-height: 70vh;
  padding: 14px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  z-index: 1200;
  overflow: auto;
}


/* === Alignment Guardrails — Universe/Savings/Loans ONLY (RESTORE) === */
/* DO NOT REMOVE: Restores approved left alignment, name column width, and scrollbar safety. */

#universe-table,
#savings-table,
#loans-table {
  table-layout: fixed;
}

/* Scroll containers: right-only gutter, fixed vertical scroll, no horizontal scroll,
   and extra padding for overlay scrollbars. */
.table-scroll.account-scroll,
.account-scroll {
  display: flow-root;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-gutter: stable !important; /* reserve space only on the right */
  padding-right: 32px; /* overlay scrollbar safety per approval */
}

/* Sticky header cells */
#universe-table thead th,
#savings-table thead th,
#loans-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}

/* First column (Name): flush-left + width target */
#universe-table thead th:first-child,
#savings-table thead th:first-child,
#loans-table thead th:first-child,
#universe-table tbody td:first-child,
#savings-table tbody td:first-child,
#loans-table tbody td:first-child {
  padding-left: 0 !important;
  width: 22ch;
  white-space: nowrap;
  text-overflow: clip;
  overflow: visible;
  font-size: 0.95em; /* approved ~5% reduction */
}

/* Inline edit input inside Name column: exact 20ch, border-box */
#universe-table tbody td:first-child input[type="text"], 
#savings-table tbody td:first-child input[type="text"], 
#loans-table tbody td:first-child input[type="text"] {
  width: 20ch;
  box-sizing: border-box;
  font-size: 0.95em; /* match cell text */
}

/* Actions column: extra right padding so Delete never sits under scrollbar */
#universe-table thead th:last-child,
#savings-table thead th:last-child,
#loans-table thead th:last-child,
#universe-table tbody td:last-child,
#savings-table tbody td:last-child,
#loans-table tbody td:last-child {
  padding-right: 44px !important; /* approved value */
}



/* Regular Income minimal reinstate (08-09-2025_1603-AEST) */
.ri-panel-title{ color:#0b3d0b; font-weight:800; margin:0 0 8px 0; }
.ri-ipd-wrap{ display:inline-flex; align-items:center; gap:6px; background:var(--pill-green-bg); border:1px solid #9ccc9c; border-radius:6px; padding:4px 8px; }


/* Regular Income tweaks (08-09-2025_1634-AEST) */
.ri-break{ flex-basis:100%; height:0; }
.ri-source, .ri-amount-wrap{ display:flex; flex-direction:column; align-items:center; text-align:center; }
.ri-amount-wrap{ gap:4px; }
.ri-source{ width:28ch; } .ri-amount-wrap{ width:22ch; }


/* Regular Income dynamic & currency (08-09-2025_1704-AEST) */
.ri-source, .ri-amount-wrap{ display:flex; flex-direction:column; align-items:center; text-align:center; }
.ri-source{ width:28ch; } .ri-amount-wrap{ width:22ch; }


/* Regular Income width reduction (-20%) 08-09-2025_1726-AEST */
.ri-source{ width: calc(28ch * 0.8) !important; }
.ri-amount-wrap{ width: calc(22ch * 0.8) !important; }

/* Done button orange 08-09-2025_1726-AEST */
#regular-income-panel #ri-done{ background: orange !important; color:#fff !important; }


/* Regular Income panel width only — set to 65% (08-09-2025_1857-AEST) */
#regular-income-panel {
  max-width: 65%;
  margin-left: auto;
  margin-right: auto;
}

/* === Budget Day: compact weekday select width override === */
#budget-day-panel #regular-budget-day.inline-select {
  width: auto !important;
  min-width: 14.3ch;
  max-width: 14.3ch;
}

/* === Budget Day: highlight bands === */
#budget-day-panel .today-band {
  background: #d9f7d9;
  border-radius: 10px;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
#budget-day-panel .test-band {
  background: #f7d9ea;
  border-radius: 10px;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}



/* ===== Budget-only: center 'Actions' to 'Edit' (2025-09-25) ===== */
#budget-table th:nth-child(12){
  text-align: center;              /* header text aligns with middle column */
}
#budget-table td:nth-child(12){
  display: grid;
  grid-auto-flow: column;          /* place buttons left-to-right in columns */
  grid-auto-columns: var(--action-btn-w, 64px);  /* equal widths */
  justify-content: center;         /* center the 3-col grid in the cell */
  column-gap: 8px;
}
#budget-table td:nth-child(12) .btn{
  width: var(--action-btn-w, 64px);    /* same width for Pay, Edit, Delete */
  text-align: center;
  padding-left: 0; padding-right: 0;   /* keep widths equal */
}


/* ===== Budget-only: +5% gap between Last Paid (col 10) and Next Due (col 11) — 2025-09-25 ===== */
#budget-table th:nth-child(10),
#budget-table td:nth-child(10){
  padding-right: 14px;  /* adds ~8px vs common ~6px base; ~5% visual bump */
}

/* === CONSOLIDATED: Savings mains button normalization (v16) === */
/* 1) Open/Close buttons on all mains -> MI look (0.86em) */
#savings-table .actions-cell .btn,
#savings-table .actions-cell .btn.open,
#savings-table .actions-cell .btn.close {
  font-family: Arial, sans-serif !important;
  font-size: 0.86em !important;  /* MI-sized */
  font-weight: 700 !important;
  line-height: 1.15 !important;
}

/* 2) "+ Add Sub" light-grey pill across all mains (target v16 DOM) */
.savings-subpanel .subpanel > div:nth-of-type(3) > .btn.edit {
  background: #e6e6e6 !important;
  color: #333333 !important;
  border: 1px solid #cfcfcf !important;
  border-radius: 8px !important;
  padding: 4px 10px !important;
  font-family: Arial, sans-serif !important;
  font-size: 0.86em !important;
  font-weight: 700 !important;
  line-height: 1.15 !important;
  box-shadow: 0 1px 1px rgba(0,0,0,0.05) !important;
}
/* Fallback coverage inside the subpanel */
.savings-subpanel .subpanel .btn.edit {
  background: #e6e6e6 !important;
  color: #333333 !important;
  border: 1px solid #cfcfcf !important;
  border-radius: 8px !important;
  padding: 4px 10px !important;
  font-family: Arial, sans-serif !important;
  font-size: 0.86em !important;
  font-weight: 700 !important;
  line-height: 1.15 !important;
  box-shadow: 0 1px 1px rgba(0,0,0,0.05) !important;
}

/* === Additions for Savings mains === */
/* Hide 'Breakdown For ...' headings in MI subpanels */
.savings-subpanel .subpanel h1,
.savings-subpanel .subpanel h2,
.savings-subpanel .subpanel h3,
.savings-subpanel .subpanel h4,
.savings-subpanel .subpanel h5,
.savings-subpanel .subpanel .panel-title,
.savings-subpanel .subpanel .breakdown-title { display: none !important; }
/* Yellow highlight while a main is open */
#savings-table tr.mi-open > td { background: #fff6a6 !important; }

/* ======================================================================
 Appended: 28-10-2025 16:27 AEDT
 This uses CSS :has() to highlight the main Savings row when its
 subpanel is the immediate next <tr>.
 Covers both engines:
   - v16 engine:   <tr class="savings-subpanel" data-main="...">
   - legacy MI:    <tr class="misubs-row">
====================================================================== */


/* HFA: Main Investment highlight (class-based, CSS-only; Appended 28-10-2025 16:36 AEDT) */
#savings-body > tr.__mi-open,
#savings-body > tr.__mi-open > td {
  background: #fff8d5 !important;
  transition: background-color .2s ease;
}
/* END HFA HIGHLIGHT */


/* ===== Transfer / Recurring overlays ===== */
.xf-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}
.xf-overlay.hidden{ display:none !important; }
.xf-panel{
  background:#fff;
  min-width: min(940px, 96vw);
  max-height: 90vh;
  overflow:auto;
  border-radius:14px;
  box-shadow:0 12px 30px rgba(0,0,0,.25);
  padding:14px 16px 20px;
}
.xf-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
.tf-body .tf-columns{ display:grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tf-list{
  max-height: calc(18 * 28px);
  overflow-y:auto;
  background:#f9fafb;
  border:1px solid #dbe3ef;
  border-radius:10px;
  padding:6px;
}
.tf-row{
  display:flex;
  align-items:center;
  gap:8px;
  padding:4px 6px;
  border-bottom:1px solid rgba(0,0,0,.02);
  border-radius:6px;
}
.tf-main-row{ font-weight:700; pointer-events:none; }
.tf-row.cat-U{ background:rgba(245,243,255,.85); }
.tf-row.cat-B{ background:rgba(231,240,255,.85); }
.tf-row.cat-I{ background:rgba(236,253,245,.85); }
.tf-row.cat-S{ background:rgba(255,251,235,.9); }
.tf-amount{ display:flex; gap:8px; align-items:center; margin-top:12px; border-top:1px solid #e5e7eb; padding-top:10px; }
.tf-recurring{ gap:10px; align-items:center; }
.rt-list{
  display:flex;
  flex-direction:column;
  gap:6px;
  max-height: calc(15 * 34px);
  overflow-y:auto;
}
.rt-row{
  display:grid;
  grid-template-columns: 110px 1fr 1fr 90px 110px 70px;
  gap:6px;
  align-items:center;
  background:#f3f4f6;
  padding:4px 6px;
  border-radius:6px;
}
.rt-row.rt-header{ background:#eef0f4; font-weight:700; }
.rt-row.cat-U{ background:rgba(245,243,255,.8); }
.rt-row.cat-B{ background:rgba(231,240,255,.8); }
.rt-row.cat-I{ background:rgba(236,253,245,.8); }
.rt-row.cat-S{ background:rgba(255,251,235,.85); }
@media (max-width:900px){
  .tf-body .tf-columns{ grid-template-columns: 1fr; }
  .xf-panel{ min-width: min(96vw, 900px); }
  .rt-row{ grid-template-columns: 90px 1fr 1fr 70px 100px 60px; }
}

/* === 01-11-2025: transfer tidy 2 (right amounts, deeper lists, yellow recurring) === */

/* right-align ALL transfer amounts (main + subs) */
.tf-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tf-row .tf-name {
  flex: 1 1 auto;
}
.tf-row .tf-amt {
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}

/* make the account lists ~10% deeper than last time */
.tf-list {
  max-height: calc(13 * 28px);
}

/* keep the panel narrower from previous step */
.xf-panel {
  min-width: min(660px, 96vw);
  max-height: 95vh;
}

/* force Make Recurring button to yellow */
.tf-amount .btn.edit:last-child {
  background: #facc15 !important;
  border-color: #facc15 !important;
  color: #1f2937 !important;
}

/* 02-11-2025_1725-AEDT — Budget toolbar small buttons aligned */
.budget-toolbar #income-details > summary,
.budget-toolbar #budget-day-details > summary.btn.budget-day,
.budget-toolbar .budget-history-dropdown > summary.btn.history-btn,
.budget-toolbar #networth-details > summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px !important;       /* match toolbar compact buttons */
  border-radius: 8px !important;
  font-size: 0.92rem !important;
  line-height: 1.1;
  white-space: nowrap;
}

/* tighten Net Worth amount so pill isn’t overly wide */
.budget-toolbar #net-worth-amount {
  min-width: 6.2ch !important;  /* was 11ch */
  padding: 0 2px !important;
}

/* 02-11-2025_1934-AEDT — SAVINGS-REGRESSION-FIX */
#savings-body td:nth-child(2)::before {
  content: none !important;
}
#savings-section .undo-redo-container {
  display: none !important;
}
#savings-section button[onclick="openRecurringTransfers()"],
#savings-section .btn.recurring-transfers {
  background: #facc15 !important;
  border-color: #facc15 !important;
  color: #1f2937 !important;
}
#tf-amount {
  width: 20% !important;
  flex: 0 0 20% !important;
}


/* 04-11-2025_AEDT — TOTAL-BORROWED-PILL align with toolbar buttons */
.budget-toolbar .pill.red {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;           /* match Buffer Wks label / toolbar pills */
  border-radius: 6px;          /* same corner radius as toolbar buttons */
  border: 1px solid #cfcfcf;   /* subtle edge to match Budget History */
  font-weight: 700;
}

.btn.budget-day { background: #8ecaff; color: #003366; }

/* 04-11-2025_AEDT — Toolbar equal spacing + inner gaps (spacing only) */
.budget-toolbar {
  justify-content: space-evenly;
}

/* Extra room between Borrow button and Total Borrowed pill */
.budget-toolbar .toolbar-item > .pill.red {
  margin-left: 12px;
}

/* Space out the 4 Buffer Wks elements (label, number, $, %) */
.budget-toolbar .buffer-chip {
  gap: 10px;
}


/* Income Bank visual tweaks (layout fix) */
#ri-bank-choice-btn,
.bank-choice-btn {
  background: #ffeb3b !important;
  color: #000 !important;
  border-color: #f0c000 !important;
}

#ri-bank-panel {
  display: none;
}


.ri-bank-header{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.ri-bank-actions{
  display:flex;
  gap:6px;
}

.btn-light-blue{
  background:#cfe9ff;
  border-color:#9ec5ff;
  color:#000;
}

.btn-light-red{
  background:#ffd6d6;
  border-color:#f5a3a3;
  color:#000;
}


/* Income Bank account list layout */
#ri-bank-panel #ri-bank-list{
  margin-top: 8px;
}

#ri-bank-panel .ri-bank-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.9rem;
}

#ri-bank-panel .ri-bank-left{
  display: flex;
  align-items: center;
  gap: 6px;
}

#ri-bank-panel .ri-bank-checkbox{
  margin: 0;
}

#ri-bank-panel .ri-bank-name{
  white-space: nowrap;
}

#ri-bank-panel .ri-bank-amount{
  margin-left: auto;
}



/* === HUNT Budget – Frequency pastel bands with dark text (Budget section) === */

/* Daily: grey on grey */
#budget-body tr.freq-daily td,
#budget-body tr[data-freq="daily"] td {
  background-color: #e5e7eb;
  color: #374151 !important;
}

/* Weekly: blue on blue */
#budget-body tr.freq-weekly td,
#budget-body tr[data-freq="weekly"] td {
  background-color: #e0f2fe;
  color: #1d4ed8 !important;
}

/* Fortnightly: purple on purple */
#budget-body tr.freq-fortnightly td,
#budget-body tr[data-freq="fortnightly"] td {
  background-color: #f3e8ff;
  color: #6d28d9 !important;
}

/* Monthly: yellow on yellow */
#budget-body tr.freq-monthly td,
#budget-body tr[data-freq="monthly"] td {
  background-color: #fef9c3;
  color: #ca8a04 !important;
}

/* Quarterly: green on green */
#budget-body tr.freq-quarterly td,
#budget-body tr[data-freq="quarterly"] td {
  background-color: #dcfce7;
  color: #047857 !important;
}

/* Custom: orange on orange */
#budget-body tr.freq-custom td,
#budget-body tr[data-freq="custom"] td {
  background-color: #ffedd5;
  color: #c05621 !important;
}

/* Yearly: black on light blue */
#budget-body tr.freq-yearly td,
#budget-body tr[data-freq="yearly"] td {
  background-color: #e0f2fe;      /* light blue */
  color: #000000 !important;      /* black text */
}



/* Borrow From Budget / loan rows: keep background, dark red text */
#budget-body tr.loan-row td,
#budget-body tr.loan-row input,
#budget-body tr.loan-row select {
  color: #7f1d1d !important;
}



/* === Strong Yearly override: black text on light blue (wins over any older rules) === */
#budget-body tr:not(.loan-row)[data-freq="yearly"],
#budget-body tr:not(.loan-row).freq-yearly,
#budget-body tr:not(.loan-row)[data-freq="yearly"] td,
#budget-body tr:not(.loan-row).freq-yearly td {
  background-color: #e0f2fe;      /* light blue */
  color: #000000 !important;      /* black text */
}


/* Universe available-to-deposit hint row */
.universe-available-row {
  margin-top: 4px;
}

.universe-available-hint {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}



/* === BUFFER WEEKS: match toolbar button height exactly (SAFE) === */
.budget-toolbar .buffer-chip,
.budget-toolbar .buffer-chip .pill.yellow {
  display: inline-flex;
  align-items: center;
}

.budget-toolbar .buffer-chip .pill.yellow {
  padding: 3px 8px !important;   /* exact toolbar button padding */
  line-height: 1.1 !important;
  font-size: 0.92rem !important;
  font-weight: 400 !important;   /* unbold */
  border-radius: 8px !important; /* same as toolbar buttons */
}
/* ===== Universe: Deposit $ rocker — remove any extra chevron glyphs (v2) =====
   Some global button styles add an ::after chevron. The deposit rocker buttons
   must be ONLY ▲ / ▼ with no extra right-pointing triangles. */
button.u-deposit-rocker::after,
button.u-deposit-rocker::before,
.u-deposit-rocker::after,
.u-deposit-rocker::before{
  content: none !important;
}


/* --- Adjust column cleanup: remove zipper look --- */
.adj-rocker-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.adj-rocker-btn {
  background: none !important;
  border: none !important;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1;
  color: inherit;
  cursor: pointer;
}

.adj-rocker-btn:hover {
  opacity: 0.75;
}
