/* views-billing.css — Billing & credit (#/billing), the invoice view and the
   owner's Wallets page (economics D). Tokens from styles/tokens.css. */
.billing { display: flex; flex-direction: column; gap: 16px; max-width: 960px; margin: 0 auto; padding: 16px; }
.billing-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.billing-title { font-size: 20px; margin: 0; }
.billing-note { color: var(--text-muted); font-size: 12px; margin: 8px 0 0; }
.billing-warn { color: var(--warn, #d69e2e); font-size: 13px; }
.billing-balance { font-family: 'IBM Plex Mono', monospace; font-size: 32px; font-weight: 600; }
.billing-state { margin: 8px 0; }
.billing-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.billing-amount, .billing-auto input[type="text"] { width: 120px; }
.billing-auto { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 12px; }
.billing-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
/* A checkbox field: inline row (checkbox + text), never stretched to the full
   row width — the default column layout above stretches a bare <input> to
   the label's cross-axis size (align-items: stretch), which for a checkbox
   in a flex-column ancestor (.bw-settings) blows it up to the card's width. */
.billing-field-check { flex-direction: row; align-items: center; gap: 8px; }
.billing-field-check input[type="checkbox"] { flex: 0 0 auto; width: auto; align-self: auto; }
.billing-tier { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.billing-tier-incl { color: var(--text-muted); font-size: 12px; }
.billing-doc-bar { display: flex; justify-content: space-between; align-items: center; }
.billing-paper { background: #fff; color: #111; padding: 32px; border-radius: 4px; }
.billing-paper .dt, .billing-paper .dt th, .billing-paper .dt td { color: #111; }
/* The paper is always a white page (screen or print), regardless of the
   app's theme — but .dt thead (components.css) paints var(--bg-1), which is
   dark in dark theme, under the #111 header text above (dark-on-dark,
   unreadable). Force a light header background here too. */
.billing-paper .dt thead { background: #f3f3f3; }
.billing-parties { display: flex; flex-wrap: wrap; gap: 48px; margin: 24px 0; }
.billing-paper-total { font-weight: 600; margin-top: 16px; }
.billing-paper-note { font-size: 12px; color: #444; }
.billing-paper-test { border: 2px solid #b45309; color: #b45309; font-weight: 700; padding: 8px 12px; margin: 0 0 16px; text-align: center; letter-spacing: 0.02em; }
.billing-test-text { font-size: 13px; color: var(--warn); margin: 4px 0 8px; }
.billing-with-test { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bw-adjust { display: flex; flex-direction: column; gap: 12px; }
.bw-settings { display: flex; flex-direction: column; gap: 12px; }
@media print {
  .nav-shell, .topbar, .tabbar, .no-print { display: none !important; }
  .billing { padding: 0; max-width: none; }
  .billing-paper { padding: 0; }
}

/* ── Economics E: the Billing tab row, the spend-cap editor ── */
.billing-tabs { display: flex; flex-wrap: wrap; gap: 4px; max-width: 960px; margin: 16px auto 0; padding: 0 16px; border-bottom: 1px solid var(--border); box-sizing: border-box; }
/* Inside a page root the row takes the root's width: the planner's tab slot,
   and the .billing roots of E's Live usage / Statements pages (Tasks 17/18
   append the row inside `.billing`; D's Credit page puts it before its root). */
.billing > .billing-tabs, .pp-tabs-slot > .billing-tabs { margin: 0; padding: 0; max-width: none; }
.pp-tabs-slot:empty { display: none; }
.billing-tabs a { padding: 8px 12px; border-radius: 6px 6px 0 0; color: var(--text-muted); text-decoration: none; }
.billing-tabs a:hover { color: var(--text-1, inherit); }
.billing-tabs a.active { color: var(--text-1, inherit); border: 1px solid var(--border); border-bottom-color: transparent; }
.billing-cap-editor .billing-actions { align-items: flex-end; }
.billing-cap-editor input[data-field="cap"] { width: 140px; }

/* ── Economics E: the planner's billing parts (price-planner.js, .pp-*) ── */
.pp-credit .card-body, .pp-cap .card-body, .pp-saved .card-body { display: flex; flex-direction: column; gap: var(--s2, 8px); }
.pp-required { margin: 0; font-size: 14px; color: var(--text-1, inherit); line-height: 1.5; }
.pp-included { color: var(--text-2, inherit); }
.pp-saved-note, .pp-recomputed { margin: 0 0 var(--s2, 8px); font-size: 13px; color: var(--text-2, inherit); }
.pp-saved[hidden] { display: none; }
.pp-result-slot { display: flex; flex-direction: column; gap: var(--s4, 16px); }
.pp-result-slot:empty { display: none; }
@media (max-width: 480px) {
  .billing-cap-editor input[data-field="cap"] { width: 100%; }
  .billing-cap-editor .billing-field { flex: 1 1 100%; }
}

/* ── Economics E: the in-app customer alert banner (Task 19, nav-shell.js) ──
   Sits right under .topbar, full width, in the #app flex column (nav-shell.js
   inserts `.billing-alert-slot` as .topbar's next sibling). Same monochrome
   dim-background/accent-text convention as the platform's other severity
   banners/chips (styles/views-device-health.css .dh-stale-banner,
   styles/views-dect.css .alert-chip, styles/status.css .st-chip) — no new
   colour language. sev-info is a neutral fallback (the feed today only ever
   sends warn/critical). */
.billing-alert-slot:empty { display: none; }
.billing-alert-banner {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s3, 12px);
  padding: 10px calc(18px + var(--safe-right)) 10px calc(18px + var(--safe-left));
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px; line-height: 1.4;
}
.billing-alert-banner.sev-warn { background: var(--warn-dim); color: var(--warn); }
.billing-alert-banner.sev-critical { background: var(--danger-dim); color: var(--danger); }
.billing-alert-banner.sev-info { background: var(--bg-2); color: var(--text-2); }
.billing-alert-text { flex: 1 1 260px; min-width: 0; word-break: break-word; }
.billing-alert-open {
  flex: none; color: inherit; font-weight: 600; text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
}
.billing-alert-open:hover { text-decoration-color: currentColor; }
.billing-alert-dismiss {
  flex: none; margin-left: auto; font-family: var(--font-ui); font-size: 12px; line-height: 1.2;
  color: inherit; background: transparent; border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  border-radius: var(--r-sm); padding: 4px 10px; cursor: pointer;
}
.billing-alert-dismiss:hover { background: color-mix(in srgb, currentColor 14%, transparent); }
.billing-alert-open:focus-visible, .billing-alert-dismiss:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
@media (max-width: 480px) {
  .billing-alert-banner {
    padding: 8px calc(12px + var(--safe-right)) 8px calc(12px + var(--safe-left));
    font-size: 12.5px;
  }
  .billing-alert-text { flex-basis: 100%; }
  .billing-alert-dismiss { margin-left: 0; }
}

/* ── Economics E: Live usage (billing-live.js) and Statements (billing-statements.js) ──
   Found in the Task 20 real-browser check: without these the alert log ran
   time, title and body together and each statement label ran into its amount. */
.live-body, .statements-body, .statement-body { display: flex; flex-direction: column; gap: var(--s4, 16px); }
.live-show-all, .statement-body > a { align-self: flex-start; font-size: 13px; }
.live-credit, .live-burn, .live-event, .live-alerts {
  display: flex; flex-direction: column; gap: var(--s2, 8px); font-size: 13px; line-height: 1.5;
}
.live-credit p, .live-burn p, .live-event p { margin: 0; }
.live-credit > a { align-self: flex-start; }
.live-balance { font-family: 'IBM Plex Mono', monospace; font-size: 28px; font-weight: 600; }
.live-credit .billing-state { align-self: flex-start; margin: 0; }
.live-at-zero, .live-projection { color: var(--text-2); }
.live-burn-total { font-weight: 600; }
.live-cap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2, 8px) var(--s3, 12px); }
.live-cap progress { flex: 0 1 160px; max-width: 100%; height: 8px; accent-color: var(--accent); }
.live-cap[data-reached="true"] progress { accent-color: var(--danger); }
.live-cap[data-reached="true"] .live-cap-text { color: var(--danger); }
.live-cap-text { flex: 1 1 220px; min-width: 0; }
.live-alert {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px var(--s3, 12px);
  padding: 6px 0 6px var(--s3, 12px); border-left: 3px solid var(--border-strong);
}
.live-alert[data-severity="warn"] { border-left-color: var(--warn); }
.live-alert[data-severity="critical"] { border-left-color: var(--danger); }
.live-alert-time { grid-column: 1; grid-row: 1; color: var(--text-muted); font-family: 'IBM Plex Mono', monospace; font-size: 12px; white-space: nowrap; }
.live-alert-title, .live-alert-body, .live-alert-note { grid-column: 2; min-width: 0; word-break: break-word; }
.live-alert-body { color: var(--text-2); }
.live-alert-note { color: var(--text-muted); font-size: 12px; }
.live-metered { margin: 0; color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.statement-summary { display: flex; flex-direction: column; gap: var(--s2, 8px); }
.statement-figure {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline;
  gap: var(--s1, 4px) var(--s4, 16px); padding-bottom: var(--s2, 8px); border-bottom: 1px solid var(--border-subtle);
}
.statement-figure .billing-note { margin: 0; font-size: 13px; }
.statement-figure strong { font-family: 'IBM Plex Mono', monospace; font-size: 15px; }
.statement-figure.st-total strong { font-size: 17px; }
.st-balance-note { margin: 0; }
@media (max-width: 480px) {
  .live-alert { grid-template-columns: minmax(0, 1fr); }
  .live-alert-time, .live-alert-title, .live-alert-body, .live-alert-note { grid-column: 1; grid-row: auto; }
}
