/* budget: top sheet, detail sheet, actuals, setup. Every class starts with bdg-. */

/* ------------------------------------------------------------ frame */

.bdg-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: var(--s-5) var(--s-6) var(--s-7);
}
.bdg-body-detail {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.bdg-card {
  min-width: 0;
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.bdg-card + .bdg-card { margin-top: var(--s-4); }
.bdg-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-3);
  margin-bottom: var(--s-3);
}
.bdg-card-title {
  margin: 0;
  font: 600 var(--fs-lg)/1.2 var(--font-display);
}
.bdg-card-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  color: var(--on-candy);
  background: var(--c);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-sm);
}
.bdg-card-intro { margin: calc(-1 * var(--s-1)) 0 var(--s-3); }
.bdg-foot-note { margin: var(--s-2) 0 0; }
.bdg-card .table-wrap { border-width: 1px; border-color: var(--border); }

.bdg-swatch {
  display: inline-block;
  flex: none;
  width: 11px;
  height: 11px;
  background: var(--c);
  border: 1.5px solid var(--line);
  border-radius: 4px;
}
.bdg-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  max-width: 100%;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}
.bdg-link:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.bdg-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.bdg-var { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bdg-var.is-under { color: var(--ok-text); }
.bdg-var.is-over { color: var(--danger-text); font-weight: 800; }
.bdg-over { color: var(--danger-text); font-weight: 800; }

.bdg-bar {
  display: block;
  width: 100%;
  min-width: 56px;
  height: 8px;
  overflow: hidden;
  background: var(--surface-sunken);
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1px var(--border);
}
.bdg-bar-fill {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}
.bdg-bar.is-near .bdg-bar-fill { background: var(--amber); }
.bdg-bar.is-over .bdg-bar-fill { background: var(--red); }

.bdg-dialog-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-4);
}
.bdg-form p { margin: 0 0 var(--s-3); }

/* ------------------------------------------------------------ top sheet */

.bdg-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.bdg-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: var(--s-4) var(--s-4) var(--s-3);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.bdg-tile::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: var(--c);
}
.bdg-tile.is-danger { background: var(--red-soft); border-color: var(--danger); }
.bdg-tile.is-warn { background: var(--amber-soft); }
.bdg-tile-top { display: flex; align-items: center; gap: var(--s-2); }
.bdg-tile-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  color: var(--on-candy);
  background: var(--c);
  border: var(--bw) solid var(--line);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}
.bdg-tile-label { font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); }
.bdg-tile-value {
  margin-top: 4px;
  font: 600 var(--fs-2xl)/1.1 var(--font-display);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bdg-tile.is-danger .bdg-tile-value { color: var(--danger-text); }
.bdg-tile-sub { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bdg-tile-meter { margin-top: 6px; }

.bdg-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(280px, 1fr);
  gap: var(--s-4);
  align-items: start;
}
.bdg-top-side { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.bdg-top-side .bdg-card + .bdg-card { margin-top: 0; }

.bdg-table .bdg-col-code { width: 64px; color: var(--text-muted); font-weight: 700; }
.bdg-table .bdg-col-bar { width: 110px; }
.bdg-table td.num, .bdg-table th.num { white-space: nowrap; }
.bdg-sec-row > td { padding-top: 8px; padding-bottom: 6px; }
.bdg-sec-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font: 600 12.5px/1.3 var(--font-display);
  letter-spacing: 0.02em;
  color: var(--on-candy);
  background: var(--c);
  border: var(--bw-thin) solid var(--line);
  border-radius: var(--r-pill);
}
.bdg-subtotal > td { font-weight: 700; background: var(--surface-2); border-bottom: var(--bw-thin) solid var(--line) !important; }
.bdg-line-total > td { font-weight: 800; }
.bdg-contingency > td { vertical-align: middle; }
.bdg-cont-label { align-items: center; }
.bdg-pct-input { width: 96px; flex: none; }
.bdg-unassigned > td { font-style: italic; }
.table tr.bdg-grand > td,
.table tr.bdg-grand:hover > td {
  padding-top: 12px;
  padding-bottom: 12px;
  font: 600 var(--fs-lg)/1.2 var(--font-display);
  color: var(--on-candy);
  background: var(--green);
}
.bdg-grand .bdg-var { color: var(--on-candy); }
.bdg-grand .bdg-bar { background: var(--surface); }

.bdg-share { display: flex; flex-direction: column; gap: var(--s-3); }
.bdg-donut-wrap { display: flex; justify-content: center; }
.bdg-donut { width: 190px; height: 190px; overflow: visible; }
.bdg-donut-track { stroke: var(--surface-sunken); }
.bdg-donut-seg { cursor: pointer; transition: stroke-width 120ms ease-out, opacity 120ms; }
.bdg-donut-seg.is-hover { stroke-width: 34px; }
.bdg-donut-big { font: 600 22px var(--font-display); fill: var(--text); }
.bdg-donut-small { font: 600 11px var(--font-ui); fill: var(--text-muted); }
.bdg-share-sections { display: flex; flex-direction: column; gap: 6px; }
.bdg-legend-sections { display: flex; flex-wrap: wrap; gap: 4px var(--s-3); font-size: var(--fs-xs); color: var(--text-2); }
.bdg-legend-sec { display: inline-flex; align-items: center; gap: 5px; }
.bdg-legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 2px var(--s-2);
  max-height: 260px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}
