/* ==========================================================================
   FOCO · Componentes de UI
   ========================================================================== */

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 11px 16px; min-height: 42px; border-radius: var(--r-md);
  font-weight: 600; font-size: var(--fs-sm);
  border: 1px solid transparent; white-space: nowrap;
  transition: background .18s var(--ease-out), border-color .18s, transform .12s var(--ease-out), filter .18s, box-shadow .18s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent-grad); color: var(--text-on-accent); box-shadow: var(--glow); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: scale(.97); filter: none; }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-subtle { background: var(--surface-2); color: var(--text-muted); border-color: var(--line); }
.btn-subtle:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-strong); color: var(--text); }
.btn-danger { background: var(--danger-tint); color: var(--danger-soft); border-color: color-mix(in oklch, var(--danger) 40%, transparent); }
.btn-danger:hover:not(:disabled) { background: color-mix(in oklch, var(--danger) 22%, transparent); color: #f6d7d1; }
.btn-ok { background: #3f7a4d; color: #eef6ef; }
.btn-ok:hover:not(:disabled) { background: #4b8c5a; }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; padding: 15px 20px; font-size: var(--fs-body); border-radius: var(--r-lg); }
.btn-icon { padding: 0; width: 40px; height: 40px; min-height: 40px; border-radius: var(--r-md); }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-5);
  position: relative;
}
.card-tight { padding: var(--sp-4); }
.card-hover { transition: border-color .18s var(--ease-out), background .18s, transform .18s; cursor: pointer; }
.card-hover:hover { border-color: var(--line-strong); background: var(--surface-2); }
.card-accent { border-left: 3px solid var(--accent); }
/* Tarjeta "hero" con calidez de marca (KPI destacado) */
.card-hero { background: linear-gradient(165deg, #24190e 0%, var(--surface-1) 58%); border-color: #3a2a16; overflow: hidden; }

.card-title { font-family: var(--font-display); font-size: var(--fs-h3); color: var(--text); }
.section-label {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-dim); font-weight: 600;
}

/* ---------- Chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: var(--r-full);
  font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--line);
}
.chip-dot::before { content:""; width:5px; height:5px; border-radius:50%; background: currentColor; }
.chip-ok    { background: var(--ok-tint);     color: var(--ok-soft);     border-color: color-mix(in oklch, var(--ok) 32%, transparent); }
.chip-warn  { background: var(--warn-tint);   color: var(--warn-soft);   border-color: color-mix(in oklch, var(--warn) 34%, transparent); }
.chip-danger{ background: var(--danger-tint); color: var(--danger-soft); border-color: color-mix(in oklch, var(--danger) 34%, transparent); }
.chip-accent{ background: var(--accent-tint); color: var(--accent);      border-color: var(--accent-tint-2); }
.chip-info  { background: var(--info-tint);   color: var(--info-soft);   border-color: color-mix(in oklch, var(--info) 32%, transparent); }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: var(--fs-xs); color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 11px 13px; color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 4px var(--accent-tint); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.input-invalid { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-tint); }
.input-money { position: relative; }
.input-money .pfx { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--accent); font-family: var(--font-display); font-weight: 600; pointer-events: none; }
.input-money .input { padding-left: 30px; font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
.field-error { font-size: var(--fs-xs); color: var(--danger-soft); }

/* Segmentos / toggles (filtros) */
.segmented { display: inline-flex; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-full); padding: 4px; gap: 3px; }
.segmented button { padding: 8px 15px; border-radius: var(--r-full); font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); transition: background .18s var(--ease-out), color .18s; }
.segmented button:hover:not([aria-pressed="true"]) { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--accent-grad); color: var(--text-on-accent); box-shadow: var(--glow); }

