/* PiN Admin · componentes: tarjetas blancas sobre fondo oscuro (admin v2), KPI con
   degradado gris, tablas con encabezado #707070 que en teléfono se vuelven fichas,
   estatus con los colores del catálogo, cajón/hoja inferior, paleta de comandos. */

/* ---------- Tarjeta ---------- */
.tarjeta { background: #fff; color: var(--texto); border-radius: var(--r-card); box-shadow: var(--sombra-suave); min-width: 0; }
.tarjeta-cabeza { display: flex; align-items: center; gap: .6rem; padding: .95rem 1.1rem .2rem; }
.tarjeta-cabeza h2 { font-size: .95rem; font-weight: 700; }
.tarjeta-cabeza .extra { margin-left: auto; font-size: .76rem; color: var(--texto-2); font-weight: 600; white-space: nowrap; }
.tarjeta-cuerpo { padding: .8rem 1.1rem 1.1rem; }
.tarjeta-cuerpo.sin-pad { padding: 0; }

/* ---------- Rejillas ---------- */
.rejilla { display: grid; gap: 14px; }
.rejilla-kpi { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rejilla-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.rejilla-1-1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rejilla-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rejilla-fichas { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

/* ---------- KPI (card-gradient-black del admin v2) ---------- */
.kpi {
  position: relative; overflow: hidden; display: grid; grid-template-columns: auto 1fr; grid-template-areas: "ico etq" "valor valor" "delta delta";
  gap: .1rem .65rem; align-items: center; padding: .95rem 1rem .9rem; border-radius: var(--r-card);
  background: var(--grad-kpi); color: #fff; text-decoration: none; box-shadow: 0 1px 2px rgba(0, 0, 0, .4); min-width: 0;
}
a.kpi:hover { filter: brightness(1.1); }
.kpi-icono { grid-area: ico; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--grad); }
.kpi-etq { grid-area: etq; font-size: .74rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: #e2dedb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-valor { grid-area: valor; font-size: clamp(1.3rem, 2.2vw, 1.7rem); font-weight: 800; letter-spacing: -.01em; margin-top: .5rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-delta { grid-area: delta; justify-self: start; display: inline-flex; align-items: center; gap: .25rem; font-size: .74rem; font-weight: 700; padding: .12rem .5rem; border-radius: 99px; background: rgba(255, 255, 255, .1); color: #e2dedb; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-delta.sube { color: #8ff08f; }
.kpi-delta.baja { color: #ffb4ad; }
.kpi-serie { position: absolute; right: .8rem; bottom: .9rem; width: 34%; max-width: 120px; height: 34px; opacity: .9; }

/* ---------- Estatus (colores de est.TB_Estatus) ---------- */
.chip {
  --c: var(--st-neutro);
  display: inline-flex; align-items: center; gap: .38rem; height: 24px; padding: 0 .6rem; border-radius: 6px;
  background: color-mix(in srgb, var(--c) 14%, #fff); color: color-mix(in srgb, var(--c) 62%, #000);
  font-size: .74rem; font-weight: 700; white-space: nowrap;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.chip[data-st="ok"] { --c: var(--st-ok); }
.chip[data-st="pendiente"] { --c: var(--st-pendiente); }
.chip[data-st="revision"] { --c: var(--st-revision); }
.chip[data-st="rechazo"] { --c: var(--st-rechazo); }
.chip[data-st="edicion"] { --c: var(--st-edicion); }
.chip[data-st="asignado"] { --c: var(--st-asignado); }
.chip[data-st="inconcluso"] { --c: var(--st-inconcluso); }
.chip.solo-punto { padding: 0; background: none; height: auto; }
.etiqueta { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.etiqueta::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--c, var(--st-neutro)); flex: none; }
.pildora { display: inline-flex; align-items: center; height: 22px; padding: 0 .55rem; border-radius: 99px; background: var(--gris-claro); color: var(--texto); font-size: .72rem; font-weight: 700; white-space: nowrap; }
.pildora.oscura { background: var(--carbon); color: #fff; }

/* ---------- Tabla (.tabla-admin-pin) ---------- */
.tabla-barra { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .8rem; padding: .85rem 1rem; }
.tabla-barra .buscador { flex: 1 1 240px; max-width: 360px; }
.filtros { display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.filtros button {
  flex: none; height: 32px; padding: 0 .75rem; border: 0; border-radius: 99px; background: var(--gris-claro); color: var(--texto);
  font-size: .78rem; font-weight: 650; white-space: nowrap;
}
.filtros button span { opacity: .6; margin-left: .25rem; }
.filtros button[aria-pressed="true"] { background: var(--carbon); color: #fff; }
.tabla-conteo { margin-left: auto; font-size: .78rem; color: var(--texto-2); font-weight: 600; white-space: nowrap; }
.tabla-envoltura { overflow-x: auto; }
.tabla { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .84rem; }
.tabla th {
  position: sticky; top: 0; background: var(--gris); color: #fff; text-align: left; white-space: nowrap;
  font: 600 .7rem/1 var(--fuente-2); letter-spacing: .07em; text-transform: uppercase; padding: 0;
}
.tabla th:first-child { border-top-left-radius: 12px; }
.tabla th:last-child { border-top-right-radius: 12px; }
.tabla th button, .tabla th > span { display: flex; align-items: center; gap: .3rem; width: 100%; height: 40px; padding: 0 .9rem; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; }
.tabla th.der button, .tabla th.der > span { justify-content: flex-end; }
.tabla td { padding: .62rem .9rem; border-bottom: 1px solid #efedeb; vertical-align: middle; }
.tabla tbody tr:nth-child(even) td { background: #faf9f8; }
.tabla tbody tr[data-fila] { cursor: pointer; }
.tabla tbody tr[data-fila]:hover td { background: #fdf0f3; }
.tabla td.der { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabla .principal b { display: block; font-weight: 700; }
.tabla .principal small { display: block; font-size: .74rem; color: var(--texto-2); margin-top: 1px; }
.tabla .acciones-fila { width: 1%; white-space: nowrap; text-align: right; }
.paginador { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .55rem 1rem; font-size: .78rem; color: var(--texto-2); font-weight: 600; border-top: 1px solid var(--linea); }
.paginador div { display: flex; gap: .2rem; }
.vacio { padding: 2.4rem 1rem; text-align: center; color: var(--texto-2); }
.barra { --w: 0%; height: 7px; border-radius: 99px; background: var(--gris-claro); overflow: hidden; min-width: 70px; }
.barra > i { display: block; width: var(--w); height: 100%; border-radius: inherit; background: var(--grad); }
.barra.ok > i { background: var(--st-ok); }
.barra.aviso > i { background: var(--st-revision); }
.barra.malo > i { background: var(--st-rechazo); }
.con-barra { display: flex; align-items: center; gap: .5rem; }
.con-barra small { min-width: 34px; text-align: right; color: var(--texto-2); font-weight: 700; }

/* ---------- Cajón de detalle / hoja inferior ---------- */
.cajon-velo { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .55); animation: aparece .15s ease; }
.cajon {
  position: fixed; z-index: 91; top: 0; right: 0; bottom: 0; width: min(500px, 100vw); display: flex; flex-direction: column;
  background: #fff; color: var(--texto); box-shadow: -16px 0 40px rgba(0, 0, 0, .4); animation: entra-der .2s ease;
}
.cajon-cabeza { display: flex; align-items: flex-start; gap: .8rem; padding: 1.1rem 1.1rem 1rem 1.3rem; background: var(--grad-kpi); color: #fff; }
.cajon-cabeza small { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; opacity: .8; font-weight: 700; }
.cajon-cabeza h2 { font-size: 1.15rem; font-weight: 800; margin-top: .2rem; }
.cajon-cabeza .chip { margin-top: .5rem; }
.cajon-cabeza .btn-icono { margin-left: auto; color: #fff; }
.cajon-cabeza .btn-icono:hover { background: rgba(255, 255, 255, .15); }
.cajon-cuerpo { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #c9c4c1 transparent; padding: 1.1rem 1.3rem 1.4rem; display: grid; gap: 1.1rem; align-content: start; }
.cajon-cuerpo h3 { font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--texto-2); font-weight: 750; }
.cajon-pie { display: flex; gap: .5rem; justify-content: flex-end; padding: .8rem 1.1rem calc(.8rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--linea); background: #fff; }
.datos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; margin: 0; }
.datos div { min-width: 0; }
.datos dt { font: 700 .72rem var(--fuente-2); color: var(--texto-2); text-transform: uppercase; letter-spacing: .05em; }
.datos dd { margin: .2rem 0 0; font-weight: 600; overflow-wrap: anywhere; }
.formulario { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.formulario .ancho { grid-column: 1 / -1; }
.nota { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .85rem; border-radius: 10px; background: #f4f2f1; color: var(--texto-2); font-size: .8rem; }
.nota .ico { color: var(--st-pendiente); margin-top: 1px; }
.nota.aviso { background: #fff6e6; }
.nota.aviso .ico { color: #c97c00; }

/* ---------- Paleta de comandos (Ctrl/⌘ K) ---------- */
.paleta-velo { position: fixed; inset: 0; z-index: 95; background: rgba(0, 0, 0, .55); }
.paleta {
  position: fixed; z-index: 96; top: 10vh; left: 50%; transform: translateX(-50%); width: min(620px, calc(100vw - 20px));
  background: #fff; color: var(--texto); border-radius: 16px; box-shadow: var(--sombra); overflow: hidden;
}
.paleta-buscar { display: flex; align-items: center; gap: .6rem; padding: .9rem 1rem; border-bottom: 1px solid var(--linea); color: var(--texto-2); }
.paleta-buscar input { flex: 1; border: 0; outline: 0; font-size: 1rem; color: var(--texto); background: none; min-width: 0; }
.paleta-lista { list-style: none; margin: 0; padding: .4rem; max-height: min(420px, 60vh); overflow-y: auto; }
.paleta-grupo { padding: .6rem .7rem .25rem; font: 700 .68rem var(--fuente-2); letter-spacing: .1em; text-transform: uppercase; color: var(--texto-2); }
.paleta-op { display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: 10px; cursor: pointer; font-weight: 600; }
.paleta-op small { margin-left: auto; color: var(--texto-2); font-weight: 600; font-size: .74rem; }
.paleta-op[aria-selected="true"] { background: #fdf0f3; color: var(--magenta); }
.paleta-pie { display: flex; gap: 1rem; padding: .55rem 1rem; border-top: 1px solid var(--linea); font-size: .72rem; color: var(--texto-2); }
.paleta-pie kbd { background: var(--gris-claro); color: var(--texto); }

/* ---------- Avisos (toasts) ---------- */
#avisos { position: fixed; z-index: 99; right: 16px; bottom: 16px; display: grid; gap: .5rem; width: min(360px, calc(100vw - 24px)); }
.toast { display: flex; gap: .65rem; align-items: flex-start; padding: .75rem .9rem; border-radius: 12px; background: var(--carbon); color: #fff; box-shadow: var(--sombra); border-left: 4px solid var(--rojo); font-size: .84rem; animation: entra-abajo .2s ease; }
.toast b { display: block; }
.toast span { color: #d9d4d1; }

/* ---------- Listas del panel ---------- */
.lista { list-style: none; margin: 0; padding: 0; }
.pendiente a { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.1rem; text-decoration: none; border-top: 1px solid #f0eeec; }
.pendiente:first-child a { border-top: 0; }
.pendiente a:hover { background: #fbf7f8; }
.pendiente .ico-caja { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #fff2dc; color: #b86e00; flex: none; }
.pendiente.malo .ico-caja { background: #ffe3e3; color: #d10000; }
.pendiente .texto { flex: 1; font-weight: 600; font-size: .86rem; }
.pendiente .valor { font-weight: 800; font-size: .95rem; }
.actividad li { display: grid; grid-template-columns: 46px 1fr; gap: .6rem; padding: .55rem 1.1rem; font-size: .84rem; }
.actividad time { color: var(--texto-2); font-weight: 700; font-size: .76rem; padding-top: 1px; }
.actividad b { font-weight: 700; }
.actividad .donde { color: var(--magenta); font-weight: 700; }

/* ---------- Gráficas SVG ---------- */
.grafica { width: 100%; height: auto; overflow: visible; }
.grafica text { font-family: var(--fuente); }
.leyenda { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .76rem; color: var(--texto-2); font-weight: 600; }
.leyenda span { display: inline-flex; align-items: center; gap: .35rem; }
.leyenda i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.dona-envoltura { display: grid; grid-template-columns: minmax(0, 150px) 1fr; gap: 1rem; align-items: center; }
.dona-envoltura .leyenda { display: grid; gap: .5rem; }
.dona-envoltura .leyenda b { margin-left: auto; color: var(--texto); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; }
.columna { scroll-snap-align: start; background: rgba(255, 255, 255, .06); border-radius: var(--r-card); padding: .7rem; display: grid; gap: .6rem; align-content: start; }
.columna > header { display: flex; align-items: baseline; gap: .5rem; padding: .1rem .3rem; }
.columna h3 { font-size: .8rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.columna > header span { margin-left: auto; font-size: .74rem; color: var(--texto-inv-2); font-weight: 700; }
.ficha { background: #fff; color: var(--texto); border-radius: 12px; padding: .75rem .8rem; display: grid; gap: .55rem; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); cursor: pointer; }
.ficha:hover { box-shadow: 0 0 0 2px var(--rojo); }
.ficha b { font-size: .88rem; line-height: 1.25; }
.ficha-pie { display: flex; align-items: center; gap: .5rem; font-size: .76rem; color: var(--texto-2); font-weight: 600; }
.ficha-pie .avatar { margin-left: auto; }

/* ---------- Fichas de clientes, personas y plásticos ---------- */
.ficha-cliente { display: grid; gap: .8rem; padding: 1rem 1.1rem; cursor: pointer; }
.ficha-cliente:hover { box-shadow: 0 0 0 2px var(--rojo); }
.ficha-cliente header { display: flex; align-items: center; gap: .7rem; }
.ficha-cliente h3 { font-size: .95rem; font-weight: 750; }
.ficha-cliente header .chip { margin-left: auto; }
.logo-cliente { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .8rem; background: linear-gradient(135deg, var(--g1), var(--g2)); flex: none; }
.cifras { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.cifras b { display: block; font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cifras span { font-size: .7rem; color: var(--texto-2); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.chips-linea { display: flex; flex-wrap: wrap; gap: .3rem; }
.ficha-persona { display: grid; justify-items: center; text-align: center; gap: .35rem; padding: 1.1rem .9rem 1rem; cursor: pointer; }
.ficha-persona .avatar { width: 56px; height: 56px; font-size: 1rem; box-shadow: none; margin-bottom: .3rem; }
.ficha-persona b { font-size: .92rem; }
.ficha-persona small { color: var(--texto-2); font-size: .78rem; }
.plastico {
  position: relative; aspect-ratio: 1.586; border-radius: 14px; padding: .9rem 1rem; color: #fff; overflow: hidden;
  background: linear-gradient(135deg, var(--g1), var(--g2)); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); display: flex; flex-direction: column; cursor: pointer;
}
.plastico::after { content: ""; position: absolute; right: -30%; top: -40%; width: 80%; height: 120%; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.plastico .chip-oro { width: 36px; height: 27px; border-radius: 6px; background: linear-gradient(135deg, #f1d58a, #b8902f); margin-top: .5rem; }
.plastico b { margin-top: auto; font-size: .95rem; letter-spacing: .02em; }
.plastico small { opacity: .85; font-size: .72rem; letter-spacing: .12em; }
.plastico .placa-logo { position: absolute; right: .9rem; top: .8rem; width: 28px; height: 28px; border-radius: 8px; }
.plastico .placa-logo img { width: 14px; height: 19px; }

.tema-pin { --g1: #ee2737; --g2: #890c59; }
.tema-rojo { --g1: #db0011; --g2: #7d0010; }
.tema-carbon { --g1: #72706e; --g2: #2d2926; }
.tema-naranja { --g1: #ff8000; --g2: #c43b00; }
.tema-turquesa { --g1: #26ddd1; --g2: #0b7f87; }
.tema-violeta { --g1: #a048f8; --g2: #4a1a8c; }
.tema-azul { --g1: #2664dd; --g2: #142e6e; }

/* ---------- Vista previa de webview / navegador ---------- */
.vista-previa { display: grid; justify-items: center; gap: .8rem; }
.telefono { width: 264px; padding: 10px; border-radius: 40px; background: #0d0d0d; box-shadow: 0 18px 40px rgba(0, 0, 0, .55), inset 0 0 0 2px #2a2a2a; }
.telefono-pantalla { height: 520px; border-radius: 31px; overflow: hidden; background: #f0eeee; color: var(--texto); display: flex; flex-direction: column; }
.tel-cabeza { padding: 1.4rem 1rem .9rem; color: #fff; background: linear-gradient(180deg, var(--g1), var(--g2)); }
.tel-cabeza small { display: block; opacity: .85; font-size: .7rem; font-weight: 600; }
.tel-cabeza b { font-size: 1.05rem; }
.tel-ahorro { margin-top: .7rem; padding: .55rem .7rem; border-radius: 12px; background: rgba(0, 0, 0, .22); font-size: .76rem; }
.tel-ahorro b { font-size: 1rem; display: block; }
.tel-cuerpo { flex: 1; overflow: hidden; padding: .7rem; display: grid; gap: .5rem; align-content: start; grid-template-columns: 1fr 1fr; }
.tel-promo { background: #fff; border-radius: 12px; padding: .6rem; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); display: grid; gap: .2rem; font-size: .72rem; }
.tel-promo i { height: 46px; border-radius: 8px; background: color-mix(in srgb, var(--c) 22%, #fff); display: block; margin-bottom: .2rem; }
.tel-promo b { font-size: .76rem; line-height: 1.2; }
.tel-promo span { color: var(--texto-2); }
.tel-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #fff; border-top: 1px solid #e3e0de; }
.tel-tab { display: grid; justify-items: center; gap: 2px; min-width: 0; padding: .45rem .1rem .55rem; font-size: .56rem; font-weight: 700; color: var(--texto-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tel-tab.activa { color: #fff; background: linear-gradient(180deg, var(--g1), var(--g2)); }
.navegador { width: 100%; max-width: 560px; border-radius: 12px; background: #fff; color: var(--texto); overflow: hidden; box-shadow: 0 14px 34px rgba(0, 0, 0, .45); }
.nav-barra { display: flex; align-items: center; gap: .35rem; padding: .55rem .7rem; background: #ebe8e6; }
.nav-barra i { width: 10px; height: 10px; border-radius: 50%; background: #c9c4c1; }
.nav-barra span { margin-left: .6rem; flex: 1; background: #fff; border-radius: 99px; padding: .2rem .7rem; font-size: .72rem; color: var(--texto-2); }
.nav-menu { display: flex; gap: .3rem; flex-wrap: wrap; padding: .7rem .9rem; color: #fff; background: var(--carbon); font-size: .74rem; font-weight: 700; }
.nav-menu span { padding: .25rem .6rem; border-radius: 99px; }
.nav-menu span:first-child { background: linear-gradient(90deg, var(--g1), var(--g2)); }
.nav-cuerpo { padding: .9rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; background: #f0f0f0; }
.nav-cuerpo .tel-promo { font-size: .7rem; }
.secciones li { display: flex; align-items: center; gap: .7rem; padding: .7rem 1.1rem; border-top: 1px solid #f0eeec; font-weight: 600; }
.secciones li:first-child { border-top: 0; }
.secciones .orden { width: 22px; color: var(--texto-2); font-size: .76rem; font-weight: 800; }
.secciones .agarre { color: #b5afab; cursor: grab; }
.secciones .nombre { flex: 1; display: flex; align-items: center; gap: .55rem; }

/* ---------- Revisión por secciones ---------- */
.revision li { display: flex; align-items: center; gap: .7rem; padding: .6rem 0; border-top: 1px solid #f0eeec; }
.revision li:first-child { border-top: 0; }
.revision .que { flex: 1; min-width: 0; }
.revision .que b { display: block; font-size: .86rem; }
.revision .que small { color: #c00; font-weight: 600; }
.revision .botones { display: flex; gap: .3rem; }
.revision .botones button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--linea); background: #fff; display: grid; place-items: center; color: var(--texto-2); }
.revision .botones button[aria-pressed="true"].si { border-color: #53cf05; background: #53cf05; color: #fff; }
.revision .botones button[aria-pressed="true"].no { border-color: #ff0000; background: #ff0000; color: #fff; }

/* ---------- Conversación de ticket ---------- */
.hilo { display: grid; gap: .7rem; }
.mensaje { display: grid; grid-template-columns: auto 1fr; gap: .6rem; }
.mensaje .burbuja { background: #f4f2f1; border-radius: 4px 12px 12px 12px; padding: .55rem .75rem; font-size: .84rem; }
.mensaje .burbuja b { font-size: .78rem; }
.mensaje .burbuja time { font-size: .72rem; color: var(--texto-2); margin-left: .4rem; }

/* ---------- Matriz de permisos ---------- */
.matriz th:first-child, .matriz td:first-child { position: sticky; left: 0; z-index: 1; }
.matriz td:first-child { background: #fff; font-weight: 700; text-align: left; white-space: nowrap; }
.matriz tbody tr:nth-child(even) td:first-child { background: #faf9f8; }
.matriz td { text-align: center; }
.nivel { display: inline-grid; place-items: center; min-width: 30px; height: 26px; padding: 0 .4rem; border-radius: 7px; font-size: .72rem; font-weight: 800; }
.nivel-T { background: var(--grad); color: #fff; }
.nivel-A { background: #ffe9c7; color: #8a5200; }
.nivel-G { background: #dcebff; color: #0050a8; }
.nivel-C { background: var(--gris-claro); color: var(--texto); }
.nivel-P, .nivel-L { background: #e8f7e5; color: #1d6b14; }
.nivel-x { color: #c9c4c1; }

/* ---------- Bóveda ---------- */
.boveda-cerrada { max-width: 440px; margin: 6vh auto 0; text-align: center; display: grid; gap: 1rem; padding: 2rem 1.6rem 1.6rem; }
.candado-grande { width: 76px; height: 76px; margin: 0 auto; border-radius: 22px; display: grid; place-items: center; color: #fff; background: var(--grad); box-shadow: 0 10px 26px rgba(238, 39, 55, .35); }
.boveda-cerrada h2 { font-size: 1.2rem; font-weight: 800; }
.boveda-cerrada .sellos { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; }
.boveda { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 14px; align-items: start; }
.colecciones { display: grid; gap: 2px; padding: .5rem; }
.colecciones button { display: flex; align-items: center; gap: .65rem; height: 40px; padding: 0 .7rem; border: 0; border-radius: 9px; background: none; color: var(--texto); font-weight: 600; text-align: left; }
.colecciones button span { flex: 1; }
.colecciones button small { color: var(--texto-2); font-weight: 700; }
.colecciones button[aria-pressed="true"] { background: #fdf0f3; color: var(--magenta); }
.secreto { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .3rem .8rem; align-items: center; padding: .8rem 1.1rem; border-top: 1px solid #f0eeec; }
.secreto:first-child { border-top: 0; }
.secreto .ico-caja { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--gris-claro); color: var(--texto); grid-row: span 2; }
.secreto b { font-size: .9rem; }
.secreto .meta { grid-column: 2; display: flex; flex-wrap: wrap; gap: .3rem .8rem; font-size: .76rem; color: var(--texto-2); font-weight: 600; }
.secreto .valor-oculto { font-family: var(--mono); letter-spacing: .12em; color: var(--texto); }
.secreto .acciones { grid-row: 1 / span 2; grid-column: 3; display: flex; gap: .15rem; }
.medidor { --w: 0%; display: inline-block; width: 54px; height: 6px; border-radius: 9px; background: var(--gris-claro); overflow: hidden; vertical-align: middle; }
.medidor > i { display: block; height: 100%; width: var(--w); background: var(--st-ok); }
.medidor.medio > i { background: var(--st-revision); }
.cuenta-atras { display: inline-flex; align-items: center; gap: .35rem; }

/* ---------- Parámetros ---------- */
.param { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto; gap: .4rem 1rem; align-items: center; padding: .75rem 1.1rem; border-top: 1px solid #f0eeec; }
.param:first-child { border-top: 0; }
.param code { font-family: var(--mono); font-size: .8rem; font-weight: 700; color: var(--magenta); }
.param small { display: block; color: var(--texto-2); font-size: .76rem; margin-top: 2px; }
.param .control { height: 36px; }
.param .lado { display: flex; align-items: center; gap: .4rem; justify-content: flex-end; }
.param .bloqueado { display: flex; align-items: center; gap: .4rem; font-family: var(--mono); font-size: .78rem; color: var(--texto-2); }
.muestra-color { width: 22px; height: 22px; border-radius: 6px; background: var(--c); flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.barra-guardar { position: sticky; bottom: 12px; z-index: 20; display: flex; align-items: center; gap: .8rem; padding: .6rem .7rem .6rem 1rem; border-radius: 99px; background: var(--carbon); color: #fff; box-shadow: var(--sombra); width: max-content; max-width: 100%; margin-inline: auto; }

/* ---------- Inventario ---------- */
.servidor { padding: 1rem 1.1rem; display: grid; gap: .7rem; }
.servidor header { display: flex; align-items: center; gap: .6rem; }
.servidor header b { font-size: .95rem; }
.servidor header small { display: block; color: var(--texto-2); font-size: .76rem; }
.servidor header .chip { margin-left: auto; }
.uso { display: grid; grid-template-columns: 38px 1fr 40px; gap: .5rem; align-items: center; font-size: .74rem; font-weight: 700; color: var(--texto-2); }
.sitio { display: flex; align-items: center; gap: .7rem; padding: .7rem 1.1rem; border-top: 1px solid #f0eeec; }
.sitio:first-child { border-top: 0; }
.sitio .punto { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 20%, transparent); flex: none; }
.sitio .nombre { flex: 1; min-width: 0; }
.sitio .nombre b { display: block; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sitio .nombre small { color: var(--texto-2); font-size: .74rem; }
.sitio .metrica { text-align: right; font-size: .76rem; color: var(--texto-2); font-weight: 600; }
.sitio .metrica b { display: block; color: var(--texto); font-size: .84rem; }

/* ---------- Cargas masivas ---------- */
.plantilla { display: flex; align-items: center; gap: .7rem; padding: .8rem .9rem; border: 1px solid var(--linea); border-radius: 12px; background: #fff; color: var(--texto); text-align: left; font-weight: 650; }
.plantilla small { display: block; color: var(--texto-2); font-weight: 600; font-size: .74rem; }
.plantilla[aria-pressed="true"] { border-color: var(--rojo); box-shadow: 0 0 0 2px rgba(238, 39, 55, .2); }
.plantilla .ico-caja { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: #fdf0f3; color: var(--rojo); flex: none; }
.zona-carga { display: grid; justify-items: center; gap: .5rem; text-align: center; padding: 1.6rem 1rem; border: 2px dashed #cfcac7; border-radius: 14px; color: var(--texto-2); font-weight: 600; }
.zona-carga .ico-caja { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--grad); color: #fff; }

/* ---------- Mi cuenta ---------- */
.fuerza { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.fuerza i { height: 6px; border-radius: 9px; background: var(--gris-claro); }
.fuerza[data-nivel="1"] i:nth-child(-n+1) { background: var(--st-rechazo); }
.fuerza[data-nivel="2"] i:nth-child(-n+2) { background: var(--st-revision); }
.fuerza[data-nivel="3"] i:nth-child(-n+3) { background: #8bc34a; }
.fuerza[data-nivel="4"] i { background: var(--st-ok); }
.sesion { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.1rem; border-top: 1px solid #f0eeec; }
.sesion:first-child { border-top: 0; }
.sesion .que { flex: 1; min-width: 0; }
.sesion .que b { display: block; font-size: .86rem; }
.sesion .que small { color: var(--texto-2); font-size: .76rem; }

/* ---------- Animaciones ---------- */
@keyframes aparece { from { opacity: 0; } }
@keyframes entra-der { from { transform: translateX(30px); opacity: 0; } }
@keyframes entra-abajo { from { transform: translateY(16px); opacity: 0; } }

/* ---------- Responsivo ---------- */
@media (max-width: 1180px) {
  .rejilla-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rejilla-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabla .prio-3 { display: none; }
}
@media (max-width: 980px) {
  .rejilla-2-1, .rejilla-1-1 { grid-template-columns: minmax(0, 1fr); }
  .boveda { grid-template-columns: minmax(0, 1fr); }
  .colecciones { display: flex; overflow-x: auto; scrollbar-width: none; }
  .colecciones button { flex: none; }
}
@media (max-width: 760px) {
  .rejilla, .rejilla-kpi { gap: 10px; }
  .rejilla-3 { grid-template-columns: minmax(0, 1fr); }
  .kpi { padding: .8rem .8rem .75rem; grid-template-areas: "ico ico" "etq etq" "valor valor" "delta delta"; }
  .kpi-etq { font-size: .68rem; margin-top: .45rem; }
  .kpi-valor { font-size: 1.28rem; margin-top: .15rem; }
  .kpi-serie { display: none; }
  .tarjeta-cabeza { padding: .85rem .9rem .1rem; }
  .tarjeta-cuerpo { padding: .7rem .9rem .9rem; }
  .tabla-barra { padding: .75rem .8rem; }
  .tabla-barra .buscador { max-width: none; flex-basis: 100%; }
  .tabla-conteo { display: none; }

  /* Tabla → fichas: principal arriba, estatus a la derecha, resto como pares etiqueta/valor */
  .tabla thead { display: none; }
  .tabla, .tabla tbody { display: block; }
  .tabla tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3rem .8rem; padding: .8rem .9rem; border-top: 1px solid #efedeb; }
  .tabla tbody tr:nth-child(even) td, .tabla tbody tr[data-fila]:hover td { background: none; }
  .tabla tbody tr[data-fila]:active { background: #fdf0f3; }
  .tabla td { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: 0; border: 0; grid-column: 1 / -1; font-size: .8rem; }
  .tabla td::before { content: attr(data-etq); color: var(--texto-2); font-size: .72rem; font-weight: 700; }
  .tabla td.principal, .tabla td.estatus { grid-column: auto; }
  .tabla td.principal { grid-row: 1; display: block; font-size: .86rem; padding-bottom: .15rem; }
  .tabla td.estatus { grid-row: 1; align-self: start; }
  .tabla td.principal::before, .tabla td.estatus::before, .tabla td.acciones-fila::before { content: none; }
  .tabla td.der { text-align: right; }
  .tabla .prio-2, .tabla .prio-3 { display: none; }
  .matriz thead { display: table-header-group; }
  .matriz, .matriz tbody { display: table; }
  .matriz tbody { display: table-row-group; }
  .matriz tbody tr { display: table-row; padding: 0; }
  .matriz td { display: table-cell; padding: .5rem .55rem; font-size: .78rem; }
  .matriz td::before { content: none; }

  .datos, .formulario { grid-template-columns: minmax(0, 1fr); }
  .cajon { top: auto; left: 0; width: 100%; max-height: 90dvh; border-radius: 18px 18px 0 0; animation-name: entra-abajo; }
  .cajon-cabeza { border-radius: 18px 18px 0 0; }
  .cajon-cabeza::before { content: ""; position: absolute; left: 50%; top: 6px; width: 40px; height: 4px; margin-left: -20px; border-radius: 9px; background: rgba(255, 255, 255, .45); }
  #avisos { left: 12px; right: 12px; width: auto; bottom: calc(var(--alto-tabbar) + 12px + env(safe-area-inset-bottom)); }
  .kanban { grid-auto-columns: 84%; }
  .param { grid-template-columns: minmax(0, 1fr); }
  .param .lado { justify-content: flex-start; }
  .dona-envoltura { grid-template-columns: 120px 1fr; }
  .nav-cuerpo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .secreto { grid-template-columns: auto minmax(0, 1fr); }
  .secreto .acciones { grid-column: 1 / -1; grid-row: auto; justify-content: flex-end; }
  .telefono { width: 244px; }
  .telefono-pantalla { height: 470px; }
}

/* ---------- Gráficas HTML/SVG (etiquetas en HTML: legibles a cualquier ancho) ---------- */
.area { margin: 0; display: grid; gap: .45rem; }
.area-lienzo { position: relative; height: 190px; }
.area-svg { width: 100%; height: 100%; display: block; }
.area-marca { --h: 0%; position: absolute; right: 0; bottom: var(--h); transform: translate(6px, 50%); }
.area-marca b { display: block; background: var(--carbon); color: #fff; font-size: .72rem; padding: .15rem .45rem; border-radius: 6px; box-shadow: 0 0 0 3px #fff; transform: translateX(-100%); }
.area-ejes { display: flex; justify-content: space-between; font-size: .7rem; font-weight: 700; color: var(--texto-2); }
.barras-h { list-style: none; margin: 0; padding: 0; display: grid; gap: .65rem; }
.barras-h li { display: grid; grid-template-columns: minmax(84px, 30%) 1fr auto; gap: .7rem; align-items: center; font-size: .8rem; }
.bh-etq { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bh-pista { height: 12px; border-radius: 99px; background: #f1efee; overflow: hidden; }
.bh-pista i { --w: 0%; display: block; width: var(--w); height: 100%; border-radius: inherit; background: var(--c, var(--rojo)); }
.bh-valor { font-variant-numeric: tabular-nums; font-size: .8rem; min-width: 52px; text-align: right; }
.columnas { margin: 0; display: grid; gap: .45rem; }
.col-lienzo { height: 190px; display: flex; align-items: flex-end; gap: 4%; padding: 0 1%; border-bottom: 1px solid #ebe8e6; background: repeating-linear-gradient(to top, transparent 0 47px, #f3f1f0 47px 48px); }
.col-grupo { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.col-grupo i { --h: 0%; width: min(18px, 40%); height: var(--h); border-radius: 5px 5px 0 0; background: var(--c); }
.leyenda i { background: var(--c, var(--st-neutro)); }