.bdg-legend-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  padding: 4px 6px;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text);
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--r-xs);
  cursor: pointer;
}
.bdg-legend-item:hover, .bdg-legend-item.is-hover { background: var(--hover); }
.bdg-legend-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.bdg-legend-name { flex: 1 1 auto; min-width: 0; }
.bdg-legend-pct { font-weight: 800; font-variant-numeric: tabular-nums; }
.bdg-legend-amt { width: 52px; text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.bdg-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); padding: var(--s-3); }
.bdg-fact {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  column-gap: var(--s-2);
  min-width: 0;
  padding: var(--s-2) var(--s-3);
  background: var(--c-soft);
  border-radius: var(--r-md);
}
.bdg-fact-icon { grid-row: 1; display: grid; place-items: center; color: var(--c-ink); }
.bdg-fact-label { grid-row: 1; font-size: var(--fs-xs); font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bdg-fact-value { grid-column: 1 / -1; font: 600 var(--fs-lg)/1.3 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bdg-fact-sub { grid-column: 1 / -1; font-size: var(--fs-xs); color: var(--text-2); }
.bdg-notes p { margin: 0; }

/* ------------------------------------------------------------ empty state and templates */

.bdg-empty { max-width: 1100px; }
.bdg-empty-intro {
  display: flex;
  gap: var(--s-4);
  align-items: flex-start;
  margin-bottom: var(--s-5);
  padding: var(--s-5);
  background: var(--c-soft);
  border-radius: var(--r-lg);
}
.bdg-empty-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  flex: none;
  color: var(--on-candy);
  background: var(--c);
  border: var(--bw) solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  transform: rotate(-4deg);
}
.bdg-empty-title { margin: 0 0 var(--s-2); font: 600 var(--fs-xl)/1.2 var(--font-display); }
.bdg-empty-text { max-width: 70ch; margin: 0 0 var(--s-3); color: var(--text); line-height: 1.5; }
.bdg-empty-text code, .bdg-card code, .bdg-form code {
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--surface-sunken);
  border-radius: 5px;
}

.bdg-templates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--s-3);
}
.bdg-template {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-4) var(--s-3);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.bdg-template::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--c); }
.bdg-template-head { display: flex; align-items: center; gap: var(--s-2); }
.bdg-template-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  color: var(--on-candy);
  background: var(--c);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
}
.bdg-template-name { font: 600 var(--fs-md)/1.2 var(--font-display); }
.bdg-template-blurb { flex: 1 1 auto; margin: 0; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.4; }
.bdg-template-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); padding: 2px 3px 3px 0; }
.bdg-templates.is-compact .bdg-template-blurb { font-size: var(--fs-xs); }

/* ------------------------------------------------------------ detail sheet */

.bdg-detail {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.bdg-detail-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2);
  flex: none;
  padding: var(--s-2) var(--s-6);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.bdg-find { flex: 0 1 240px; }
.bdg-sheet-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: var(--s-4) var(--s-6) var(--s-6);
}
.bdg-nomatch { padding: var(--s-6); text-align: center; }

.bdg-sec { margin-bottom: var(--s-5); }
.bdg-sec-head {
  position: sticky;
  left: 0;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-2);
}
.bdg-sec-total { font: 600 var(--fs-md)/1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--text-2); }
.bdg-sec-body { display: flex; flex-direction: column; gap: var(--s-3); border-radius: var(--r-lg); }
.bdg-sec-body.dnd-over { background: var(--surface-sunken); }

