@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500&display=swap');

:root {
  --ink: #f2ede4;
  --paper: #1c1b19;
  --surface: #242220;
  --line: #3a3733;
  --line-subtle: #2c2a27;
  --red: #cd0811;
  --red-dark: #e8534f;
  --red-light: rgba(205, 8, 17, .16);
  --gray: #948e83;
  --gray-light: #2c2a27;
  --gray-dim: #6b665c;
  --table-text: #c9c4b8;
  --ok: #7bd6a3;
  --ok-light: rgba(60, 160, 110, .15);
  --error: #f2726d;
  --warn: #f2726d;
  --sans: "Inter", "IBM Plex Sans", Arial, sans-serif;
  --mono: var(--sans);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  padding: 40px 20px;
}
a.back { display: inline-block; font-size: 12.5px; color: var(--gray); text-decoration: none; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.brand img { height: 56px; width: auto; }
h1 { font-size: 20px; letter-spacing: 0.02em; margin: 0; color: var(--ink); }
.subtitle { color: var(--gray); font-size: 13.5px; margin: 6px 0 28px 0; }
.brand-rule {
  height: 4px;
  background: linear-gradient(90deg, var(--red) 0%, var(--red) 60%, var(--gray) 100%);
  margin: 14px 0 28px 0;
}

/* Header persistente (todas las páginas salvo login) */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}
.app-header-left { display: flex; align-items: center; gap: 16px; }
.app-header-logo { height: 40px; width: auto; display: block; }
.app-header-sep { width: 1px; height: 28px; background: var(--line); }
.app-header-title { color: var(--gray); font-size: 15px; font-weight: 500; }
.app-header-right { display: flex; align-items: center; gap: 12px; font-size: 13.5px; flex-wrap: wrap; }
.app-header-email { color: var(--gray); font-size: 13px; }
.btn-outline {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--sans);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-outline:hover { background: var(--gray-light); border-color: var(--gray); }

/* Hub de categorías (index.html) */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.category-card {
  display: block;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}
.category-card:hover { border-color: var(--red); background: var(--line-subtle); }
.category-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--red-dark);
  background: var(--red-light);
  border-radius: 4px;
  padding: 3px 7px;
}
.category-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(205, 8, 17, .15);
  color: var(--red-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 16px;
}
.category-title { font-size: 15.5px; font-weight: 600; margin: 0 0 6px 0; }
.category-desc { font-size: 12px; color: var(--gray); margin: 0; }

/* Sub-hub de módulos */
.module-list { display: flex; flex-direction: column; gap: 12px; }
.module-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: 8px;
  padding: 18px 22px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.15s;
}
.module-row:hover { background: var(--line-subtle); }
.module-row-title { font-size: 15px; font-weight: 600; }
.module-row-desc { font-size: 12px; color: var(--gray); margin-top: 3px; }
.module-row-arrow { color: var(--gray); font-size: 18px; flex-shrink: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
  overflow-x: auto;
}
/* Cuando no hay .subtitle entre el h1 y el primer bloque, el h1 (margin:0)
   necesita este espacio para no quedar pegado al borde superior. */
h1 + .card,
h1 + .tabs,
h1 + .report-grid {
  margin-top: 20px;
}
label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  margin-bottom: 6px;
}
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
input[type="file"] {
  width: 100%;
  font-size: 13px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
.hint { font-size: 12px; color: var(--gray-dim); margin-top: 4px; }
#log {
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  line-height: 1.6;
  margin-top: 18px;
}
.ok { color: var(--ok); }
.err { color: var(--error); font-weight: 600; }

/* ============================================================
   Sistema de UI compartido — extraído del módulo Proveedores.
   Única fuente de verdad para botones/inputs/tablas/dropzone del
   sitio. No redefinir estas reglas localmente en un archivo.
   ============================================================ */

/* --- Botones --- */
button {
  padding: 10px 18px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
}
button:hover { background: var(--red-dark); }
button:disabled { background: var(--gray); cursor: not-allowed; }
button.secundario { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.secundario:hover { background: var(--gray-light); }
/* Botón de texto chico (ej. "Limpiar filtros") */
button.chico { padding: 4px 10px; font-size: 12px; }
/* Botón cuadrado de ícono (ej. ✕ borrar fila en una tabla) */
button.btn-icon { padding: 4px 8px; font-size: 15px; line-height: 1; }
/* CTA de ancho completo — para pantallas de una sola acción
   (login, generadores de archivo) en vez del botón compacto por
   defecto, que es para pantallas con varias acciones lado a lado. */
button.btn-full {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  font-size: 14px;
  letter-spacing: 0.03em;
}

/* --- Inputs de formulario --- */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="email"],
input[type="password"],
select {
  width: 100%;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--mono);
  background: var(--paper);
  color: var(--ink);
}
select { font-family: var(--sans); }

