/* ══════════════════════════════════════════════════════
   SANDRA CONTROL — style.css
   Dark premium design system
   ══════════════════════════════════════════════════════ */

/* ── Google Fonts fallback (si no hay internet) ──────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── Variables / Design Tokens ───────────────────────── */
:root {
  /* Backgrounds */
  --bg:          #06090f;
  --bg-2:        #0b1120;
  --bg-3:        #101928;
  --surface:     #111928;
  --surface-2:   #162135;

  /* Borders */
  --border:      rgba(255,255,255,0.06);
  --border-2:    rgba(255,255,255,0.11);

  /* Green = Entradas */
  --green:       #10b981;
  --green-light: #34d399;
  --green-bg:    rgba(16,185,129,0.09);
  --green-bd:    rgba(16,185,129,0.22);
  --green-glow:  rgba(16,185,129,0.18);

  /* Amber = Salidas */
  --amber:       #f59e0b;
  --amber-light: #fcd34d;
  --amber-bg:    rgba(245,158,11,0.09);
  --amber-bd:    rgba(245,158,11,0.22);

  /* Red = Danger / Deuda */
  --red:         #ef4444;
  --red-light:   #fca5a5;
  --red-bg:      rgba(239,68,68,0.09);
  --red-bd:      rgba(239,68,68,0.25);

  /* Indigo = Clientes / Primary */
  --indigo:      #818cf8;
  --indigo-dark: #6366f1;
  --indigo-bg:   rgba(129,140,248,0.09);
  --indigo-bd:   rgba(129,140,248,0.22);

  /* Text */
  --text:        #f1f5f9;
  --text-2:      #94a3b8;
  --text-3:      #475569;

  /* Misc */
  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   18px;
  --shadow:      0 8px 32px rgba(0,0,0,0.45);
  --shadow-sm:   0 2px 12px rgba(0,0,0,0.3);
  --transition:  0.18s ease;

  /* Font */
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-feature-settings: 'cv11','ss01','ss03';
}

/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════════
   LOGIN SCREEN
   ══════════════════════════════════════════════════════ */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 20% 50%, rgba(16,185,129,0.07) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(129,140,248,0.08) 0%, transparent 50%),
              var(--bg);
}

.login-bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  animation: orbFloat 8s ease-in-out infinite;
}
.orb-1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(16,185,129,0.12) 0%, transparent 70%);
  top: -100px; left: -100px;
}
.orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(129,140,248,0.1) 0%, transparent 70%);
  bottom: -150px; right: -150px;
  animation-delay: -4s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0,0) scale(1); }
  50%       { transform: translate(20px,-20px) scale(1.05); }
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,0.04);
  backdrop-filter: blur(20px);
  position: relative;
  animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 24px rgba(16,185,129,0.4));
}

