:root {
  --bg-deep: #0c0d0b;
  --bg-stone: #161714;
  --glass-surface: rgba(255, 255, 255, 0.08);
  --glass-btn-bg: rgba(255, 255, 255, 0.1);
  --glass-btn-hover: rgba(255, 255, 255, 0.19);
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-border-subtle: rgba(229, 200, 92, 0.28);
  --accent-yellow: #e5c85c;
  --accent-yellow-glow: rgba(229, 200, 92, 0.18);
  --text-primary: #f4f4f1;
  --text-secondary: #c2c3bb;
  --text-muted: #8b8d84;
  --success-tone: #6ee7b7;
  --danger-tone: #fda4af;
  --font-display: 'Barlow Condensed', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: #0c0d0b;
  background-image: url("./fondo.jpeg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: grayscale(100%) contrast(1.22) brightness(0.62) blur(1px);
  transform: scale(1.02);
}

.ambient-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(10, 11, 9, 0.42) 0%, rgba(12, 13, 11, 0.22) 50%, rgba(10, 11, 9, 0.52) 100%),
    radial-gradient(circle at 50% 45%, transparent 25%, rgba(8, 9, 7, 0.42) 100%);
  pointer-events: none;
}

.glass-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 16, 13, 0.72);
  backdrop-filter: blur(22px) saturate(125%);
  -webkit-backdrop-filter: blur(22px) saturate(125%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.5);
}

.topbar {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.9rem 2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.95rem;
}

.brand-logo {
  height: 42px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  display: block;
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 2.2px;
  line-height: 1.1;
  color: var(--text-primary);
}

.brand-text h1 .brand-sub {
  color: var(--text-secondary);
  font-weight: 700;
}

.brand-text span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 1.3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.barcode-decor {
  width: 42px;
  height: 22px;
  background: repeating-linear-gradient(
    90deg,
    rgba(244, 244, 241, 0.75) 0px,
    rgba(244, 244, 241, 0.75) 2px,
    transparent 2px,
    transparent 5px,
    rgba(244, 244, 241, 0.75) 5px,
    rgba(244, 244, 241, 0.75) 6px,
    transparent 6px,
    transparent 9px
  );
  opacity: 0.7;
}

.glass-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  padding: 0.42rem 0.95rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-yellow);
  box-shadow: 0 0 8px var(--accent-yellow-glow);
}

.status-dot.online {
  background: var(--success-tone);
  box-shadow: 0 0 10px rgba(110, 231, 183, 0.5);
}

.status-dot.error {
  background: #fb7185;
  box-shadow: 0 0 10px rgba(251, 113, 133, 0.5);
}

nav.unified-nav {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.8rem 2rem 0.95rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-dropdown-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.nav-group-label {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  white-space: nowrap;
  margin: 0;
}

.glass-control,
select {
  appearance: none;
  -webkit-appearance: none;
  background-color: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  color-scheme: dark;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%23c2c3bb' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 13px;
  padding-right: 2.35rem;
  transition: all 0.22s ease;
}

select option {
  background-color: #181916;
  color: var(--text-primary);
}

select option:checked {
  background-color: #2b2c26;
  color: #ffffff;
}

.nav-select {
  width: auto;
  min-width: 245px;
  padding: 0.52rem 2.35rem 0.52rem 0.95rem;
  font-size: 0.92rem;
}

.nav-select:hover,
.nav-select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.36);
  background-color: rgba(255, 255, 255, 0.14);
}

.nav-select.active-menu {
  border-color: rgba(255, 255, 255, 0.34);
  background-color: rgba(255, 255, 255, 0.12);
}

.btn,
.glass-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1.2rem;
  border-radius: 12px;
  background: var(--glass-btn-bg);
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.22s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn:hover,
.glass-btn:hover {
  background: var(--glass-btn-hover);
  border-color: rgba(255, 255, 255, 0.36);
  transform: translateY(-1px);
}