.bdg-acct {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 6px solid var(--c);
  border-radius: var(--r-md);
}
.bdg-acct.is-dragging { opacity: 0.45; }
.bdg-acct.dnd-before { box-shadow: 0 -4px 0 0 var(--focus); }
.bdg-acct.dnd-after { box-shadow: 0 4px 0 0 var(--focus); }
.bdg-acct.is-flash { animation: bdg-flash 1.4s ease-out; }
@keyframes bdg-flash {
  0%, 30% { box-shadow: 0 0 0 4px var(--c); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.bdg-acct-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 46px;
  padding: 6px var(--s-3) 6px 4px;
  background: var(--c-soft);
  border-radius: calc(var(--r-md) - 2px) calc(var(--r-md) - 2px) 0 0;
}
.bdg-acct-head:last-child { border-radius: 0 calc(var(--r-md) - 2px) calc(var(--r-md) - 2px) 0; }
.bdg-acct-head.dnd-over { box-shadow: inset 0 0 0 2px var(--focus); }
.bdg-acct-grip, .bdg-grip {
  display: grid;
  place-items: center;
  flex: none;
  color: var(--text-muted);
  cursor: grab;
  border-radius: var(--r-xs);
}
.bdg-acct-grip { width: 22px; height: 30px; }
.bdg-acct-grip:hover, .bdg-grip:hover { color: var(--text); background: var(--hover); }
.bdg-chev {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  padding: 0;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: var(--r-xs);
  cursor: pointer;
}
.bdg-chev:hover { background: var(--surface); }
.bdg-chev:focus-visible { outline: 2px solid var(--focus); }
.bdg-chev .icon { transition: transform 120ms ease-out; }
.bdg-chev.is-open .icon { transform: rotate(90deg); }
.bdg-acct-code { flex: none; min-width: 48px; font-family: var(--font-mono); font-weight: 700; font-size: var(--fs-sm); color: var(--text-2); }
.bdg-acct-code .inline-edit-input { width: 72px; }
.bdg-acct-name { flex: 0 1 auto; min-width: 120px; max-width: 45%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 600 var(--fs-lg)/1.2 var(--font-display); }
.bdg-acct-name .inline-edit-input { width: 280px; font: inherit; }
.bdg-acct-count {
  flex: none;
  padding: 1px 8px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-2);
  background: var(--surface);
  border-radius: var(--r-pill);
}
.bdg-acct-fig { display: flex; flex-direction: column; align-items: flex-end; min-width: 84px; line-height: 1.15; }
.bdg-acct-fig-label { font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.bdg-acct-fig-value { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }

.bdg-sheet {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}
.bdg-c-handle { width: 26px; }
.bdg-c-qty { width: 70px; }
.bdg-c-unit { width: 72px; }
.bdg-c-x { width: 56px; }
.bdg-c-rate { width: 88px; }
.bdg-c-fringe { width: 84px; }
.bdg-c-money { width: 88px; }
.bdg-c-fmoney { width: 72px; }
.bdg-c-total { width: 96px; }
.bdg-c-notes { width: 150px; }
.bdg-c-menu { width: 36px; }
.bdg-sheet thead th {
  padding: 6px 8px;
  font: 800 10px/1.2 var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.bdg-sheet th.num, .bdg-sheet td.num { text-align: right; }
.bdg-sheet td {
  padding: 0 8px;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.bdg-sheet td.num { padding-top: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bdg-sheet td.cell-input { padding: 2px; }
.bdg-sheet tbody tr:hover > td { background: var(--surface-2); }
.bdg-sheet tr.is-selected > td { background: var(--c-soft); }
.bdg-sheet tr.is-selected > td:first-child { box-shadow: inset 4px 0 0 0 var(--c); }
.bdg-sheet tr:focus { outline: none; }
.bdg-sheet tr:focus-visible > td { box-shadow: inset 0 2px 0 var(--focus), inset 0 -2px 0 var(--focus); }
.bdg-sheet tr.is-dragging { opacity: 0.4; }
.bdg-sheet tr.dnd-before > td { box-shadow: inset 0 3px 0 0 var(--focus); }
.bdg-sheet tr.dnd-after > td { box-shadow: inset 0 -3px 0 0 var(--focus); }
.bdg-sheet tbody.dnd-over { background: var(--surface-sunken); }
.bdg-sheet tfoot td { padding: 4px 8px 6px; }
.bdg-noline td { padding: 8px; }

.bdg-handle { padding: 0 !important; }
.bdg-grip { width: 24px; height: 32px; margin: 2px auto 0; }

.bdg-in {
  display: block;
  width: 100%;
  height: 32px;
  min-width: 0;
  margin: 0;
  padding: 0 8px;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
}
.bdg-in::placeholder { color: var(--text-muted); opacity: 0.8; }
.bdg-in:hover { background: var(--field-bg); border-color: var(--border); }
.bdg-in:focus { background: var(--field-bg); border-color: var(--field-line); outline: 2px solid var(--focus); outline-offset: -1px; }
select.bdg-in { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 4px; }
.bdg-numcell .bdg-in { text-align: right; font-variant-numeric: tabular-nums; }

.bdg-expr { position: relative; display: block; }
.bdg-expr.is-expr .bdg-in { background: var(--indigo-soft); font-weight: 700; }
.bdg-expr.is-expr .bdg-in:focus { background: var(--field-bg); font-family: var(--font-mono); font-weight: 400; text-align: left; }
.bdg-expr.is-editing .bdg-in { font-family: var(--font-mono); }
.bdg-fx {
  position: absolute;
  top: 2px;
  left: 4px;
  font: italic 700 11px/1 var(--font-ui);
  color: var(--indigo-ink);
  pointer-events: none;
}
.bdg-expr-prefix { position: absolute; top: 9px; left: 6px; font-size: var(--fs-xs); color: var(--text-muted); pointer-events: none; }
.bdg-expr.is-error .bdg-in { color: var(--danger-text); background: var(--red-soft); border-color: var(--danger); }
.bdg-expr.is-error:not(.is-editing) .bdg-in { padding-left: 24px; text-overflow: ellipsis; }
.bdg-expr.is-error:not(.is-editing) .bdg-fx { display: none; }
.bdg-expr-bang {
  position: absolute;
  top: 8px;
  left: 4px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  font: 800 11px/1 var(--font-ui);
  color: var(--on-candy);
  background: var(--red);
  border: 1.5px solid var(--line);
  border-radius: 50%;
  pointer-events: none;
}
.bdg-expr-preview {
  position: absolute;
  z-index: 5;
  top: calc(100% + 3px);
  right: 0;
  max-width: 260px;
  padding: 3px 8px;
  font: 700 var(--fs-xs)/1.3 var(--font-ui);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--tooltip-fg);
  background: var(--tooltip-bg);
  border-radius: var(--r-xs);
  pointer-events: none;
}
.bdg-expr-preview.is-error { color: var(--on-candy); background: var(--red); border: 1.5px solid var(--line); }

.bdg-desc .bdg-in { font-weight: 600; }
.bdg-desc-meta { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 6px 6px; }
.bdg-linkchip, .bdg-hint, .bdg-example {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  height: 20px;
  padding: 0 8px;
  font: 700 11px/1 var(--font-ui);
  color: var(--text);
  border-radius: var(--r-pill);
}
.bdg-linkchip { max-width: 220px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; }
.bdg-linkchip:hover { border-color: var(--line); }
.bdg-linkchip.is-missing { background: var(--red-soft); }
.bdg-example { background: var(--amber-soft); }
.bdg-hint { background: var(--violet-soft); border: 1px dashed var(--violet-ink); cursor: pointer; }
.bdg-hint:hover { border-style: solid; }
.bdg-linkchip:focus-visible, .bdg-hint:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.bdg-fringecell { padding: 2px !important; }
.bdg-fringe-btn {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px;
  width: 100%;
  min-height: 32px;
  padding: 3px 6px;
  font: inherit;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  cursor: pointer;
}
.bdg-fringe-btn:hover { background: var(--field-bg); border-color: var(--border); }
.bdg-fringe-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: -1px; }
.bdg-fringe-btn.is-empty { opacity: 0.6; }
.bdg-fchip { padding: 1px 6px; font: 700 11px/1.4 var(--font-ui); color: var(--text); background: var(--pink-soft); border-radius: var(--r-pill); }
.bdg-total { font-weight: 800; }
.bdg-notes .bdg-in { font-size: var(--fs-xs); color: var(--text-2); }
.bdg-rowmenu { padding: 2px 2px 0 0 !important; text-align: right; }
.bdg-addline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font: 700 var(--fs-xs) var(--font-ui);
  color: var(--text-2);
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--r-pill);
  cursor: pointer;
}
.bdg-addline:hover { color: var(--text); border-color: var(--line); background: var(--surface-2); }
.bdg-addline:focus-visible { outline: 2px solid var(--focus); }

