/* ==========================================================================
   INVENTARIO TI — ACCESO
   Panel de instrumentación + tarjeta de cristal · claro / oscuro
   ========================================================================== */

:root {
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
    --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
    --font-body: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', Consolas, monospace;

    --r-sm: 12px;
    --r-md: 16px;
    --r-lg: 24px;

    /* Claro por defecto */
    --bg: #E9EDF4;
    --panel: rgba(255, 255, 255, .72);
    --panel-brd: rgba(255, 255, 255, .9);
    --field: rgba(255, 255, 255, .55);
    --ink: #0F1626;
    --ink-2: #3B475F;
    --ink-3: #6B7793;
    --ink-4: #98A3B9;
    --hairline: rgba(16, 22, 35, .1);
    --shadow: 0 4px 12px rgba(16, 22, 35, .07), 0 34px 70px rgba(16, 22, 35, .16);
    --canvas-line: rgba(15, 22, 38, .55);

    --acc: #E11D2E;
    --acc-2: #FF6A3D;
    --acc-rgb: 225, 29, 46;
}

[data-bs-theme="dark"] {
    --bg: #05070C;
    --panel: rgba(20, 26, 39, .66);
    --panel-brd: rgba(255, 255, 255, .1);
    --field: rgba(255, 255, 255, .045);
    --ink: #EAEEF8;
    --ink-2: #C4CCDD;
    --ink-3: #8D9AB4;
    --ink-4: #616E87;
    --hairline: rgba(255, 255, 255, .1);
    --shadow: 0 8px 20px rgba(0, 0, 0, .55), 0 42px 90px rgba(0, 0, 0, .7);
    --canvas-line: rgba(150, 180, 230, .75);

    --acc: #FF4D5E;
    --acc-rgb: 255, 77, 94;
}

