/* budget.css — Make a Budget worksheet page
   Light "worksheet" form on cream, dark teal-ink summary panel on the right.
   Reuses the shared tokens from styles.css (--teal, --gold, --cream, --ink ...). */

/* ── hero tweaks ─────────────────────────────────────────── */
.budget-hero { padding: 60px 0 36px; }
.budget-hero .calc-hub-head h1 { max-width: 12ch; }
.budget-hero .lede { max-width: 460px; }

/* ── layout shell ────────────────────────────────────────── */
.budget { padding: 8px 0 96px; }
.budget-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 36px;
  align-items: start;
}
.budget-main { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.budget-aside { position: sticky; top: 84px; }

/* ── worksheet cards ─────────────────────────────────────── */
.b-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 24px 24px;
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 14px 30px -24px rgba(60,50,30,.4);
}
.b-card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin-bottom: 4px;
}
.b-card-titles { display: flex; flex-direction: column; gap: 3px; }
.b-card-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--teal-deep);
}
.b-card-title { font-family: "Instrument Serif", serif; font-size: 27px; line-height: 1; color: var(--ink); }
.b-card-sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.b-card-total {
  font-family: "Instrument Serif", serif; font-size: 26px; color: var(--ink);
  white-space: nowrap;
}
.b-card-total .per { font-size: 13px; color: var(--ink-3); font-style: italic; font-family: "Manrope"; }