/* --- Grillas de formulario --- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) {
  .grid4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
}

.acciones { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; align-items: center; }

/* --- Tablas --- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray);
  padding: 8px 6px;
  border-bottom: 2px solid var(--line);
}
td { padding: 8px 6px; border-bottom: 1px solid var(--line-subtle); vertical-align: middle; color: var(--table-text); }
tr:hover td { background: var(--gray-light); }

/* Tabla densa editable (ej. previsualización de carga, tablas de Admin) —
   contexto genuinamente distinto de una tabla de lectura: más columnas,
   inputs embebidos, necesita menos aire por fila a propósito. */
.tabla-compacta { font-size: 12.5px; }
.tabla-compacta th { font-size: 10.5px; padding: 8px 5px; }
.tabla-compacta td { padding: 5px; }
.tabla-compacta td input[type="text"],
.tabla-compacta td input[type="number"],
.tabla-compacta td input[type="date"],
.tabla-compacta td select {
  font-size: 12px;
  padding: 5px 6px;
  border-radius: 4px;
}

/* --- Zona de carga con drag & drop --- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 8px;
  padding: 56px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--paper);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--red); background: var(--line-subtle); }
.dropzone-text { font-size: 16px; font-weight: 600; color: var(--ink); margin: 0 0 6px 0; }
.dropzone-sub { font-size: 13px; color: var(--gray); margin: 0; }
.dropzone-filename { font-size: 12.5px; color: var(--ok); margin-top: 6px; }

/* --- Resumen de métricas (tarjetas de números grandes) --- */
.resumen { display: flex; gap: 24px; margin-bottom: 18px; font-size: 13px; flex-wrap: wrap; }
.resumen strong { display: block; font-size: 22px; color: var(--ink); }
.resumen .venc strong { color: var(--warn); }

/* --- Chips de filtro --- */
.chip { padding: 8px 14px; background: var(--gray-light); color: var(--gray); font-size: 12.5px; font-weight: 600; cursor: pointer; border-radius: 6px; }
.chip.activo { background: var(--ink); color: white; }

/* --- Barra de proporción horizontal --- */
.barra { height: 8px; background: var(--gray-light); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.barra-fill { height: 100%; background: var(--red); }

.empty-state { color: var(--gray); font-size: 13px; }

/* --- Pills de estado — mismo tamaño en todo el sitio, cada página
   usa el nombre semántico que corresponda a su propio dominio. --- */
.estado-tag { font-size: 10.5px; text-transform: uppercase; padding: 3px 9px; border-radius: 4px; font-weight: 700; white-space: nowrap; display: inline-block; }
.estado-alta, .estado-ok, .estado-pagada { background: var(--ok-light); color: var(--ok); }
.estado-baja, .estado-error, .estado-existe, .estado-vencida { background: var(--red-light); color: var(--warn); }
.estado-neutro, .estado-nueva, .estado-pendiente { background: var(--gray-light); color: var(--gray); }

.tipo-tag { font-size: 10.5px; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.downloads { margin-top: 18px; display: none; }
.downloads a {
  display: block;
  padding: 12px 16px;
  background: var(--red-light);
  border: 1px solid var(--red);
  border-radius: 6px;
  color: var(--red-dark);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}
.downloads a:hover { background: var(--red); color: white; }

@media (max-width: 640px) {
  .category-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  body { padding: 24px 14px; }
  .brand img { height: 44px; }
  .card { padding: 18px; }
  .app-header { padding-bottom: 12px; margin-bottom: 20px; }
  .app-header-logo { height: 32px; }
  .app-header-sep { height: 22px; }
}

/* Reportes: gráficos CSS, sin librerías */
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.report-grid .card { margin-bottom: 0; }
.report-card-title { font-size: 13px; font-weight: 600; color: var(--ink); margin: 0 0 18px 0; }

.chart-bar-row { margin-bottom: 16px; }
.chart-bar-row:last-child { margin-bottom: 0; }
.chart-bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.chart-bar-label .valor { font-weight: 600; color: var(--ink); }
.chart-bar-track { height: 8px; background: var(--line-subtle); border-radius: 4px; overflow: hidden; }
.chart-bar-fill { height: 100%; background: var(--red); border-radius: 4px; }

.chart-bars-vertical { display: flex; align-items: flex-end; gap: 18px; height: 200px; padding-top: 24px; }
.chart-bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1; height: 100%; }
.chart-bar-col-value { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.chart-bar-col-bar { width: 100%; max-width: 44px; background: var(--red); border-radius: 4px 4px 0 0; }
.chart-bar-col-label { font-size: 11.5px; color: var(--gray); margin-top: 8px; }

.chart-donut-wrap { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.chart-donut { width: 160px; height: 160px; border-radius: 50%; flex-shrink: 0; }
.chart-legend { display: flex; flex-direction: column; gap: 10px; font-size: 13px; flex: 1; min-width: 140px; }
.chart-legend-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chart-legend-item .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 8px; flex-shrink: 0; }
.chart-legend-item .nombre { display: flex; align-items: center; color: var(--ink); }
.chart-legend-item .valor { color: var(--gray); font-weight: 600; }

@media (max-width: 700px) {
  .report-grid { grid-template-columns: 1fr; }
  .chart-donut-wrap { flex-direction: column; align-items: flex-start; }
}