/* ---------- Barra superior de sección ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3) var(--sp-4);
  flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar > :first-child { min-width: 0; flex: 1 1 auto; }
.topbar > .row { flex-wrap: wrap; justify-content: flex-end; }
.topbar > .row select { max-width: 100%; }
.topbar h1 { font-size: 1.5rem; }
.topbar .subtitle { font-size: var(--fs-xs); color: var(--text-dim); margin-top: 2px; }

/* ---------- Navegación ---------- */
.rail { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-nav);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: color-mix(in srgb, var(--surface-1) 97%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}
.tabbar a, .tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-dim); font-size: 10px; font-weight: 600; letter-spacing: .01em;
  min-height: 44px; -webkit-tap-highlight-color: transparent; transition: color .15s ease;
}
.tabbar a .ic, .tabbar button .ic { width: 22px; height: 22px; }
.tabbar a[aria-current="page"], .tabbar button[aria-current="page"] { color: var(--accent-soft); }
.tabbar a[aria-current="page"] .ic, .tabbar button[aria-current="page"] .ic { color: var(--accent); }

/* Hoja "Más" (secciones secundarias en móvil) */
.mas-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 4px; }
.mas-item {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-weight: 600; transition: background .15s ease, transform .12s ease;
}
.mas-item:hover { background: var(--surface-3); }
.mas-item:active { transform: scale(.98); }
.mas-item .ico-badge { flex: none; }

/* ---------- Pagos · layout responsivo ---------- */
.pagos-top { display: grid; grid-template-columns: 1fr; gap: 12px; }
.pagos-sec { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pagos-cards { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) {
  .pagos-top { grid-template-columns: 1.6fr 1fr; align-items: stretch; }
  .pagos-sec { grid-template-columns: 1fr; }
  .pagos-cards { grid-template-columns: 1fr 1fr; }
}

/* ---------- Estados vacíos ---------- */
.empty {
  text-align: center; padding: var(--sp-10) var(--sp-5);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
}
.empty .ic { width: 44px; height: 44px; color: var(--text-faint); }
.empty h3 { color: var(--text); }
.empty p { color: var(--text-dim); max-width: 34ch; font-size: var(--fs-sm); }

/* ---------- Hoja inferior / modal ---------- */
.scrim {
  position: fixed; inset: 0; z-index: var(--z-sheet);
  background: rgba(8,9,11,.68); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .3s ease;
}
@media (min-width: 720px) { .scrim { align-items: center; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--sp-2) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px -20px rgba(0,0,0,.6);
  animation: sheetUp .42s var(--ease-out);
}
@media (min-width: 720px) { .sheet { border-radius: var(--r-xl); border-bottom: 1px solid var(--line); max-height: 92dvh; animation: pop .32s var(--ease-out); } }
.sheet-handle { width: 38px; height: 4px; border-radius: 999px; background: var(--line-strong); margin: 6px auto var(--sp-4); }
.sheet-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border); }
.sheet-header h2 { font-size: 1.3rem; }

@keyframes fade { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(16px); opacity: 0; } }
@keyframes secIn { from { transform: translateY(10px); opacity: 0; } }
@keyframes pop { from { transform: scale(.95); opacity: 0; } }
@keyframes sheetUp { from { transform: translateY(101%); } }
@keyframes toastIn { from { transform: translate(-50%, -10px); opacity: 0; } }
@keyframes shimmer { from { background-position: -180px 0; } to { background-position: 180px 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulseRing { 0%,100% { box-shadow: 0 0 0 0 rgba(216,80,60,.28); } 50% { box-shadow: 0 0 0 7px rgba(216,80,60,0); } }

/* ---------- Pasos (wizard) ---------- */
.steps { display: flex; align-items: center; gap: 6px; margin-bottom: var(--sp-4); }
.steps .dot { height: 4px; border-radius: 999px; flex: 1; background: var(--surface-3); transition: background .3s var(--ease-out); }
.steps .dot.on { background: var(--accent-grad); }
.step-label { font-size: var(--fs-xs); color: var(--text-dim); }

/* ---------- Listas ---------- */
.list { display: flex; flex-direction: column; gap: var(--sp-2); }
.list-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 14px;
  transition: background .18s var(--ease-out), border-color .18s;
}
.list-item.card-hover:hover { background: var(--surface-2); border-color: var(--line-strong); }
.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 13px;
  display: grid; place-items: center; font-family: var(--font-body);
  font-weight: 600; font-size: 13px; color: var(--text-muted);
  background: var(--surface-3); border: 1px solid var(--line);
}