.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.login-subtitle {
  text-align: center;
  color: var(--text-2);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.login-form { display: flex; flex-direction: column; gap: 1rem; }

.login-error {
  background: var(--red-bg);
  border: 1px solid var(--red-bd);
  color: var(--red-light);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.875rem;
  font-size: 0.875rem;
  display: none;
}
.login-error.visible { display: block; }

/* ── Fields ──────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field input,
.field select,
.field textarea,
.filter-input {
  background: var(--bg-2);
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  padding: 0.65rem 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.filter-input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(129,140,248,0.15);
}

.field textarea {
  resize: vertical;
  min-height: 80px;
}

select.filter-input,
select.field-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

.input-wrap {
  position: relative;
  display: flex;
}

.input-wrap input { padding-right: 2.75rem; }

.toggle-pass {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.5;
  transition: opacity var(--transition);
  padding: 0.25rem;
}
.toggle-pass:hover { opacity: 1; }

/* ══════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.3;
  min-height: 40px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--indigo-dark);
  border-color: var(--indigo-dark);
  color: #fff;
  box-shadow: 0 2px 12px rgba(99,102,241,0.35);
}
.btn-primary:hover:not(:disabled) {
  background: var(--indigo);
  border-color: var(--indigo);
  box-shadow: 0 4px 20px rgba(99,102,241,0.45);
}

.btn-success {
  background: var(--green);
  border-color: var(--green);
  color: #022c22;
  box-shadow: 0 2px 12px rgba(16,185,129,0.35);
  font-weight: 700;
}
.btn-success:hover:not(:disabled) {
  background: var(--green-light);
  box-shadow: 0 4px 20px rgba(16,185,129,0.45);
}

.btn-warning {
  background: var(--amber);
  border-color: var(--amber);
  color: #1c0f00;
  box-shadow: 0 2px 12px rgba(245,158,11,0.3);
  font-weight: 700;
}
.btn-warning:hover:not(:disabled) {
  background: var(--amber-light);
  box-shadow: 0 4px 20px rgba(245,158,11,0.4);
}

.btn-danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 2px 12px rgba(239,68,68,0.3);
}
.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  box-shadow: 0 4px 20px rgba(239,68,68,0.4);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-2);
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text);
}

.btn-sm { font-size: 0.8125rem; padding: 0.4rem 0.875rem; min-height: 34px; }
.btn-full { width: 100%; }
.btn-icon-only { font-size: 1.1rem; }

/* ══════════════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════════════ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  height: 60px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-icon { font-size: 1.5rem; }

.header-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  display: none;
}

.header-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--text-3);
  font-weight: 400;
}

@media (min-width: 640px) {
  .header-title { display: block; }
  .header-sub { display: block; }
}

/* ══════════════════════════════════════════════════════
   NAV TABS
   ══════════════════════════════════════════════════════ */
.nav-tabs {
  display: flex;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 60px;
  z-index: 99;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.7rem 1rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 64px;
}

.nav-tab:hover { color: var(--text-2); background: rgba(255,255,255,0.03); }

.nav-tab.active {
  color: var(--indigo);
  border-bottom-color: var(--indigo);
}

.tab-icon { font-size: 1.3rem; }
.tab-label { font-size: 0.675rem; }

@media (min-width: 480px) {
  .nav-tab { flex-direction: row; gap: 0.4rem; font-size: 0.8125rem; }
  .tab-icon { font-size: 1rem; }
  .tab-label { font-size: 0.8125rem; }
}

/* ══════════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════════ */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

@media (min-width: 768px) {
  .main-content { padding: 2rem 1.5rem 3rem; }
}

.tab-panel { display: block; animation: fadeIn 0.2s ease; }
.tab-panel.hidden { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Page Header ─────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.page-sub {
  color: var(--text-2);
  font-size: 0.875rem;
  margin-top: 0.2rem;
}

/* ── Filters Bar ─────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 130px;
}

.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-grow { flex: 1; min-width: 180px; }

.filter-actions {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
  padding-bottom: 1px;
}

/* ══════════════════════════════════════════════════════
   STAT CARDS — RESUMEN
   ══════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 99px 99px 0 0;
}

.stat-card.green::before { background: var(--green); }
.stat-card.amber::before { background: var(--amber); }
.stat-card.blue::before  { background: var(--indigo); }

.stat-card.red-theme { background: var(--red-bg); border-color: var(--red-bd); }
.stat-card.red-theme::before { background: var(--red); }
.stat-card.green-theme { background: var(--green-bg); border-color: var(--green-bd); }
.stat-card.green-theme::before { background: var(--green); }

.stat-label {
  font-size: 0.7375rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.stat-unit {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-3);
  margin-top: 0.25rem;
}

.stat-badge {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-favor { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-bd); }
.badge-deuda { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-bd); }

.balance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.balance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.balance-icon { font-size: 2.5rem; }

.balance-content {}
.balance-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.balance-value {
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.balance-value.positive { color: var(--green); }
.balance-value.negative { color: var(--red); }
.balance-value.neutral  { color: var(--text-2); }

/* ── Recent Activity ─────────────────────────────────── */
.section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}

/* ══════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════ */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.7375rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

td {
  padding: 0.875rem 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.025); }

.td-fecha { font-weight: 600; white-space: nowrap; }
.td-num   { font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; }
.td-green { color: var(--green); }
.td-amber { color: var(--amber); }
.td-name  { font-weight: 600; }

