/* =============================================================================
   Backoffice LOMA 2026 · Registro de visitantes
   Paleta tomada de loyalty-congress.com y del logo del evento.
   ============================================================================= */

:root {
    /* Marca */
    --navy-950: #17172f;
    --navy-900: #1f1f3d;
    --navy-800: #2b2b52;
    --navy-700: #3c3c6d;
    --navy-600: #464678;
    --navy-500: #5a5a92;
    --navy-100: #e4e4f1;
    --navy-50: #f0f0f8;
    --red-700: #b12537;
    --red-600: #d02f44;
    --red-50: #fcecee;
    --teal: #64bed0;
    --amber: #efaa59;
    --coral: #d88362;
    --berry: #ba4360;
    --franja: linear-gradient(90deg, #64bed0 0%, #efaa59 38%, #d88362 64%, #ba4360 100%);

    /* Estados */
    --ok-600: #16875a;
    --ok-50: #e5f5ee;
    --warn-600: #b7700f;
    --warn-50: #fdf3e3;
    --err-600: #c42a3e;
    --err-50: #fdebed;
    --info-600: #2f6fb3;
    --info-50: #e8f1fb;

    /* Neutros */
    --bg: #f4f5f9;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --border: #e3e5ee;
    --border-strong: #cfd2df;
    --text: #1b1c32;
    --text-2: #474a63;
    --muted: #767a93;

    --radius-lg: 16px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(23, 23, 47, .06);
    --shadow: 0 1px 3px rgba(23, 23, 47, .06), 0 8px 24px -12px rgba(23, 23, 47, .12);
    --shadow-lg: 0 24px 60px -20px rgba(23, 23, 47, .35);
    --sidebar: 260px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--navy-600); text-decoration: none; }
a:hover { color: var(--red-600); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
code, pre { font-family: var(--mono); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* =============================================================================
   Layout
   ============================================================================= */

.app-cargando { visibility: hidden; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar);
    background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
    color: #d9d9ec;
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform .25s ease;
}

.sidebar::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: var(--franja);
}

.sidebar-marca { padding: 30px 24px 22px; }
.sidebar-marca img { display: block; width: 190px; max-width: 100%; height: auto; }
.sidebar-marca .etiqueta {
    margin-top: 14px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #9d9dc4;
}

.nav { padding: 8px 14px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-titulo {
    margin: 16px 10px 6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #7f7fa8;
}
.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #c9c9e2;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.activo {
    background: rgba(255, 255, 255, .1);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--red-600);
}
.nav a.activo svg { opacity: 1; color: var(--amber); }

.sidebar-pie { padding: 16px 20px 22px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 13px; }
.sidebar-pie .evento { color: #9d9dc4; font-size: 12px; }
.sidebar-pie .evento strong { display: block; color: #fff; font-size: 13px; font-weight: 600; }

.principal { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 32px;
    background: rgba(244, 245, 249, .85);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid transparent;
}
.topbar.con-sombra { border-bottom-color: var(--border); }
.topbar .espaciador { flex: 1; }
.topbar .btn-menu { display: none; }

.usuario-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 999px; }
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--navy-700);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    flex: none;
}
.usuario-chip .datos { line-height: 1.2; }
.usuario-chip .datos strong { display: block; font-size: 13px; font-weight: 600; }
.usuario-chip .datos span { font-size: 12px; color: var(--muted); }

.contenido { padding: 12px 32px 48px; width: 100%; }

.encabezado { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 10px 0 24px; flex-wrap: wrap; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--red-600); margin-bottom: 6px; }
.encabezado h1 { font-size: 28px; color: var(--navy-900); }
.encabezado .sub { color: var(--muted); margin-top: 4px; }
.encabezado .acciones { display: flex; gap: 10px; flex-wrap: wrap; }

.backdrop-menu { display: none; }

/* =============================================================================
   Tarjetas e indicadores
   ============================================================================= */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.card-cab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px 14px;
    flex-wrap: wrap;
}
.card-cab h2 { font-size: 16px; }
.card-cab .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-cuerpo { padding: 0 22px 22px; }
.contenido > .card + .card, .contenido > .grid + .card, .contenido > .card + .grid, .contenido > .grid + .grid, .contenido > section + section { margin-top: 20px; }

