/* ====== Reset y base ====== */
*,*::before,*::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 12px;
  color: #1e1e1e;
  background: #ececec;
}
.mono { font-family: "Consolas", "Courier New", monospace; font-variant-numeric: tabular-nums; }

/* ====== Topbar ====== */
.topbar {
  height: 36px;
  background: #2c64a8;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
}
.topbar .brand { font-weight: 600; font-size: 13px; letter-spacing: .3px; }
.topbar .sep { width: 1px; height: 16px; background: rgba(255,255,255,.3); }
.topbar .meta { font-size: 11px; opacity: .85; }
.topbar .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ====== App container ====== */
.app {
  min-height: calc(100vh - 36px - 24px);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  background: #f5f5f5;
}

/* ====== Header de pantalla ====== */
.screen-title { font-size: 16px; font-weight: 600; color: #2c64a8; margin: 0; }
.screen-sub  { font-size: 11px; color: #777; margin: 2px 0 0 0; }

/* ====== Filtros rapidos (chips) ====== */
.quick-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid #c5c5c5;
  padding: 8px 12px;
}
.quick-filters .qf-label {
  font-size: 10px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-right: 4px;
}
.chip {
  height: 24px;
  padding: 0 12px;
  border: 1px solid #b6b6b6;
  background: #fff;
  font-family: inherit;
  font-size: 11px;
  color: #1e1e1e;
  cursor: pointer;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  letter-spacing: .2px;
}
.chip:hover { background: #ffe79a; border-color: #d4a000; }
.chip.active {
  background: #2c64a8;
  color: #fff;
  border-color: #1a3a6c;
  font-weight: 600;
}

/* ====== Filtros ====== */
.filters {
  background: #fff;
  border: 1px solid #c5c5c5;
  padding: 12px 16px;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: 10px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.field input, .field select {
  height: 26px;
  border: 1px solid #7a7a7a;
  background: #fff;
  padding: 0 8px;
  font-size: 12px;
  font-family: inherit;
}
.field input:focus, .field select:focus { outline: 2px solid #4682c5; outline-offset: -1px; }
.field-fecha input { width: 130px; }
.field-cliente select { width: 200px; }
.field-busqueda input { width: 280px; }
.filters-actions { display:flex; gap:8px; }

/* ====== Botones ====== */
.btn {
  height: 28px;
  padding: 0 14px;
  border: 1px solid #7a7a7a;
  background: #f5f5f5;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.btn:hover { background: #ffe79a; }
.btn:disabled { opacity: .5; cursor: not-allowed; background: #ececec; }
.btn-primary {
  background: #2c64a8;
  color: #fff;
  border-color: #1a3a6c;
  font-weight: 600;
}
.btn-primary:hover { background: #4682c5; }
.btn-ghost { background: transparent; border-color: #b6b6b6; }

/* ====== KPIs ====== */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.kpi {
  background: #fff;
  border: 1px solid #c5c5c5;
  border-left: 4px solid #2c64a8;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi.kpi-success { border-left-color: #2a8a3a; }
.kpi.kpi-warn    { border-left-color: #d4a000; }
.kpi.kpi-info    { border-left-color: #4682c5; }
.kpi.kpi-danger  { border-left-color: #a40000; cursor: pointer; }
.kpi.kpi-danger:hover { background: #fff7f7; }
.kpi.kpi-danger .kpi-value { color: #a40000; }
.kpi-label {
  font-size: 10px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.kpi-value { font-size: 22px; font-weight: 700; color: #1e1e1e; }
.kpi-hint  { font-size: 11px; color: #777; }

/* ====== Tabla / grilla ====== */
.grid-wrap {
  background: #fff;
  border: 1px solid #c5c5c5;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.grid-head-bar {
  height: 32px;
  border-bottom: 1px solid #c5c5c5;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
}
.grid-head-bar .title { font-size: 12px; font-weight: 600; color: #1e1e1e; }
.grid-head-bar .right { margin-left: auto; display: flex; gap: 6px; }

.grid-scroll { overflow: auto; flex: 1; min-height: 360px; }
table.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
table.grid thead th {
  position: sticky;
  top: 0;
  background: #ececec;
  color: #1e1e1e;
  font-weight: 600;
  text-align: left;
  padding: 4px 8px;
  height: 24px;
  border-bottom: 1px solid #b6b6b6;
  border-right: 1px solid #d8d8d8;
  white-space: nowrap;
}
table.grid thead th:last-child { border-right: none; }
table.grid thead th.num { text-align: right; }
table.grid tbody td {
  padding: 4px 8px;
  height: 26px;
  border-bottom: 1px solid #ececec;
  border-right: 1px solid #f0f0f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
table.grid tbody td:last-child { border-right: none; }
table.grid tbody tr:nth-child(even) { background: #fafafa; }
table.grid tbody tr:hover { background: #ffe79a; cursor: default; }
table.grid td.num { text-align: right; font-family: "Consolas", monospace; font-variant-numeric: tabular-nums; }
table.grid td.cod { font-family: "Consolas", monospace; }
table.grid td.center { text-align: center; }

/* ====== Pills método de pago ====== */
.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  border: 1px solid;
}
.pill-transf    { background: #e8f0fb; color: #1a3a6c; border-color: #4682c5; }
.pill-efect     { background: #e9f6ec; color: #1c5a26; border-color: #2a8a3a; }
.pill-credit    { background: #fdf2dc; color: #6b4d00; border-color: #d4a000; }
.pill-tarj      { background: #f1e8fb; color: #4a1a8c; border-color: #7e3fdc; }
.pill-otro      { background: #ececec; color: #555; border-color: #b6b6b6; }
.pill-pagado    { background: #e9f6ec; color: #1c5a26; border-color: #2a8a3a; }
.pill-pendiente { background: #fbe9e9; color: #7a0a0a; border-color: #a40000; }
.pill-anulado   { background: #ececec; color: #555; border-color: #999; }

/* Fila con crédito pendiente */
table.grid tbody tr.row-pendiente td:first-child {
  box-shadow: inset 3px 0 0 #a40000;
}
table.grid tbody tr.row-pendiente { background: #fff7f7; }
table.grid tbody tr.row-pendiente:nth-child(even) { background: #fdeeee; }

/* Fila anulada (tachada) */
table.grid tbody tr.row-anulado td {
  color: #999;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* ====== Pager ====== */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px;
  border-top: 1px solid #ececec;
  background: #fff;
  font-size: 12px;
}
.pager #pager-info { color: #555; min-width: 200px; text-align: center; }

/* ====== Footer totales ====== */
.totals-bar {
  display: flex;
  align-items: center;
  border-top: 1px solid #c5c5c5;
  background: #f5f5f5;
  padding: 8px 12px;
  gap: 24px;
  font-size: 12px;
  flex-wrap: wrap;
}
.totals-bar .label { color: #555; }
.totals-bar .value { font-weight: 700; font-family: "Consolas", monospace; }
.totals-bar .right { margin-left: auto; display: flex; gap: 24px; }

/* ====== Status bar ====== */
.statusbar {
  height: 24px;
  background: #2c64a8;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 11px;
  gap: 16px;
}
.statusbar .right { margin-left: auto; opacity: .85; }

/* ====== Print ====== */
@media print {
  .topbar, .statusbar, .filters, .pager, .grid-head-bar .right, .btn { display: none !important; }
  .app { padding: 0; background: #fff; }
  .grid-wrap { border: none; }
  .grid-scroll { overflow: visible; min-height: 0; }
  table.grid thead th { position: static; background: #fff; border: 1px solid #999; }
  table.grid tbody td { border: 1px solid #ccc; }
  .kpis { grid-template-columns: repeat(5, 1fr); }
  .kpi { border: 1px solid #ccc !important; border-left-width: 4px !important; }
}

/* ====== Responsive (tablet) ====== */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .field-busqueda input { width: 220px; }
}
