/* databridge2 - estilos base (branding via --primary / --accent) */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #f4f6f9;
  color: #1d2b36;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- barra superior --- */
.topbar {
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 20px;
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; }
.topbar nav { display: flex; gap: 16px; flex: 1; }
.topbar nav a { color: #dce6ee; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.topbar nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.pill-inst {
  background: var(--accent);
  color: #14212b;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  vertical-align: middle;
  text-transform: uppercase;
}

/* --- contenido --- */
.content { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 24px 20px; }
h1 { font-size: 1.4rem; margin-bottom: 8px; }
h2 { font-size: 1.05rem; margin: 22px 0 8px; }
.muted { color: #5d707e; margin-bottom: 14px; }

/* --- login --- */
.layout-login .content { display: flex; align-items: center; justify-content: center; }
.login-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(11, 44, 67, 0.12);
  padding: 34px 38px;
  width: 360px;
  text-align: center;
}
.login-card h1 { color: var(--primary); }
.login-card form { text-align: left; margin-top: 18px; }
.login-card label { display: block; font-size: 0.85rem; margin: 12px 0 4px; color: #405260; }
.login-card input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #c8d3dc;
  border-radius: 7px;
  font-size: 0.95rem;
}
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* --- botones --- */
.btn {
  border: 0;
  border-radius: 7px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  background: #e3e9ee;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.15); }
.btn-block { width: 100%; margin-top: 18px; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* --- tarjetas dashboard --- */
.cards { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
.card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(11, 44, 67, 0.08);
  padding: 18px 22px;
}
.card.stat { min-width: 180px; text-align: center; }
.stat-n { font-size: 1.7rem; font-weight: 700; color: var(--primary); }
.stat-l { color: #5d707e; font-size: 0.85rem; margin-top: 4px; }

/* --- tablas --- */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 10px rgba(11, 44, 67, 0.08); font-size: 0.88rem; }
.data-table th { background: var(--primary); color: #fff; text-align: left; padding: 8px 10px; font-weight: 600; }
.data-table td { padding: 7px 10px; border-top: 1px solid #eef2f5; }
.data-table.compact td, .data-table.compact th { padding: 5px 8px; font-size: 0.82rem; }
.data-table .num { text-align: right; }
.data-table .empty { text-align: center; color: #7b8b97; padding: 18px; }
.mono { font-family: Consolas, monospace; }
.small { font-size: 0.8rem; }
.neg { color: #c0392b; }

/* --- pills / badges / flash --- */
.pill { padding: 2px 9px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; }
.pill-ok { background: #e2f4e5; color: #1f7a34; }
.pill-err { background: #fde4e1; color: #b3261e; }
.pill-warn { background: #fdf3d7; color: #8a6d00; }
.badge { background: #e3ecf3; color: #33566e; padding: 2px 8px; border-radius: 9px; font-size: 0.72rem; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 0.9rem; }
.flash-error { background: #fde4e1; color: #b3261e; }
.flash-warning { background: #fdf3d7; color: #8a6d00; }
.flash-success { background: #e2f4e5; color: #1f7a34; }

/* --- filtros / footer --- */
.filter-bar { display: flex; align-items: center; gap: 8px; margin: 8px 0 10px; }
.filter-bar select { padding: 5px 8px; border-radius: 6px; border: 1px solid #c8d3dc; }
.app-footer { text-align: center; padding: 12px; color: #7b8b97; }

/* ---- Reportes (Hito 5 cola) ---- */
.grid-reportes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.reporte-item { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid #dfe5ea; border-radius: 8px; text-decoration: none; color: inherit; background: #fff; }
.reporte-item:hover { border-color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.reporte-item .icono { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 700; }
.run-cabecera { display: flex; align-items: baseline; justify-content: space-between; }
.filtros { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filtro { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; }
.filtro select, .filtro input { padding: 6px 8px; border: 1px solid #c8d1d9; border-radius: 6px; min-width: 140px; }
.resumen-kpis { display: flex; flex-wrap: wrap; gap: 18px; }
.kpi { display: flex; flex-direction: column; }
.kpi-label { font-size: .75rem; color: #5c6b78; }
.kpi-valor { font-size: 1.1rem; font-weight: 700; }
.tabla-scroll { overflow-x: auto; max-height: 65vh; overflow-y: auto; }
.tabla-reporte { border-collapse: collapse; width: 100%; font-size: .85rem; }
.tabla-reporte th { position: sticky; top: 0; background: var(--primary); color: #fff; padding: 6px 8px; text-align: left; white-space: nowrap; }
.tabla-reporte td { padding: 4px 8px; border-bottom: 1px solid #eef1f4; white-space: nowrap; }
.tabla-reporte tr:hover td { background: #f4f8e8; }
.celda-money, .celda-number, .celda-pct { text-align: right; font-variant-numeric: tabular-nums; }
.hoja-pie { color: #5c6b78; font-size: .8rem; }
.btn-sec { background: #fff; color: var(--primary); border: 1px solid var(--primary); }

/* ---- Dashboard KPIs (Hito 6) ---- */
.grid-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi-card { padding: 14px; }
.kpi-titulo { font-size: .8rem; color: #5c6b78; margin-bottom: 4px; }
.kpi-valor-g { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .78rem; margin-top: 4px; }
.kpi-sub.up { color: #2e7d32; }
.kpi-sub.down { color: #c62828; }
.kpi-err .kpi-titulo { color: #c62828; }
.filtros-inline { display: flex; gap: 10px; align-items: flex-end; }
.titulo-seccion { margin-top: 8px; }
.muted { color: #7a8791; }
.fila-inactiva td { opacity: .5; }
.acciones { white-space: nowrap; }
.celda-ppto { width: 92px; padding: 3px 5px; border: 1px solid #c8d1d9; border-radius: 4px; text-align: right; font-variant-numeric: tabular-nums; }
.tabla-presupuesto td { padding: 3px 4px; }

/* ---- Vista jerarquica contable ---- */
.fila-seccion td { background: #e8eef3; font-weight: 700; color: var(--primary); border-top: 2px solid var(--primary); }
.fila-subseccion td { background: #f2f5f8; font-weight: 600; }
.fila-detalle td:first-child { padding-left: 26px; }
.fila-total td { font-weight: 700; border-top: 2px solid var(--primary); background: #f6f9ec; }
.fila-pct td { font-style: italic; color: #5c6b78; }

/* ---- Drill-down ---- */
.celda-drill { cursor: zoom-in; text-decoration: underline dotted; }
.drill-modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.drill-caja { background: #fff; border-radius: 10px; padding: 16px; width: min(1000px, 92vw); max-height: 85vh; display: flex; flex-direction: column; }
.drill-caja .tabla-scroll { max-height: 60vh; }
.drill-cabecera { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

/* ---- Alertas ---- */
.pill-sev { padding: 2px 8px; border-radius: 10px; font-size: .72rem; font-weight: 700; color: #fff; }
.pill-alta { background: #c62828; }
.pill-media { background: #ef6c00; }
.pill-baja { background: #607d8b; }
.pill-estado { background: #eef1f4; border-radius: 10px; padding: 2px 8px; font-size: .75rem; margin-left: 4px; }
.detalle-alerta { max-width: 420px; white-space: normal; font-size: .8rem; }
.drill-modal[hidden] { display: none; }
.celda-money.neg { color: #c62828; }