.grid { display: grid; gap: 20px; }
.grid-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.35fr); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi { position: relative; overflow: hidden; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.kpi::after {
    content: "";
    position: absolute;
    right: -38px;
    bottom: -38px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 14px solid currentColor;
    opacity: .06;
}
.kpi-cab { display: flex; align-items: center; gap: 12px; }
.kpi-icono {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #fff;
    flex: none;
}
.kpi-icono svg { width: 20px; height: 20px; }
.kpi-titulo { font-size: 13px; font-weight: 600; color: var(--text-2); }
.kpi-valor { font-size: 32px; font-weight: 800; letter-spacing: -.02em; color: var(--navy-900); line-height: 1; }
.kpi-pie { font-size: 12px; color: var(--muted); }
.kpi-barra { height: 6px; border-radius: 99px; background: var(--navy-50); overflow: hidden; }
.kpi-barra i { display: block; height: 100%; border-radius: 99px; background: currentColor; transition: width .6s ease; }
.kpi.navy { color: var(--navy-600); } .kpi.navy .kpi-icono { background: var(--navy-600); }
.kpi.ok { color: var(--ok-600); } .kpi.ok .kpi-icono { background: var(--ok-600); }
.kpi.err { color: var(--err-600); } .kpi.err .kpi-icono { background: var(--err-600); }
.kpi.warn { color: var(--warn-600); } .kpi.warn .kpi-icono { background: var(--amber); }

.hero {
    position: relative;
    overflow: hidden;
    padding: 22px 24px;
    border-radius: var(--radius-lg);
    color: #fff;
    background:
        radial-gradient(120% 140% at 100% 0%, rgba(208, 47, 68, .55) 0%, rgba(208, 47, 68, 0) 55%),
        linear-gradient(135deg, var(--navy-800) 0%, var(--navy-600) 100%);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
}
.hero::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--franja); }
.hero::after {
    content: "";
    position: absolute;
    right: -30px;
    bottom: -60px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .18);
    box-shadow: 0 0 0 26px rgba(255, 255, 255, .04);
}
.hero .eyebrow { color: #f3c38a; }
.hero .folio { font-size: 30px; font-weight: 800; letter-spacing: .02em; font-family: var(--mono); }
.hero .texto { font-size: 12.5px; color: #d7d7ee; max-width: 36ch; }

/* =============================================================================
   Botones y controles
   ============================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    font: 600 13.5px/1 var(--font);
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
    user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:disabled, .btn.deshabilitado { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible, .input:focus-visible, .select:focus-visible { outline: 3px solid rgba(70, 70, 120, .25); outline-offset: 1px; }

.btn-primario { background: var(--navy-700); color: #fff; box-shadow: 0 6px 16px -8px rgba(60, 60, 109, .8); }
.btn-primario:hover { background: var(--navy-800); color: #fff; }
.btn-acento { background: var(--red-600); color: #fff; box-shadow: 0 6px 16px -8px rgba(208, 47, 68, .8); }
.btn-acento:hover { background: var(--red-700); color: #fff; }
.btn-secundario { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secundario:hover { border-color: var(--navy-500); color: var(--navy-700); }
.btn-fantasma { background: transparent; color: var(--text-2); }
.btn-fantasma:hover { background: var(--navy-50); color: var(--navy-700); }
.btn-peligro { background: var(--surface); color: var(--err-600); border-color: #f0c4ca; }
.btn-peligro:hover { background: var(--err-50); border-color: var(--err-600); color: var(--err-600); }
.btn-peligro-solido { background: var(--err-600); color: #fff; }
.btn-peligro-solido:hover { background: var(--red-700); color: #fff; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-icono { width: 34px; height: 34px; padding: 0; border-radius: 9px; }
.btn-bloque { width: 100%; height: 46px; font-size: 14.5px; }

.btn .spinner { width: 14px; height: 14px; border-width: 2px; }

.campo { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.campo label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.campo .ayuda { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: 400 14px var(--font);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--navy-500); box-shadow: 0 0 0 4px rgba(70, 70, 120, .12); }
.input-lg { height: 48px; font-size: 15px; border-radius: 12px; background: var(--surface-2); }
.select { appearance: none; padding-right: 34px; 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='%23767a93' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input-icono { position: relative; }
.input-icono svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icono .input { padding-left: 36px; }
.input-grupo { display: flex; gap: 8px; }

.interruptor { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.interruptor input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.interruptor input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.interruptor input:checked { background: var(--ok-600); }
.interruptor input:checked::after { transform: translateX(16px); }

.filtros { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(5, minmax(120px, 1fr)) auto; gap: 12px; align-items: end; }

.segmentado { display: inline-flex; padding: 3px; background: var(--navy-50); border-radius: 10px; gap: 2px; }
.segmentado button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; font: 600 12.5px var(--font); color: var(--text-2); cursor: pointer; }
.segmentado button.activo { background: var(--surface); color: var(--navy-800); box-shadow: var(--shadow-sm); }
.segmentado .cuenta { margin-left: 6px; font-weight: 700; color: var(--muted); }

/* =============================================================================
   Chips
   ============================================================================= */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    background: var(--navy-50);
    color: var(--navy-700);
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.sin-punto::before { display: none; }
.chip .ico-chip { width: 13px; height: 13px; }
.chip-ok { background: var(--ok-50); color: var(--ok-600); }
.chip-err { background: var(--err-50); color: var(--err-600); }
.chip-warn { background: var(--warn-50); color: var(--warn-600); }
.chip-info { background: var(--info-50); color: var(--info-600); }
.chip-neutro { background: #eef0f5; color: var(--text-2); }

.bandera { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.bandera.si { background: var(--ok-50); color: var(--ok-600); }
.bandera.no { background: #f0f1f5; color: #a3a6b8; }

/* =============================================================================
   Tablas
   ============================================================================= */

.tabla-contenedor { overflow-x: auto; }
.tabla { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tabla th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    padding: 11px 14px;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}
.tabla td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabla tbody tr { transition: background .1s; }
.tabla tbody tr:hover { background: #fafafe; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla .centro { text-align: center; }
.tabla .acciones { text-align: right; white-space: nowrap; }
.tabla .acciones .btn + .btn { margin-left: 6px; }
.tabla .folio { font-family: var(--mono); font-weight: 600; color: var(--navy-700); white-space: nowrap; }
.tabla .secundario { display: block; color: var(--muted); font-size: 12.5px; }
.tabla .truncar { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabla .col-visitante { min-width: 210px; }
#tabla-registros tbody tr[data-id] { cursor: pointer; }
.tabla .servicios { display: flex; gap: 6px; flex-wrap: wrap; }
.tabla .servicio { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.tabla-compacta td { padding: 9px 12px; }
.tabla-compacta th { padding: 9px 12px; }

/* Previsualización con errores por celda */
.tabla-preview td { white-space: nowrap; }
.tabla-preview tr.fila-error td:first-child { box-shadow: inset 3px 0 0 var(--err-600); }
.tabla-preview td.celda-error { background: var(--err-50); color: var(--err-600); white-space: normal; min-width: 180px; }
.tabla-preview td.celda-error .valor { font-weight: 600; color: var(--text); }
.tabla-preview td.celda-error .valor:empty::before { content: "(vacío)"; color: var(--muted); font-weight: 400; font-style: italic; }
.tabla-preview td.celda-error .msg { display: flex; gap: 5px; align-items: flex-start; font-size: 12px; margin-top: 3px; line-height: 1.35; }
.tabla-preview td.celda-error .msg svg { width: 13px; height: 13px; flex: none; margin-top: 1px; }

.paginador { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--border); flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.paginador .controles { display: flex; align-items: center; gap: 6px; }
.paginador .pagina { min-width: 34px; }
.paginador .pagina.activa { background: var(--navy-700); color: #fff; border-color: var(--navy-700); }

.vacio { padding: 48px 24px; text-align: center; color: var(--muted); }
.vacio svg { width: 40px; height: 40px; color: var(--border-strong); margin-bottom: 10px; }
.vacio strong { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }

/* =============================================================================
   Importación
   ============================================================================= */

.pasos { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.paso { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: 13px; }
.paso .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--navy-50); color: var(--navy-600); font-size: 12px; font-weight: 700; }
.paso.activo { border-color: var(--navy-600); color: var(--navy-800); box-shadow: 0 0 0 3px rgba(70, 70, 120, .1); }
.paso.activo .n { background: var(--navy-700); color: #fff; }
.paso.hecho { color: var(--ok-600); }
.paso.hecho .n { background: var(--ok-600); color: #fff; }

.zona-carga {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 46px 24px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.zona-carga:hover, .zona-carga.arrastrando { border-color: var(--navy-500); background: var(--navy-50); }
.zona-carga .icono { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface); color: var(--navy-600); box-shadow: var(--shadow); }
.zona-carga .icono svg { width: 26px; height: 26px; }
.zona-carga strong { font-size: 16px; color: var(--navy-900); }
.zona-carga input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.reglas { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px 20px; margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--text-2); }
.reglas li { display: flex; gap: 8px; }
.reglas li svg { width: 16px; height: 16px; flex: none; color: var(--ok-600); margin-top: 2px; }

.resumen-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.tile .etq { font-size: 12px; color: var(--muted); font-weight: 600; }
.tile .val { font-size: 24px; font-weight: 800; color: var(--navy-900); line-height: 1.2; }
.tile.ok .val { color: var(--ok-600); }
.tile.err .val { color: var(--err-600); }
.tile.warn .val { color: var(--warn-600); }

.progreso { height: 12px; border-radius: 99px; background: var(--navy-50); overflow: hidden; }
.progreso i { display: block; height: 100%; width: 0; background: var(--franja); border-radius: 99px; transition: width .3s ease; }
.progreso-cab { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.progreso-cab .pct { font-size: 26px; font-weight: 800; color: var(--navy-900); }

.bitacora-vivo { max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.bitacora-vivo .item { display: grid; grid-template-columns: 64px minmax(0, 1.4fr) 110px 100px minmax(0, 2fr); gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; animation: aparecer .25s ease; }
.bitacora-vivo .item:last-child { border-bottom: 0; }
.bitacora-vivo .item .fila { color: var(--muted); font-variant-numeric: tabular-nums; }
.bitacora-vivo .item .msg { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@keyframes aparecer { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* =============================================================================
   Detalle / JSON
   ============================================================================= */

.detalle-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 20px; }
.dato .etq { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.dato .val { font-weight: 500; word-break: break-word; }
.seccion-titulo { font-size: 13px; font-weight: 700; color: var(--navy-800); margin: 22px 0 12px; display: flex; align-items: center; gap: 8px; }
.seccion-titulo::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.json { margin: 0; padding: 14px 16px; background: var(--navy-950); color: #d8dcf0; border-radius: var(--radius); font-size: 12px; line-height: 1.55; max-height: 280px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.json .k { color: #9fd6e2; } .json .s { color: #f3c38a; } .json .n { color: #f19aa8; } .json .b { color: #b9a4f5; }
.alerta { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); font-size: 13px; }
.alerta svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alerta-err { background: var(--err-50); color: var(--err-600); }
.alerta-warn { background: var(--warn-50); color: var(--warn-600); }
.alerta-info { background: var(--info-50); color: var(--info-600); }
.alerta-ok { background: var(--ok-50); color: var(--ok-600); }

/* Barras de distribución (dashboard) */
.barras { display: flex; flex-direction: column; gap: 12px; }
.barra-fila .cab { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 5px; }
.barra-fila .cab span { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-fila .cab strong { font-variant-numeric: tabular-nums; }
.barra-fila .pista { height: 8px; border-radius: 99px; background: var(--navy-50); overflow: hidden; }
.barra-fila .pista i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--navy-600), var(--navy-500)); }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-stats .tile { text-align: center; }

/* Vista previa del gafete */
.gafete-preview {
    position: relative;
    max-width: 320px;
    margin: 4px auto 0;
    padding: 26px 22px 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
    overflow: hidden;
}
.gafete-preview::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--franja); }
.gafete-nombre { font-size: 24px; font-weight: 800; color: var(--navy-900); line-height: 1.1; }
.gafete-apellido { font-size: 17px; font-weight: 700; color: var(--navy-700); margin-top: 2px; }
.gafete-puesto { margin-top: 12px; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.gafete-empresa { font-size: 13px; color: var(--red-600); font-weight: 700; margin-top: 2px; }
.gafete-extra { display: inline-block; margin-top: 10px; padding: 3px 10px; border-radius: 99px; background: var(--warn-50); color: var(--warn-600); font-size: 11.5px; font-weight: 700; }
.gafete-qr { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border-strong); font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.gafete-qr svg { width: 15px; height: 15px; }

/* Configuración */
.lista-def { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; margin: 0; }
.lista-def dt { color: var(--muted); font-weight: 500; }
.lista-def dd { margin: 0; font-weight: 600; word-break: break-all; }
.lista-def code { background: var(--navy-50); padding: 2px 6px; border-radius: 6px; font-size: 12.5px; }

/* =============================================================================
   Modal, toasts, cargador
   ============================================================================= */

.modal-fondo {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 6vh 16px 16px;
    background: rgba(23, 23, 47, .5);
    backdrop-filter: blur(3px);
    overflow-y: auto;
    animation: fundido .15s ease;
}
.modal {
    width: 100%;
    max-width: 520px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: subir .2s ease;
}
.modal.grande { max-width: 980px; }
.modal.mediano { max-width: 720px; }
.modal-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 24px 12px; }
.modal-cab h3 { font-size: 18px; color: var(--navy-900); }
.modal-cab .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.modal-cuerpo { padding: 8px 24px 20px; }
.modal-pie { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; background: var(--surface-2); border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-pie .izq { margin-right: auto; }
.form-grid { display: grid; gap: 14px; }

@keyframes fundido { from { opacity: 0; } to { opacity: 1; } }
@keyframes subir { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--navy-900);
    color: #fff;
    box-shadow: var(--shadow-lg);
    font-size: 13.5px;
    animation: subir .2s ease;
}
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.ok svg { color: #6fdcaa; }
.toast.error { background: #3a1520; }
.toast.error svg { color: #ff8f9f; }
.toast.aviso svg { color: var(--amber); }
.toast .cerrar { margin-left: auto; background: none; border: 0; color: rgba(255, 255, 255, .6); cursor: pointer; padding: 0; font-size: 18px; line-height: 1; }
.toast.saliendo { opacity: 0; transform: translateY(8px); transition: all .2s; }

.barra-carga { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 300; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity .2s; }
.barra-carga.activa { opacity: 1; }
.barra-carga::before { content: ""; position: absolute; top: 0; bottom: 0; width: 40%; background: var(--franja); animation: carga 1s ease-in-out infinite; }
@keyframes carga { from { left: -40%; } to { left: 100%; } }

.spinner { display: inline-block; width: 20px; height: 20px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: girar .7s linear infinite; opacity: .8; }
@keyframes girar { to { transform: rotate(360deg); } }
.cargando-bloque { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 48px; color: var(--muted); }
.esqueleto { background: linear-gradient(90deg, #eef0f5 25%, #f7f8fb 50%, #eef0f5 75%); background-size: 200% 100%; animation: brillo 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes brillo { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* =============================================================================
   Login / cambio de contraseña
   ============================================================================= */

.acceso {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
    background:
        radial-gradient(60% 50% at 0% 0%, rgba(100, 190, 208, .12), transparent 70%),
        radial-gradient(50% 50% at 100% 100%, rgba(208, 47, 68, .08), transparent 70%),
        var(--bg);
}
.acceso-card {
    position: relative;
    width: 100%;
    max-width: 1000px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--surface);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    min-height: 580px;
}
.acceso-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--franja); z-index: 2; }
.acceso-marca {
    position: relative;
    overflow: hidden;
    padding: 48px 44px;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background:
        radial-gradient(90% 70% at 100% 0%, rgba(208, 47, 68, .45), transparent 60%),
        radial-gradient(70% 60% at 0% 100%, rgba(100, 190, 208, .22), transparent 60%),
        linear-gradient(160deg, var(--navy-800) 0%, var(--navy-950) 100%);
}
.acceso-marca img { width: 260px; max-width: 100%; height: auto; position: relative; z-index: 1; }
.acceso-marca .anillo { position: absolute; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .1); }
.acceso-marca .anillo.a1 { width: 420px; height: 420px; right: -180px; top: -140px; box-shadow: 0 0 0 60px rgba(255, 255, 255, .025); }
.acceso-marca .anillo.a2 { width: 260px; height: 260px; left: -120px; bottom: -100px; }
.acceso-marca .montana { position: absolute; right: 40px; bottom: 150px; width: 170px; opacity: .9; }
.acceso-marca .pie { position: relative; z-index: 1; }
.acceso-marca .eyebrow { color: #f3c38a; }
.acceso-marca h2 { font-size: 34px; line-height: 1.1; letter-spacing: -.02em; }
.acceso-marca .fecha { margin-top: 10px; color: #cfd0ea; }
.acceso-form { padding: 64px 56px; display: flex; flex-direction: column; justify-content: center; }
.acceso-form h1 { font-size: 30px; color: var(--navy-900); letter-spacing: -.02em; }
.acceso-form .sub { color: var(--muted); margin: 8px 0 30px; }
.acceso-form .form-grid { gap: 18px; }
.acceso-form .btn-bloque { margin-top: 8px; }
.acceso-form .nota { margin-top: 22px; font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.acceso-form .nota svg { width: 15px; height: 15px; flex: none; }
.politica { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.politica li { display: flex; gap: 6px; align-items: center; }
.politica li::before { content: "○"; font-size: 11px; }
.politica li.cumple { color: var(--ok-600); }
.politica li.cumple::before { content: "●"; }
.ver-password { position: relative; }
.ver-password .input { padding-right: 44px; }
.ver-password button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; }
.ver-password button:hover { color: var(--navy-700); background: var(--navy-50); }
.ver-password button svg { width: 18px; height: 18px; display: block; }

/* =============================================================================
   Utilidades
   ============================================================================= */

.flex { display: flex; align-items: center; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.entre { justify-content: space-between; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.texto-muted { color: var(--muted); }
.texto-err { color: var(--err-600); }
.texto-ok { color: var(--ok-600); }
.fw-600 { font-weight: 600; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 1320px) {
    .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-kpi .hero { grid-column: 1 / -1; }
    .filtros { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .filtros .campo:first-child { grid-column: 1 / -1; }
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.menu-abierto .sidebar { transform: none; }
    body.menu-abierto .backdrop-menu { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(23, 23, 47, .4); }
    .principal { margin-left: 0; }
    .topbar .btn-menu { display: inline-flex; }
    .grid-2-1, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .detalle-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .acceso-card { grid-template-columns: minmax(0, 1fr); min-height: 0; }
    .acceso-marca { padding: 36px 32px; min-height: 220px; }
    .acceso-marca .montana { display: none; }
    .acceso-form { padding: 40px 32px; }
}

@media (max-width: 640px) {
    .solo-escritorio { display: none; }
    .topbar, .contenido { padding-left: 16px; padding-right: 16px; }
    .usuario-chip .datos { display: none; }
    .encabezado h1 { font-size: 23px; }
    .grid-kpi { grid-template-columns: minmax(0, 1fr); }
    .resumen-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filtros { grid-template-columns: minmax(0, 1fr); }
    .detalle-grid { grid-template-columns: minmax(0, 1fr); }
    .bitacora-vivo .item { grid-template-columns: 50px 1fr; }
    .bitacora-vivo .item .msg { grid-column: 1 / -1; white-space: normal; }
    .card-cab, .card-cuerpo { padding-left: 16px; padding-right: 16px; }
    .modal-cab, .modal-cuerpo, .modal-pie { padding-left: 18px; padding-right: 18px; }
    .acceso-form { padding: 32px 22px; }
    .lista-def { grid-template-columns: 1fr; gap: 2px; }
    .lista-def dd { margin-bottom: 10px; }
}