.bdg-sumbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-5);
  flex: none;
  padding: 10px var(--s-6);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border-top: var(--bw) solid var(--line);
}
.bdg-sum-label { margin-right: 4px; font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); }
.bdg-sum-grand {
  padding: 4px 12px;
  font: 600 var(--fs-md)/1.2 var(--font-display);
  color: var(--on-candy);
  background: var(--green);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-sm);
}
.bdg-sum-grand .bdg-sum-label { color: var(--on-candy); }

/* ------------------------------------------------------------ actuals */

.bdg-act-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}
.bdg-act-stats { display: grid; grid-template-rows: repeat(4, 1fr); gap: var(--s-2); }
.bdg-mini {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0 var(--s-2);
  padding: 8px 12px;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: var(--c-soft);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.bdg-mini:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-md); }
.bdg-mini:active { transform: translate(1px, 1px); box-shadow: none; }
.bdg-mini:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.bdg-mini.is-alert { background: var(--red-soft); }
.bdg-mini-label { font-size: var(--fs-xs); font-weight: 800; }
.bdg-mini-value { grid-row: span 2; font: 600 var(--fs-lg)/1.1 var(--font-display); font-variant-numeric: tabular-nums; text-align: right; }
.bdg-mini-sub { font-size: 11px; color: var(--text-2); }