.glass-btn-accent {
  width: 100%;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border-subtle);
  color: var(--text-primary);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.glass-btn-accent:hover {
  background: rgba(229, 200, 92, 0.22);
  border-color: rgba(229, 200, 92, 0.55);
  color: #ffffff;
}

.glass-btn-danger {
  background: rgba(225, 29, 72, 0.2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(251, 113, 133, 0.45);
  color: #fecdd3;
}

.glass-btn-danger:hover {
  background: rgba(225, 29, 72, 0.35);
  border-color: #fda4af;
  color: #ffffff;
}

.nav-btn.finance-btn {
  color: var(--text-primary);
}

.nav-btn.active {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.38);
  color: #ffffff;
}

main {
  max-width: 1440px;
  margin: 2rem auto 4rem;
  padding: 0 2rem;
}

.view-section {
  display: none;
  animation: fadeSlide 0.28s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--glass-border);
}

.section-header .glass-btn-accent {
  width: auto;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 1.6px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-title::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 22px;
  border-radius: 3px;
  background: rgba(244, 244, 241, 0.75);
}

.badge-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.24rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  letter-spacing: 0.8px;
}

.auto-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  margin-left: 0.3rem;
}

.glass-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.04) 100%);
  backdrop-filter: blur(22px) saturate(130%);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.glass-card.accent-border {
  border-color: var(--glass-border-subtle);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--text-primary);
  margin-bottom: 1.15rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mode-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.18rem 0.55rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-secondary);
}

.crud-grid {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 1.75rem;
  align-items: start;
}

.report-split {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.75rem;
  align-items: start;
}

@media (max-width: 1080px) {
  .crud-grid,
  .report-split {
    grid-template-columns: 1fr;
  }
}

.chart-container {
  position: relative;
  height: 310px;
  width: 100%;
}

.form-group {
  margin-bottom: 0.95rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

input,
textarea {
  width: 100%;
  background: rgba(12, 13, 11, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 0.62rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.94rem;
  border-radius: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

select {
  width: 100%;
  padding: 0.62rem 2.35rem 0.62rem 0.85rem;
  font-size: 0.94rem;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.42);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

textarea {
  resize: vertical;
  min-height: 76px;
}

.helper-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.1rem;
}

.form-actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 0.45rem;
}

.btn-cancel-edit {
  display: none;
}

.btn-cancel-edit.visible {
  display: inline-flex;
}

.action-cell {
  display: flex;
  gap: 0.45rem;
  white-space: nowrap;
}

.btn-mini {
  padding: 0.3rem 0.68rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  transition: all 0.18s ease;
}

.btn-mini:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
}

.btn-mini.del {
  background: rgba(225, 29, 72, 0.16);
  border-color: rgba(251, 113, 133, 0.38);
  color: #fecdd3;
}