/* ── line-item rows ──────────────────────────────────────── */
.b-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.b-row { display: grid; grid-template-columns: minmax(0,1fr) 152px 30px; gap: 10px; align-items: center; }
.b-label {
  font-family: "Manrope", sans-serif; font-size: 14.5px; color: var(--ink);
  background: transparent; border: 0; border-bottom: 1px solid transparent;
  padding: 7px 2px; width: 100%; transition: border-color .15s;
}
.b-label::placeholder { color: var(--ink-3); }
.b-label:hover { border-bottom-color: var(--line); }
.b-label:focus { outline: none; border-bottom-color: var(--teal); }
.b-amount {
  display: flex; align-items: center; gap: 4px;
  background: var(--cream); border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 10px; transition: border-color .15s, background .15s;
}
.b-amount:focus-within { border-color: var(--teal); background: var(--white); }
.b-amount .cur { color: var(--ink-3); font-size: 14px; }
.b-amount input {
  flex: 1; min-width: 0; width: 100%; text-align: right;
  border: 0; background: transparent; outline: none;
  font-family: "Manrope", sans-serif; font-size: 15px; font-weight: 600; color: var(--ink);
}
.b-amount .per { color: var(--ink-3); font-size: 11px; font-style: italic; }
.b-remove {
  display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 8px; border: 1px solid transparent; background: transparent;
  color: var(--ink-3); font-size: 20px; line-height: 1; cursor: pointer;
  transition: all .15s;
}
.b-remove:hover { background: #f6e7e3; color: #b54343; border-color: #eccfc8; }

.b-add {
  margin-top: 14px;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  background: transparent; border: 1px dashed var(--line); border-radius: 10px;
  padding: 9px 14px; cursor: pointer;
  font-family: "Manrope", sans-serif; font-size: 13px; font-weight: 600; color: var(--teal-deep);
  transition: all .15s;
}
.b-add:hover { border-color: var(--teal); background: #f3f8f7; }

/* ── category cards ──────────────────────────────────────── */
.cat { border: 1px solid var(--line); border-radius: 14px; background: var(--white); overflow: hidden; }
.cat + .cat { margin-top: 12px; }
.cat-head {
  display: grid; grid-template-columns: 22px minmax(0,1fr) auto; gap: 12px; align-items: center;
  padding: 15px 18px; cursor: pointer; user-select: none;
}
.cat-head:hover { background: #fcf9f1; }
.cat-caret {
  width: 22px; height: 22px; display: grid; place-items: center; color: var(--ink-3);
  transition: transform .2s;
}
.cat.open .cat-caret { transform: rotate(90deg); }
.cat-id { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cat-name {
  font-family: "Instrument Serif", serif; font-size: 21px; line-height: 1.05; color: var(--ink);
  background: transparent; border: 0; padding: 1px 2px; border-radius: 6px; width: 100%;
  border-bottom: 1px solid transparent;
}
.cat-name:focus { outline: none; border-bottom-color: var(--teal); }
.cat-count { font-size: 11.5px; color: var(--ink-3); padding-left: 2px; }
.cat-right { display: flex; align-items: center; gap: 14px; }
.cat-total { font-family: "Instrument Serif", serif; font-size: 22px; color: var(--ink); white-space: nowrap; }

/* need / want toggle */
.seg2 { display: inline-flex; background: var(--cream); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.seg2 button {
  border: 0; background: transparent; cursor: pointer;
  font-family: "Manrope", sans-serif; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-3); padding: 4px 11px; border-radius: 999px;
  transition: all .15s;
}
.seg2 button.on.need { background: var(--teal); color: #fff; }
.seg2 button.on.want { background: var(--gold-deep); color: #fff; }

.cat-body { padding: 4px 18px 18px; border-top: 1px solid var(--line); }
.cat-tools { display: flex; justify-content: flex-end; margin-top: 12px; }
.cat-delete {
  background: transparent; border: 0; color: var(--ink-3); font-size: 12px; font-weight: 600;
  cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.cat-delete:hover { color: #b54343; }

.cat-add-wrap { margin-top: 14px; }

/* ── allocation ──────────────────────────────────────────── */
.alloc-empty {
  font-size: 14px; color: var(--ink-2); line-height: 1.55;
  background: var(--cream); border: 1px dashed var(--line); border-radius: 12px; padding: 18px 20px;
  margin-top: 14px;
}
.alloc-empty strong { color: var(--ink); }
.alloc-cash {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: #f1f7f6; border: 1px solid var(--teal-soft); border-radius: 14px;
  padding: 15px 18px; margin: 16px 0 4px;
}
.alloc-cash.warn { background: #fbf0ec; border-color: #eccfc8; }
.alloc-cash-l { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.alloc-cash-name { display: flex; align-items: center; gap: 9px; font-size: 14.5px; font-weight: 700; color: var(--ink); }
.alloc-cash-note { font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }
.alloc-cash.warn .alloc-cash-note { color: #b54343; font-weight: 600; }
.alloc-cash-v { text-align: right; white-space: nowrap; }
.alloc-cash-v .money { font-family: "Instrument Serif", serif; font-size: 30px; line-height: 1; color: var(--teal-deep); }
.alloc-cash.warn .alloc-cash-v .money { color: #b54343; }
.alloc-cash-v .pct { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }

.alloc-rows { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }

/* Cash row — the computed residual; looks like a dial but greyed + read-only */
.alloc-row--cash { margin-top: 4px; padding-top: 18px; border-top: 1px dashed var(--line); }
.alloc-row--cash .alloc-name { color: var(--ink-2); }
.alloc-tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
  color: var(--ink-3); background: var(--cream-2); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 999px; margin-left: 9px;
}
.alloc-input.is-static { background: var(--cream-2); border-style: dashed; }
.alloc-input.is-static input { color: var(--ink-2); cursor: default; }
.alloc-input.is-static .pct { color: var(--ink-3); }
.b-range--cash { opacity: .7; cursor: default; }
.b-range--cash::-webkit-slider-thumb { background: var(--ink-3); box-shadow: none; cursor: default; }
.b-range--cash::-moz-range-thumb { background: var(--ink-3); box-shadow: none; cursor: default; }
.alloc-cash-hint { font-size: 12px; color: var(--ink-3); margin-top: 9px; line-height: 1.45; }
.alloc-cash-hint.over { color: #b54343; font-weight: 600; }
.alloc-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
.alloc-row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.alloc-name { display: flex; align-items: center; gap: 9px; font-size: 14.5px; font-weight: 600; color: var(--ink); min-width: 0; white-space: nowrap; }
.alloc-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.alloc-val { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; flex: none; }
.alloc-val .money { font-family: "Instrument Serif", serif; font-size: 19px; color: var(--ink); }
.alloc-val .pct { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

.alloc-input {
  display: flex; align-items: center; gap: 6px; flex: none;
  background: var(--cream); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
  transition: border-color .15s, background .15s;
}
.alloc-input:focus-within { border-color: var(--teal); background: var(--white); }
.alloc-input .cur { color: var(--ink-3); font-size: 14px; }
.alloc-input input {
  width: 66px; text-align: right; border: 0; background: transparent; outline: none;
  font-family: "Manrope", sans-serif; font-size: 15px; font-weight: 700; color: var(--ink);
}
.alloc-input .pct {
  font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums;
  min-width: 34px; text-align: right; padding-left: 2px; border-left: 1px solid var(--line);
}

.b-range { -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 999px; background: var(--line); outline: none; }
.b-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 19px; height: 19px; border-radius: 50%;
  background: var(--teal); border: 3px solid var(--white); box-shadow: 0 2px 6px -1px rgba(43,107,102,.5); cursor: pointer;
}
.b-range::-moz-range-thumb {
  width: 19px; height: 19px; border-radius: 50%; background: var(--teal);
  border: 3px solid var(--white); box-shadow: 0 2px 6px -1px rgba(43,107,102,.5); cursor: pointer;
}
.alloc-buffer {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}
.alloc-buffer .k { font-size: 13px; color: var(--ink-2); }
.alloc-buffer .k small { display: block; color: var(--ink-3); font-size: 11.5px; margin-top: 2px; }
.alloc-buffer .v { font-family: "Instrument Serif", serif; font-size: 22px; color: var(--ink); white-space: nowrap; }
.alloc-buffer.over .v { color: #b54343; }
.alloc-over-note { font-size: 12px; color: #b54343; margin-top: 8px; font-weight: 600; }

/* ── summary panel (dark) ────────────────────────────────── */
.b-summary {
  background: var(--ink); color: var(--cream);
  border-radius: 18px; padding: 26px 26px 24px;
  box-shadow: 0 30px 60px -28px rgba(33,29,24,.7);
}
.b-summary-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--gold);
}
.b-cash {
  font-family: "Instrument Serif", serif; font-size: 62px; line-height: 1; letter-spacing: -.02em;
  margin: 8px 0 2px; color: var(--cream);
}
.b-cash.neg { color: #f0907f; }
.b-cash .per { font-size: 15px; color: rgba(250,245,236,.5); font-style: italic; font-family: "Manrope"; margin-left: 4px; }
.b-cash-note { font-size: 12.5px; color: rgba(250,245,236,.6); line-height: 1.5; }
.b-cash-note.pos { color: #8fd1b6; }
.b-cash-note.neg { color: #f0907f; }

.b-mini { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; }
.b-mini-row { display: flex; align-items: baseline; justify-content: space-between; padding: 7px 0; font-size: 13px; }
.b-mini-row .k { color: rgba(250,245,236,.62); }
.b-mini-row .v { font-family: "Instrument Serif", serif; font-size: 18px; color: var(--cream); }
.b-mini-row.minus .v { color: #e9c48f; }

.b-divider { border: 0; border-top: 1px solid rgba(250,245,236,.14); margin: 20px 0; }

/* 50/30/20 gauge */
.gauge-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 11px; }
.gauge-title { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: rgba(250,245,236,.6); }
.gauge-rule { font-size: 11px; color: rgba(250,245,236,.4); font-style: italic; }
.gauge-bar {
  display: flex; height: 16px; border-radius: 999px; overflow: hidden;
  background: rgba(250,245,236,.08);
}
.gauge-seg { height: 100%; transition: width .25s ease; }
.gauge-legend { display: flex; flex-direction: column; gap: 9px; margin-top: 14px; }
.gauge-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.gauge-dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.gauge-k { color: rgba(250,245,236,.78); }
.gauge-v { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--cream); font-weight: 600; }
.gauge-target { color: rgba(250,245,236,.4); font-size: 11px; font-variant-numeric: tabular-nums; min-width: 62px; text-align: right; }

/* allocation recap inside summary */
.b-recap { display: flex; flex-direction: column; gap: 7px; }
.b-recap-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.b-recap-row .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.b-recap-row .k { color: rgba(250,245,236,.72); }
.b-recap-row .v { margin-left: auto; font-family: "Instrument Serif", serif; font-size: 16px; color: var(--cream); }
.b-recap-row.buffer .k { color: rgba(250,245,236,.5); font-style: italic; }

/* actions */
.b-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 22px; }
.b-actions .btn { justify-content: center; width: 100%; }
.b-actions .btn.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.b-actions .btn.gold:hover { background: var(--gold-deep); border-color: var(--gold-deep); color: #fff; }
.b-actions .btn.line {
  background: transparent; border: 1px solid rgba(250,245,236,.25); color: var(--cream); box-shadow: none;
}
.b-actions .btn.line:hover { background: rgba(250,245,236,.08); border-color: rgba(250,245,236,.5); }
.b-action-split { display: flex; gap: 9px; }
.b-action-split .btn { flex: 1; min-width: 0; }
.b-status { margin-top: 14px; font-size: 11.5px; color: rgba(250,245,236,.42); text-align: center; line-height: 1.5; }
.b-status .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #6bbf97; margin-right: 6px; vertical-align: middle; }

.b-reset { text-align: center; margin-top: 16px; }
.b-reset--top { text-align: right; margin: 0 0 -6px; }
.b-reset button { background: transparent; border: 0; color: var(--ink-3); font-size: 12px; cursor: pointer; text-decoration: underline; }
.b-reset button:hover { color: #b54343; }

/* ── load modal ──────────────────────────────────────────── */
.b-modal { position: fixed; inset: 0; z-index: 200; background: rgba(33,29,24,.55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 24px; }
.b-modal-card {
  background: var(--cream); border: 1px solid var(--line); border-radius: 18px;
  width: min(520px, 100%); padding: 30px; position: relative;
  box-shadow: 0 40px 80px -30px rgba(33,29,24,.6);
}
.b-modal-close { position: absolute; top: 16px; right: 18px; background: transparent; border: 0; font-size: 26px; line-height: 1; color: var(--ink-3); cursor: pointer; }
.b-modal-close:hover { color: var(--ink); }
.b-modal-card h3 { font-family: "Instrument Serif", serif; font-size: 30px; margin: 0 0 6px; color: var(--ink); }
.b-modal-card p { font-size: 14px; color: var(--ink-2); margin: 0 0 16px; line-height: 1.5; }
.b-modal-card textarea {
  width: 100%; min-height: 120px; resize: vertical; border-radius: 12px; border: 1px solid var(--line);
  background: var(--white); padding: 12px 14px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px; color: var(--ink); line-height: 1.5; outline: none;
}
.b-modal-card textarea:focus { border-color: var(--teal); }
.b-modal-err { color: #b54343; font-size: 13px; margin: 10px 0 0; font-weight: 600; }
.b-modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.b-modal-actions .btn { flex: 1; justify-content: center; }

/* ── toast ───────────────────────────────────────────────── */
.b-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: var(--cream); padding: 12px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; z-index: 300; box-shadow: 0 12px 30px -10px rgba(0,0,0,.5);
  display: flex; align-items: center; gap: 9px;
  animation: b-toast-in .2s ease;
}
.b-toast .dot { width: 7px; height: 7px; border-radius: 50%; background: #6bbf97; }
@keyframes b-toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ── closing note ────────────────────────────────────────── */
.budget-note { padding: 0 0 88px; }
.budget-note-card {
  background: linear-gradient(160deg, var(--cream-2) 0%, var(--cream) 70%);
  border: 1px solid var(--line); border-radius: 20px; padding: 40px 44px;
  display: grid; grid-template-columns: 1.4fr auto; gap: 32px; align-items: center;
}
.budget-note-card h2 { font-family: "Instrument Serif", serif; font-size: clamp(30px, 3.6vw, 44px); line-height: 1.05; margin: 8px 0 12px; color: var(--ink); }
.budget-note-card h2 .accent { color: var(--teal-deep); font-style: italic; }
.budget-note-card p { font-size: 15.5px; color: var(--ink-2); line-height: 1.6; margin: 0; max-width: 52ch; }
.budget-note-cta { display: flex; flex-direction: column; gap: 10px; }
.budget-note-cta .btn { justify-content: center; white-space: nowrap; }

/* ── print summary (screen-hidden) ───────────────────────── */
.print-summary { display: none; }

@media (max-width: 980px) {
  .budget-shell { grid-template-columns: 1fr; gap: 24px; }
  .budget-aside { position: static; order: -1; }
  .budget-note-card { grid-template-columns: 1fr; gap: 22px; padding: 32px; }
}
@media (max-width: 540px) {
  .b-row { grid-template-columns: minmax(0,1fr) 128px 26px; }
  .cat-right { gap: 8px; }
  .cat-total { font-size: 19px; }
}

/* ── PRINT ───────────────────────────────────────────────── */
@media print {
  @page { margin: 14mm; }
  .topbar, .nav, #__contact-fab-root, #__apply-confirm-root,
  .budget, .budget-hero, footer, .contact, #contact, .budget-note,
  .b-toast, .b-modal { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .print-summary { display: block !important; }
  .ps-doc { font-family: "Manrope", system-ui, sans-serif; color: #1a1a1a; max-width: 720px; }
  .ps-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 8px; }
  .ps-brand { font-family: "Instrument Serif", serif; font-size: 30px; color: var(--ink); }
  .ps-brand small { display: block; font-family: "Manrope"; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--teal-deep); font-weight: 700; }
  .ps-date { font-size: 12px; color: #555; }
  .ps-cash { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 0; padding: 14px 18px; border: 1px solid #ccc; border-radius: 10px; background: #faf7f0; }
  .ps-cash .l { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: #555; }
  .ps-cash .n { font-family: "Instrument Serif", serif; font-size: 34px; }
  .ps-cash .n.neg { color: #b03a2e; }
  .ps-h { font-family: "Instrument Serif", serif; font-size: 19px; margin: 20px 0 6px; border-bottom: 1px solid #ddd; padding-bottom: 4px; }
  .ps-line { display: flex; justify-content: space-between; font-size: 12.5px; padding: 3px 0; }
  .ps-line.sub { color: #555; padding-left: 14px; }
  .ps-line.tot { font-weight: 700; border-top: 1px solid #ccc; margin-top: 4px; padding-top: 5px; }
  .ps-cat { break-inside: avoid; margin-bottom: 8px; }
  .ps-cat-h { display: flex; justify-content: space-between; font-weight: 700; font-size: 13px; }
  .ps-code-box { margin-top: 22px; border: 1px dashed #999; border-radius: 10px; padding: 14px 16px; break-inside: avoid; }
  .ps-code-box .t { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: #555; font-weight: 700; margin-bottom: 6px; }
  .ps-code-box .c { font-family: ui-monospace, Menlo, monospace; font-size: 9px; word-break: break-all; line-height: 1.5; color: #333; }
  .ps-foot { margin-top: 18px; font-size: 10.5px; color: #777; line-height: 1.5; }
}
