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

/* PAGE TABS (sub-tabs within each page) */
.page-tabs {
  border-bottom: 2px solid #e2e8f0;
  gap: 2px;
  margin-bottom: 12px;
}
.page-tabs .nav-link {
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 8px 18px;
  margin-bottom: -2px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  background: transparent;
  transition: all 0.2s;
}
.page-tabs .nav-link:hover { color: #e94560; background: #f8fafc; }
.page-tabs .nav-link.active {
  border: none;
  border-bottom: 3px solid #e94560;
  color: #1a1a2e;
  background: transparent;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 200px;
  background: #fff;
  padding: 0;
  border-right: 1px solid #e2e8f0;
  box-shadow: 2px 0 12px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 16px 16px 12px;
  flex-shrink: 0;
}

.sidebar-header .logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.sidebar .logo-dot {
  width: 10px;
  height: 10px;
  background: #e94560;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar h1 {
  font-size: 18px;
  font-weight: 800;
  color: #1a1a2e;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.sidebar .subtitle {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
  padding-left: 20px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
}

nav {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: transparent;
  border: none;
  color: #64748b;
  padding: 9px 12px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s;
  position: relative;
}

.nav-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 20px;
  background: #e94560;
  border-radius: 0 3px 3px 0;
  transition: transform 0.2s;
}

.nav-btn:hover {
  background: #f8fafc;
  color: #1a1a2e;
}

.nav-btn:hover::before {
  transform: translateY(-50%) scaleY(0.6);
}

.nav-btn.active {
  background: #fff1f3;
  color: #e94560;
  font-weight: 600;
}

.nav-btn.active::before {
  transform: translateY(-50%) scaleY(1);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.nav-btn:hover .nav-icon { opacity: 1; }
.nav-btn.active .nav-icon { opacity: 1; }

.nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  background: #f8fafc;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
  padding: 12px 0;
  margin-bottom: 16px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
}

.page-desc {
  font-size: 13px;
  color: #64748b;
  margin-top: 4px;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  border: 1px solid #e2e8f0;
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

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

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.field input, .field select {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  color: #1a1a2e;
  background: #f8fafc;
  outline: none;
  transition: all 0.2s;
}

.field input:focus, .field select:focus {
  border-color: #e94560;
  box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.1);
  background: #fff;
}

.btn-primary {
  background: #e94560;
  color: #fff;
  border: none;
  padding: 10px 28px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 4px;
}