.bdg-burn-svg { display: block; width: 100%; height: auto; }
.bdg-grid { stroke: var(--border); stroke-width: 1; }
.bdg-axis { font: 600 11px var(--font-ui); fill: var(--text-muted); }
.bdg-shoot { fill: var(--amber-soft); }
.bdg-shoot-label { font: 800 10px var(--font-ui); fill: var(--amber-ink); letter-spacing: 0.06em; text-transform: uppercase; }
.bdg-burn-area { fill: var(--green-soft); opacity: 0.85; }
.bdg-burn-line { fill: none; stroke: var(--green-ink); stroke-width: 2.5; stroke-linejoin: round; }
.bdg-burn-line.is-over { stroke: var(--danger-text); }
.bdg-burn-dot { fill: var(--green); stroke: var(--line); stroke-width: 1.5; }
.bdg-est-line { stroke: var(--text-2); stroke-width: 2; stroke-dasharray: 6 5; }
.bdg-est-label { font: 800 11px var(--font-ui); fill: var(--text-2); }
.bdg-today { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 3 4; }
.bdg-today-label { font: 800 10.5px var(--font-ui); fill: var(--accent-ink); }
.bdg-burn-legend { display: flex; flex-wrap: wrap; gap: var(--s-4); margin-top: var(--s-2); font-size: var(--fs-xs); color: var(--text-2); }
.bdg-burn-legend .legend-item { display: inline-flex; align-items: center; gap: 6px; }
.bdg-key { display: inline-block; width: 18px; height: 10px; border-radius: 3px; }
.bdg-key.is-spend { background: var(--green-soft); box-shadow: inset 0 -3px 0 var(--green-ink); }
.bdg-key.is-est { height: 0; border-top: 2px dashed var(--text-2); border-radius: 0; }
.bdg-key.is-shoot { background: var(--amber-soft); }

