/* ── Cierre Contable ─────────────────────────────────────────── */

.cierre-root {
  padding-bottom: 40px;
}

/* Controls row */
.cierre-controls {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cierre-period-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.cierre-select-mes {
  flex: 1;
  min-width: 140px;
}

.cierre-input-anio {
  width: 90px;
  flex-shrink: 0;
}

.cierre-btn-generar {
  flex-shrink: 0;
}

.cierre-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cierre-btn-action {
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: var(--r2);
  color: var(--t2);
  font-size: 12px;
  font-family: var(--font-b);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.cierre-btn-action:hover {
  background: var(--bg3);
  color: var(--t1);
}

.cierre-btn-action:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* Error */
.cierre-error {
  padding: 14px 16px;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--r2);
  color: var(--err);
  font-size: 13px;
  margin-bottom: 16px;
}

/* Skeleton */
.cierre-skeleton-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.cierre-skel-row {
  height: 64px;
  border-radius: var(--r2);
}

/* Empty */
.cierre-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--t3);
}

/* Print title (solo visible en print) */
.cierre-print-title {
  display: none;
  font-size: 18px;
  font-weight: 700;
  color: #000;
  margin-bottom: 16px;
}

/* ── Secciones colapsables ───────────────────────────────────── */
.cierre-section {
  border: 1px solid var(--border);
  border-radius: var(--r2);
  overflow: hidden;
  margin-bottom: 8px;
}

.cierre-section.open {
  border-color: var(--border2);
}

.cierre-sec-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  background: var(--bg2);
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}

.cierre-sec-header:hover {
  background: var(--bg3);
}

.cierre-sec-arrow {
  font-size: 11px;
  color: var(--t3);
  flex-shrink: 0;
  width: 14px;
}

.cierre-sec-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
  font-family: var(--font-b);
}

.cierre-sec-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}

.cierre-sec-body {
  padding: 16px;
  background: var(--bg1);
  border-top: 1px solid var(--border);
}

/* ── KPI Grid (Sección 1) ────────────────────────────────────── */
.cierre-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.cierre-kpi {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 14px;
}

.cierre-kpi-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--t3);
  margin-bottom: 6px;
}

.cierre-kpi-value {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-h);
  margin-bottom: 4px;
}

.cierre-kpi-sub {
  font-size: 10px;
  color: var(--t3);
  line-height: 1.4;
}

/* ── Cards 2 columnas ────────────────────────────────────────── */
.cierre-cards-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.cierre-mini-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 14px;
}

.cierre-mini-card-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--t3);
  margin-bottom: 4px;
}

.cierre-mini-card-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--t1);
  font-family: var(--font-h);
  margin-bottom: 4px;
}

.cierre-mini-card-sub {
  font-size: 11px;
  color: var(--t3);
  line-height: 1.4;
}

/* ── Sub-sección title ───────────────────────────────────────── */
.cierre-subsec-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--t3);
  margin-bottom: 10px;
}

/* ── Tablas ──────────────────────────────────────────────────── */
.cierre-table-wrap {
  overflow-x: auto;
  border-radius: var(--r2);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.cierre-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--font-b);
}

.cierre-table th {
  background: var(--bg3);
  color: var(--t3);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}

.cierre-table td {
  padding: 8px 10px;
  color: var(--t1);
  border-top: 1px solid var(--border);
  white-space: nowrap;
}

.cierre-th-right {
  text-align: right !important;
}

.cierre-td-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cierre-tfoot td {
  background: var(--bg3);
  border-top: 1px solid var(--border2);
}

/* ── Empty sec ───────────────────────────────────────────────── */
.cierre-empty-sec {
  font-size: 12px;
  color: var(--t3);
  padding: 10px 0;
  font-style: italic;
}

/* ── Info grid (Sección 8) ───────────────────────────────────── */
.cierre-info-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cierre-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.cierre-info-row:last-child {
  border-bottom: none;
}

.cierre-info-label {
  font-size: 12px;
  color: var(--t3);
  font-weight: 600;
}

.cierre-info-value {
  font-size: 13px;
  color: var(--t1);
  text-align: right;
}