/* ---------- Stat / KPI ---------- */
.stat { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); }
.stat .k { font-size: var(--fs-xs); color: var(--text-dim); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.stat .v { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; color: var(--text); margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px); z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong);
  padding: 11px 16px; border-radius: var(--r-full); font-size: var(--fs-sm); font-weight: 600;
  box-shadow: var(--shadow-2); animation: toastIn .4s var(--ease-out); display: flex; align-items: center; gap: 8px;
}
.toast.ok { border-color: color-mix(in oklch, var(--ok) 40%, transparent); }
.toast .ic { width: 16px; height: 16px; }

/* ---------- Banner offline / error ---------- */
.banner { display: flex; align-items: center; gap: var(--sp-2); padding: 12px 14px; font-size: var(--fs-sm); border-radius: 14px; border: 1px solid transparent; }
.banner-warn { background: var(--warn-tint); color: var(--warn-soft); border-color: color-mix(in oklch, var(--warn) 30%, transparent); border-left: 3px solid var(--warn); }
.banner-danger { background: var(--danger-tint); color: var(--danger-soft); border-color: color-mix(in oklch, var(--danger) 30%, transparent); border-left: 3px solid var(--danger); }

/* ---------- Barra de progreso (vida útil) ---------- */
.meter { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.meter.warn > span { background: var(--warn); }
.meter.danger > span { background: var(--danger); }

/* ---------- Divisores ---------- */
.hr { height: 1px; background: var(--border); border: 0; margin: var(--sp-4) 0; }

/* ==========================================================================
   Calendario (almanaque mensual)
   ========================================================================== */
.cal-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--tc, var(--accent)); }
.cal-dot.clase  { background: var(--t-clase); }
.cal-dot.salida { background: var(--t-salida); }
.cal-dot.evento,
.cal-dot.recordatorio { background: var(--t-recordatorio); }
.cal-dot.vencimiento { background: var(--t-vencimiento); }
.cal-dot.cumple { background: var(--t-cumple); }

/* --- Colores por tipo de evento --- */
.t-clase        { --tc: var(--t-clase); }
.t-salida       { --tc: var(--t-salida); }
.t-vencimiento  { --tc: var(--t-vencimiento); }
.t-cumple       { --tc: var(--t-cumple); }
.t-recordatorio { --tc: var(--t-recordatorio); }

