:root {
  --bg:          #f5f5f5;
  --panel:       #ffffff;
  --border:      #cccccc;
  --text:        #333333;
  --text-sec:    #666666;
  --accent:      #0a5277;
  --accent-dark: #083d59;
  --th-bg:       #e8e8e8;
  --alt:         #fafafa;
  --font:        Arial, 'Segoe UI', sans-serif;
  --fz:          13px;
}

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

body {
  font-family: var(--font);
  font-size: var(--fz);
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── HEADER ── */
#app-header {
  background: var(--accent);
  color: #fff;
  height: 38px;
  min-height: 38px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--accent-dark);
  flex-shrink: 0;
}
#app-header .app-title { font-size: 13px; font-weight: bold; letter-spacing: 0.4px; }
#app-header .version   { font-size: 11px; opacity: 0.8; }

/* ── FILTROS ── */
#filtros {
  background: #efefef;
  border-bottom: 1px solid var(--border);
  padding: 6px 12px;
  flex-shrink: 0;
}
.filtro-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.filtro-row:last-child { margin-bottom: 0; }
.filtro-row label {
  font-size: 12px;
  font-weight: bold;
  color: #555;
  white-space: nowrap;
}
.filtro-row select,
.filtro-row input[type="text"] {
  height: 24px;
  border: 1px solid var(--border);
  font-family: var(--font);
  font-size: 13px;
  padding: 0 5px;
  background: #fff;
}

/* ── BOTONES ── */
.btn {
  height: 24px;
  padding: 0 10px;
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  white-space: nowrap;
}
.btn:hover { background: var(--th-bg); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dark);
  font-weight: bold;
}
.btn-primary:hover { background: var(--accent-dark); }

/* ── LEYENDA ── */
#leyenda {
  padding: 3px 12px;
  display: flex;
  gap: 16px;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  flex-shrink: 0;
}
.leg { color: #555; }
.leg-gestion    { color: #a05000; }
.leg-parcial    { color: #bf4600; }
.leg-cobrado    { color: #1b5e20; }
.leg-incobrable { color: #880e4f; }

/* ── TABLA ── */
#tabla-wrap {
  flex: 1;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
thead { position: sticky; top: 0; z-index: 1; }
th {
  background: var(--th-bg);
  border: 1px solid var(--border);
  padding: 4px 7px;
  text-align: left;
  font-size: 11px;
  font-weight: bold;
  color: var(--accent);
  white-space: nowrap;
}
td {
  border: 1px solid #dddddd;
  padding: 3px 7px;
  white-space: nowrap;
}
tbody tr:nth-child(even) td { background: var(--alt); }
tbody tr:hover td { background: #ddeef5 !important; }

.num  { text-align: right; font-variant-numeric: tabular-nums; }
.tc   { text-align: center; }
.obs  { white-space: normal; min-width: 180px; }

/* columnas destacadas */
.col-mes   { color: var(--accent); font-weight: bold; }
.col-saldo { color: #c62800; font-weight: bold; }

/* fila de totales */
tfoot tr.fila-total td {
  background: var(--th-bg) !important;
  font-weight: bold;
  border-top: 2px solid #aaaaaa;
  font-size: 12px;
}

/* colores de estado en filas */
tr.est-gestion    td { background: #fffde7 !important; }
tr.est-parcial    td { background: #fff3e0 !important; }
tr.est-cobrado    td { background: #e8f5e9 !important; }
tr.est-incobrable td { background: #fce4ec !important; }

tr.est-gestion:hover    td { background: #fff9c4 !important; }
tr.est-parcial:hover    td { background: #ffe0b2 !important; }
tr.est-cobrado:hover    td { background: #c8e6c9 !important; }
tr.est-incobrable:hover td { background: #f8bbd0 !important; }

/* badges de estado */
.badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: bold;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}
.badge.est-gestion    { color: #a05000; border-color: #a05000; background: #fffde7; }
.badge.est-parcial    { color: #bf4600; border-color: #bf4600; background: #fff3e0; }
.badge.est-cobrado    { color: #1b5e20; border-color: #1b5e20; background: #e8f5e9; }
.badge.est-incobrable { color: #880e4f; border-color: #880e4f; background: #fce4ec; }

/* ── BARRA INFERIOR ── */
#barra-inf {
  height: 28px;
  min-height: 28px;
  background: #e8e8e8;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 11px;
  gap: 20px;
  flex-shrink: 0;
}
#info-deudores { color: var(--text-sec); white-space: nowrap; }
.totales-barra { display: flex; gap: 24px; margin-left: auto; }
.totales-barra span { white-space: nowrap; }
.totales-barra strong { color: var(--accent); }
