/* =============================================
   LEXMINX — Estándar de Diseño (Lex-Minómina / Lex-Gestión)
   Retenciones y Libros · Paleta Navy/Teal/Ámbar · Dark Mode
   ============================================= */

:root {
  --primary: #1B365D;
  --primary-hover: #12243F;
  --primary-tint: #EDF3FA;
  --secondary: #0D9488;
  --secondary-hover: #0F766E;
  --accent: #B45309;
  --accent-tint: #FEF3C7;
  --success: #059669;
  --success-tint: #ECFDF5;
  --warning: #D97706;
  --warning-tint: #FFFBEB;
  --danger: #DC2626;
  --danger-tint: #FEF2F2;
  --info: #0284C7;
  --info-tint: #F0F9FF;

  --bg: #F8FAFC;
  --card: #FFFFFF;
  --card-elev: #FFFFFF;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-muted: #64748B;

  --sidebar-w: 256px;
  --topbar-h: 64px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 10px 10px -5px rgba(15, 23, 42, 0.04);
  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --font-head: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

[data-theme="dark"] {
  --primary: #38BDF8;
  --primary-hover: #0284C7;
  --primary-tint: #1E293B;
  --secondary: #14B8A6;
  --secondary-hover: #2DD4BF;
  --accent: #F59E0B;
  --accent-tint: #452A14;
  --success: #10B981;
  --success-tint: #0F2E26;
  --warning: #FBBF24;
  --warning-tint: #33270F;
  --danger: #F87171;
  --danger-tint: #3B1A1A;
  --info: #38BDF8;
  --info-tint: #0B2A38;

  --bg: #090D16;
  --card: #0F172A;
  --card-elev: #1E293B;
  --border: #1E293B;
  --border-strong: #334155;
  --text: #F8FAFC;
  --text-muted: #94A3B8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; overscroll-behavior-x: none; }

body {
  overscroll-behavior-x: none;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 13px;
  line-height: 1.45;
  transition: background 0.3s ease;
}

h1, h2, h3, h4, .brand-name, .stat-card-value {
  font-family: var(--font-head);
}

/* ============ LOGIN (unificado con Visor y Nómina) ============ */
/* ── Pantalla de login (estándar LEXMINX — idéntica a Nómina/Visor) ── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(135deg, rgba(27, 54, 93, 0.06), var(--bg) 40%, rgba(13, 148, 136, 0.05));
}
.login-overlay[hidden] { display: none; }
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px -20px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
}
[data-theme="dark"] .login-card {
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7);
}
.login-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  margin: 0 auto 1rem;
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
}
.login-title {
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.login-kicker {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0.25rem 0 1.5rem;
}
.login-card .field-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  text-align: left;
  margin-bottom: 0.875rem;
}
.login-card .form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}
.login-input {
  width: 100%;
  padding: 0.5625rem 0.875rem;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}
.login-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 54, 93, 0.12);
}
.login-input::placeholder { color: var(--text-muted); }
.login-error {
  min-height: 18px;
  font-size: 12px;
  font-weight: 600;
  color: var(--danger);
  margin-bottom: 8px;
}
.login-btn {
  width: 100%;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}
.login-foot {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}
@media (max-width: 480px) {
  .login-card { padding: 26px 20px 22px; }
}

/* ============ SHELL ============ */
.app-shell { display: flex; min-height: 100vh; min-width: 0; }

/* ============ SIDEBAR ============ */
.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 60;
  transition: var(--transition);
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
}
.brand-badge { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 13.5px; font-weight: 700; color: var(--text); letter-spacing: -0.2px; white-space: nowrap; }
.brand-tag { font-size: 10px; color: var(--text-muted); white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-section-title {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 12px 10px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 12.5px;
  transition: var(--transition);
  margin-bottom: 2px;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: var(--primary-tint); color: var(--primary); }
.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px -4px rgba(27, 54, 93, 0.5);
}
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  background: var(--accent);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.sidebar-footer { padding: 10px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  color: #fff; font-weight: 700; font-size: 11px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-name { font-weight: 700; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10.5px; color: var(--text-muted); }

/* ============ MAIN + TOPBAR ============ */
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-search {
  flex: 1 1 0%;
  min-width: 0;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-muted);
}
.topbar-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
}
.kbd-hint {
  font-size: 9.5px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 4px;
  background: var(--card);
  font-family: var(--font-mono);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }
.topbar-empresa { font-size: 11.5px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.select-input {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.select-input:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

/* Selector de empresa (botón + modal) — reemplaza el <select> nativo que se
   desacoplaba en móvil por el ancho de las razones sociales largas */
.topbar-empresa-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  max-width: 240px;
  min-width: 0;
}
.topbar-empresa-btn:hover { border-color: var(--secondary); }
.topbar-empresa-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}
.empresa-modal-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  padding: 10px 14px;
  height: auto;
  white-space: normal;
}