/* ── Print styles ────────────────────────────────────────────── */
@media print {
  /* Ocultar elementos de navegación e interacción */
  .cierre-no-print,
  .nav-shell,
  .sidebar,
  .app-shell-nav,
  .page-header .btn-primary,
  .cierre-controls,
  .cierre-error {
    display: none !important;
  }

  /* Mostrar título de print */
  .cierre-print-title {
    display: block !important;
  }

  /* Reset a fondo blanco / texto negro */
  body, .cierre-root, .cierre-section, .cierre-sec-body,
  .cierre-kpi, .cierre-mini-card, .cierre-table th,
  .cierre-tfoot td {
    background: #fff !important;
    color: #000 !important;
  }

  .cierre-sec-header {
    background: #f0f0f0 !important;
    color: #000 !important;
  }

  .cierre-kpi-label,
  .cierre-mini-card-title,
  .cierre-subsec-title,
  .cierre-info-label {
    color: #555 !important;
  }

  .cierre-kpi-sub,
  .cierre-mini-card-sub,
  .cierre-empty-sec,
  .cierre-info-value {
    color: #444 !important;
  }

  /* Bordes visibles en tablas */
  .cierre-table th,
  .cierre-table td {
    border: 1px solid #ccc !important;
    color: #000 !important;
  }

  .cierre-table-wrap {
    border: 1px solid #ccc !important;
  }

  /* Expandir todas las secciones en print */
  .cierre-sec-body {
    display: block !important;
  }

  /* Secciones en nueva página */
  .cierre-section {
    page-break-inside: avoid;
    break-inside: avoid;
    border: 1px solid #ccc !important;
    margin-bottom: 16px;
  }

  /* Salto de página entre secciones grandes */
  .cierre-section + .cierre-section {
    page-break-before: auto;
  }
}

/* ── Botón flotante de IA ───────────────────────────────────── */
.cierre-fab {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 200;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  cursor: not-allowed;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  transition: background .3s, box-shadow .3s, transform .15s;
  background: var(--bg3);
  color: var(--t3);
}

.cierre-fab.ready {
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  color: #fff;
  cursor: pointer;
}

.cierre-fab.ready:hover {
  box-shadow: 0 6px 24px rgba(124,58,237,0.45);
  transform: scale(1.07);
}

/* ── Modal IA ───────────────────────────────────────────────── */
.cierre-modal-ia {
  max-width: 560px;
  width: 95vw;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 20px;
  padding: 24px 20px 28px;
  background: var(--bg1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  position: relative;
}

.cierre-ia-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.cierre-ia-kpi {
  background: var(--bg3);
  border-radius: 10px;
  padding: 12px 14px;
}

.cierre-ia-kpi-label {
  font-size: 11px;
  color: var(--t3);
  margin-bottom: 4px;
}

.cierre-ia-kpi-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--t1);
}

.cierre-ia-texto {
  font-size: 13px;
  line-height: 1.75;
  color: var(--t1);
  background: linear-gradient(135deg,rgba(124,58,237,0.06),rgba(236,72,153,0.04));
  border: 1px solid rgba(124,58,237,0.15);
  border-radius: 12px;
  padding: 16px;
}
.cierre-ia-texto h3 { font-size:14px; font-weight:700; margin:12px 0 4px; color:var(--t1); }
.cierre-ia-texto h4 { font-size:13px; font-weight:700; margin:10px 0 3px; color:var(--t2); }
.cierre-ia-texto ul { margin:4px 0 4px 16px; padding:0; }
.cierre-ia-texto li { margin:3px 0; }
.cierre-ia-texto hr { border:none; border-top:1px solid rgba(124,58,237,0.2); margin:12px 0; }
.cierre-ia-texto p  { margin:0 0 8px; }

.cierre-ia-historial {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cierre-ia-hist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s;
}

.cierre-ia-hist-item:hover {
  border-color: var(--border2);
}

@media print {
  .cierre-fab { display: none !important; }
}

/* ── Estado Financiero Simplificado ─────────────────────────── */
.cierre-ef-tabla {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 680px;
}

.cierre-ef-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 6px 12px;
  gap: 16px;
  border-radius: 4px;
  transition: background .1s;
}

.cierre-ef-row:hover {
  background: var(--bg3);
}

.cierre-ef-indent {
  padding-left: 24px;
  padding-top: 0;
}

.cierre-ef-concepto {
  font-size: 13px;
  color: var(--t2);
  flex: 1;
}

.cierre-ef-monto {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 140px;
  text-align: right;
}

.cierre-ef-subtotal {
  border-top: 1px solid var(--border);
  margin-top: 2px;
  padding-top: 8px;
}

.cierre-ef-separator {
  height: 0;
  border-top: 1px dashed var(--border);
  margin: 10px 0;
}

.cierre-ef-resultado {
  padding: 10px 12px;
  margin-top: 4px;
}

@media (max-width: 480px) {
  .cierre-ef-monto {
    min-width: 100px;
    font-size: 12px;
  }
  .cierre-ef-concepto {
    font-size: 12px;
  }
}
