/**
 * Billing Dashboard — compact Stripe / Linear style
 */

.bd-root {
  max-width: 100%;
  overflow-x: hidden;
}

.bd {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bd--loading .bd-kpi--skeleton {
  min-height: 68px;
  border-radius: 12px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: bd-shimmer 1.2s ease-in-out infinite;
}

@keyframes bd-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Blocks */
.bd-block {
  min-width: 0;
}

.bd-block__title {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}

.bd-block__lead {
  margin: 0 0 12px;
  font-size: 13px;
  color: #64748b;
}

.bd-block--panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.bd-block--history {
  padding-bottom: 12px;
}

/* KPI grid */
.bd-kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 640px) {
  .bd-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .bd-kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.bd-kpi {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 68px;
  min-width: 0;
}

.bd-kpi__label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #94a3b8;
}

.bd-kpi__renewal-urgent {
  color: #dc2626;
  font-weight: 700;
  animation: bd-renewal-blink 1.15s ease-in-out infinite;
}

@keyframes bd-renewal-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.bd-kpi__value {
  font-size: 1.125rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: #0f172a;
  word-break: break-word;
}

.bd-kpi__value .bd-badge {
  font-size: 10px;
  padding: 4px 10px;
}

.bd-kpi__meta {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.3;
}

/* Usage */
.bd-usage-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.bd-usage-stat {
  text-align: center;
  padding: 8px 6px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
}

.bd-usage-stat--accent {
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.12);
}

.bd-usage-stat strong {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
}

.bd-usage-stat--accent strong {
  color: var(--primary, #6366f1);
}

.bd-usage-stat span {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.bd-usage-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.bd-usage-bar__fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  transition: width 0.4s ease;
}

/* Payment card */
.bd-pay-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  min-width: 0;
}

.bd-pay-card--empty {
  flex-wrap: wrap;
}

.bd-pay-card__icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.bd-pay-card__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bd-pay-card__info strong {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.bd-pay-card__info span {
  font-size: 12px;
  color: #64748b;
}

/* Actions */
.bd-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bd-action {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.bd-action:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.bd-action--danger {
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.2);
}

.bd-action--danger:hover {
  background: #fef2f2;
}

.bd-action--primary {
  color: var(--primary, #6366f1);
  border-color: rgba(99, 102, 241, 0.25);
}

/* Buttons */
.bd-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--primary, #6366f1);
  color: #fff;
  white-space: nowrap;
}

.bd-btn:hover {
  filter: brightness(1.05);
}

.bd-btn--ghost {
  background: #fff;
  color: #334155;
  border: 1px solid #e2e8f0;
}

.bd-btn--ghost:hover {
  background: #f8fafc;
}

/* Payable invoices (Billing Activity) */
.bd-payable-empty {
  padding: 16px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px dashed #e2e8f0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

.bd-payable-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.bd-payable-card {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    'main side'
    'actions actions';
  gap: 8px 12px;
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
}

.bd-payable-card__main { grid-area: main; min-width: 0; }
.bd-payable-card__side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.bd-payable-card__actions {
  grid-area: actions;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.bd-payable-card__title {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
}
.bd-payable-card__meta {
  margin-top: 4px;
  font-size: 12px;
  color: #64748b;
}
.bd-payable-card__dot { margin: 0 4px; }
.bd-payable-card__amount {
  font-size: 15px;
  color: #0f172a;
}

.af-host--after-payable {
  margin-top: 4px;
}

/* Alerts */
.bd-alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
}

.bd-alert--error {
  border-color: rgba(239, 68, 68, 0.25);
  background: #fef2f2;
}

.bd-alert--warn {
  border-color: rgba(245, 158, 11, 0.25);
  background: #fffbeb;
}

.bd-alert__copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.bd-alert__copy strong {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.bd-alert__copy span {
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

.bd-alert__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* History */
.bd-history-empty {
  padding: 20px 12px;
  text-align: center;
  color: #64748b;
}

.bd-history-empty span {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.bd-history-empty p {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.4;
}

.bd-table-wrap {
  border: 1px solid #f1f5f9;
  border-radius: 10px;
  overflow: hidden;
  max-width: 100%;
}

.bd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

.bd-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.bd-table th:nth-child(1) { width: 28%; }
.bd-table th:nth-child(2) { width: 24%; }
.bd-table th:nth-child(3) { width: 24%; }
.bd-table th:nth-child(4) { width: 24%; }

.bd-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
  word-break: break-word;
}

.bd-table tbody tr:last-child td {
  border-bottom: none;
}

.bd-link {
  color: var(--primary, #6366f1);
  font-weight: 600;
  font-size: 12px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}

.bd-muted {
  color: #cbd5e1;
}

/* Badges */
.bd-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bd-badge--active { background: rgba(16, 185, 129, 0.14); color: #047857; }
.bd-badge--trial { background: rgba(59, 130, 246, 0.14); color: #1d4ed8; }
.bd-badge--pending { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.bd-badge--warn { background: rgba(239, 68, 68, 0.12); color: #b91c1c; }
.bd-badge--refund { background: rgba(100, 116, 139, 0.14); color: #475569; }
.bd-badge--danger { background: rgba(239, 68, 68, 0.14); color: #b91c1c; }
.bd-badge--neutral { background: #f1f5f9; color: #475569; }

/* Mobile table cards */
@media (max-width: 560px) {
  .bd-kpi__value { font-size: 1rem; }
  .bd-usage-stats { grid-template-columns: 1fr; }
  .bd-alert { flex-direction: column; align-items: stretch; }
  .bd-alert__actions { width: 100%; }

  .bd-table thead { display: none; }
  .bd-table tbody tr {
    display: block;
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
  }
  .bd-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
  }
  .bd-table td::before {
    content: attr(data-label);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    color: #94a3b8;
    flex-shrink: 0;
  }
}
