/* billing screens — design/canvas/Billing.dc.html, Checkout-Flow.dc.html and design/STYLE.md.
   Shared components are in /app.css. Everything here is scoped under .bl / .bl-*. */
.bl { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.bl p { margin: 0; }
#bl-how-btn[hidden] { display: none; }
.bl .mono { font-family: var(--mono); font-size: 13px; }

/* ---------- Stripe return states ---------- */
.bl-ret { background: var(--panel); border: 1px solid var(--line-3); border-radius: var(--r-card); padding: 12px 12px 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.bl-ret.cancel { border-color: var(--line-2); }
.bl-ret-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.bl-ret-row > svg { flex: none; align-self: flex-start; margin-top: 2px; }
.bl-ret-msg { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bl-ret .t { font-weight: 500; color: var(--text); }
.bl-ret .s { font-size: 13px; color: var(--body); }
.bl-ret .ok { color: var(--ok-text); }
.bl-ret.pending > .bl-ret-row > svg { color: var(--info); }
.bl-ret.waiting > .bl-ret-row > svg { color: var(--info); }
.bl-ret.credited > .bl-ret-row > svg { color: var(--ok); }
.bl-ret.cancel > .bl-ret-row > svg { color: var(--muted); }
.bl-ret .bl-dismiss { color: var(--muted); }
.bl-spin { animation: bl-spin 0.9s linear infinite; }
@keyframes bl-spin { to { transform: rotate(360deg); } }
.bl-progress { height: 3px; border-radius: 999px; background: var(--line); overflow: hidden; position: relative; }
.bl-progress > span { position: absolute; top: 0; bottom: 0; width: 38%; border-radius: 999px; background: var(--info); animation: bl-slide 1.4s ease-in-out infinite; }
@keyframes bl-slide { from { left: -38%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .bl-spin, .bl-progress > span { animation: none; }
  .bl-progress > span { left: 22%; }
}

/* ---------- credit warnings ---------- */
.bl-warn { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 12px 12px 12px 18px; background: var(--panel); border: 1px solid var(--warn-line); border-radius: var(--r-card); }
.bl-warn > svg { flex: none; color: var(--warn); }
.bl-warn.out { border-color: var(--bad-line); }
.bl-warn.out > svg { color: var(--bad); }
.bl-warn .msg { flex: 1 1 320px; min-width: 0; color: var(--text); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.bl-warn .msg strong { color: var(--bad); }
.bl-warn .msg .sub { color: var(--text-2); }
.bl-pill { font: 12px var(--mono); color: var(--bad); background: var(--bad-bg); border: 1px solid var(--bad-line); border-radius: 999px; padding: 1px 10px; white-space: nowrap; }
.bl-ask { font-size: 13px; color: var(--body); }
.bl-goadd { font-weight: 600; }

/* ---------- summary tiles ---------- */
.bl-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.bl-tile { background: var(--panel); border: 1px solid var(--line-card); border-radius: var(--r-card); padding: 20px 24px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bl-tile h2 { margin: 0; font: 500 13px/1.4 var(--sans); letter-spacing: 0; color: var(--muted); }
.bl-tile .v { font: 500 30px/1.2 var(--mono); color: var(--text); overflow-wrap: anywhere; }
.bl-tile .v.warn { color: var(--warn); }
.bl-tile .v.bad { color: var(--bad); }
.bl-tile .s { font-size: 13px; color: var(--body); }

/* ---------- two-up rows ---------- */
.bl-split { display: flex; flex-wrap: wrap; gap: 24px; align-items: stretch; }
.bl-split > * { min-width: 0; }

/* ---------- add credit ---------- */
.bl-add { flex: 1 1 360px; max-width: 440px; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.bl-add:only-child { max-width: 560px; }
.bl-add h2 { margin: 0; }
.bl-amounts { border: 0; margin: 0; padding: 0; min-width: 0; }
.bl-amounts legend { padding: 0; margin: 0 0 10px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.bl-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.bl-preset { min-width: 72px; border-radius: 999px; font: 400 14px var(--mono); }
.bl-preset[aria-pressed="true"] { background: var(--raised); border-color: var(--accent-text); color: var(--accent-text); font-weight: 500; }
.bl-field { display: flex; flex-direction: column; gap: 6px; }
.bl-money { position: relative; }
.bl-money > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font: 14px var(--mono); color: var(--muted); pointer-events: none; }
.bl-money input { width: 100%; padding-left: 28px; font-family: var(--mono); }
.bl-money input[aria-invalid="true"] { border-color: var(--bad-line); }
.bl-sum { margin: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.bl-sum > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.bl-sum dt { color: var(--muted); }
.bl-sum dd { margin: 0; font-weight: 500; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.bl-sum dd.mono { font-weight: 400; }
.bl-add .hint { margin: 0; }
.bl-locked { display: flex; gap: 12px; align-items: flex-start; color: var(--body); }
.bl-locked > svg { flex: none; margin-top: 2px; color: var(--muted); }
/* promo code (below the top-up form) */
.bl-promo { display: flex; flex-direction: column; gap: 6px; padding-top: 20px; border-top: 1px solid var(--line); }
.bl-promo-row { display: flex; gap: 8px; }
.bl-promo-row input { flex: 1 1 auto; min-width: 0; font-family: var(--mono); text-transform: uppercase; }
.bl-promo-row input::placeholder { text-transform: none; }
.bl-promo-row input[aria-invalid="true"] { border-color: var(--bad-line); }
.bl-promo-row button { flex: none; }

/* ---------- spend chart ---------- */
.bl-chart { flex: 2 1 560px; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.bl-chart-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.bl-chart-head h2 { margin: 0; }
.bl-chart-head p { font-size: 13px; color: var(--muted); }
.bl-chart-head .mono { color: var(--text); }
.bl-chart .empty { padding: 56px 20px; }
.bl-plot { display: flex; gap: 12px; flex: 1; min-height: 0; }
.bl-y { position: relative; flex: none; width: 52px; height: 220px; font: 12px var(--mono); color: var(--muted); }
.bl-y span { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; }
.bl-area { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.bl-bars { position: relative; height: 220px; border-bottom: 1px solid var(--line-3); }
.bl-bars svg { display: block; overflow: visible; }
.bl-bars .grid { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.bl-bars .bar { fill: var(--info); }
.bl-bars .now { fill: var(--accent-text); }
.bl-bars .zero { fill: var(--line-3); }
.bl-bars .hit { fill: transparent; }
.bl-bars .hit.on { fill: var(--hover-tint); }
.bl-tip { position: absolute; top: -8px; transform: translateY(-100%); background: var(--raised); border: 1px solid var(--line-3); border-radius: var(--r); padding: 6px 10px; font: 12px var(--mono); color: var(--text); white-space: nowrap; pointer-events: none; z-index: 2; }
.bl-tip[hidden] { display: none; }
.bl-x { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); font: 12px/1.4 var(--mono); color: var(--muted); }
.bl-x span { min-width: 0; white-space: nowrap; }
.bl-x b { font-weight: 400; color: var(--text-2); }
.bl-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--body); }
.bl-legend li { display: flex; align-items: center; gap: 8px; }
.bl-legend .sw { width: 10px; height: 10px; border-radius: 2px; background: var(--info); }
.bl-legend .sw.now { background: var(--accent-text); }
.bl-legend .sw.zero { height: 2px; border-radius: 0; background: var(--line-3); }

/* ---------- table sections ---------- */
.bl-sec { min-width: 0; }
/* keeps absolutely positioned .sr-only cells inside the scroll box (else they widen the page) */
.bl-sec .table-wrap { position: relative; }
.bl-sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; padding: 20px 24px 12px; }
.bl-sec-head h2 { margin: 0; }
.bl-sec-head p { font-size: 13px; color: var(--muted); }
.bl-table th { padding: 10px 16px; }
.bl-table td, .bl-table tbody th { padding: 12px 16px; height: 48px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.bl-table th:first-child, .bl-table td:first-child { padding-left: 24px; }
.bl-table th:last-child, .bl-table td:last-child { padding-right: 24px; }
.bl-table tbody tr:last-child td, .bl-table tbody tr:last-child th { border-bottom: 0; }
.bl-table tbody th { text-align: left; font: 500 14px var(--sans); color: var(--text); white-space: normal; }
.bl-table .num { text-align: right; font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.bl-table thead th.num { font: 500 12px var(--sans); }
.bl-table .num.dim, .bl-table .dim { color: var(--body); }
.bl-table .num .txt { font-family: var(--sans); font-size: 14px; color: var(--body); }
.bl-table .num .txt.sub { font-size: 12px; color: var(--muted); }
.bl-table .mono.muted { color: var(--muted); white-space: nowrap; }
.bl-table td.mono { white-space: nowrap; }
.bl-table tbody tr > :first-child { min-width: 140px; }
.bl-table .plan { color: var(--text-2); }
.bl-inst { color: var(--text); font-weight: 500; }
.bl-inst:hover { color: var(--accent-text); text-decoration: none; }
.bl-del { display: inline-block; margin-top: 4px; font-size: 13px; color: var(--bad); white-space: nowrap; }
.bl-table .when { color: var(--text-2); white-space: nowrap; }
.bl-table .pos { color: var(--ok-text); }
.bl-table .neg { color: var(--bad); }
.bl-table .note { color: var(--body); min-width: 180px; }
.bl-table .links { white-space: nowrap; }
.bl-table .links a + a { margin-left: 16px; }
.bl-table tr.total td, .bl-table tr.total th { border-top: 1px solid var(--line-3); }
.bl-table tr.total th { font-weight: 600; }
.bl-table tr.total td:last-child { font-weight: 500; }
.bl-foot { padding: 12px 24px 18px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.bl-sec .empty { border-top: 1px solid var(--line); }

/* usage + how billing works */
.bl-split > .bl-sec { flex: 3 1 520px; }
.bl-how { flex: 2 1 340px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.bl-how h2 { margin: 0; }
.bl-how ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; color: var(--body); }
.bl-how li { display: flex; gap: 12px; }
.bl-how li > svg { flex: none; margin-top: 2px; color: var(--muted); }
.bl-how .hi { color: var(--text); }

.bl-locked-sec h2 { margin: 0 0 6px; }
.bl-error { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; border-color: var(--bad-line); }
.bl-error p { flex: 1 1 280px; color: var(--text-2); }

/* ---------- checkout confirm dialog ---------- */
.bl-dlg { width: min(400px, calc(100vw - 32px)); }
.bl-dlg form { display: flex; flex-direction: column; gap: 16px; }
.bl-dlg h2 { margin: 0; font-size: 19px; }
.bl-dlg p { margin: 0; }
.bl-dlg .actions { margin-top: 0; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .bl-add { max-width: none; }
  .bl-tile .v { font-size: 26px; }
  .bl-preset, .bl-goadd, .bl-ret button, .bl-dlg button, #bl-continue, #bl-reload, #bl-how-btn, .bl-money input, .bl-promo-row input, .bl-promo-row button { min-height: 44px; }
  .bl-ret .bl-dismiss { width: 44px; }
}
@media (max-width: 560px) {
  .bl-chart, .bl-add, .bl-how { padding: 20px 16px; }
  .bl-sec-head { padding: 16px 16px 10px; }
  .bl-table th:first-child, .bl-table td:first-child { padding-left: 16px; }
  .bl-table th:last-child, .bl-table td:last-child { padding-right: 16px; }
  .bl-foot { padding: 12px 16px 16px; }
  .bl-y { width: 44px; }
  .bl-plot { gap: 8px; }
  .bl-x { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bl-x span:nth-child(even) { display: none; }
  .bl-warn .msg { flex-basis: 100%; }
}
.bl-spin .track { stroke: var(--line-card); }