.btn-primary:hover {
  background: #d63851;
  box-shadow: 0 4px 12px rgba(233, 69, 96, 0.35);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover { background: #e2e8f0; }

.btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover { background: #fee2e2; }

.busqueda-card {
  background: #fff;
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  border: 1px solid #e2e8f0;
  margin-bottom: 16px;
}

.busqueda-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.busqueda-input-group {
  flex: 1;
  min-width: 250px;
}

.busqueda-input-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.busqueda-row {
  display: flex;
  gap: 10px;
}

.busqueda-row input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a2e;
  background: #f8fafc;
  outline: none;
  transition: all 0.2s;
  min-width: 120px;
}

.busqueda-row input:focus {
  border-color: #e94560;
  box-shadow: 0 0 0 4px rgba(233, 69, 96, 0.1);
  background: #fff;
}

.busqueda-row .btn-primary {
  padding: 10px 22px;
  font-size: 14px;
  white-space: nowrap;
}

.busqueda-divider {
  width: 1px;
  height: 50px;
  background: #e2e8f0;
  flex-shrink: 0;
}

.busqueda-opciones {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.toggle-wrap { display: flex; align-items: center; }

.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle-label input { display: none; }

.toggle-switch {
  width: 44px;
  height: 24px;
  background: #cbd5e1;
  border-radius: 12px;
  position: relative;
  transition: background 0.25s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-label input:checked + .toggle-switch { background: #e94560; }
.toggle-label input:checked + .toggle-switch::after { transform: translateX(20px); }

.toggle-text {
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  white-space: nowrap;
}

.restantes-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 6px 12px;
}

.restantes-label {
  font-size: 13px;
  color: #b91c1c;
  font-weight: 500;
}

.restantes-num {
  font-size: 18px;
  font-weight: 800;
  color: #dc2626;
}

.resultado { margin-top: 0; display: none; }
.resultado.visible { display: block; }

.result-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid #e2e8f0;
}

.result-table th {
  background: #1a1a2e;
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  text-align: left;
}

.result-table td {
  padding: 6px 10px;
  font-size: 14px;
  border-bottom: 1px solid #f1f5f9;
}

.result-table tr:last-child td { border-bottom: none; }

.result-table td.label {
  color: #64748b;
  font-weight: 500;
  width: 55%;
}

.result-table td.valor {
  color: #1a1a2e;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.result-table td.valor.accent { color: #059669; }
.result-table td.valor.warn { color: #d97706; }
.result-table td.valor.danger { color: #dc2626; }
.result-table td.valor.info { color: #2563eb; }
.result-table td.valor.total { color: #1a1a2e; font-size: 14px; }
.result-table td.valor.accent.total { color: #059669; font-size: 14px; }
.result-table.compact td { padding: 6px 12px; }
.result-table.compact td.label { width: 40%; }
.result-table td.valor.strong { font-size: 16px; }

.pct-info {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
  margin-left: 6px;
  white-space: nowrap;
}

.sin2x1 {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.tipo-label {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
}
.tipo-label.ord { background: #dbeafe; color: #1d4ed8; }
.tipo-label.extra { background: #f3e8ff; color: #7c3aed; }

.result-table td.total-row {
  border-top: 2px solid #e2e8f0;
  font-weight: 700;
  font-size: 14px;
  padding-top: 8px;
}
.result-table td.total-final {
  border-top: 3px double #1a1a2e;
  font-size: 14px;
}

.result-table .section-row td {
  background: #f8fafc;
  font-weight: 700;
  color: #1a1a2e;
  padding: 6px 10px;
  border-bottom: 2px solid #e2e8f0;
}

.historial-wrapper {
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

.loading { color: #94a3b8; padding: 12px 0; }

.historial-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.historial-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
  text-align: left;
}

.historial-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}

.historial-table tr:hover td { background: #f8fafc; }

.tipo-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.tipo-badge.ordinario { background: #dbeafe; color: #1d4ed8; }
.tipo-badge.extraordinario { background: #f3e8ff; color: #7c3aed; }

.monto { font-weight: 600; font-variant-numeric: tabular-nums; }
.monto.pos { color: #059669; }
.monto.neg { color: #dc2626; }

.paginacion {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.page-btn {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  color: #475569;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  min-width: 38px;
  text-align: center;
}

.page-btn:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.page-btn.active {
  background: #e94560;
  color: #fff;
  border-color: #e94560;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.page-info {
  font-size: 12px;
  color: #94a3b8;
  margin-left: 8px;
}

.nav-tabs {
  border-bottom: 2px solid #e2e8f0;
  gap: 4px;
  padding: 0;
  margin-bottom: 14px;
}
.nav-tabs .nav-link {
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 10px 18px;
  margin-bottom: -2px;
  transition: all 0.2s;
  background: transparent;
}
.nav-tabs .nav-link:hover {
  border-color: transparent;
  background: #f8fafc;
  isolation: auto;
}
.nav-tabs .nav-link.active {
  border: none;
  border-bottom: 3px solid var(--bs-nav-tabs-link-active-color, #e94560);
  background: transparent;
}

.pct-below {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #94a3b8;
  margin-top: 2px;
  line-height: 1.3;
}

.mes-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.mes-tab {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  color: #475569;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.mes-tab:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.mes-tab.active {
  background: #e94560;
  color: #fff;
  border-color: #e94560;
}

.config-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.config-table thead th {
  text-align: left;
  padding: 8px 10px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 2px solid #e2e8f0;
}
.config-table thead th:first-child { border-radius: 8px 0 0 0; }
.config-table thead th:last-child { border-radius: 0 8px 0 0; }
.config-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s;
}
.config-table tbody tr:hover { background: #f8fafc; }
.config-table tbody tr:last-child { border-bottom: none; }
.config-table td {
  padding: 6px 10px;
  vertical-align: middle;
}
.config-label {
  font-weight: 600;
  color: #1a1a2e;
  white-space: nowrap;
}
.config-input {
  width: 90px;
  padding: 7px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  color: #1a1a2e;
  text-align: right;
  outline: none;
  font-family: inherit;
}
.config-input:focus {
  border-color: #e94560;
  box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.08);
}
.config-input-monto {
  width: 140px;
  padding: 7px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  color: #1a1a2e;
  text-align: right;
  outline: none;
  font-family: inherit;
}
.config-input-monto:focus {
  border-color: #e94560;
  box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.08);
}
.config-select {
  width: 180px;
  padding: 7px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  color: #1a1a2e;
  background: #fff;
  outline: none;
  font-family: inherit;
}
.config-select:focus {
  border-color: #e94560;
  box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.08);
}
.config-na {
  color: #94a3b8;
  font-size: 13px;
  text-align: center;
}
.config-iva {
  font-size: 13px;
  color: #64748b;
  white-space: nowrap;
}
.config-solo td {
  padding: 10px 12px;
}
.config-solo .config-label {
  font-size: 14px;
}
.btn-guardar-config {
  background: #059669;
  color: #fff;
  border: none;
  padding: 10px 28px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 14px;
  transition: all 0.2s;
}

.btn-guardar-config:hover {
  background: #047857;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
}

.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #059669;
  color: #fff;
  padding: 12px 22px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  animation: slideUp 0.3s ease;
  z-index: 200;
}

.toast.error { background: #dc2626; }

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

.checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.checkbox-wrap input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #e94560;
  cursor: pointer;
}

.checkbox-label {
  font-size: 14px;
  color: #475569;
  cursor: pointer;
}

.card-header-hist {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.eq-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.eq-card.pos { border-left: 4px solid #059669; }
.eq-card.neg { border-left: 4px solid #dc2626; }
.eq-card.neutral { border-left: 4px solid #2563eb; background: #eff6ff; }

.eq-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.eq-val {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.eq-sub {
  font-size: 12px;
  color: #94a3b8;
}

.historial-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.btn-export {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #059669;
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-export:hover {
  background: #047857;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
  transform: translateY(-1px);
}

.btn-export:active { transform: translateY(0); }

.export-icon {
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}

.modal-overlay.visible { display: flex; }

.modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  text-align: center;
  animation: modalIn 0.25s ease;
}

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

.modal-icon {
  font-size: 36px;
  margin-bottom: 12px;
  line-height: 1;
}

.modal-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 6px;
}

.modal-desc {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 14px;
  line-height: 1.4;
}

.modal-card input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 16px;
  text-align: center;
  letter-spacing: 4px;
  outline: none;
  transition: all 0.2s;
  margin-bottom: 6px;
}

.modal-card input[type="password"]:focus {
  border-color: #e94560;
  box-shadow: 0 0 0 4px rgba(233, 69, 96, 0.1);
}

.modal-error {
  font-size: 12px;
  color: #dc2626;
  display: none;
  margin-bottom: 8px;
}

.modal-error.visible { display: block; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.modal-actions .btn-secondary,
.modal-actions .btn-primary {
  flex: 1;
  text-align: center;
}

@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar-header { padding: 12px 8px; }
  .sidebar h1 { font-size: 13px; letter-spacing: 0; }
  .sidebar .logo-dot { display: none; }
  .sidebar .subtitle, .sidebar-footer, .nav-label { display: none; }
  nav { padding: 6px 6px; }
  .nav-btn { justify-content: center; padding: 10px; }
  .nav-btn::before { display: none; }
  .nav-icon { width: 22px; height: 22px; }
  .content { padding: 16px; }
  .config-grid { grid-template-columns: 1fr; }
  .busqueda-inner { flex-direction: column; align-items: stretch; gap: 12px; }
  .busqueda-divider { width: 100%; height: 1px; }
  .busqueda-opciones { justify-content: space-between; }
  .busqueda-row input { font-size: 16px; }
  .historial-header { flex-direction: column; }
  .btn-export { width: 100%; justify-content: center; }
}