.bdg-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.bdg-filters > .select-wrap { flex: 0 1 220px; min-width: 160px; }
.bdg-daterange { display: inline-flex; align-items: center; gap: 6px; }
.bdg-daterange .input { width: 140px; }
.bdg-sort {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
.bdg-sort.is-active { color: var(--text); }
.bdg-exp-row { cursor: pointer; }
.bdg-nowrap { white-space: nowrap; }
.bdg-cell-clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bdg-cell-where { max-width: 280px; }
.bdg-where { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bdg-unassigned-tag { padding: 1px 8px; font-size: var(--fs-xs); font-weight: 700; background: var(--gray-soft); border-radius: var(--r-pill); }
.bdg-status {
  padding: 1px 9px;
  font: 800 11px/1.5 var(--font-ui);
  white-space: nowrap;
  color: var(--on-candy);
  background: var(--c);
  border: 1.5px solid var(--line);
  border-radius: var(--r-pill);
  cursor: pointer;
}
.bdg-status:hover { box-shadow: var(--shadow-sm); }
.bdg-status:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.bdg-col-receipt { width: 64px; text-align: center !important; }
.bdg-thumb {
  display: inline-block;
  width: 32px;
  height: 32px;
  padding: 0;
  overflow: hidden;
  background: var(--surface-sunken);
  border: 1.5px solid var(--line);
  border-radius: var(--r-xs);
  cursor: zoom-in;
}
.bdg-thumb .asset-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bdg-receipt-big { display: grid; place-items: center; height: min(70vh, 720px); }
.bdg-receipt-big .asset-img { max-width: 100%; max-height: 100%; }
.table tr.is-over > td { background: var(--red-soft); }

/* ------------------------------------------------------------ dialogs */

.bdg-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: var(--s-4); }
.bdg-form-receipt { display: flex; flex-direction: column; gap: 6px; }
.bdg-import-opts { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-4); margin-bottom: var(--s-3); }
.bdg-import-map { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-2) var(--s-3); margin-bottom: var(--s-3); }
.bdg-import-preview { max-height: 240px; }
.bdg-import-preview td { max-width: 180px; }
.bdg-ai-wait { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-5) var(--s-2); }
.bdg-ai-list { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.bdg-ai-item { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 6px 8px; border-radius: var(--r-sm); }
.bdg-ai-item:hover { background: var(--surface-2); }
.bdg-ai-item.is-off { opacity: 0.55; }
.bdg-ai-math { flex: none; font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.bdg-report { display: flex; flex-direction: column; gap: var(--s-3); height: min(76vh, 860px); }
.bdg-report-opts { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-4); }
.bdg-report-viewer { flex: 1 1 auto; min-height: 0; }

/* ------------------------------------------------------------ setup */

.bdg-setup { display: flex; flex-direction: column; gap: var(--s-4); max-width: 1180px; }
.bdg-setup .bdg-card + .bdg-card { margin-top: 0; }
.bdg-setup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); align-items: start; }
.bdg-globals td { vertical-align: top; }
.bdg-globals .bdg-in { height: 30px; }
.bdg-globals .bdg-gval { width: 150px; }
.bdg-globals .bdg-gval .bdg-in { text-align: right; font-family: var(--font-mono); }
.bdg-gname-cell { width: 190px; }
.bdg-gname { display: block; }
.bdg-gname .bdg-in { font-weight: 700; }
.bdg-gname.is-error .bdg-in { color: var(--danger-text); background: var(--red-soft); border-color: var(--danger); }
.bdg-gname-err { display: block; padding: 2px 8px 4px; font-size: 11px; font-weight: 700; color: var(--danger-text); white-space: normal; }
.bdg-gsrc { width: 230px; }
.bdg-gsrc .tiny { margin-top: 3px; white-space: normal; }
.bdg-gnow { font-weight: 800; }
.bdg-gnow.is-auto { padding: 1px 8px; background: var(--teal-soft); border-radius: var(--r-pill); }
.bdg-uses { font-size: var(--fs-xs); font-weight: 700; }
.bdg-fpct { width: 120px; }
.bdg-settings { align-items: start; }

.bdg-scale-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--s-3); max-width: 620px; }
.bdg-scale-result {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-4);
  margin-top: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--c-soft);
  border-radius: var(--r-md);
}
.bdg-scale-result > div { display: flex; flex-direction: column; }
.bdg-scale-label { font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); }
.bdg-scale-num { font: 600 var(--fs-xl)/1.2 var(--font-display); font-variant-numeric: tabular-nums; }
.bdg-delta { margin-left: auto; padding: 4px 12px; font-weight: 800; font-variant-numeric: tabular-nums; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pill); }
.bdg-delta.is-up { color: var(--danger-text); }
.bdg-delta.is-down { color: var(--ok-text); }

/* ------------------------------------------------------------ narrow */

@media (max-width: 1180px) {
  .bdg-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bdg-top-grid { grid-template-columns: minmax(0, 1fr); }
  .bdg-act-top { grid-template-columns: minmax(0, 1fr); }
  .bdg-act-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: none; }
}
@media (max-width: 900px) {
  .bdg-body { padding: var(--s-4); }
  .bdg-setup-grid { grid-template-columns: minmax(0, 1fr); }
  .bdg-form-grid { grid-template-columns: minmax(0, 1fr); }
  .bdg-import-map { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bdg-act-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bdg-facts { grid-template-columns: minmax(0, 1fr); }
}
