/* Bills (V1.1 Lane B). Every class and id here starts with `bl-` (contract §8); shared
   classes (.btn, .chip, .segctl, .inp, .pdrawer, .sec …) are used as they are and only
   ever adjusted under `.bl-page`. Tokens only: no new colour, radius 2px, no shadow.
   Teal (--data) is the marks; red is an overdue FIGURE only; plum only marks a picked chip. */

.bl-page .page-head.bl-head { grid-template-columns: 168px minmax(0, 1fr); }
.bl-page .bl-head .page-tools { align-self: flex-end; }
.bl-page [data-slot="set-aside"]:empty { display: none; }
.bl-neg { color: var(--red); }
.bl-page .sec > .mg .sum.bl-neg { color: var(--red); }

/* ── the month strip: one column a day, each due a stacked mark sized by amount ── */
.bl-strip { margin: 0; max-width: 680px; }
.bl-cols { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 2px; height: 120px; align-items: end; border-bottom: 1px solid var(--rule); }
.bl-day { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.bl-stack { display: flex; flex-direction: column-reverse; justify-content: flex-start; height: 100%; }
.bl-seg { display: block; width: 100%; background: var(--data); border-radius: 1px 1px 0 0; transform-origin: bottom; }
.bl-seg + .bl-seg { margin-bottom: 1px; }
.bl-seg-paid { background: var(--data-lite); }
.bl-seg-late { background: var(--red); }
.bl-seg-unknown { height: 6px; background: transparent; border: 1px dashed var(--data); box-sizing: border-box; }
.bl-mark { align-self: center; white-space: nowrap; font-size: 12px; font-weight: 600; color: var(--ink); line-height: 1; margin-bottom: 4px; }
.bl-mark.bl-mark-start { align-self: flex-start; }
.bl-mark.bl-mark-end { align-self: flex-end; }
.bl-today::after { content: ''; position: absolute; left: 50%; bottom: -7px; width: 1px; height: 6px; background: var(--ink); }
.bl-today { background: var(--paper-2); }
.bl-axis { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); margin-top: 8px; font-size: 12px; color: var(--ink-mid); line-height: 1.2; }
.bl-axis span { white-space: nowrap; justify-self: center; }
.bl-axis span:first-child { justify-self: start; }
.bl-axis span:last-child:not(.bl-tick-today) { justify-self: end; }
.bl-axis .bl-tick-today { color: var(--ink); font-weight: 500; }

@media (prefers-reduced-motion: no-preference) {
  html:not(.motion-light) .bl-seg { animation: bl-grow 360ms cubic-bezier(.2,0,0,1) both; }
  html:not(.motion-light) .bl-size > i, html:not(.motion-light) .bl-track > i { animation: bl-grow-x 360ms cubic-bezier(.2,0,0,1) both; transform-origin: left; }
}
@keyframes bl-grow { from { transform: scaleY(0); } to { transform: none; } }
@keyframes bl-grow-x { from { transform: scaleX(0); } to { transform: none; } }

/* ── the groups ── */
.bl-list { list-style: none; margin: 0; padding: 0; max-width: 680px; }
.bl-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 14px; padding: 6px 0; border-bottom: 1px solid var(--rule-soft); }
.bl-row:last-child { border-bottom: 0; }
.bl-open { display: grid; gap: 3px; min-height: 44px; padding: 6px 0; border: 0; background: none; text-align: left; color: var(--ink); cursor: pointer; min-width: 0; }
.bl-name { font-size: 15px; font-weight: 500; line-height: 1.3; }
.bl-meta { font-size: 13px; color: var(--ink-mid); line-height: 1.4; }
.bl-size { display: block; height: 4px; margin-top: 5px; max-width: 220px; background: var(--paper-3); border-radius: 1px; overflow: hidden; }
.bl-size > i { display: block; height: 100%; background: var(--data); border-radius: 1px; position: relative; }
.bl-size .bl-size-paid { position: absolute; left: 0; top: 0; bottom: 0; background: var(--data-lite); }
.bl-amt { font-size: 15px; font-weight: 500; text-align: right; white-space: nowrap; }
.bl-paid { min-height: 44px; min-width: 64px; }
.bl-paid-gap { width: 64px; }
.bl-muted .bl-name, .bl-muted .bl-amt { color: var(--ink-mid); font-weight: 400; }
.bl-muted .bl-size > i { background: var(--data-lite); }

/* Paid this month: one progress bar */
.bl-progress { display: grid; gap: 8px; max-width: 680px; margin-bottom: 8px; }
.bl-track { display: block; height: 10px; background: var(--paper-3); border-radius: 1px; overflow: hidden; }
.bl-track > i { display: block; height: 100%; min-width: 2px; background: var(--data); }
.bl-progress-fig { font-size: 14px; font-weight: 500; }

.bl-add { gap: 6px; }
.bl-add .ico { width: 15px; height: 15px; }
.bl-addsec > .bd { border-bottom: 0; }
.bl-empty { margin-top: 28px; }
.bl-failed { padding: 28px 0 0 196px; }