.btn-mini.del:hover {
  background: rgba(225, 29, 72, 0.35);
  border-color: #fda4af;
  color: #ffffff;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(10, 11, 9, 0.42);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

thead {
  background: rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

th {
  text-align: left;
  padding: 0.78rem 0.9rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-primary);
  white-space: nowrap;
}

td {
  padding: 0.72rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.pill {
  display: inline-block;
  padding: 0.18rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.pill-active, .pill-pagado, .pill-true {
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(110, 231, 183, 0.4);
  color: var(--success-tone);
}

.pill-pending {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--text-secondary);
}

.pill-danger, .pill-false, .pill-cancelada, .pill-vencido {
  background: rgba(225, 29, 72, 0.18);
  border: 1px solid rgba(253, 164, 175, 0.4);
  color: var(--danger-tone);
}

.tx-terminal {
  margin-top: 1.1rem;
  background: rgba(10, 11, 9, 0.72);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-left: 4px solid var(--text-secondary);
  border-radius: 12px;
  padding: 0.95rem 1.05rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  color: var(--text-secondary);
  min-height: 92px;
}

.tx-terminal.tx-commit {
  border-left-color: var(--success-tone);
  background: rgba(16, 185, 129, 0.1);
  color: #a7f3d0;
}

.tx-terminal.tx-rollback {
  border-left-color: #fb7185;
  background: rgba(225, 29, 72, 0.14);
  color: #fecdd3;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.kpi-box {
  padding: 1.15rem 1.35rem;
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 0.2rem;
  letter-spacing: 1px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(8, 9, 7, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
  animation: fadeSlide 0.2s ease;
}

.modal-box {
  width: 100%;
  max-width: 440px;
  border-color: rgba(251, 113, 133, 0.4);
}

.modal-header {
  margin-bottom: 0.75rem;
}

.modal-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: #fda4af;
  letter-spacing: 1px;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-primary);
  margin-top: 0.2rem;
}

.modal-body-text {
  font-size: 0.94rem;
  color: var(--text-secondary);
  margin-bottom: 1.35rem;
  line-height: 1.55;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

/* CARTEL MODAL TIPO RECIBO DE PAGO (COMMIT) */
.receipt-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(5, 6, 8, 0.72);
  backdrop-filter: blur(10px);
}

.receipt-backdrop.open {
  display: flex;
  animation: fadeSlide 0.2s ease;
}

.receipt-card {
  width: 100%;
  max-width: 460px;
  background: rgba(20, 22, 27, 0.92);
  backdrop-filter: blur(22px);
  border: 1px solid rgba(110, 231, 183, 0.45);
  border-top: 3px solid #10b981;
  border-radius: 6px;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
  color: #f4f4f1;
}

.receipt-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px dashed rgba(194, 195, 187, 0.28);
}

.receipt-brand {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1.1;
}

.receipt-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  color: #6ee7b7;
  margin-top: 0.2rem;
}

.receipt-folio {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: #c2c3bb;
}

.receipt-rows {
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-size: 0.92rem;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.receipt-row span:first-child {
  color: #a4acb9;
}

.receipt-row span:last-child {
  font-weight: 600;
  text-align: right;
}

.receipt-total {
  margin-top: 0.75rem;
  padding-top: 0.85rem;
  border-top: 1px dashed rgba(194, 195, 187, 0.28);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.receipt-total-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  text-transform: uppercase;
  color: #c2c3bb;
}

.receipt-total-amount {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.9rem;
  font-weight: 800;
  color: #6ee7b7;
}

.receipt-actions {
  margin-top: 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media print {
  body > *:not(#receipt-modal) {
    display: none !important;
  }
  #receipt-modal {
    position: static;
    background: #fff;
    backdrop-filter: none;
    padding: 0;
  }
  .receipt-card {
    background: #fff;
    color: #111;
    border: 1px solid #111;
    box-shadow: none;
  }
  .receipt-row span:first-child,
  .receipt-folio,
  .receipt-total-label {
    color: #333;
  }
  .receipt-sub,
  .receipt-total-amount {
    color: #065f46;
  }
  .receipt-actions {
    display: none;
  }
}

.lookup-popover {
  position: fixed;
  z-index: 1100;
  max-width: 310px;
  padding: 0.65rem 0.9rem;
  border-radius: 14px;
  background: rgba(18, 19, 16, 0.88);
  backdrop-filter: blur(20px) saturate(135%);
  -webkit-backdrop-filter: blur(20px) saturate(135%);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  color: var(--text-primary);
  font-size: 0.83rem;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.lookup-popover.visible {
  opacity: 1;
  transform: translateY(0);
}

.lookup-popover .lp-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.lookup-popover .lp-body {
  color: var(--text-primary);
  line-height: 1.4;
}

#toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-width: 420px;
}

.toast {
  background: rgba(18, 19, 16, 0.88);
  backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border);
  border-left: 4px solid var(--text-secondary);
  border-radius: 12px;
  padding: 0.82rem 1.05rem;
  font-size: 0.9rem;
  color: var(--text-primary);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
}

.toast.success { border-left-color: var(--success-tone); }
.toast.error { border-left-color: #fb7185; }