/* --- Barra de herramientas de la agenda --- */
.ag-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ag-monthnav { display: flex; align-items: center; gap: 6px; }
.ag-monthname { min-width: 146px; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.ag-count { margin-left: auto; font-size: .76rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* --- Cuerpo: grilla + panel del día --- */
.ag-body { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.ag-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 8px; flex: 1; }
.ag-dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.ag-dow span { font-size: .64rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--text-dim); padding: 0 4px 2px; }

.ag-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px;
  grid-auto-rows: 76px; animation: gridIn .17s cubic-bezier(.2,0,0,1) both;
}
.ag-cell {
  display: flex; flex-direction: column; gap: 5px; padding: 7px 7px 6px; border-radius: 10px;
  cursor: pointer; min-height: 0; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface-1);
  transition: background .12s, border-color .12s;
}
.ag-cell:hover { border-color: var(--line-strong); }
.ag-cell.off { background: transparent; opacity: .4; }
.ag-cell.sel { border-color: var(--accent); background: var(--surface-2); }
.ag-cell-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.ag-daynum { font-size: .76rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.ag-cell.hoy .ag-daynum { color: var(--accent); }
.ag-today-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex: none; }
.ag-chips { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.ag-chip { display: flex; align-items: center; gap: 5px; padding: 2px 5px; border-radius: 5px; background: var(--surface-3); min-width: 0; }
.ag-chip i { width: 6px; height: 6px; border-radius: 2px; flex: none; background: var(--tc, var(--accent)); }
.ag-chip span { font-size: .66rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-more { padding-left: 5px; font-size: .6rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* --- Panel del día --- */
.ag-rail {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg);
  animation: railIn .16s cubic-bezier(.2,0,0,1) both;
}
.ag-rail-head { display: flex; align-items: flex-end; gap: 12px; padding: 16px 16px 13px; border-bottom: 1px solid var(--border); }
.ag-rail-num { font-family: var(--font-display); font-size: 2.5rem; font-weight: 700; line-height: .9; letter-spacing: -2px; font-variant-numeric: tabular-nums; }
.ag-rail-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.ag-rail-foot { padding: 12px; border-top: 1px solid var(--border); }
.ag-ev {
  display: flex; flex-direction: column; gap: 5px; padding: 11px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--border); border-left: 2px solid var(--tc, var(--accent));
  animation: rowIn .16s cubic-bezier(.2,0,0,1) both;
}
.ag-ev-top { display: flex; align-items: center; gap: 8px; }
.ag-tag { margin-left: auto; padding: 2px 7px; border-radius: 5px; font-size: .62rem; font-weight: 600; color: var(--tc, var(--accent)); background: color-mix(in srgb, var(--tc, var(--accent)) 16%, transparent); }
.ag-hora { font-size: .68rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* --- Vistas semana y lista --- */
.ag-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.ag-week-col { display: flex; flex-direction: column; gap: 5px; min-height: 190px; padding: 8px 7px; border-radius: 10px; background: var(--surface-1); border: 1px solid var(--border); cursor: pointer; }
.ag-week-col.sel { border-color: var(--accent); }
.ag-week-col:hover { border-color: var(--line-strong); }

@keyframes gridIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes railIn { from { opacity: 0; transform: translateX(14px); } }
@keyframes rowIn  { from { opacity: 0; transform: translateY(8px); } }
@keyframes growUp { from { transform: scaleY(0); } }
@keyframes growRight { from { transform: scaleX(0); } }

@media (min-width: 960px) {
  .ag-body { flex-direction: row; gap: 16px; height: calc(100dvh - 236px); min-height: 470px; }
  .ag-rail { flex: 0 0 320px; max-width: 340px; }
  .ag-grid { grid-auto-rows: minmax(0, 1fr); flex: 1; }
  .ag-chip span { font-size: .7rem; }
  .ag-daynum { font-size: .82rem; }
}
@media (max-width: 959px) { .ag-rail-body { max-height: 320px; } }
/* En pantallas chicas los chips colapsan a puntos de color */
@media (max-width: 560px) {
  .ag-grid { grid-auto-rows: 66px; gap: 4px; }
  .ag-chips { flex-direction: row; flex-wrap: wrap; gap: 3px; }
  .ag-chip { width: 7px; height: 7px; padding: 0; border-radius: 50%; background: var(--tc, var(--accent)); gap: 0; }
  .ag-chip i, .ag-chip span, .ag-more { display: none; }
}

/* Badge de ícono reutilizable (panel, insights) */
.ico-badge { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; color: var(--tc, var(--accent)); background: color-mix(in srgb, var(--tc, var(--accent)) 15%, transparent); }

/* ==========================================================================
   Gráficos (Estadísticas)
   ========================================================================== */
.chart { width: 100%; overflow: visible; }

/* Barras verticales (SVG rect con crecimiento) */
.bar-grow { transform-origin: bottom; animation: barGrow .7s cubic-bezier(.22,1,.36,1) both; }
@keyframes barGrow { from { transform: scaleY(0); } }

/* Donut / anillo */
.ring-track { stroke: var(--surface-4); }
.ring-fill { transition: stroke-dashoffset 1s cubic-bezier(.22,1,.36,1); stroke-linecap: round; }
.ring-anim { animation: ringIn 1.1s cubic-bezier(.22,1,.36,1) both; }
@keyframes ringIn { from { stroke-dashoffset: var(--circ); } }

/* Línea / área (dibujado) */
.line-path { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.2s ease forwards; }
.area-fill { opacity: 0; animation: fadeIn .8s ease .5s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadeIn { to { opacity: 1; } }
.dot-pop { animation: dotPop .3s ease both; }
@keyframes dotPop { from { transform: scale(0); } }

/* Barras horizontales (ocupación / niveles) */
.hbar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.hbar > span { display: block; height: 100%; border-radius: 999px; width: 0; animation: hbarGrow .85s cubic-bezier(.22,1,.36,1) forwards; }
@keyframes hbarGrow { to { width: var(--w); } }

.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.legend .it { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--text-muted); }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }

.kpi-big { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); }
.kpi-big .k { font-size: var(--fs-xs); color: var(--text-dim); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.kpi-big .v { font-family: var(--font-display); font-size: 2rem; font-weight: 800; margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi-big .sub { font-size: .78rem; color: var(--text-dim); margin-top: 6px; }

/* ==========================================================================
   Layout de aplicación (desktop rail)
   ========================================================================== */
.app { min-height: 100dvh; position: relative; z-index: 1; }
.content { max-width: var(--content-max); margin: 0 auto; padding: 0 0 calc(var(--nav-h) + 24px); }
.section-pad { padding: var(--sp-5); }

@media (min-width: 960px) {
  .app { display: grid; grid-template-columns: var(--rail-w) 1fr; }
  .tabbar { display: none; }
  .content { padding-bottom: var(--sp-8); }
  .rail {
    display: flex; flex-direction: column; gap: var(--sp-1);
    position: sticky; top: 0; height: 100dvh;
    padding: var(--sp-5) var(--sp-3);
    border-right: 1px solid var(--border); background: var(--surface-1);
  }
  .rail .brand { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3) var(--sp-5); }
  .rail .brand .mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; color: var(--text-on-accent); font-family: var(--font-display); font-weight: 700; font-size: 20px; }
  .rail .brand .name { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: .04em; }
  .rail a {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 11px var(--sp-3); border-radius: var(--r-md);
    color: var(--text-dim); font-weight: 600; font-size: var(--fs-sm);
  }
  .rail a .ic { width: 20px; height: 20px; }
  .rail a:hover { background: var(--surface-2); color: var(--text); }
  .rail a[aria-current="page"] { background: var(--accent-tint); color: var(--accent-soft); }
  .rail a[aria-current="page"] .ic { color: var(--accent); }
  .rail .spacer { flex: 1; }
}

