/* Resumen por cliente — Facturación e ingresos (Ingenio CRM) */

.cbs-page {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.cbs-hero {
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 55%, #f1f5f9 100%);
  border: 1px solid #dbeafe;
  border-radius: 16px;
  padding: 1.35rem 1.5rem;
}

.cbs-hero__title {
  margin: 0;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 800;
  color: #082b5b;
  letter-spacing: -0.02em;
}

.cbs-hero__lead {
  margin: 0.4rem 0 0;
  color: #64748b;
  font-size: 0.92rem;
  max-width: 52ch;
}

/* Filtros responsive */
.cbs-filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem 1rem;
  margin-top: 1.15rem;
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(15, 76, 151, 0.05);
}

@media (min-width: 640px) {
  .cbs-filters {
    grid-template-columns: repeat(2, 1fr);
  }
  .cbs-filters__actions {
    grid-column: 1 / -1;
  }
}

@media (min-width: 900px) {
  .cbs-filters {
    grid-template-columns: 1.4fr 1fr 1fr 1fr auto auto;
    align-items: end;
  }
  .cbs-filters__actions {
    grid-column: auto;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }
}

.cbs-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.cbs-field__label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cbs-field__label svg {
  width: 14px;
  height: 14px;
  color: #0f4c97;
  flex-shrink: 0;
}

.cbs-field input,
.cbs-field select {
  height: 42px;
  padding: 0 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #0f172a;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.cbs-field input:focus,
.cbs-field select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.cbs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 42px;
  padding: 0 1rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.15s;
}

.cbs-btn svg {
  width: 16px;
  height: 16px;
}

