:root {
    --fondo: #f1f5f9;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --texto: #0f172a;
    --texto-suave: #64748b;
    --borde: #e2e8f0;
    --marca: #4f46e5;
    --marca-fuerte: #4338ca;
    --marca-suave: #eef2ff;
    --lateral-fondo: #0f172a;
    --lateral-texto: #94a3b8;
    --lateral-activo: rgba(79, 70, 229, 0.15);
    --ok: #059669;
    --warn: #d97706;
    --danger: #e11d48;
    --sombra: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --radio: 12px;
}

[data-tema="dark"] {
    --fondo: #0f172a;
    --panel: #1e293b;
    --panel-2: #16213b;
    --texto: #f1f5f9;
    --texto-suave: #94a3b8;
    --borde: #334155;
    --marca: #6366f1;
    --marca-fuerte: #818cf8;
    --marca-suave: rgba(99, 102, 241, .14);
    --lateral-fondo: #0b1120;
    --sombra: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--fondo);
    color: var(--texto);
    font-size: 14px;
    line-height: 1.5;
    transition: background-color .25s, color .25s;
}

body.sin-scroll { overflow: hidden; }

svg { width: 18px; height: 18px; flex-shrink: 0; }
.ic-marca { color: var(--marca); }

a { color: var(--marca); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; }
p { margin: 0; }

.ocultar-sm { display: inline; }

/* ============ LAYOUT ============ */
.lateral {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    background: var(--lateral-fondo);
    color: var(--lateral-texto);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform .25s ease;
}
.lateral-marca {
    height: 64px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    border-bottom: 1px solid rgba(148, 163, 184, .15);
    flex-shrink: 0;
}
.logo {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #6366f1, #9333ea);
    color: #fff;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.marca-nombre { color: #fff; font-weight: 700; font-size: 17px; }
.lateral-menu { flex: 1; overflow-y: auto; padding: 16px 12px; scrollbar-width: none; }
.lateral-menu::-webkit-scrollbar { display: none; }
.lateral-seccion {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 14px 12px 6px;
    opacity: .7;
}
.lateral-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 9px;
    color: var(--lateral-texto);
    margin-bottom: 2px;
    transition: background .15s, color .15s;
}
.lateral-item:hover { background: rgba(148, 163, 184, .12); color: #fff; text-decoration: none; }
.lateral-item.activo { background: var(--lateral-activo); color: #fff; font-weight: 600; }
.lateral-pie {
    border-top: 1px solid rgba(148, 163, 184, .15);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.lateral-pie .boton-icono { color: var(--lateral-texto); }
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--marca);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}
.pie-datos { min-width: 0; flex: 1; }
.pie-datos strong { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pie-datos small { font-size: 11px; }

.principal {
    margin-left: 250px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.superior {
    position: sticky;
    top: 0;
    z-index: 30;
    height: 64px;
    background: var(--panel);
    border-bottom: 1px solid var(--borde);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 20px;
}
.superior-izq, .superior-der { display: flex; align-items: center; gap: 10px; }
.superior-der .boton-icono { background: transparent; }

.selector-empresa {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel-2);
    border: 1px solid var(--borde);
    border-radius: 10px;
    padding: 6px 10px;
}
.selector-empresa select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    color: var(--texto);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    outline: none;
    max-width: 140px;
}

.buscador {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel-2);
    border: 1px solid var(--borde);
    border-radius: 10px;
    padding: 6px 12px;
    color: var(--texto-suave);
}
.buscador input {
    border: none;
    background: transparent;
    outline: none;
    color: var(--texto);
    width: 170px;
    font-size: 13px;
}

.contenido { flex: 1; padding: 24px 28px; max-width: 1400px; width: 100%; margin: 0 auto; }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .6);
    backdrop-filter: blur(2px);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
body.lateral-abierto .overlay { opacity: 1; pointer-events: auto; }

