/* Budget by month (#/budget?v=budget), also the base of the Latest estimate and Compare views. It follows the Summary (budget.css,
   docs/ui-design/frs.css): .m-card, .m-table, .m-btn, .m-badge, .m-kpi, .m-seg. Here only what those do not give: the scenario bar,
   the by-month grid with its sticky first column, rule chips, input cells, panels, and the dialogs and drawers (.card, .btn, .field, .in).
   The grid scrolls inside .plan-gridwrap so the page itself never scrolls sideways. */
.plan, .plan-ws { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.plan-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.plan-help { color: var(--ink-3); font-size: 12.5px; margin: 0; overflow-wrap: anywhere; }
.plan-err { display: inline-flex; align-items: center; gap: 6px; color: var(--bad); font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.plan-err .ic { width: 15px; height: 15px; flex: none; }
.plan-text { margin: 8px 0 0; font-size: 13.5px; color: var(--ink-2); }
.plan-text code, .plan-mono { font-family: var(--mono); }
.plan-skel { display: grid; gap: 12px; }
.plan-skel i { display: block; height: 72px; border-radius: var(--r-lg); background: linear-gradient(90deg, var(--sunken) 25%, #e9e6e1 50%, var(--sunken) 75%); background-size: 200% 100%; animation: m-shimmer 1.6s linear infinite; }
@media (prefers-reduced-motion: reduce) { .plan-skel i { animation: none; } }
.plan a.m-btn, .cmp a.m-btn { text-decoration: none; }
.plan .m-btn .ic, .cmp .m-btn .ic { width: 16px; height: 16px; }

/* notes (saved, failed, returned, read only): the banner of the Summary, smaller */
.bv-note { padding: 10px 16px; gap: 12px; }
.bv-note .ico { width: 28px; height: 28px; border-radius: 8px; background: var(--sunken); color: var(--ink-2); }
.bv-note .ico .ic { width: 16px; height: 16px; }
.bv-note b { font-size: 14px; }
.bv-note--ok { border-color: #c6e6d8; background: linear-gradient(90deg, var(--ok-tint), var(--surface) 60%); }
.bv-note--ok .ico { background: var(--ok); color: #fff; }
.bv-note--bad, .bv-note--block, .bv-note--warn { border-color: #f4c9c0; background: linear-gradient(90deg, var(--coral-tint), var(--surface) 60%); }
.bv-note--bad .ico, .bv-note--block .ico, .bv-note--warn .ico { background: var(--coral); color: var(--ink); }
.bv-note--warn { border-color: #f0d9ad; background: linear-gradient(90deg, var(--warn-tint), var(--surface) 60%); }
.bv-note--warn .ico { background: var(--warn-tint); color: var(--warn); }
.bv-empty { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 40px 0; text-align: center; }
.bv-empty > b { font-size: 17px; line-height: 24px; font-weight: 600; }

/* scenario bar: picker and status on the left, the actions on the right */
.plan-bar { padding: 14px 20px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; }
.plan-bar-1 { display: flex; flex-wrap: nowrap; align-items: flex-end; gap: 10px 12px; min-width: 0; flex: 1 1 auto; }
.plan-bar .field label { font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.plan-bar .in { height: 36px; border-radius: var(--r-md); border-color: var(--line-2); }
.plan-bar-1 > .m-badge, .plan-bar-1 > .m-seg { align-self: flex-end; }
.plan-bar-1 > .m-badge { margin-bottom: 6px; }
.plan-bar-1 > .m-seg { margin-bottom: 1px; }
.plan-pick-scn { min-width: 0; flex: 0 1 320px; }
.plan-pick-scn select { width: 100%; }
.plan-acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; justify-content: flex-end; }
.plan-act { display: inline-flex; flex-direction: column; gap: 3px; }
.plan-why { font-size: 12.5px; color: var(--ink-3); max-width: 240px; }
.plan .m-btn[aria-pressed="true"] { background: var(--brand-tint); border-color: var(--brand-line); color: var(--brand-deep); }

/* pending bar */
.plan-pending { position: sticky; bottom: 8px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 10px 16px; background: var(--brand-tint); border: 1px solid var(--brand-line); border-radius: var(--r-lg); box-shadow: var(--sh-3); }
.plan-pending-t { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-width: 0; }
.plan-pending-t b { font-weight: 600; }
.plan-pending-t details { flex-basis: 100%; font-size: 13px; }
.plan-pending-t ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 2px; }

/* grid */
.plan-grid-card { overflow: hidden; }
.plan-gridwrap { overflow: auto; max-width: 100%; max-height: 70vh; }
.plan-gridwrap:focus-visible { outline: none; box-shadow: inset var(--focus); }
.plan-t { min-width: max-content; font-size: 14px; }
.plan-t th, .plan-t td { padding-top: 6px; padding-bottom: 6px; padding-left: 12px; padding-right: 12px; }
.plan-t td { height: 44px; background: var(--surface); }
.plan-t thead th { position: sticky; top: 0; z-index: 4; }
.plan-t .plab, .le-t .plab { position: sticky; left: 0; z-index: 3; min-width: 240px; max-width: 300px; white-space: normal; border-right: 1px solid var(--line); }
.plan-t thead th.plab { z-index: 5; }
.plan-t td.plab { background: var(--surface); }
.plan-t td.plab, .plan-t td.plab .plab-t { color: var(--ink); font-weight: 500; }
.plan-t .r { text-align: right; }
.plan-t .pc, .plan-t .pfy { font-variant-numeric: tabular-nums; position: relative; }
.plan-t .pfy { color: var(--ink); font-weight: 600; }
.plan-t td.neg, .plan-t td.neg .pbtn { color: var(--bad); }
.plan-t td.bridge, .plan-t th.bridge { color: var(--ink-3); background: var(--sunken); }
.plan-t td.bad { background: var(--bad-tint); }
.plan-t td.ovr { box-shadow: inset 0 0 0 1px var(--warn); }
.plan-t td.alc { background: var(--brand-tint); }
.plan-t tr.der td { font-weight: 600; color: var(--ink); background: #faf9f7; border-top: 1px solid var(--line-2); }
.plan-t tr.pyr td { color: var(--ink-3); font-weight: 400; font-size: 12.5px; height: 32px; }
.plan-t tr.pyr td.plab { padding-left: 28px; }
.plan-t tr.pct td { color: var(--ink-3); font-weight: 500; }
.plan-gridbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.plab-in { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.plab-t { overflow-wrap: anywhere; }
.plab-err { display: flex; align-items: flex-start; gap: 5px; margin-top: 3px; color: var(--bad); font-size: 12.5px; font-weight: 500; }
.plab-err .ic { width: 14px; height: 14px; flex: none; margin-top: 1px; }
.plan .chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; height: 22px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink-2); font: 500 12px var(--font); overflow-wrap: anywhere; text-align: left; white-space: nowrap; }
.plan button.chip { cursor: pointer; transition: background-color .15s ease, border-color .15s ease; }
.plan button.chip:hover { background: var(--brand-tint); border-color: var(--brand-line); }
.plan .chip.edited { border-color: var(--brand-line); background: var(--brand-tint); color: var(--brand-deep); }
.plan .chip:focus-visible, .pbtn:focus-visible, .psec-b:focus-visible, .pin:focus-visible { outline: none; box-shadow: var(--focus); }
.pmark { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); flex: none; }
.pc .pmark { position: absolute; top: 4px; right: 4px; }
.pmark.alc { background: var(--chart-3); border-radius: 2px; }
.pin { width: 88px; height: 32px; padding: 0 8px; text-align: right; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: inherit; font-variant-numeric: tabular-nums; box-shadow: var(--sh-1); }
.pin:focus { border-color: var(--brand); }
.pbtn { border: 0; background: transparent; font: inherit; color: inherit; padding: 2px 6px; border-radius: 6px; cursor: pointer; font-variant-numeric: tabular-nums; }
.pbtn:hover { background: var(--brand-tint); }
.perr { display: inline-flex; align-items: center; gap: 4px; color: var(--bad); }
.perr .ic { width: 14px; height: 14px; }
.plan-t .psec-h th { text-align: left; background: #faf9f7; padding: 0; height: 38px; border-bottom: 1px solid var(--line); position: sticky; left: 0; display: table-cell; }
.psec-b { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px 0 20px; border: 0; background: transparent; font: 600 13px/1 var(--font); color: var(--ink); cursor: pointer; position: sticky; left: 0; }
.psec-b .ic { width: 15px; height: 15px; color: var(--ink-3); }
.psec-n { color: var(--ink-3); font-weight: 500; }
.psec.band td.plab { box-shadow: inset 3px 0 0 var(--brand); }
.plan-none { color: var(--ink-3); padding: 4px 20px 16px; margin: 0; font-size: 13px; }

/* panels */
.plan-panels { display: grid; gap: 12px; }
.plan-panel summary { cursor: pointer; padding: 14px 20px; font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.plan-list { list-style: none; margin: 0; padding: 0 20px 14px; display: grid; gap: 8px; }
.plan-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; font-size: 14px; overflow-wrap: anywhere; }
.plan-list small { color: var(--ink-3); font-size: 12.5px; }

/* dialogs, drawers */
.plan-layer { position: relative; }
.plan-modal { position: fixed; z-index: 52; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); display: flex; flex-direction: column; box-shadow: var(--sh-pop); }
.plan-modal.wide { width: min(760px, calc(100vw - 24px)); }
.plan-modal-b { display: grid; gap: 12px; overflow-y: auto; }
.plan-modal-f { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.plan-drawer .db { display: grid; gap: 12px; align-content: start; }
.plan-drawer .db h4 { margin: 8px 0 0; }
.plan-fields { display: grid; gap: 12px; }
.plan-seg { justify-self: start; flex-wrap: wrap; }
.plan-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-sug { list-style: none; margin: 0; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); display: grid; }
.plan-sug button { width: 100%; text-align: left; border: 0; background: transparent; padding: 6px 8px; border-radius: 6px; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.plan-sug button:hover { background: var(--tint); }
.plan-uses { display: grid; gap: 6px; font-size: 13px; }
.plan-uses .chip { margin: 0 4px 4px 0; font-family: inherit; }
.plan-mini { overflow: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.plan-mini table { min-width: max-content; font-size: 13px; }
.plan-mini th, .plan-mini td { padding: 5px 9px; }
.plan-mini tr.after td { font-weight: 750; }
.plan-mini td.bad { color: var(--red); }
.plan-pick { list-style: none; margin: 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; max-height: 190px; overflow: auto; display: grid; gap: 4px; }
.plan-pick label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; }
.plan-file { height: auto; padding: 8px 10px; }
.plan-report { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 8px; }
.plan-report-h { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 13.5px; }
.plan-diff { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13.5px; }
.plan-diag { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13.5px; max-height: 240px; overflow: auto; }
.plan-diag li { overflow-wrap: anywhere; }
.plan-diag li.bad { color: var(--red); }
.plan-diag li.warn { color: var(--amber); }
.plan-diag code { font-family: var(--mono); font-size: 12.5px; background: var(--sunk); padding: 0 5px; border-radius: 4px; color: var(--ink-2); }

@media (max-width: 760px) {
  .plan-t .plab, .le-t .plab { min-width: 150px; max-width: 170px; }
  .plan-gridwrap { max-height: 60vh; }
  .plan-pending { bottom: 66px; }
  .plan-bar-1 { flex-wrap: wrap; }
  .plan-pick-scn { flex-basis: 100%; }
  .plan-drawer { width: 100vw; }
  .plan-modal { top: 0; left: 0; transform: none; width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
  .plan-act, .plan-why { max-width: none; }
}
/* the whole embedded view does not rise as one tall layer (it renders blank in a full-page capture); its parts are plain */
.m-page > .plan, .m-page > .cmp { animation: none; }
.plan .m-kpi .fig, .cmp .m-kpi .fig { animation: none; }
