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

/* ── Variables NODO/BRIO ── */
:root {
  --prim:       #2c64a8;
  --prim-h:     #4682c5;
  --prim-d:     #1a3a6c;
  --acento:     #ffe79a;
  --bg:         #f5f5f5;
  --bg2:        #fff;
  --bg3:        #ececec;
  --texto:      #1e1e1e;
  --texto2:     #555;
  --texto3:     #777;
  --borde:      #c5c5c5;
  --borde-in:   #7a7a7a;
  --ok:         #2a8a3a;
  --warn:       #d4a000;
  --peligro:    #a40000;
  --info:       #4682c5;
  --radio:      4px;
  --header-h:   44px;
  --nav-h:      54px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--texto);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 13px;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: "Consolas", "Courier New", monospace; font-variant-numeric: tabular-nums; }
.oculto { display: none !important; }

/* ── Login ── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.login-box {
  width: min(380px, 92vw);
  background: var(--bg2);
  border: 1px solid var(--borde);
  border-radius: 6px;
  box-shadow: 0 4px 24px rgba(0,0,0,.13);
  overflow: hidden;
}

.login-logo {
  background: var(--prim);
  color: #fff;
  padding: 20px 24px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.login-logo-titulo {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
}

.login-logo-titulo span { color: var(--acento); }

.login-logo-sub {
  font-size: 10px;
  color: rgba(255,255,255,.65);
  letter-spacing: 0.4px;
}

.login-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 24px 24px;
}

.login-box input {
  display: block;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--borde-in);
  border-radius: var(--radio);
  background: var(--bg2);
  color: var(--texto);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.login-box input:focus {
  border-color: var(--prim);
  outline: 2px solid rgba(70,130,197,.25);
  outline-offset: -1px;
}

.login-box button {
  display: block;
  width: 100%;
  height: 34px;
  background: var(--prim);
  color: #fff;
  border: 1px solid var(--prim-d);
  border-radius: var(--radio);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.2px;
  transition: background 0.15s;
}

.login-box button:hover   { background: var(--prim-h); }
.login-box button:active  { background: var(--prim-d); }
.login-box button:disabled { opacity: .5; cursor: not-allowed; }

.login-error {
  font-size: 11px;
  color: var(--peligro);
  text-align: center;
  min-height: 14px;
  font-weight: 600;
}

/* ── App layout ── */
.app { display: flex; flex-direction: column; height: 100dvh; }

/* ── Header (topbar NODO/BRIO) ── */
.header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: var(--header-h);
  background: var(--prim);
  color: #fff;
  flex-shrink: 0;
  border-bottom: 1px solid var(--prim-d);
}

.header-titulo {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-version {
  font-size: 10px;
  color: rgba(255,255,255,.6);
}

.btn-icono {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.8);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 5px;
  border-radius: var(--radio);
  line-height: 1;
}

.btn-icono:hover  { background: rgba(255,255,255,.15); color: #fff; }
.btn-icono:active { background: rgba(0,0,0,.15); }

/* ── Main ── */
.main-content { flex: 1; overflow-y: auto; background: var(--bg); }
.seccion { padding: 12px; }

/* ── Nav inferior (bottom tab bar) ── */
.nav-inferior {
  display: flex;
  background: var(--bg2);
  border-top: 1px solid var(--borde);
  height: var(--nav-h);
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  color: var(--texto3);
  border: none;
  background: none;
  cursor: pointer;
  transition: color 0.15s;
  letter-spacing: 0.1px;
  font-family: inherit;
}

.nav-btn i { font-size: 1.25rem; }
.nav-btn.activo { color: var(--prim); font-weight: 600; }
.nav-btn:hover  { color: var(--prim-h); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 10px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 3px;
  font-size: 12px;
  z-index: 300;
  white-space: nowrap;
  background: #1e1e1e;
  color: #fff;
  border: 1px solid #000;
  box-shadow: 0 3px 10px rgba(0,0,0,.25);
  animation: fadeInOut 2.8s ease forwards;
}

@keyframes fadeInOut {
  0%   { opacity: 0; transform: translateX(-50%) translateY(6px); }
  12%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Card (panel) — estilo BRIO ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.card-titulo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--texto2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bg3);
}

.card-titulo i { font-size: 12px; color: var(--prim); }

/* ── Dashboard filtros ── */
.dash-filtros {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  background: var(--bg2);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 10px 12px;
}