.td-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  white-space: nowrap;
}

.btn-table-edit {
  background: var(--indigo-bg);
  border: 1px solid var(--indigo-bd);
  color: var(--indigo);
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all var(--transition);
}
.btn-table-edit:hover {
  background: var(--indigo-dark);
  color: #fff;
}

.btn-table-del {
  background: var(--red-bg);
  border: 1px solid var(--red-bd);
  color: var(--red);
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all var(--transition);
}
.btn-table-del:hover {
  background: var(--red);
  color: #fff;
}

/* Table footer with totals */
.table-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-3);
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-2);
}

.table-footer strong { color: var(--text); font-weight: 700; }
.table-count { color: var(--text-3); font-size: 0.8rem; }

/* ══════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--text-3);
}

.empty-icon { font-size: 3rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-title { font-size: 1rem; font-weight: 600; color: var(--text-2); margin-bottom: 0.4rem; }
.empty-sub   { font-size: 0.875rem; }

/* ── Loading state ───────────────────────────────────── */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-3);
  gap: 0.5rem;
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-2);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════
   CLIENTE CARDS
   ══════════════════════════════════════════════════════ */
.clientes-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.875rem;
}

@media (min-width: 640px)  { .clientes-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .clientes-grid { grid-template-columns: 1fr 1fr 1fr; } }

