/* billing_spa.css — BriefProposal Billing & Wallet UI
   Uses the same CSS variables as spa.css:
   --bg, --surface, --surface2, --border, --border2,
   --text1, --text2, --text3, --accent, --accent-bg, --accent-border,
   --pass, --pass-bg, --warn, --warn-bg, --fail, --fail-bg,
   --font-sans, --font-mono, --font-display
*/

/* ── WALLET WIDGET in topbar ───────────────────────────────── */
#bp-wallet-widget {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, box-shadow .15s;
  text-decoration: none;
  color: var(--text2);
}
#bp-wallet-widget:hover {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 2px var(--accent-bg);
  color: var(--text1);
}
#bp-wallet-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
}
#bp-wallet-dot.ok   { background: var(--pass); }
#bp-wallet-dot.warn { background: var(--warn); }
#bp-wallet-dot.low  { background: var(--fail); }

/* ── BILLING PAGE ──────────────────────────────────────────── */
.bp-page {
  padding: 28px 32px 56px;
  max-width: 1060px;
}
.bp-page-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text1);
  margin-bottom: 24px;
}
.bp-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 28px 0 12px;
}
.bp-section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text3);
}

/* ── STAT CARDS ────────────────────────────────────────────── */
.bp-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.bp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
}
.bp-card--accent {
  border-color: var(--accent-border);
  background: var(--accent-bg);
}
.bp-card--profit {
  border-color: #86efac;
  background: var(--pass-bg);
}
.bp-card__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text3);
  margin-bottom: 6px;
}
.bp-card__value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text1);
  line-height: 1.2;
}
.bp-card__sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
  line-height: 1.4;
}

/* Credit progress bar */
.bp-bar-track {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.bp-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width .4s ease;
  background: var(--pass);
}
.bp-bar-fill.warn { background: var(--warn); }
.bp-bar-fill.low  { background: var(--fail); }

/* ── TABLE ─────────────────────────────────────────────────── */
.bp-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 4px;
}
.bp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.bp-table thead th {
  background: var(--surface2);
  color: var(--text3);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 9px 13px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.bp-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.bp-table tbody tr:last-child { border-bottom: none; }
.bp-table tbody tr:hover { background: var(--surface2); }
.bp-table td {
  padding: 9px 13px;
  color: var(--text1);
  vertical-align: middle;
}
.bp-mono { font-family: var(--font-mono); font-size: 12px; }
.bp-trunc { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-empty { text-align: center; color: var(--text3); padding: 28px !important; font-style: italic; }

/* ── BADGES ────────────────────────────────────────────────── */
.bp-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.bp-badge--ok   { background: var(--pass-bg);  color: var(--pass); }
.bp-badge--info { background: var(--accent-bg); color: var(--accent); }
.bp-badge--warn { background: var(--warn-bg);   color: var(--warn); }
.bp-badge--fail { background: var(--fail-bg);   color: var(--fail); }
.bp-badge--dim  { background: var(--surface2);  color: var(--text3); }

/* ── ALERT BANNERS ─────────────────────────────────────────── */
.bp-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}
.bp-alert--warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }
.bp-alert--ok   { background: var(--pass-bg); color: var(--pass); border: 1px solid #86efac; }

/* ── BUTTONS ───────────────────────────────────────────────── */
.bp-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text1);
  font-family: var(--font-sans);
  transition: all .13s;
  white-space: nowrap;
}
.bp-btn:hover { background: var(--surface2); border-color: var(--border2); }
.bp-btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.bp-btn--primary:hover { filter: brightness(1.1); }
.bp-btn--danger {
  background: var(--fail-bg);
  color: var(--fail);
  border-color: #fca5a5;
}
.bp-btn--danger:hover { background: var(--fail); color: #fff; }
.bp-btn--sm { padding: 4px 10px; font-size: 12px; }
.bp-btn--xs { padding: 2px 7px; font-size: 11px; border-radius: 4px; }

/* ── FORM CONTROLS ─────────────────────────────────────────── */
.bp-input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-sans);
  background: var(--surface);
  color: var(--text1);
  transition: border-color .15s;
}
.bp-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.bp-err { color: var(--fail); font-size: 12px; margin-top: 5px; }

/* ── OFFBOARD MODAL CONTENT ────────────────────────────────── */
.bp-offboard {
  text-align: center;
  max-width: 460px;
  margin: 0 auto;
}
.bp-offboard__icon { font-size: 44px; color: var(--warn); margin-bottom: 10px; }
.bp-offboard__title { font-family: var(--font-display); font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.bp-offboard__body { font-size: 14px; color: var(--text2); line-height: 1.6; }
.bp-offboard .bp-input { margin-top: 14px; text-align: center; font-weight: 600; }
.bp-offboard__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ── MODAL OVERLAY (shared with main SPA style) ────────────── */
#bp-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(18,20,26,.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
}
#bp-modal-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 28px 30px;
  max-width: 680px;
  width: 92%;
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
}

/* ── STATE ─────────────────────────────────────────────────── */
.bp-loading {
  padding: 48px;
  text-align: center;
  color: var(--text3);
  font-size: 14px;
}
.bp-error {
  padding: 16px;
  background: var(--fail-bg);
  color: var(--fail);
  border-radius: 6px;
  font-size: 13px;
  margin: 20px;
}

/* ── TEXT COLOUR UTILITIES ─────────────────────────────────── */
.bp-green { color: var(--pass); }
.bp-amber { color: var(--warn); }
.bp-red   { color: var(--fail); }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .bp-page { padding: 16px 14px 40px; }
  .bp-cards { grid-template-columns: 1fr; }
  .bp-page-title { font-size: 18px; }
  .bp-section-head { flex-direction: column; align-items: flex-start; }
  .bp-table thead th, .bp-table td { padding: 8px 10px; font-size: 12px; }
}

/* ── MARGIN COLOUR CLASSES ──────────────────────────────────── */
.bp-margin--good { color: #16a34a; font-weight: 600; }
.bp-margin--ok   { color: var(--text2); }
.bp-margin--loss { color: var(--fail); font-weight: 600; }