/* Chips (filtros rápidos) — estilo BRIO */
.dash-rangos {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  align-items: center;
}
.dash-rangos::-webkit-scrollbar { display: none; }

.dash-rango-btn {
  height: 26px;
  padding: 0 12px;
  border: 1px solid var(--borde);
  background: var(--bg2);
  color: var(--texto);
  font: inherit;
  font-size: 11px;
  border-radius: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}

.dash-rango-btn:hover {
  background: var(--acento);
  border-color: var(--warn);
}

.dash-rango-btn.activo {
  background: var(--prim);
  border-color: var(--prim-d);
  color: #fff;
  font-weight: 700;
}

/* Select sucursal — estilo BRIO input */
.dash-sucursal-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.dash-sucursal-wrap > i {
  position: absolute;
  left: 9px;
  color: var(--texto2);
  font-size: 12px;
  pointer-events: none;
}

#dash-sucursal {
  height: 28px;
  padding: 0 10px 0 28px;
  border: 1px solid var(--borde-in);
  background: var(--bg2);
  color: var(--texto);
  font: inherit;
  font-size: 12px;
  width: 100%;
  outline: none;
  border-radius: var(--radio);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%23555' d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

#dash-sucursal:focus { outline: 2px solid rgba(70,130,197,.3); outline-offset: -1px; }

/* ── KPI grid — estilo BRIO ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

@media (min-width: 560px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .kpi-grid { grid-template-columns: repeat(5, 1fr); } }

/* p-dashboard-kpi BRIO: fondo blanco, border-left 4px coloreado */
.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--borde);
  border-left: 4px solid var(--clr, var(--prim));
  border-radius: var(--radio);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.kpi-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.kpi-label {
  font-size: 9px;
  color: var(--texto2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.kpi-icon {
  font-size: 13px;
  color: var(--clr, var(--prim));
  opacity: 0.7;
}

.kpi-valor {
  font-size: 20px;
  font-weight: 700;
  color: var(--texto);
  line-height: 1.1;
  font-family: "Consolas", "Courier New", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

/* ── Gráficos ── */
.chart-wrap { position: relative; height: 190px; }
.chart-wrap.alto { height: 250px; }

.charts-grid-2 { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .charts-grid-2 { grid-template-columns: 1fr 1fr; } }

/* ── Tabla — estilo grilla BRIO ── */
.tabla {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.tabla thead th {
  background: var(--bg3);
  color: var(--texto);
  font-weight: 600;
  text-align: left;
  padding: 4px 8px;
  height: 24px;
  border-bottom: 1px solid var(--borde);
  border-right: 1px solid #d8d8d8;
  white-space: nowrap;
  font-size: 11px;
}

.tabla thead th:last-child { border-right: none; }
.tabla thead th.num { text-align: right; }

.tabla tbody td {
  padding: 5px 8px;
  height: 26px;
  border-bottom: 1px solid #ececec;
  border-right: 1px solid #f0f0f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
  vertical-align: middle;
}

.tabla tbody td:last-child { border-right: none; }
.tabla tbody tr:nth-child(even) { background: #fafafa; }
.tabla tbody tr:hover { background: var(--acento); cursor: default; }
.tabla tbody tr:last-child td { border-bottom: none; }

.tabla .num   { text-align: right; font-family: "Consolas", monospace; font-variant-numeric: tabular-nums; }
.tabla .monto { color: var(--ok); font-weight: 700; font-family: "Consolas", monospace; }
.tabla .nombre { max-width: 140px; font-size: 12px; }

/* ── Rank badges — estilo BRIO pill ── */
.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 9px;
  font-size: 9px;
  font-weight: 700;
  margin-right: 5px;
  vertical-align: middle;
  background: var(--bg3);
  color: var(--texto2);
  border: 1px solid var(--borde);
  flex-shrink: 0;
}

.rank-1 { background: #fef3c7; color: #92400e; border-color: #d97706; }
.rank-2 { background: #f1f5f9; color: #334155; border-color: #94a3b8; }
.rank-3 { background: #fff7ed; color: #7c2d12; border-color: #c2410c; }

.sin-datos {
  color: var(--texto3);
  font-size: 12px;
  padding: 20px 0;
  text-align: center;
}

/* ── Loading ── */
.dash-cuerpo.cargando { opacity: 0.5; pointer-events: none; }

/* ── Responsive mobile ── */
@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-valor { font-size: 17px; }
}