/* ==========================================================================
   Beta Norte · Rediseño visual (marca, animaciones, responsive, inventario)
   ========================================================================== */

/* --- Marca: logo BN real (recoloreado) en el rail --- */
.rail .brand .mark { width: auto !important; height: auto !important; background: none !important; border: none !important; border-radius: 0 !important; display: grid; place-items: center; }
.rail .brand .name { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; font-size: 20px; text-transform: none; }

/* --- Botones (pulido) --- */
.btn { transition: background .16s var(--ease-out), border-color .16s, transform .12s var(--ease-out), box-shadow .16s, filter .16s; letter-spacing: .01em; }
.btn:not(.btn-icon):not(:disabled):hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.99); }
.btn-primary { box-shadow: 0 2px 10px rgba(217,130,43,0.22); }
.btn-primary:hover:not(:disabled) { box-shadow: var(--glow-accent); }
.btn-ok { color: #06140c; }

/* --- Títulos de sección --- */
.topbar h1 { text-transform: none; letter-spacing: -0.02em; }
.section-label { font-family: var(--font-body); font-weight: 600; font-size: .72rem; letter-spacing: .09em; }
.card-title { text-transform: none; }

/* --- Tarjetas (hover más vivo) --- */
.card { transition: border-color .15s, background .15s, transform .15s var(--ease-out), box-shadow .15s; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }

/* --- Entrada de sección --- */
.section-pad { animation: secIn .26s var(--ease-out) both; }
@keyframes secIn { from { opacity: 0; transform: translateY(8px); } }
.topbar { animation: fadeIn .2s ease both; }

/* --- Scrollbar --- */
* { scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 999px; border: 2px solid var(--bg); }
::selection { background: var(--accent-tint-2); color: var(--text); }

/* --- KPI / stat: display font para números --- */
.stat .v, .kpi-big .v { font-family: var(--font-display); font-weight: 700; letter-spacing: .01em; }

/* ==========================================================================
   Estadísticas (dashboard analítico)
   ========================================================================== */
.st-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 12px; }
.st-kpi { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); }
.st-kpi-v { font-family: var(--font-display); font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.st-delta { padding: 3px 8px; border-radius: 6px; font-size: .68rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-delta.ok  { background: var(--ok-tint); color: var(--ok-soft); }
.st-delta.bad { background: var(--danger-tint); color: var(--danger-soft); }
.st-delta.off { background: var(--surface-2); color: var(--text-faint); }

.st-2col { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 900px) {
  .st-2col { grid-template-columns: 1fr 1fr; }
  .st-2col.wide { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
}

/* Barras cobrado vs proyectado */
.st-bars { display: flex; align-items: flex-end; gap: 8px; height: 190px; }
.st-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; min-width: 0; }
.st-bar-track { position: relative; flex: 1; width: 100%; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.st-bar-fill { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 6px; background: linear-gradient(180deg, var(--acc2), var(--accent)); transform-origin: bottom; animation: growUp .3s cubic-bezier(.2,0,0,1) both; }
.st-bar-goal { position: absolute; left: 0; right: 0; height: 2px; background: var(--text-faint); }
.st-bar-val { font-size: .68rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.st-bar-lab { font-size: .62rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); }

/* Barra segmentada de cobranza */
.st-seg { display: flex; height: 12px; gap: 3px; border-radius: 6px; overflow: hidden; }
.st-seg > div { transform-origin: left; animation: growRight .3s cubic-bezier(.2,0,0,1) both; }

/* Heatmap de ocupación */
.st-heat { display: grid; gap: 5px; align-items: center; }
.st-heat-cell { display: flex; align-items: center; justify-content: center; height: 34px; border-radius: 6px; font-size: .68rem; font-variant-numeric: tabular-nums; }

/* Barras divergentes (altas / bajas) */
.st-div { display: flex; gap: 8px; height: 168px; }
.st-div-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.st-div-up { flex: 1; display: flex; align-items: flex-end; }
.st-div-up > span { width: 100%; background: var(--ok-soft); border-radius: 5px 5px 0 0; transform-origin: bottom; animation: growUp .28s cubic-bezier(.2,0,0,1) both; }
.st-div-axis { height: 1px; background: var(--border); }
.st-div-dn { flex: 1; display: flex; align-items: flex-start; }
.st-div-dn > span { width: 100%; background: var(--danger-soft); border-radius: 0 0 5px 5px; transform-origin: top; animation: growUp .28s cubic-bezier(.2,0,0,1) both; }
.st-div-col .st-bar-lab { padding-top: 6px; text-align: center; }

/* Estado vacío por bloque */
.st-empty { min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; padding: 16px; }

/* ==========================================================================
   Inventario en cuadrícula (cajones)
   ========================================================================== */
.inv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .inv-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 960px) { .inv-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; } }

/* Cajones de categoría (nivel 1 del inventario) */
.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .cat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .cat-grid { grid-template-columns: repeat(4, 1fr); } }
.cat-tile { position: relative; overflow: hidden; cursor: pointer; min-height: 124px;
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
  transition: transform .14s var(--ease-out), border-color .14s, box-shadow .14s; }
