:root {
  --teal: #00A790;
  --azul: #008DD0;
  --grad: linear-gradient(180deg, var(--teal), var(--azul));
  --grad-h: linear-gradient(90deg, var(--teal), var(--azul));
  --oscuro: #1D1D1E;
  --oscuro-2: #2A2A2C;
  --carbon: #3A3A3C;
  --gris: #6B7780;
  --gris-claro: #A9B6BE;
  --linea: #E3E9ED;
  --fondo: #F4F7F8;
  --blanco: #FFFFFF;
  --verde-suave: #F2FAF8;
  --rojo: #C8453E;
  --radio: 14px;
  --sombra: 0 2px 10px rgba(30, 50, 70, .07);
  --titulos: "Montserrat", "Segoe UI", system-ui, sans-serif;
  --texto: "Inter", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--fondo); color: var(--carbon); font: 14px/1.45 var(--texto); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }

/* ---------- Acceso ---------- */
.acceso { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.acceso-marca { background: var(--oscuro); color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(24px, 6vw, 80px); position: relative; overflow: hidden; }
.acceso-logo { width: min(420px, 80%); height: auto; }
.acceso-lema { font-family: var(--titulos); font-weight: 500; font-size: clamp(16px, 2vw, 20px); color: var(--gris-claro); margin: 28px 0 0; max-width: 26ch; }
.barras { position: absolute; right: -40px; bottom: 48px; display: grid; gap: 14px; justify-items: end; opacity: .9; }
.barras span { display: block; height: 22px; border-radius: 11px; background: var(--grad-h); }
.barras span:nth-child(1) { width: 140px; opacity: .35; }
.barras span:nth-child(2) { width: 190px; opacity: .55; }
.barras span:nth-child(3) { width: 240px; opacity: .8; }
.acceso-panel { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 32px 20px; gap: 18px; }
.tarjeta-form { width: 100%; max-width: 380px; background: var(--blanco); border-radius: 18px; padding: 32px 28px; box-shadow: 0 8px 30px rgba(30, 50, 70, .10); display: grid; gap: 14px; position: relative; }
.tarjeta-form::before { content: ""; position: absolute; left: 0; top: 24px; bottom: 24px; width: 5px; border-radius: 0 4px 4px 0; background: var(--grad); }
.tarjeta-form h1 { font: 700 22px/1.2 var(--titulos); margin: 0; color: var(--oscuro); }
.tarjeta-form .sub { margin: -6px 0 4px; color: var(--gris); }
.tarjeta-form label { display: grid; gap: 6px; font-weight: 500; font-size: 13px; color: var(--carbon); }
.tarjeta-form input { border: 1px solid var(--linea); border-radius: 10px; padding: 11px 12px; background: #FBFCFD; transition: border-color .15s, box-shadow .15s; }
.tarjeta-form input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 167, 144, .15); }
.btn-primario { background: var(--grad-h); color: #fff; border: 0; border-radius: 10px; padding: 12px 16px; font-weight: 600; cursor: pointer; transition: filter .15s, transform .05s; }
.btn-primario:hover { filter: brightness(1.06); }
.btn-primario:active { transform: translateY(1px); }
.btn-primario:disabled { opacity: .6; cursor: wait; }
.btn-primario.chico { padding: 9px 14px; white-space: nowrap; }
.btn-enlace { background: none; border: 0; color: var(--azul); cursor: pointer; padding: 0; justify-self: start; }
.btn-sec { background: var(--blanco); border: 1px solid var(--linea); color: var(--carbon); border-radius: 9px; padding: 7px 12px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn-sec:hover { border-color: var(--teal); color: var(--teal); }
.mensaje { margin: 0; min-height: 1.2em; font-size: 13px; color: var(--gris); }
.mensaje.error { color: var(--rojo); }
.mensaje.ok { color: var(--teal); }
.pie-acceso { color: var(--gris); font-size: 12px; margin: 0; }

/* ---------- Banda superior ---------- */
.banda { background: var(--oscuro); color: #fff; position: sticky; top: 0; z-index: 10; }
.banda::after { content: ""; display: block; height: 4px; background: var(--grad-h); }
.banda-in { max-width: 1320px; margin: 0 auto; padding: 14px 20px 10px; display: flex; align-items: center; gap: 20px; }
.banda-logo { height: 38px; width: auto; flex: none; }
.banda-titulo { flex: 1; min-width: 0; border-left: 1px solid rgba(255, 255, 255, .22); padding-left: 20px; }
.cliente-nombre { font: 700 20px/1.2 var(--titulos); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cliente-sub { color: var(--gris-claro); font-size: 11.5px; letter-spacing: .02em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banda-filtros { display: flex; gap: 10px; align-items: flex-end; }
.filtro { display: grid; gap: 4px; font: 600 10px/1 var(--titulos); letter-spacing: .08em; text-transform: uppercase; color: var(--teal); }
.filtro select { background: var(--oscuro-2); color: #fff; border: 1px solid rgba(0, 167, 144, .7); border-radius: 9px; padding: 8px 30px 8px 10px; min-width: 96px; max-width: 240px; font: 500 13px var(--texto); letter-spacing: 0; text-transform: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2300A790' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.btn-salir { background: transparent; border: 1px solid rgba(255, 255, 255, .25); color: #fff; border-radius: 9px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; }
.btn-salir:hover { border-color: var(--teal); color: var(--teal); }
.pestanas { max-width: 1320px; margin: 0 auto; padding: 0 14px; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.pestanas::-webkit-scrollbar { display: none; }
.pestanas button { background: none; border: 0; color: var(--gris-claro); padding: 10px 14px 12px; font: 600 13px var(--titulos); cursor: pointer; position: relative; white-space: nowrap; }
.pestanas button:hover { color: #fff; }
.pestanas button.activa { color: #fff; }
.pestanas button.activa::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--grad-h); }

/* ---------- Contenido ---------- */
.contenido { max-width: 1320px; margin: 0 auto; padding: 20px; display: grid; gap: 16px; }
.tab { display: grid; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px 16px 14px 26px; position: relative; min-height: 96px; display: flex; flex-direction: column; justify-content: center; }
.kpi::before { content: ""; position: absolute; left: 11px; top: 16px; bottom: 16px; width: 5px; border-radius: 4px; background: var(--grad); }
.kpi .valor { font: 700 23px/1.15 var(--titulos); color: var(--oscuro); letter-spacing: -.01em; }
.kpi .etiqueta { color: var(--gris); font-size: 12px; margin-top: 4px; }
.kpi .var { display: inline-block; font-size: 11.5px; font-weight: 600; margin-top: 6px; padding: 2px 7px; border-radius: 20px; background: var(--verde-suave); color: var(--teal); width: fit-content; }
.kpi .var.neg { background: #FCEDEC; color: var(--rojo); }
.kpi .var.neutro { background: #EEF2F4; color: var(--gris); }
.fila { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.fila:has(.ancho-2) { grid-template-columns: 2fr 1fr; }
.card { background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra); padding: 18px 18px 16px; min-width: 0; }
.card h2 { font: 600 14px/1.3 var(--titulos); margin: 0 0 12px; color: var(--oscuro); }
.card h2 .nota { font: 400 12px var(--texto); color: var(--gris); }
.card-cab { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-cab h2 { margin: 0; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.acciones input { border: 1px solid var(--linea); border-radius: 9px; padding: 7px 10px; min-width: 220px; }
.acciones input:focus { outline: none; border-color: var(--teal); }
.grafico { position: relative; height: 270px; }
.ayuda { color: var(--gris); font-size: 12.5px; margin: 0 0 12px; }
code { background: var(--fondo); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

/* Filtros activos */
.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra); padding: 10px 14px; }
.chips-tit { font: 600 12px var(--titulos); color: var(--gris); }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer; border-radius: 20px; padding: 6px 10px 6px 12px; font: 600 12.5px var(--texto); color: #fff; background: var(--grad-h); }
.chip span { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(255, 255, 255, .25); font-size: 10px; }
.chip:hover span { background: rgba(255, 255, 255, .45); }

/* Ranking */
.ranking { display: grid; gap: 9px; }
.rank { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; width: calc(100% + 12px); background: none; border: 0; padding: 5px 6px; margin: 0 -6px; border-radius: 9px; text-align: left; font: inherit; color: inherit; cursor: pointer; transition: background .15s, opacity .15s; }
.rank:hover { background: var(--fondo); }
.rank.sel { background: var(--verde-suave); box-shadow: inset 3px 0 0 var(--teal); }
.rank.compra.sel { background: #EAF5FC; box-shadow: inset 3px 0 0 var(--azul); }
.rank.atenuada { opacity: .45; }
.rank.atenuada:hover { opacity: .8; }
.rank .n { font: 700 12px var(--titulos); color: var(--gris-claro); }
.rank .nom { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.rank .monto { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--oscuro); }
.rank .barra { grid-column: 2 / 4; height: 6px; background: #EEF2F4; border-radius: 4px; overflow: hidden; }
.rank .barra i { display: block; height: 100%; border-radius: 4px; background: var(--grad-h); }
.rank.compra .barra i { background: linear-gradient(90deg, var(--azul), #5FB4E3); }

/* Tablas */
.tabla-wrap { overflow: auto; max-height: 420px; border-radius: 10px; border: 1px solid var(--linea); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th { position: sticky; top: 0; background: var(--oscuro); color: #fff; font: 600 12px var(--titulos); text-align: left; padding: 9px 12px; white-space: nowrap; z-index: 1; }
tbody td { padding: 8px 12px; border-top: 1px solid #EDF1F3; white-space: nowrap; }
tbody tr:nth-child(even) td { background: var(--verde-suave); }
tbody tr:hover td { background: #E6F6F3; }
table.clic tbody tr { cursor: pointer; }
tbody tr.sel td { background: #D3EFEA !important; font-weight: 600; }
tbody tr.atenuada td { opacity: .45; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.neg { color: var(--rojo); }
tfoot td { position: sticky; bottom: 0; background: #DDF2EE; font-weight: 700; padding: 9px 12px; color: var(--oscuro); white-space: nowrap; }
.etq { display: inline-block; padding: 1px 7px; border-radius: 12px; font-size: 11px; font-weight: 600; background: #EEF2F4; color: var(--gris); }
.etq.NC { background: #FCEDEC; color: var(--rojo); }
.etq.FE { background: var(--verde-suave); color: var(--teal); }
.mas { padding: 10px 12px; color: var(--gris); font-size: 12px; text-align: center; border-top: 1px solid var(--linea); }

/* Administración */
.zona-carga { display: grid; place-items: center; gap: 8px; border: 2px dashed #C9D6DD; border-radius: 14px; padding: 30px 16px; color: var(--gris); cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.zona-carga:hover, .zona-carga.sobre { border-color: var(--teal); background: var(--verde-suave); color: var(--teal); }
.zona-carga input { display: none; }
.bitacora { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 4px; font-size: 13px; }
.bitacora .ok { color: var(--teal); }
.bitacora .error { color: var(--rojo); }
.form-linea { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.form-linea input, .form-linea select { border: 1px solid var(--linea); border-radius: 9px; padding: 8px 10px; flex: 1; min-width: 150px; }
.btn-quitar { background: none; border: 0; color: var(--rojo); cursor: pointer; font-weight: 600; }

.cargando, .vacio { background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra); padding: 28px; text-align: center; color: var(--gris); display: flex; align-items: center; justify-content: center; gap: 12px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid #DDE6EA; border-top-color: var(--teal); animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.pie { text-align: center; color: var(--gris); font-size: 11.5px; padding: 8px 16px 28px; }

/* ---------- Celular y tableta ---------- */
@media (max-width: 960px) {
  .fila, .fila:has(.ancho-2) { grid-template-columns: minmax(0, 1fr); }
  .banda-in { flex-wrap: wrap; gap: 12px 16px; }
  .banda-titulo { order: 3; flex-basis: 100%; border-left: 0; padding-left: 0; }
  .banda-filtros { margin-left: auto; }
}
@media (max-width: 640px) {
  .acceso { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .acceso-marca { padding: 36px 24px 30px; }
  .acceso-logo { width: 240px; }
  .acceso-lema { margin-top: 14px; font-size: 15px; }
  .barras { display: none; }
  .acceso-panel { justify-content: flex-start; padding-top: 24px; }
  .banda-in { padding: 12px 16px 8px; }
  .banda-logo { height: 28px; }
  .banda-filtros { width: 100%; margin-left: 0; }
  .banda-filtros .filtro { flex: 1; }
  .filtro select { width: 100%; max-width: none; }
  .banda-titulo { order: 2; }
  .banda-filtros { order: 3; }
  .cliente-nombre { font-size: 18px; }
  .cliente-sub { white-space: normal; }
  .contenido { padding: 14px 12px; gap: 12px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { min-height: 84px; padding: 12px 10px 12px 22px; }
  .kpi::before { left: 9px; top: 14px; bottom: 14px; width: 4px; }
  .kpi .valor { font-size: 18px; }
  .card { padding: 14px 12px; }
  .grafico { height: 230px; }
  .acciones, .acciones input { width: 100%; min-width: 0; }
  .acciones input { flex: 1; }
}