.cliente-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.cliente-card:hover {
  border-color: var(--indigo-bd);
  background: var(--surface-2);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.cliente-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.cliente-avatar {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.avatar-proveedor { background: linear-gradient(135deg, var(--green), #059669); }
.avatar-cliente   { background: linear-gradient(135deg, var(--amber), #d97706); }
.avatar-ambos     { background: linear-gradient(135deg, var(--indigo-dark), #4338ca); }

.cliente-card-name { font-weight: 700; font-size: 1rem; color: var(--text); line-height: 1.2; }

.tipo-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tipo-proveedor { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-bd); }
.tipo-cliente   { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-bd); }
.tipo-ambos     { background: var(--indigo-bg); color: var(--indigo); border: 1px solid var(--indigo-bd); }

.cliente-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.mini-stat {
  background: var(--bg-3);
  border-radius: 8px;
  padding: 0.5rem 0.625rem;
}

.mini-stat-label { font-size: 0.65rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.mini-stat-value { font-size: 1.05rem; font-weight: 800; margin-top: 0.1rem; }
.mini-stat-value.green { color: var(--green); }
.mini-stat-value.amber { color: var(--amber); }

.cliente-card-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 1rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
}

.btn-ver-historial {
  flex: 1;
  background: var(--indigo-bg);
  border: 1px solid var(--indigo-bd);
  color: var(--indigo);
  font-size: 0.8125rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all var(--transition);
  text-align: center;
}
.btn-ver-historial:hover {
  background: var(--indigo-dark);
  color: #fff;
}

/* ── Client detail view ──────────────────────────────── */
.detail-title-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.back-btn {
  flex-shrink: 0;
}

.detail-header-actions {
  display: flex;
  gap: 0.5rem;
}

.detail-stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 0.5rem;
}

@media (min-width: 640px) {
  .detail-stats-row { grid-template-columns: repeat(4, 1fr); }
}

/* Tipo-row movimientos */
.mov-tipo-entrada { background: rgba(16,185,129,0.06); }
.mov-tipo-salida  { background: rgba(245,158,11,0.05); }

.mov-badge-entrada {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-bd);
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.mov-badge-salida {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber-bd);
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════════════
   BACKUPS LIST
   ══════════════════════════════════════════════════════ */
.backup-info {
  background: var(--green-bg);
  border: 1px solid var(--green-bd);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.backup-info-icon { font-size: 1.25rem; flex-shrink: 0; margin-top: 0.1rem; }

.backup-info-text { font-size: 0.875rem; color: var(--green-light); }
.backup-info-text strong { color: var(--green-light); }

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

.backup-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: background var(--transition);
}

.backup-item:hover { background: var(--surface-2); }

.backup-ext {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.45rem;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.ext-db   { background: var(--indigo-bg); color: var(--indigo); border: 1px solid var(--indigo-bd); }
.ext-json { background: var(--amber-bg);  color: var(--amber);  border: 1px solid var(--amber-bd); }

.backup-name { font-size: 0.875rem; font-weight: 500; color: var(--text); font-family: monospace; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.backup-size { font-size: 0.8rem; color: var(--text-3); white-space: nowrap; }

/* ══════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}

.modal-overlay.hidden { display: none !important; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color var(--transition);
  border-radius: 6px;
}

.modal-close:hover { color: var(--text); background: var(--bg-3); }

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* Modal form rows */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.875rem;
}

/* ══════════════════════════════════════════════════════
   CONFIRM DIALOG
   ══════════════════════════════════════════════════════ */
.confirm-box {
  background: var(--surface);
  border: 1px solid var(--red-bd);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: scaleIn 0.2s ease;
}

.confirm-icon { font-size: 2.5rem; margin-bottom: 0.875rem; }
.confirm-box h3 { font-size: 1.125rem; font-weight: 800; margin-bottom: 0.5rem; }
.confirm-box p  { font-size: 0.875rem; color: var(--text-2); line-height: 1.5; margin-bottom: 1.5rem; }

.confirm-actions { display: flex; gap: 0.75rem; justify-content: center; }

/* ══════════════════════════════════════════════════════
   TOASTS
   ══════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1.125rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 240px;
  max-width: 360px;
  box-shadow: var(--shadow);
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: auto;
}

.toast.visible { transform: translateX(0); opacity: 1; }

.toast-success {
  background: #052e16;
  border: 1px solid var(--green-bd);
  color: var(--green-light);
}

.toast-error {
  background: #1c0303;
  border: 1px solid var(--red-bd);
  color: var(--red-light);
}

.toast-info {
  background: var(--indigo-bg);
  border: 1px solid var(--indigo-bd);
  color: var(--indigo);
}

/* ══════════════════════════════════════════════════════
   MISC
   ══════════════════════════════════════════════════════ */
.hidden { display: none !important; }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-red   { color: var(--red); }
.text-muted { color: var(--text-3); }
.font-mono  { font-family: monospace; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nota-text {
  font-size: 0.8rem;
  color: var(--text-3);
  font-style: italic;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Responsive tweaks ───────────────────────────────── */
@media (max-width: 480px) {
  .form-row   { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .balance-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .btn-label-desktop { display: none; }
}

/* ══════════════════════════════════════════════════════
   NUEVOS COMPONENTES — v2
   ══════════════════════════════════════════════════════ */

/* ── Header actions group ─────────────────────────────── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ── Quick filter chips ───────────────────────────────── */
.quick-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.625rem 1.25rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.qf-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.25rem;
  white-space: nowrap;
}

.qf-btn {
  padding: 0.28rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.qf-btn:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-2);
}

.qf-btn.active {
  color: #fff;
  background: var(--indigo-dark);
  border-color: var(--indigo-dark);
  font-weight: 600;
}

/* ── Chart container ──────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  box-sizing: border-box;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
  .chart-grid { grid-template-columns: 1fr; }
}

/* ── Section header (title + button) ─────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

/* ── Nombre select (dropdowns in forms) ───────────────── */
.nombre-select {
  width: 100%;
  padding: 0.65rem 0.875rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.25rem;
  transition: border-color 0.18s;
}

.nombre-select:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(129,140,248,0.15);
}

.nombre-select option.opt-nuevo {
  color: var(--indigo);
  font-weight: 600;
}

.nuevo-nombre-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
  animation: slideDown 0.18s ease;
}

.nuevo-nombre-row input {
  flex: 1;
}

.nuevo-hint {
  font-size: 0.75rem;
  color: var(--indigo);
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Required field marker ────────────────────────────── */
.req { color: var(--red); margin-left: 2px; }

/* ── Red text for negative balances ──────────────────────*/
.td-red { color: var(--red) !important; }

/* ── Monthly table tfoot ──────────────────────────────── */
tfoot td {
  padding: 0.7rem 1rem;
  font-size: 0.875rem;
}

/* ── Detail stats row ─────────────────────────────────── */
.detail-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.875rem;
  margin-top: 0.5rem;
}

@media (max-width: 900px) {
  .detail-stats-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .detail-stats-row { grid-template-columns: 1fr 1fr; }
}

/* ── Empty months in monthly table ───────────────────── */
.month-empty { opacity: 0.3; }

/* ── Year selector in resumen ─────────────────────────── */
.year-selector-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ══════════════════════════════════════════════════════
   PRINT STYLES
   ══════════════════════════════════════════════════════ */
@media print {
  .header, .nav-tabs, .page-header .btn,
  .filters-bar, .quick-filters, .filter-actions,
  .td-actions, .header-actions, #toast-container,
  #modal-overlay, #confirm-overlay { display: none !important; }

  body { background: white !important; color: black !important; }
  .tab-panel { display: block !important; }
  .tab-panel.hidden { display: none !important; }
  table { border-collapse: collapse; width: 100%; }
  th, td { border: 1px solid #ccc; padding: 6px 10px; color: black !important; }
  .stat-card, .balance-card { background: #f9f9f9 !important; border: 1px solid #ddd !important; }
}

/* ══════════════════════════════════════════════════════
   NUEVOS COMPONENTES — v3
   ══════════════════════════════════════════════════════ */

/* ── Balance negativo alert banner ───────────────────── */
.balance-alert {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(239,68,68,0.08));
  border-bottom: 1px solid rgba(239,68,68,0.35);
  color: #fca5a5;
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideDown 0.25s ease;
}
.alert-icon { font-size: 1.1rem; flex-shrink: 0; }
.balance-alert span:nth-child(2) { flex: 1; }
.alert-dismiss {
  background: none; border: none; color: #fca5a5; cursor: pointer;
  font-size: 1rem; padding: 0.2rem 0.4rem; border-radius: 4px;
  opacity: 0.7; transition: opacity 0.15s;
}
.alert-dismiss:hover { opacity: 1; background: rgba(239,68,68,0.2); }

/* ── Global search overlay ────────────────────────────── */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(3rem, 8vh, 7rem);
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.search-panel {
  width: 100%;
  max-width: 680px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  overflow: hidden;
  animation: slideDown 0.2s ease;
  margin: 0 1rem;
}

.search-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.search-icon { font-size: 1.2rem; flex-shrink: 0; }

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--text);
  caret-color: var(--indigo);
}
.search-input::placeholder { color: var(--text-3); }

.search-close {
  background: none; border: none; color: var(--text-3);
  font-size: 1rem; cursor: pointer; padding: 0.25rem 0.5rem;
  border-radius: 6px; transition: all 0.15s;
}
.search-close:hover { color: var(--text); background: var(--surface-2); }

.search-filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.search-results {
  max-height: 55vh;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.search-hint {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--text-3);
  font-size: 0.875rem;
}

.search-section-title {
  padding: 0.5rem 1.25rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}
.search-section-title:first-child { border-top: none; margin-top: 0; }

.search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  cursor: pointer;
  transition: background 0.12s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.search-result-item:hover { background: var(--surface-2); }

.sri-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.sri-main {
  flex: 1;
  min-width: 0;
}
.sri-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sri-sub {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-top: 0.1rem;
}
.sri-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  flex-shrink: 0;
  align-self: center;
}
.sri-badge-entrada { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-bd); }
.sri-badge-salida  { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-bd); }
.sri-badge-cliente { background: var(--indigo-bg); color: var(--indigo); border: 1px solid var(--indigo-bd); }

.search-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--text-3);
  font-size: 0.875rem;
}

/* ── Evolución chart filter row ───────────────────────── */
.evol-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

/* ── Print overlay (informe) ──────────────────────────── */
.print-modal-content {
  display: flex;
  flex-direction: column;
  gap: 0;
}

@media print {
  .search-overlay, .balance-alert { display: none !important; }
}