.cat-tile:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.cat-tile .ticon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-tint); color: var(--accent); }
.cat-tile .tname { font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; line-height: 1.1; }
.cat-tile .tcount { font-size: .78rem; color: var(--text-dim); margin-top: 2px; }
.cat-tile .talert { position: absolute; top: 12px; right: 12px; width: 22px; height: 22px; border-radius: 50%; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; }
.drawer {
  position: relative; overflow: hidden; cursor: pointer;
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 8px;
  transition: transform .13s var(--ease-out), border-color .13s, box-shadow .13s;
}
.drawer::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--tc, var(--accent)); }
.drawer:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.drawer.alerta { --tc: var(--danger); }
.drawer.aviso  { --tc: var(--warn); }
.drawer .qty { font-family: var(--font-display); font-size: 1.7rem; font-weight: 800; line-height: 1; }
.drawer .qty small { font-size: .8rem; color: var(--text-dim); font-weight: 600; }
.drawer .ref { font-weight: 600; font-size: .92rem; line-height: 1.2; }
.drawer .sub { font-size: .72rem; color: var(--text-dim); }
.drawer .spacer { flex: 1; }

/* --- Grillas responsivas de KPIs/stats en desktop --- */
@media (min-width: 960px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .stats-grid-4 { grid-template-columns: repeat(4, 1fr) !important; }
}