.cbs-btn--primary {
  background: linear-gradient(135deg, #0f4c97, #1d5fbb);
  color: #fff;
  border-color: #0f4c97;
}

.cbs-btn--primary:hover {
  background: linear-gradient(135deg, #0d4080, #0f4c97);
}

.cbs-btn--ghost {
  background: #fff;
  color: #0f4c97;
  border-color: #bfdbfe;
}

.cbs-btn--ghost:hover {
  background: #eff6ff;
}

.cbs-btn:active {
  transform: scale(0.98);
}

.cbs-btn.is-active {
  background: linear-gradient(135deg, #0f4c97, #1d5fbb);
  color: #fff;
  border-color: #0f4c97;
}

/* KPI cards */
.cbs-kpis {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 0.5rem;
}

@media (min-width: 640px) {
  .cbs-kpis {
    grid-template-columns: repeat(3, 1fr);
  }
}

.cbs-kpi {
  position: relative;
  padding: 1.1rem 1.15rem 1rem;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 22px rgba(15, 76, 151, 0.06);
  overflow: hidden;
}

.cbs-kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: 14px 0 0 14px;
  background: var(--cbs-accent, #0f4c97);
}

.cbs-kpi--facturado { --cbs-accent: #0f4c97; }
.cbs-kpi--pagado { --cbs-accent: #15803d; }
.cbs-kpi--saldo { --cbs-accent: #b45309; }
.cbs-kpi--saldo.cbs-kpi--ok { --cbs-accent: #64748b; }

.cbs-kpi__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.cbs-kpi__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eff6ff;
  color: #0f4c97;
}

.cbs-kpi--pagado .cbs-kpi__icon {
  background: #dcfce7;
  color: #15803d;
}

.cbs-kpi--saldo .cbs-kpi__icon {
  background: #fff7ed;
  color: #c2410c;
}

.cbs-kpi--saldo.cbs-kpi--ok .cbs-kpi__icon {
  background: #f1f5f9;
  color: #64748b;
}

.cbs-kpi__label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.cbs-kpi__value {
  margin: 0.15rem 0 0;
  font-size: clamp(1.2rem, 2.5vw, 1.55rem);
  font-weight: 800;
  color: #082b5b;
  letter-spacing: -0.02em;
}

.cbs-kpi__meta {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: #94a3b8;
}

/* Panel cliente */
.cbs-client-panel {
  border-radius: 16px;
  border: 1px solid #dbeafe;
  background: #fff;
}

.cbs-client-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}

.cbs-client-panel__name {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: #082b5b;
}

.cbs-client-panel__scope {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: #64748b;
}

.cbs-section-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 1.25rem 0 0.65rem;
  font-size: 1rem;
  font-weight: 700;
  color: #1e3a5f;
}

.cbs-section-title svg {
  width: 18px;
  height: 18px;
  color: #0f4c97;
}

/* Tablas */
.cbs-table-wrap {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: auto;
  background: #fff;
}

.cbs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.cbs-table thead {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
}

.cbs-table th {
  padding: 0.7rem 0.85rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

.cbs-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

.cbs-table tbody tr:hover {
  background: #f8fafc;
}

.cbs-table tbody tr.cbs-row--selected {
  background: #eff6ff;
}

.cbs-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.cbs-table .cbs-saldo--high {
  color: #b45309;
  font-weight: 700;
}

.cbs-table .cbs-saldo--zero {
  color: #64748b;
}

.cbs-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.cbs-badge--ticket {
  background: #dbeafe;
  color: #1d4ed8;
}

.cbs-badge--manual {
  background: #e0e7ff;
  color: #4338ca;
}

.cbs-badge--ok {
  background: #dcfce7;
  color: #15803d;
}

.cbs-link {
  color: #0f4c97;
  font-weight: 600;
  text-decoration: none;
}

.cbs-link:hover {
  text-decoration: underline;
}

/* Estados vacíos y carga */
.cbs-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 2rem 1.25rem;
  text-align: center;
  color: #64748b;
}

.cbs-state__icon {
  width: 48px;
  height: 48px;
  color: #94a3b8;
  opacity: 0.85;
}

.cbs-state__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #475569;
}

.cbs-state__text {
  margin: 0;
  font-size: 0.85rem;
  max-width: 36ch;
}

.cbs-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 2.5rem 1rem;
  color: #64748b;
  font-size: 0.9rem;
}

.cbs-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #e2e8f0;
  border-top-color: #0f4c97;
  border-radius: 50%;
  animation: cbs-spin 0.75s linear infinite;
}

@keyframes cbs-spin {
  to { transform: rotate(360deg); }
}

.cbs-msg-bar {
  margin-top: 0.85rem;
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  font-size: 0.88rem;
}

.cbs-msg-bar--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.cbs-msg-bar--ok {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.cbs-list-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.cbs-list-card__count {
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 600;
}

/* Badges de estado facturación */
.cbs-status {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.cbs-status--pending { background: #f1f5f9; color: #475569; }
.cbs-status--info { background: #dbeafe; color: #1d4ed8; }
.cbs-status--warn { background: #fff7ed; color: #c2410c; }
.cbs-status--ok { background: #dcfce7; color: #15803d; }
.cbs-status--danger { background: #fef2f2; color: #b91c1c; }
.cbs-status--muted { background: #f8fafc; color: #64748b; }

.cbs-table tbody tr.row-selected,
.cbs-table tbody tr.cbs-row--selected {
  background: #eff6ff;
}

/* Facturación e ingresos — layout */
#view-billing-inbox .bi-form-card {
  border-radius: 16px;
}

#view-billing-inbox .bi-hint {
  margin: 0.85rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 0.88rem;
}

#view-billing-inbox .bi-hint strong {
  color: #334155;
}

#view-billing-inbox .cbs-account-panel {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid #dbeafe;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}

#view-billing-inbox .cbs-view-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 0.25rem;
}

#view-billing-inbox .client-revenue-forms-row {
  margin-top: 1.25rem;
  gap: 1.25rem;
}

@media (min-width: 1024px) {
  #view-billing-inbox .client-revenue-forms-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

#view-billing-inbox .client-revenue-form-col {
  padding: 1rem 1.1rem;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
}

#view-billing-inbox #billing-inbox-list-msg.cbs-msg-bar,
#view-billing-inbox #client-revenue-list-msg.cbs-msg-bar,
#view-billing-inbox #income-client-msg.cbs-msg-bar {
  margin-top: 0.75rem;
}

.cbs-list-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.65rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.cbs-list-pager.hidden {
  display: none;
}

.cbs-list-pager__nav {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

#view-billing-inbox .client-revenue-form-col .cbs-msg-bar {
  margin-top: 0.65rem;
}

.cbs-btn--sm {
  padding: 0.28rem 0.55rem;
  font-size: 0.78rem;
}

.cbs-detail-dialog {
  border: none;
  padding: 0;
  max-width: min(520px, calc(100vw - 2rem));
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
}

.cbs-detail-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.cbs-detail-dialog__panel {
  margin: 0;
  padding: 1.15rem 1.25rem 1rem;
}

.cbs-detail-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.cbs-detail-dialog__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e3a5f;
}

.cbs-detail-dialog__close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0 0.15rem;
}

.cbs-detail-dialog__lead {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  color: #64748b;
}

.cbs-detail-dialog__dl {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.45rem 0.75rem;
  margin: 0;
  font-size: 0.88rem;
}

.cbs-detail-dialog__dl dt {
  margin: 0;
  font-weight: 600;
  color: #475569;
}

.cbs-detail-dialog__dl dd {
  margin: 0;
  color: #1e293b;
  white-space: pre-wrap;
}

.cbs-detail-dialog__dl dd.cbs-detail-dialog__muted {
  color: #94a3b8;
}

.cbs-detail-dialog__fallback {
  margin: 0.85rem 0 0;
  font-size: 0.85rem;
  color: #64748b;
}

.cbs-detail-dialog__foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}
