/* Facturas page */
.fac-controls { margin: 1rem 0; display: flex; justify-content: flex-end; }
.fac-month {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg);
  min-width: 160px;
}

.fac-summary { display: flex; gap: 0.75rem; margin-bottom: 1.25rem; }
.fac-stat {
  flex: 1;
  background: var(--surface);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.fac-stat-label { font-size: 0.78rem; color: var(--text-muted); }
.fac-stat-val { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.fac-list { display: flex; flex-direction: column; gap: 0.5rem; }
.fac-loading, .fac-empty {
  color: var(--text-muted); font-size: 0.9rem;
  padding: 1.5rem 0.5rem; text-align: center;
}

.fac-row { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.fac-row.open { border-color: var(--border-strong); }
.fac-row-head {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  cursor: pointer;
}
.fac-row.open .fac-row-head { background: var(--surface); }
.fac-chev { color: var(--text-muted); font-size: 0.9rem; width: 1rem; }
.fac-avatar {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 50%; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
}
.fac-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fac-name { font-size: 0.95rem; font-weight: 500; }
.fac-id { font-size: 0.78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.fac-total { font-size: 0.95rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.fac-row-body { padding: 0.25rem 0.9rem 0.9rem; }
.fac-items { width: 100%; font-size: 0.82rem; border-collapse: collapse; margin-bottom: 0.75rem; }
.fac-items th {
  text-align: left; font-weight: 400; color: var(--text-faint);
  padding: 0.4rem 0.25rem; border-bottom: 1px solid var(--border);
}
.fac-items td { padding: 0.4rem 0.25rem; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.fac-items .r, .fac-book-table .r { text-align: right; }

.fac-book {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 0.8rem;
}
.fac-book-title { font-size: 0.78rem; font-weight: 600; margin-bottom: 0.5rem; }
.fac-book-table { width: 100%; font-size: 0.85rem; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.fac-book-table td { padding: 0.2rem 0; }
.fac-book-table tr.muted td { color: var(--text-muted); }
.fac-book-table tr.brd td { border-top: 1px solid var(--border-strong); padding-top: 0.45rem; }
.fac-book-table tr.strong td { font-weight: 600; }
/* Customers tab */
.cust-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0 1rem;
}
.cust-intro p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 42ch;
}
.cust-search {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}
.cust-search:focus { outline: none; border-color: var(--text); }

.cust-list { display: flex; flex-direction: column; gap: 0.5rem; }

.cust-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 1.5rem 0.5rem;
  text-align: center;
}

.cust-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.cust-avatar {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
}
.cust-main { flex: 1; min-width: 0; }
.cust-name { font-size: 0.95rem; font-weight: 500; }
.cust-id {
  font-size: 0.78rem; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.cust-noid { font-size: 0.78rem; color: var(--text-faint); font-style: italic; }

.cust-edit-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
}
.cust-edit-btn:hover { border-color: var(--text); }

/* Editing state */
.cust-row.editing {
  flex-direction: column;
  align-items: stretch;
  gap: 0.7rem;
  background: var(--surface);
  border-color: var(--border-strong);
}
.cust-edit-head { display: flex; align-items: center; gap: 0.75rem; }
.cust-edit-controls { display: flex; gap: 0.5rem; }
.cust-type-toggle {
  display: flex; flex-shrink: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  overflow: hidden;
}
.cust-type-opt {
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}
.cust-type-opt.active { background: var(--text); color: var(--bg); }
.cust-id-input {
  flex: 1;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.cust-id-input:focus { outline: none; border-color: var(--text); }
.cust-edit-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* Tab switcher */
.fac-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: 1rem 0 1.25rem;
}
.fac-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
  cursor: pointer;
  margin-bottom: -1px;
}
.fac-tab.active { color: var(--text); border-bottom-color: var(--text); }
.fac-tab-panel[hidden] { display: none; }

/* Refresh button in the tabs row */
.fac-tabs { position: relative; }
.fac-refresh {
  margin-left: auto;
  align-self: center;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  margin-bottom: 0.35rem;
}
.fac-refresh:hover { border-color: var(--text); color: var(--text); }
.fac-refresh.spinning svg { animation: fac-spin 0.6s linear; }
@keyframes fac-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* Customers tab: summary counts + group headings */
.cust-summary {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.cust-summary-stat {
  flex: 1;
  background: var(--surface);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.cust-summary-num { font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }
.cust-summary-label { font-size: 0.72rem; color: var(--text-muted); }
.cust-group-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem;
}
.cust-group-label:first-child { margin-top: 0; }