/* the 5-second undo */
.bl-undo { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 16px; background: var(--ink); color: var(--paper); border-radius: var(--radius); font-size: 14px; white-space: nowrap; }
.bl-undo[hidden] { display: none; }
.bl-undo .link.undo { color: var(--paper); text-decoration: underline; font-weight: 500; }
.bl-undo:not([hidden]) { animation: pop-in 160ms var(--ease-in) both; }

/* ── the sheets (Mark paid, the bill, Add a bill): the shared .pdrawer, a bottom sheet on a phone ── */
.bl-drawer { overflow-y: auto; }
.bl-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px 22px; border-bottom: 1px solid var(--rule); position: sticky; top: 0; background: var(--paper); z-index: 1; }
.bl-sheet-head h2 { font-family: var(--serif); font-size: 21px; font-weight: 500; margin: 0; line-height: 1.25; }
.bl-sheet-body { padding: 18px 22px 0; display: grid; gap: 18px; align-content: start; }
.bl-sheet-lead { font-family: var(--serif); font-size: 24px; font-weight: 500; margin: 0; line-height: 1.2; }
.bl-sheet-meta { margin: -12px 0 0; font-size: 13.5px; color: var(--ink-mid); }
.bl-page .bl-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.bl-page .bl-chips .chip, .bl-page .bl-days .chip { min-height: 44px; padding: 0 14px; font-size: 14px; }
.bl-page .chip[aria-pressed="true"] { background: var(--paper-2); border-color: var(--ink); font-weight: 500; box-shadow: inset 0 -2px 0 var(--plum); }
.bl-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.bl-page .bl-days .chip { padding: 0; text-align: center; justify-content: center; }
.bl-page .bl-days .chip[data-day="last"] { grid-column: span 2; }
.bl-hint { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-mid); }
.bl-hint:empty { display: none; }
.bl-suggest { margin: -6px 0 0; font-size: 13.5px; line-height: 1.5; padding: 10px 12px; border-left: 2px solid var(--rule); background: var(--paper-2); }
.bl-money-in { position: relative; display: flex; align-items: center; }
.bl-sym { position: absolute; left: 14px; font-size: 22px; color: var(--ink-mid); pointer-events: none; }
.bl-money .inp { min-height: 56px; font-size: 24px; text-align: right; padding-left: 40px; font-weight: 500; }
.bl-page .bl-drawer .inp { font-size: 16px; }
.bl-page .bl-drawer .bl-money .inp { font-size: 24px; }
.bl-page .bl-drawer .segctl { display: flex; width: 100%; }
.bl-page .bl-drawer .segctl button { flex: 1; min-height: 44px; font-size: 14px; }
.bl-date { margin-top: 8px; }
.bl-foot { position: sticky; bottom: 0; background: var(--paper); padding: 12px 0 18px; border-top: 1px solid var(--rule-soft); display: flex; gap: 10px; }
.bl-foot .btn { flex: 1; min-height: 48px; font-size: 15px; }
.bl-foot-split { justify-content: space-between; align-items: center; }
.bl-foot-split .btn { flex: 0 1 auto; }
.bl-remove { min-height: 44px; color: var(--ink); }
.bl-facts { margin: 0; display: grid; gap: 6px; }
.bl-facts div { display: grid; grid-template-columns: 96px 1fr; gap: 10px; font-size: 14px; }
.bl-facts dt { color: var(--ink-mid); }
.bl-facts dd { margin: 0; }
.bl-paidlist h3 { font-size: 12.5px; font-weight: 500; color: var(--ink-mid); margin: 0 0 6px; }
.bl-paidlist ul { list-style: none; margin: 0; padding: 0; }
.bl-paidlist li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--rule-soft); font-size: 14px; }
.bl-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.bl-actions .btn { flex: 1; min-height: 44px; }
.bl-move { display: grid; gap: 10px; }
.bl-move[hidden] { display: none; }

/* ── phone ── */
@media (max-width: 1023px) {
  .bl-page .page-head.bl-head { grid-template-columns: minmax(0, 1fr); }
  .bl-page .bl-head .page-tools { width: 100%; }
  .bl-page .bl-head .segctl { display: flex; width: 100%; }
  .bl-page .bl-head .segctl button { flex: 1; min-height: 44px; }
  .bl-cols { height: 112px; gap: 1px; }
  .bl-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "open amt" "open paid"; gap: 2px 12px; }
  .bl-open { grid-area: open; }
  .bl-amt { grid-area: amt; align-self: end; }
  .bl-paid, .bl-paid-gap { grid-area: paid; justify-self: end; }
  .bl-paid-gap { display: none; }
  .bl-size { max-width: 190px; }
  .bl-add, .bl-empty .btn { width: 100%; min-height: 48px; }
  .bl-failed { padding: 22px 0 0; }
  .bl-undo { left: 16px; right: 16px; transform: none; bottom: calc(16px + env(safe-area-inset-bottom)); justify-content: space-between; white-space: normal; }
  .bl-undo > span[aria-hidden] { display: none; }

  .bl-layer .pdrawer.bl-drawer { top: auto; left: 0; right: 0; width: 100%; max-height: 92vh; border-left: 0; border-top: 1px solid var(--rule); transform: translateY(100%); }
  .bl-layer.open .pdrawer.bl-drawer { transform: none; }
  .bl-sheet-head { padding: 12px 8px 8px 16px; }
  .bl-sheet-body { padding: 16px 16px 0; }
}