.app-content { flex: 1; padding: 20px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* ============ BOTONES ============ */
.btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 3px 10px -3px rgba(27, 54, 93, 0.4); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); }
.btn-teal { background: var(--secondary); color: #fff; }
.btn-teal:hover:not(:disabled) { background: var(--secondary-hover); }
.btn-amber { background: var(--accent); color: #fff; }
.btn-amber:hover:not(:disabled) { background: #92400e; }
.btn-danger { background: var(--danger-tint); color: var(--danger); border-color: rgba(220, 38, 38, 0.25); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-block { width: 100%; justify-content: center; }
.icon-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}
.icon-btn:hover { background: var(--primary-tint); color: var(--primary); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
.logout-btn { width: 28px; height: 28px; }

/* ============ FORMULARIOS ============ */
.input-field, .select-field, .textarea-field {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12.5px;
  outline: none;
  transition: var(--transition);
}
.input-field:focus, .select-field:focus, .textarea-field:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}
.field-label { display: block; font-size: 10.5px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.field-hint { font-size: 10.5px; color: var(--text-muted); margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid .span-2 { grid-column: span 2; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.monospace-input { font-family: var(--font-mono); }

/* ============ CARDS / KPIS ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}
.card-title {
  font-family: var(--font-head);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
}
.stat-card.teal::before { background: var(--secondary); }
.stat-card.amber::before { background: var(--accent); }
.stat-card.green::before { background: var(--success); }
.stat-card.red::before { background: var(--danger); }
.stat-card-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.stat-card-value { font-size: 17px; font-weight: 800; color: var(--text); letter-spacing: -0.4px; font-family: var(--font-mono); }
.stat-card-sub { font-size: 10.5px; color: var(--text-muted); }
.stat-card-icon { position: absolute; top: 12px; right: 12px; color: var(--text-muted); opacity: 0.5; }

/* ============ TABLAS ============ */
.table-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 700px; }
.data-table th {
  background: var(--primary-tint);
  color: var(--primary);
  font-weight: 700;
  text-align: left;
  padding: 8px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--primary-tint); }
.data-table .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.data-table .mono { font-family: var(--font-mono); font-size: 11.5px; }
.table-empty { text-align: center; padding: 32px !important; color: var(--text-muted); font-style: italic; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ============ CHIPS / BADGES ============ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.chip-success { background: var(--success-tint); color: var(--success); }
.chip-warning { background: var(--warning-tint); color: var(--warning); }
.chip-danger { background: var(--danger-tint); color: var(--danger); }
.chip-info { background: var(--info-tint); color: var(--info); }
.chip-primary { background: var(--primary-tint); color: var(--primary); }
.chip-amber { background: var(--accent-tint); color: var(--accent); }

/* ============ FILTROS / PERIODO ============ */
.filters-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.filters-bar .form-group { min-width: 150px; }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.18s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; font-family: var(--font-head); }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ============ TOASTS ============ */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.2s ease;
  max-width: 340px;
}
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info { border-left-color: var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ============ PANEL RETENCIÓN (asistente) ============ */
.retencion-panel {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.retencion-panel.obligatoria { border-color: var(--accent); background: var(--accent-tint); }
.retencion-panel-title { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.retencion-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }

/* ============ COMPROBANTE IMPRIMIBLE ============ */
.receipt-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  margin-top: 18px;
}
.receipt-header { display: grid; grid-template-columns: 2.2fr 0.8fr; gap: 24px; border-bottom: 2px solid var(--primary); padding-bottom: 14px; margin-bottom: 16px; }
.receipt-title { font-family: var(--font-head); font-size: 19px; font-weight: 800; color: var(--text); line-height: 1.25; }
.legal-note { font-size: 10.5px; color: var(--text-muted); font-style: italic; margin-top: 6px; }
.metadata-box { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.metadata-label { background: var(--primary-tint); color: var(--primary); font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 5px 10px; text-align: center; letter-spacing: 0.5px; }
.metadata-value { font-size: 14px; font-weight: 700; text-align: center; padding: 7px 10px; font-family: var(--font-mono); }
.receipt-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.receipt-table th { background: var(--primary); color: #fff; padding: 9px 4px; font-size: 10px; text-transform: uppercase; border: 1px solid var(--primary); text-align: center; }
.receipt-table td { padding: 9px 4px; border: 1px solid var(--border); text-align: center; }
.receipt-table tr.total-row td { font-weight: 700; background: var(--primary-tint); border-top: 2px solid var(--primary); }
.signature-section { display: grid; grid-template-columns: 1fr 1fr; gap: 100px; margin-top: 28px; padding: 20px 40px 0; }
.sig-box { display: flex; flex-direction: column; align-items: center; text-align: center; }
.sig-line { width: 100%; border-bottom: 1.5px solid var(--text); margin-bottom: 8px; height: 36px; }
.sig-title { font-family: var(--font-head); font-size: 13px; font-weight: 700; }
.sig-subtitle { font-size: 10px; color: var(--text-muted); margin-top: 3px; }

/* ============ UT PANEL ============ */
.ut-config-panel {
  background: var(--accent-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}
.ut-config-panel input {
  width: 70px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  text-align: center;
  font-weight: 700;
  color: var(--text);
  outline: none;
  background: var(--card);
}

/* ============ ACCIONES DE FILA ============ */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-action-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 5px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.row-action-btn:hover { background: var(--primary-tint); color: var(--primary); }
/* Navegación móvil: se elimina el bottom-nav y el FAB; la navegación es el
   sidebar (drawer con hamburguesa). No hay barra inferior ni botón flotante. */

/* ============ TABS (IVA 100%/75%) ============ */
.tab-group {
  display: flex;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  width: fit-content;
}
.tab-btn {
  background: transparent;
  border: none;
  outline: none;
  padding: 6px 16px;
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
}
.tab-btn.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ============ LIBRO PREVIEW ============ */
.libro-resumen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.resumen-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.resumen-card .r-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.resumen-card .r-value { font-size: 16px; font-weight: 800; font-family: var(--font-mono); margin-top: 2px; }

/* ============ DETALLE / HERO COMPROBANTE ============ */
.comprobante-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-md);
}
.comprobante-hero .c-number { font-family: var(--font-mono); font-size: 22px; font-weight: 800; }
.comprobante-hero .c-meta { font-size: 12px; opacity: 0.85; }

/* ============ CHECKBOX ============ */
.checkbox-custom { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.checkbox-custom input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* ============ IMPRESIÓN (solo comprobante) ============ */
@media print {
  body { background: #fff; }
  .app-sidebar, .app-topbar, .login-overlay, .modal-overlay,
  .filters-bar, .table-toolbar, .no-print, .toast-container, .comprobante-hero,
  .libro-resumen, .stats-grid {
    display: none !important;
  }
  .app-content { padding: 0; max-width: 100%; }
  .receipt-card { box-shadow: none; border: none; padding: 0; margin: 0; }
  .receipt-card .receipt-table th { background: var(--primary) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .receipt-card .receipt-table tr.total-row td { background: var(--primary-tint) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: letter landscape; margin: 10mm; }
}

/* ============ RESPONSIVE ============ */
@media screen and (max-width: 900px) {
  .app-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .app-sidebar.open { transform: translateX(0); }
  .mobile-menu-btn { display: inline-flex !important; }
  .app-content { padding: 16px 12px 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .app-topbar { padding: 0 12px; }
  .topbar-empresa { display: none; }
  .topbar-empresa-btn { max-width: 132px; padding: 5px 8px; }
  .topbar-empresa-label { max-width: 92px; }
  .topbar-search { max-width: none; }
  .kbd-hint { display: none; }
  .libro-resumen { grid-template-columns: 1fr; }
  .modal-content { max-width: 100%; margin: 0 10px; max-height: 92vh; }
  .receipt-header { grid-template-columns: 1fr; gap: 12px; }
  .signature-section { grid-template-columns: 1fr; gap: 30px; padding: 16px 0 0; }
}
@media screen and (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card-value { font-size: 18px; }
  .app-content { padding: 12px 10px 20px; }
}
.mobile-menu-btn { display: none; }

/* ============ GESTIÓN DE CLIENTES (RET-02) ============ */
.cliente-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.cliente-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.cliente-card.revocado { opacity: 0.72; }
.cliente-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cliente-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}
.cliente-nombre { font-weight: 700; font-size: 13px; line-height: 1.25; }
.cliente-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cliente-perms { display: flex; flex-wrap: wrap; gap: 6px; }
.perm-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
  transition: var(--transition);
}
.perm-chip input { accent-color: var(--success); margin: 0; }
.perm-chip.on { background: var(--success-tint); color: var(--success); border-color: transparent; }
.cliente-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}
.clave-box {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin: 10px 0;
}
.clave-box .mono { flex: 1; font-size: 13px; word-break: break-all; }

/* ============ RESUMEN CONSOLIDADO + ALERTAS (RET-04/05) ============ */
.alert-card { border-left: 3px solid var(--warning); }
.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.alert-item:last-child { border-bottom: none; }
.resumen-kpis { grid-template-columns: repeat(4, 1fr); }
@media screen and (max-width: 900px) {
  .resumen-kpis { grid-template-columns: repeat(2, 1fr); }
}