[data-theme="rojo"]     { --acc: #E11D2E; --acc-2: #FF6A3D; --acc-rgb: 225, 29, 46; }
[data-theme="cobalto"]  { --acc: #2563EB; --acc-2: #22D3EE; --acc-rgb: 37, 99, 235; }
[data-theme="terminal"] { --acc: #059669; --acc-2: #A3E635; --acc-rgb: 5, 150, 105; }
[data-theme="nebulosa"] { --acc: #7C3AED; --acc-2: #EC4899; --acc-rgb: 124, 58, 237; }
[data-theme="circuito"] { --acc: #EA580C; --acc-2: #FACC15; --acc-rgb: 234, 88, 12; }
[data-theme="titanio"]  { --acc: #0891B2; --acc-2: #6366F1; --acc-rgb: 8, 145, 178; }
[data-bs-theme="dark"][data-theme="rojo"]     { --acc: #FF4D5E; --acc-rgb: 255, 77, 94; }
[data-bs-theme="dark"][data-theme="cobalto"]  { --acc: #4F8CFF; --acc-rgb: 79, 140, 255; }
[data-bs-theme="dark"][data-theme="terminal"] { --acc: #22D08A; --acc-rgb: 34, 208, 138; }
[data-bs-theme="dark"][data-theme="nebulosa"] { --acc: #A57BFF; --acc-rgb: 165, 123, 255; }
[data-bs-theme="dark"][data-theme="circuito"] { --acc: #FB923C; --acc-rgb: 251, 146, 60; }
[data-bs-theme="dark"][data-theme="titanio"]  { --acc: #22C7E8; --acc-rgb: 34, 199, 232; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--bg);
    overflow: hidden;
    letter-spacing: -.011em;
    -webkit-font-smoothing: antialiased;
    transition: background-color .5s var(--ease-out), color .35s var(--ease-out);
}

/* --- Lienzo animado de nodos --- */
#field {
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: .55;
}
[data-bs-theme="dark"] #field { opacity: .8; }

.halo {
    position: fixed;
    z-index: 0;
    border-radius: 50%;
    filter: blur(100px);
    pointer-events: none;
    will-change: transform;
}
.halo.a {
    width: 50vw; height: 50vw;
    top: -18vw; left: -12vw;
    background: radial-gradient(circle, rgba(var(--acc-rgb), .35), transparent 68%);
    animation: float-a 22s ease-in-out infinite alternate;
}
.halo.b {
    width: 44vw; height: 44vw;
    bottom: -18vw; right: -10vw;
    background: radial-gradient(circle, rgba(90, 130, 220, .3), transparent 68%);
    animation: float-b 28s ease-in-out infinite alternate;
}
@keyframes float-a { to { transform: translate(7vw, 6vh) scale(1.18); } }
@keyframes float-b { to { transform: translate(-6vw, -5vh) scale(1.12); } }

/* --- Estructura --- */
.stage {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 560px) minmax(0, 430px);
    justify-content: center;
    align-items: center;
    gap: clamp(2.5rem, 5vw, 4rem);
    max-width: 1160px;
    margin-inline: auto;
    padding: 2.5rem clamp(1.2rem, 4vw, 2.5rem);
}

/* --- Columna izquierda: lectura del sistema --- */
.readout { max-width: 560px; animation: rise .8s var(--ease-out) both; }

.readout .tag {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    padding: .4rem .85rem;
    margin-bottom: 1.8rem;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    background: var(--field);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-family: var(--font-mono);
    font-size: .68rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink-3);
}
.tag .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 10px #10B981;
    animation: blink 2.2s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.readout h1 {
    font-family: var(--font-display);
    font-size: clamp(2.3rem, 4.6vw, 3.7rem);
    font-weight: 700;
    line-height: 1.02;
    letter-spacing: -.045em;
    margin-bottom: 1.1rem;
}
.readout h1 .grad {
    background: linear-gradient(100deg, var(--acc), var(--acc-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.readout p.lede {
    font-size: 1.02rem;
    line-height: 1.65;
    color: var(--ink-3);
    max-width: 44ch;
    margin-bottom: 2.2rem;
}

/* Consola de métricas */
.console {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .8rem;
    max-width: 480px;
}
.console .cell {
    padding: .9rem 1rem;
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    background: var(--field);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    animation: rise .8s var(--ease-out) both;
}
.console .cell:nth-child(2) { animation-delay: .09s; }
.console .cell:nth-child(3) { animation-delay: .18s; }
.console .k {
    font-family: var(--font-mono);
    font-size: .6rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink-4);
    display: block;
    margin-bottom: .35rem;
}
.console .v {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -.04em;
    color: var(--ink);
}
.console .v small { font-size: .62em; color: var(--ink-3); font-weight: 500; }

@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

/* --- Columna derecha: tarjeta de acceso --- */
.card-wrap { display: flex; justify-content: center; }

.access {
    position: relative;
    width: min(430px, 100%);
    padding: 2.4rem 2.2rem 1.8rem;
    border: 1px solid var(--panel-brd);
    border-radius: var(--r-lg);
    background: var(--panel);
    backdrop-filter: blur(26px) saturate(180%);
    -webkit-backdrop-filter: blur(26px) saturate(180%);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .55);
    overflow: hidden;
    animation: card-in .85s var(--ease-out) both .12s;
}
[data-bs-theme="dark"] .access { box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .06); }
@keyframes card-in { from { opacity: 0; transform: translateY(30px) scale(.97); } to { opacity: 1; transform: none; } }

/* Línea de escaneo al autenticar */
.access::after {
    content: '';
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--acc), transparent);
    box-shadow: 0 0 18px 2px rgba(var(--acc-rgb), .6);
    opacity: 0;
    pointer-events: none;
}
.access.scanning::after { animation: scan 1.1s linear infinite; }
@keyframes scan {
    0%   { opacity: 0; transform: translateY(0); }
    12%  { opacity: 1; }
    88%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(430px); }
}

.access.shake { animation: shake .5s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-7px); }
    40%, 60% { transform: translateX(7px); }
}

.access-head { text-align: center; margin-bottom: 1.9rem; }
.logo-plate {
    width: 92px;
    min-height: 62px;
    margin: 0 auto 1.15rem;
    padding: 9px 12px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 26px rgba(16, 22, 35, .16), 0 0 0 1px var(--hairline);
    transition: transform .5s var(--ease-spring);
}
.logo-plate:hover { transform: translateY(-3px) scale(1.04); }
.logo-plate img { max-width: 100%; max-height: 54px; object-fit: contain; display: block; }

.access-head h2 {
    font-family: var(--font-display);
    font-size: 1.42rem;
    font-weight: 700;
    letter-spacing: -.035em;
    margin-bottom: .3rem;
}
.access-head p {
    font-family: var(--font-mono);
    font-size: .67rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--ink-4);
}

/* Campos */
.field { margin-bottom: 1.05rem; }
.field label {
    display: block;
    font-size: .76rem;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: .42rem;
    letter-spacing: .01em;
}
.control { position: relative; display: flex; align-items: center; }
.control > i.pre {
    position: absolute;
    left: .95rem;
    font-size: 1rem;
    color: var(--ink-4);
    pointer-events: none;
    transition: color .2s var(--ease-out);
}
.control input {
    width: 100%;
    padding: .88rem 1rem .88rem 2.75rem;
    border: 1px solid var(--hairline);
    border-radius: var(--r-sm);
    background: var(--field);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: .93rem;
    outline: 0;
    transition: border-color .2s var(--ease-out), box-shadow .2s var(--ease-out), background .2s var(--ease-out);
}
.control input::placeholder { color: var(--ink-4); }
.control input:focus {
    border-color: var(--acc);
    box-shadow: 0 0 0 4px rgba(var(--acc-rgb), .16);
}
.control:focus-within > i.pre { color: var(--acc); }
.control input[type="password"] { padding-right: 3rem; letter-spacing: .12em; }

.peek {
    position: absolute;
    right: .5rem;
    width: 34px; height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--ink-4);
    cursor: pointer;
    transition: color .18s, background .18s;
}
.peek:hover { color: var(--acc); background: rgba(var(--acc-rgb), .1); }

/* Botón */
.enter {
    position: relative;
    width: 100%;
    margin-top: .55rem;
    padding: .95rem 1.2rem;
    border: 0;
    border-radius: var(--r-sm);
    background: linear-gradient(100deg, var(--acc), var(--acc-2));
    color: #fff;
    font-family: var(--font-body);
    font-size: .93rem;
    font-weight: 700;
    letter-spacing: -.01em;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(var(--acc-rgb), .38);
    transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out), filter .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
}
.enter:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(var(--acc-rgb), .5); }
.enter:active:not(:disabled) { transform: translateY(0) scale(.985); }
.enter:disabled { cursor: wait; filter: saturate(.65); }
.enter::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, .35) 50%, transparent 80%);
    transform: translateX(-100%);
}
.enter:hover:not(:disabled)::before { animation: sheen .9s var(--ease-out); }
@keyframes sheen { to { transform: translateX(100%); } }