/* --- Salidas: grilla (1 col móvil, 2 en desktop) --- */
.salidas-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 900px) { .salidas-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; } }

/* Salida minimalista */
.smin { display: flex; gap: 14px; align-items: stretch; cursor: pointer; }
.sdate { flex: none; width: 58px; border-radius: var(--r-md); background: var(--surface-3); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 0; }
.sdate .d { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; line-height: 1; }
.sdate .m { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); margin-top: 3px; }
.sdate.sc { background: var(--accent-tint); border-color: transparent; }
.sdate.sc .d { color: var(--accent); }

/* Selector de material (para armar la salida) */
.pick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .pick-grid { grid-template-columns: repeat(3, 1fr); } }
.pick { display: flex; align-items: center; gap: 9px; padding: 10px 11px; border: 1px solid var(--border-strong); border-radius: 11px; cursor: pointer; background: var(--surface-1); font-size: .82rem; transition: border-color .12s, background .12s; }
.pick:hover { border-color: var(--accent); }
.pick.on { border-color: var(--accent); background: var(--accent-tint); }
.pick .chk { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong); flex: none; display: grid; place-items: center; color: var(--text-on-accent); }
.pick.on .chk { background: var(--accent); border-color: var(--accent); }

/* --- Reveal de barras/hbar al entrar --- */
.hbar > span { animation-timing-function: var(--ease-out); }

/* ==========================================================================
   Login / acceso
   ========================================================================== */
body.auth-mode .rail,
body.auth-mode .tabbar { display: none !important; }
body.auth-mode .content { grid-column: 1 / -1; margin: 0; padding: 0; }

.login-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(224,145,47,0.10), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: 28px 24px;
  display: flex; flex-direction: column; gap: 16px;
  animation: secIn .4s var(--ease-out) both;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.login-mark {
  width: 56px; height: 56px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-3); border-radius: var(--r-md);
}
.login-name { font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; color: var(--text); line-height: 1.1; }
.login-sub { font-size: .82rem; color: var(--text-dim); margin-top: 2px; }
.login-error {
  background: var(--danger-tint); border: 1px solid var(--danger);
  color: var(--danger-soft); font-size: .84rem;
  padding: 9px 12px; border-radius: var(--r-sm);
}
.login-foot { text-align: center; font-size: .76rem; color: var(--text-faint); margin-top: 2px; }