/* ============ COMPONENTES ============ */
.boton-icono {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: var(--texto-suave);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.boton-icono:hover { background: var(--marca-suave); color: var(--marca); text-decoration: none; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .1s, box-shadow .15s;
    text-decoration: none !important;
    line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-primario { background: var(--marca); color: #fff; box-shadow: var(--sombra); }
.btn-primario:hover { background: var(--marca-fuerte); color: #fff; }
[data-tema="dark"] .btn-primario:hover { background: #4f46e5; }
.btn-exito { background: var(--ok); color: #fff; }
.btn-exito:hover { background: #047857; color: #fff; }
.btn-alerta { background: var(--warn); color: #fff; }
.btn-alerta:hover { background: #b45309; color: #fff; }
.btn-peligro { background: var(--danger); color: #fff; }
.btn-peligro:hover { background: #be123c; color: #fff; }
.btn-borde { background: var(--panel); color: var(--texto); border-color: var(--borde); }
.btn-borde:hover { border-color: var(--marca); color: var(--marca); }
.btn-suave { background: var(--marca-suave); color: var(--marca); }
.btn-suave:hover { filter: brightness(.96); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.tarjeta {
    background: var(--panel);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
}
.tarjeta-cuerpo { padding: 18px; }

.encabezado-pagina {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.encabezado-pagina h2 { font-size: 21px; }
.subtitulo { color: var(--texto-suave); font-size: 13px; margin-top: 2px; }
.acciones-pagina { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
    transition: transform .15s;
}
.badge.verde   { background: #d1fae5; color: #065f46; }
.badge.azul    { background: #dbeafe; color: #1e40af; }
.badge.celeste { background: #cffafe; color: #155e75; }
.badge.ambar   { background: #fef3c7; color: #92400e; }
.badge.naranja { background: #ffedd5; color: #9a3412; }
.badge.rosa    { background: #ffe4e6; color: #9f1239; }
.badge.morado  { background: #ede9fe; color: #5b21b6; }
.badge.gris    { background: #e2e8f0; color: #334155; }
[data-tema="dark"] .badge.verde   { background: rgba(16,185,129,.16); color: #6ee7b7; }
[data-tema="dark"] .badge.azul    { background: rgba(59,130,246,.16); color: #93c5fd; }
[data-tema="dark"] .badge.celeste { background: rgba(6,182,212,.16); color: #67e8f9; }
[data-tema="dark"] .badge.ambar   { background: rgba(245,158,11,.16); color: #fcd34d; }
[data-tema="dark"] .badge.naranja { background: rgba(249,115,22,.16); color: #fdba74; }
[data-tema="dark"] .badge.rosa    { background: rgba(244,63,94,.16); color: #fda4af; }
[data-tema="dark"] .badge.morado  { background: rgba(139,92,246,.16); color: #c4b5fd; }
[data-tema="dark"] .badge.gris    { background: rgba(100,116,139,.22); color: #cbd5e1; }

.tabla-contenedor { overflow-x: auto; border-radius: var(--radio); }
table.tabla { width: 100%; border-collapse: collapse; text-align: left; font-size: 13.5px; }
.tabla thead th {
    background: var(--panel-2);
    color: var(--texto-suave);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 11px 14px;
    border-bottom: 1px solid var(--borde);
}
.tabla tbody td { padding: 11px 14px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
.tabla tbody tr:last-child td { border-bottom: none; }
.tabla tbody tr:hover { background: var(--panel-2); }
tr[data-modal] { cursor: pointer; }
.celda-principal strong { color: var(--marca); }
.celda-secundaria { color: var(--texto-suave); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.texto-derecha { text-align: right; }
.sin-datos { text-align: center; padding: 40px 16px; color: var(--texto-suave); }
.sin-datos svg { width: 34px; height: 34px; opacity: .5; display: block; margin: 0 auto 8px; }

.filtros-barra {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.filtros-barra select,
.filtros-barra input[type="text"],
.filtros-barra input[type="search"] {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--borde);
    background: var(--panel);
    color: var(--texto);
    font-size: 13px;
}
.filtros-barra input[type="text"],
.filtros-barra input[type="search"] { min-width: 220px; }
.filtros-barra .etiqueta-filtro {
    font-size: 12px;
    color: var(--texto-suave);
    font-weight: 600;
    margin-left: 4px;
}

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--borde);
    margin-bottom: 14px;
}
.tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 9px 9px 0 0;
    color: var(--texto-suave);
    font-size: 13.5px;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, background .15s;
}
.tab:hover { color: var(--marca); text-decoration: none; background: var(--panel-2); }
.tab.activa { color: var(--marca); border-bottom-color: var(--marca); }
.tab-conteo {
    background: var(--panel-2);
    border: 1px solid var(--borde);
    border-radius: 20px;
    padding: 0 8px;
    font-size: 11.5px;
    line-height: 18px;
}
.tab.activa .tab-conteo { background: var(--marca-suave); border-color: transparent; color: var(--marca); }

.paginacion { display: flex; gap: 6px; justify-content: center; padding: 16px 0; flex-wrap: wrap; }
.pg {
    min-width: 32px;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--borde);
    background: var(--panel);
    color: var(--texto);
    text-align: center;
    font-size: 13px;
}
.pg:hover { border-color: var(--marca); color: var(--marca); text-decoration: none; }
.pg.actual { background: var(--marca); border-color: var(--marca); color: #fff; font-weight: 700; }
.pg-puntos { padding: 5px 4px; color: var(--texto-suave); }

/* KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.kpi {
    background: var(--panel);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 16px;
    box-shadow: var(--sombra);
    transition: transform .15s, box-shadow .15s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -8px rgba(15,23,42,.18); }
.kpi small { color: var(--texto-suave); font-size: 12.5px; }
.kpi .kpi-valor { font-size: 26px; font-weight: 800; margin-top: 4px; }
.kpi .kpi-detalle { font-size: 11.5px; color: var(--texto-suave); margin-top: 2px; }
.c-verde { color: var(--ok); }
.c-azul { color: #2563eb; }
.c-ambar { color: var(--warn); }
.c-rosa { color: var(--danger); }
.c-morado { color: #7c3aed; }
.c-marca { color: var(--marca); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }

.panel-titulo { font-weight: 700; padding: 14px 18px; border-bottom: 1px solid var(--borde); }

/* Gráfico donut CSS puro */
.donut-wrap { display: flex; align-items: center; gap: 22px; padding: 18px; flex-wrap: wrap; }
.donut {
    --seg1: 0%; --seg2: 0%;
    width: 150px; height: 150px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    background: conic-gradient(var(--donut-c1, var(--ok)) 0 var(--seg1), var(--donut-c2, var(--warn)) var(--seg1) var(--seg2), var(--donut-c3, #94a3b8) var(--seg2) 100%);
}
.donut::after {
    content: "";
    position: absolute;
    inset: 22%;
    border-radius: 50%;
    background: var(--panel);
}
.donut-centro {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    font-size: 22px;
    font-weight: 800;
}
.donut-leyenda { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.leyenda-item { display: flex; align-items: center; gap: 8px; }
.punto { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Barras horizontales */
.bar-fila { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; }
.bar-etiqueta { width: 110px; color: var(--texto-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.bar-track { flex: 1; height: 10px; background: var(--panel-2); border: 1px solid var(--borde); border-radius: 999px; overflow: hidden; }
.bar-relleno { height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); border-radius: 999px; min-width: 2px; transition: width .4s ease; }
.bar-valor { width: 34px; text-align: right; font-weight: 700; font-size: 12.5px; flex-shrink: 0; }

/* Listas tipo timeline */
.linea-tiempo { display: flex; flex-direction: column; }
.evento { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--borde); margin-left: 6px; }
.evento:last-child { border-left-color: transparent; padding-bottom: 2px; }
.evento::before {
    content: "";
    position: absolute;
    left: -6px; top: 3px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--marca);
}
.evento small { color: var(--texto-suave); display: block; font-size: 11.5px; }
.evento strong { font-size: 13px; }

.lista-simple > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--borde);
    font-size: 13px;
}
.lista-simple > div:last-child { border-bottom: none; }

/* Formularios */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.campo { display: flex; flex-direction: column; gap: 5px; }
.campo-completo { grid-column: 1 / -1; }
.campo label { font-size: 12.5px; font-weight: 600; color: var(--texto-suave); }
.campo input, .campo select, .campo textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--borde);
    border-radius: 9px;
    background: var(--panel);
    color: var(--texto);
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
    border-color: var(--marca);
    box-shadow: 0 0 0 3px var(--marca-suave);
}
.campo input[required]:invalid:not(:placeholder-shown), .campo select[required]:invalid, .campo textarea[required]:invalid { border-color: var(--danger); }
.form-pie { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--borde); }
.nota { font-size: 12px; color: var(--texto-suave); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 60; }
.modal[hidden] { display: none; }
.modal-fondo { position: absolute; inset: 0; background: rgba(15, 23, 42, .65); backdrop-filter: blur(3px); animation: aparecer .18s ease-out; }
.modal-dialog {
    position: relative;
    width: min(720px, calc(100% - 32px));
    max-height: 88vh;
    margin: 6vh auto 0;
    background: var(--panel);
    border: 1px solid var(--borde);
    border-radius: 16px;
    box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .35);
    animation: deslizar .22s ease-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-dialog.grande { width: min(940px, calc(100% - 32px)); }
#modalContenido {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}
@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }
@keyframes deslizar { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-cabecera {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--borde);
    background: var(--panel-2);
    flex-shrink: 0;
}
.modal-cabecera h3 { font-size: 17px; }
.modal-sub { font-size: 12.5px; color: var(--texto-suave); margin-top: 2px; }
.modal-cuerpo { padding: 18px 20px; overflow-y: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
.modal-pie {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 13px 20px;
    border-top: 1px solid var(--borde);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.seccion-modal { margin-bottom: 20px; }
.seccion-modal > h4 {
    font-size: 13.5px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--borde);
    margin-bottom: 10px;
}
.ficha-fila { display: flex; justify-content: space-between; gap: 14px; padding: 6px 0; border-bottom: 1px dashed var(--borde); font-size: 13px; }
.ficha-fila:last-child { border-bottom: none; }
.ficha-fila span:first-child { color: var(--texto-suave); flex-shrink: 0; }
.ficha-fila span:last-child { text-align: right; font-weight: 500; }
.caja-specs { background: var(--panel-2); border: 1px solid var(--borde); border-radius: 10px; padding: 10px 14px; font-size: 12.5px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }

/* Toasts */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #fff;
    padding: 11px 16px;
    border-radius: 11px;
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: 0 10px 26px -8px rgba(0, 0, 0, .45);
    animation: deslizar .25s ease-out;
    max-width: 360px;
}
.toast-success { background: var(--ok); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warn); }
.toast-info { background: #2563eb; }
.toast svg { color: #fff; }

/* Tema claro/oscuro en botón */
.ic-sol { display: none; }
[data-tema="dark"] .ic-luna { display: none; }
[data-tema="dark"] .ic-sol { display: block; }

.solo-movil { display: none; }

/* Login */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(900px 500px at 85% -10%, var(--marca-suave), transparent),
        radial-gradient(700px 420px at 0% 110%, rgba(147, 51, 234, .1), transparent),
        var(--fondo);
}
.auth-tarjeta {
    width: min(400px, 100%);
    background: var(--panel);
    border: 1px solid var(--borde);
    border-radius: 18px;
    box-shadow: 0 20px 50px -12px rgba(15, 23, 42, .25);
    padding: 30px 28px;
}
.auth-logo {
    width: 46px; height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #9333ea);
    color: #fff;
    font-weight: 800;
    font-size: 21px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.auth-tarjeta h1 { font-size: 21px; }
.auth-sub { color: var(--texto-suave); font-size: 13.5px; margin: 4px 0 22px; }
.auth-form .campo { margin-bottom: 14px; }
.auth-form button[type=submit] { width: 100%; justify-content: center; margin-top: 6px; }
.auth-error {
    background: #ffe4e6;
    color: #9f1239;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 14px;
    display: flex;
    gap: 8px;
    align-items: center;
}
[data-tema="dark"] .auth-error { background: rgba(244, 63, 94, .14); color: #fda4af; }

/* Resultado importación */
.resumen-importacion { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.resumen-caja { flex: 1; min-width: 140px; background: var(--panel-2); border: 1px solid var(--borde); border-radius: 10px; padding: 12px 16px; }
.resumen-caja small { color: var(--texto-suave); display: block; font-size: 12px; }
.resumen-caja strong { font-size: 22px; }

/* Responsive */
@media (max-width: 1024px) {
    .lateral { transform: translateX(-100%); }
    body.lateral-abierto .lateral { transform: translateX(0); }
    .principal { margin-left: 0; }
    .solo-movil { display: inline-flex; }
    .contenido { padding: 18px 14px; }
    .grid-2 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .ocultar-sm { display: none; }
    .buscador input { width: 120px; }
    .modal-dialog { margin-top: 3vh; }
    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .tabs::-webkit-scrollbar { display: none; }
    .tabs .tab { white-space: nowrap; }
    .superior { gap: 8px; padding: 0 14px; }
    .selector-empresa select { max-width: 110px; }
    .buscador { flex: 1; }
    .buscador input { min-width: 0; width: 100%; }
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
    .kpi .kpi-valor { font-size: 22px; }
    .caja-specs { grid-template-columns: 1fr; }
    .donut-wrap { justify-content: center; }
    .encabezado-pagina { gap: 10px; }
    .encabezado-pagina h2 { font-size: 19px; }
    .acciones-pagina { width: 100%; }
}

@media (max-width: 768px) {
    .contenido { padding: 14px 10px; }
    .encabezado-pagina { flex-direction: column; align-items: flex-start; }
    .encabezado-pagina h2 { font-size: 18px; }
    .acciones-pagina { width: 100%; }
    .acciones-pagina .btn { flex: 1; justify-content: center; min-width: 0; }
    .tarjeta-cuerpo { padding: 14px; }
    .tabla thead th { padding: 9px 10px; font-size: 11px; }
    .tabla tbody td { padding: 9px 10px; font-size: 12.5px; }
    .ficha-fila { font-size: 12.5px; gap: 10px; }
    .grid-3 { grid-template-columns: 1fr; }
    .donut { width: 120px; height: 120px; }
    .donut-centro { font-size: 18px; }
    .donut-leyenda { font-size: 12px; }
    .bar-etiqueta { width: 80px; font-size: 12px; }
    .resumen-caja { min-width: 110px; padding: 10px 12px; }
    .resumen-caja strong { font-size: 18px; }
    .toast { max-width: 280px; font-size: 12.5px; }
    .toasts { bottom: 12px; right: 12px; left: 12px; }
    .toast { max-width: none; }
    .paginacion .pg { min-width: 28px; padding: 4px 8px; font-size: 12px; }
    .filtros-barra { gap: 6px; }
    .filtros-barra select,
    .filtros-barra input[type="text"],
    .filtros-barra input[type="search"] { padding: 6px 10px; font-size: 12px; }
    .modal-dialog { width: min(600px, calc(100% - 16px)); margin-top: 2vh; border-radius: 12px; }
    .modal-dialog.grande { width: min(700px, calc(100% - 16px)); }
    .modal-cabecera { padding: 12px 16px; }
    .modal-cabecera h3 { font-size: 15px; }
    .modal-cuerpo { padding: 14px 16px; }
    .modal-pie { padding: 10px 16px; }
    .btn { padding: 8px 14px; font-size: 13px; }
    .btn-sm { padding: 4px 8px; font-size: 12px; }
}

@media (max-width: 480px) {
    body { font-size: 13px; }
    .contenido { padding: 10px 8px; }
    .superior { height: 56px; padding: 0 10px; }
    .superior-der .boton-icono { width: 30px; height: 30px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .kpi { padding: 12px; }
    .kpi small { font-size: 11px; }
    .kpi .kpi-valor { font-size: 20px; }
    .kpi .kpi-detalle { font-size: 10.5px; }
    .encabezado-pagina h2 { font-size: 16px; }
    .panel-titulo { font-size: 13px; padding: 10px 14px; }
    .tabla thead th { padding: 7px 8px; font-size: 10.5px; letter-spacing: 0; }
    .tabla tbody td { padding: 7px 8px; font-size: 12px; }
    .celda-principal strong { font-size: 13px; }
    .celda-secundaria { font-size: 11px; }
    .badge { font-size: 10.5px; padding: 2px 7px; }
    .tabs .tab { padding: 7px 12px; font-size: 12.5px; }
    .tab-conteo { font-size: 10.5px; padding: 0 6px; }
    .auth-tarjeta { padding: 22px 20px; border-radius: 14px; }
    .auth-logo { width: 40px; height: 40px; font-size: 18px; border-radius: 10px; }
    .auth-tarjeta h1 { font-size: 19px; }
    .donut-wrap { flex-direction: column; align-items: center; padding: 14px; }
    .donut-leyenda { flex-direction: row; flex-wrap: wrap; gap: 12px; justify-content: center; }
    .caja-specs { padding: 8px 10px; }
    .evento { padding-left: 18px; }
    .lista-simple > div { padding: 7px 10px; font-size: 12px; }
    .resumen-importacion { gap: 8px; }
    .resumen-caja { min-width: 90px; padding: 8px 10px; }
    .resumen-caja strong { font-size: 16px; }
    .resumen-caja small { font-size: 11px; }
    .bar-etiqueta { width: 60px; font-size: 11px; }
    .bar-valor { width: 28px; font-size: 11px; }
    .form-grid { gap: 10px; }
    .campo label { font-size: 11.5px; }
    .campo input, .campo select, .campo textarea { padding: 7px 10px; font-size: 12.5px; }
    .modal-dialog { width: calc(100% - 8px); margin-top: 1vh; border-radius: 10px; }
    .modal-dialog.grande { width: calc(100% - 8px); }
    .modal-cabecera { padding: 10px 14px; gap: 8px; }
    .modal-cabecera h3 { font-size: 14px; }
    .modal-cuerpo { padding: 12px 14px; }
    .modal-pie { padding: 8px 14px; flex-direction: column; align-items: stretch; }
    .modal-pie .btn { width: 100%; justify-content: center; }
    .ficha-fila { flex-direction: column; gap: 2px; padding: 5px 0; }
    .ficha-fila span:first-child { flex-shrink: auto; }
    .ficha-fila span:last-child { text-align: left; }
    .paginacion { gap: 4px; padding: 12px 0; }
    .pg-puntos { display: none; }
    .ocultar-xs { display: none !important; }
}