.spinner {
    width: 15px; height: 15px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: none;
}
.enter.busy .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.foot {
    margin-top: 1.5rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    font-family: var(--font-mono);
    font-size: .63rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-4);
}

/* Interruptor de tema flotante */
.theme-fab {
    position: fixed;
    top: 22px; right: 22px;
    z-index: 20;
    width: 44px; height: 44px;
    border: 1px solid var(--hairline);
    border-radius: 14px;
    background: var(--panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: var(--ink-2);
    cursor: pointer;
    overflow: hidden;
    transition: transform .2s var(--ease-out), color .2s, border-color .2s;
}
.theme-fab:hover { transform: translateY(-2px) rotate(8deg); color: var(--acc); border-color: rgba(var(--acc-rgb), .4); }
.theme-fab i {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
    transition: transform .38s var(--ease-out), opacity .38s var(--ease-out);
}
.theme-fab .ico-sun { transform: translateY(0); opacity: 1; }
.theme-fab .ico-moon { transform: translateY(130%); opacity: 0; }
[data-bs-theme="dark"] .theme-fab .ico-sun { transform: translateY(-130%); opacity: 0; }
[data-bs-theme="dark"] .theme-fab .ico-moon { transform: translateY(0); opacity: 1; }

/* --- Responsivo --- */
@media (max-width: 991.98px) {
    body { overflow-y: auto; }
    .stage {
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 2.5rem;
        padding: 5rem 1.3rem 3rem;
    }
    .readout { text-align: center; max-width: 560px; }
    .readout p.lede { margin-left: auto; margin-right: auto; }
    .console { margin: 0 auto; max-width: 440px; }
    .card-wrap { justify-content: center; width: 100%; }
}

@media (max-width: 575.98px) {
    .stage { padding: 4.5rem 1rem 2.5rem; }
    .readout h1 { font-size: 2.1rem; }
    .readout p.lede { font-size: .93rem; margin-bottom: 1.6rem; }
    .console { grid-template-columns: 1fr; gap: .6rem; }
    .console .cell { display: flex; align-items: center; justify-content: space-between; padding: .7rem .9rem; }
    .console .k { margin: 0; }
    .access { padding: 1.9rem 1.4rem 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
    #field { display: none; }
}
