:root {
    --bg: #07090d;
    --bg2: #101217;
    --panel: rgba(18, 20, 27, 0.84);
    --panel-strong: rgba(24, 27, 35, 0.94);
    --white: #f5f7fb;
    --white-soft: rgba(245, 247, 251, 0.76);
    --white-dim: rgba(245, 247, 251, 0.34);
    --red: #ff2e4d;
    --red-soft: #ff6b7f;
    --red-dark: #8b0f22;
    --muted: #a9afbd;
    --line: rgba(255, 46, 77, 0.26);
    --shadow: 0 26px 90px rgba(0, 0, 0, 0.62);
}

* {
    box-sizing: border-box;
}

body.login-body {
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
    color: var(--white);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.11), transparent 26%),
        radial-gradient(circle at 80% 74%, rgba(255, 46, 77, 0.16), transparent 30%),
        linear-gradient(135deg, #07090d 0%, #151820 52%, #050609 100%);
}

.login-bg-gradient {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(115deg, transparent 0 48%, rgba(255, 255, 255, 0.045) 49%, transparent 51% 100%),
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 46, 77, 0.045) 1px, transparent 1px);
    background-size: 220px 220px, 58px 58px, 58px 58px;
    animation: gridSlide 22s linear infinite;
}

.command-bg {
    position: fixed;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.command-bg::before {
    content: "";
    position: absolute;
    inset: -20%;
    background:
        conic-gradient(from 90deg at 50% 50%, transparent 0deg, rgba(255, 46, 77, 0.11) 42deg, transparent 86deg, transparent 360deg);
    animation: slowRotate 26s linear infinite;
    opacity: 0.66;
}

.command-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.024) 0px,
        rgba(255, 255, 255, 0.024) 1px,
        transparent 2px,
        transparent 7px
    );
    opacity: 0.34;
    animation: scanLines 7s linear infinite;
}

.hex-field {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(72vw, 920px);
    aspect-ratio: 1.35;
    transform: translate(-50%, -50%);
    opacity: 0.62;
    filter: drop-shadow(0 0 28px rgba(255, 46, 77, 0.20));
}

.hex-svg {
    width: 100%;
    height: 100%;
}

.hex-main {
    transform-origin: 50% 50%;
    animation: hexBreath 4.6s ease-in-out infinite;
}

.hex-ring {
    transform-origin: 50% 50%;
    animation: hexPulse 3.8s ease-out infinite;
}

.hex-ring.delay {
    animation-delay: 1.9s;
}

.route-path {
    stroke-dasharray: 12 18;
    animation: dashMove 2.4s linear infinite;
}

.alert-dot {
    animation: dotPulse 2s ease-in-out infinite;
}

.alert-dot:nth-of-type(2n) {
    animation-delay: .55s;
}

.alert-dot:nth-of-type(3n) {
    animation-delay: 1.1s;
}

.alert-beam {
    position: absolute;
    height: 2px;
    width: 38vw;
    background: linear-gradient(90deg, transparent, rgba(255, 46, 77, .88), rgba(255, 255, 255, .76), transparent);
    box-shadow: 0 0 18px rgba(255, 46, 77, .36);
    opacity: 0;
    animation: beamCross 6.5s ease-in-out infinite;
}

.alert-beam.b1 {
    left: 3vw;
    top: 21vh;
    transform: rotate(-8deg);
}

.alert-beam.b2 {
    right: 4vw;
    bottom: 22vh;
    transform: rotate(9deg);
    animation-delay: 2.4s;
}

.alert-beam.b3 {
    left: 31vw;
    top: 72vh;
    transform: rotate(2deg);
    animation-delay: 4.1s;
}

.side-module {
    position: absolute;
    width: 250px;
    padding: 14px 15px;
    border: 1px solid rgba(255, 255, 255, .17);
    border-left: 3px solid rgba(255, 46, 77, .82);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .025)),
        rgba(11, 13, 18, .66);
    box-shadow: 0 22px 60px rgba(0, 0, 0, .30), inset 0 1px 0 rgba(255, 255, 255, .06);
    backdrop-filter: blur(14px);
    font-family: "JetBrains Mono", monospace;
    opacity: 0;
    transform: translateY(10px);
    animation: moduleReveal 10s ease-in-out infinite;
}

.side-module::before,
.side-module::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-color: rgba(255, 46, 77, .72);
    border-style: solid;
}

.side-module::before {
    left: -1px;
    top: -1px;
    border-width: 1px 0 0 1px;
}

.side-module::after {
    right: -1px;
    bottom: -1px;
    border-width: 0 1px 1px 0;
}

.side-module.s1 {
    left: 5vw;
    top: 11vh;
    animation-delay: .3s;
}

.side-module.s2 {
    left: 6vw;
    bottom: 10vh;
    animation-delay: 3.2s;
}

.side-module.s3 {
    right: 5vw;
    top: 13vh;
    animation-delay: 1.8s;
}

.side-module.s4 {
    right: 6vw;
    bottom: 12vh;
    animation-delay: 5.2s;
}

.module-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--white);
    font-size: 10px;
    letter-spacing: .14em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.module-title span:last-child {
    color: var(--red-soft);
}

.module-value {
    color: var(--white);
    font-size: 23px;
    font-weight: 800;
    letter-spacing: -.04em;
}

.module-copy {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
}

.red-bars {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    align-items: end;
    height: 32px;
    margin-top: 12px;
}

.red-bars span {
    height: var(--h);
    background: linear-gradient(to top, rgba(255, 46, 77, .2), rgba(255, 46, 77, .95), rgba(255, 255, 255, .72));
    animation: redBar 1.35s ease-in-out infinite alternate;
}

.red-bars span:nth-child(2n) {
    animation-delay: .18s;
}

.red-bars span:nth-child(3n) {
    animation-delay: .36s;
}

.ticker {
    position: fixed;
    z-index: 4;
    left: 0;
    right: 0;
    top: 0;
    height: 32px;
    overflow: hidden;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    background: rgba(5, 6, 9, .42);
    backdrop-filter: blur(10px);
}

.ticker-track {
    display: inline-flex;
    align-items: center;
    height: 32px;
    gap: 36px;
    padding-left: 100%;
    color: rgba(245, 247, 251, .68);
    font-family: "JetBrains Mono", monospace;
    font-size: 10px;
    letter-spacing: .13em;
    white-space: nowrap;
    animation: tickerMove 28s linear infinite;
}

.ticker-track b {
    color: var(--red-soft);
    font-weight: 700;
}

.login-container {
    position: relative;
    z-index: 5;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 42px 24px 24px;
}

.login-card {
    position: relative;
    width: min(100%, 450px);
    padding: 36px 34px 34px;
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, .18);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, .105), rgba(255, 255, 255, .035)),
        rgba(11, 13, 18, .82);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .08);
    backdrop-filter: blur(24px);
    border-radius: 6px 34px 6px 34px;
    overflow: hidden;
}

.login-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(255, 46, 77, .72), transparent 34%) top left / 100% 2px no-repeat,
        linear-gradient(180deg, rgba(255, 46, 77, .72), transparent 38%) top left / 2px 100% no-repeat,
        linear-gradient(270deg, rgba(255, 255, 255, .34), transparent 36%) bottom right / 100% 1px no-repeat,
        linear-gradient(0deg, rgba(255, 255, 255, .34), transparent 36%) bottom right / 1px 100% no-repeat;
}

.login-card::after {
    content: "ACCESO SEGURO · PLATAFORMA CORPORATIVA";
    position: absolute;
    top: 14px;
    right: 16px;
    color: rgba(255, 46, 77, .72);
    font: 700 9px/1 "JetBrains Mono", monospace;
    letter-spacing: .15em;
}

.login-logo {
    text-align: center;
    margin-bottom: 26px;
}

.login-logo-badge {
    width: 78px;
    height: 78px;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    color: var(--white);
    font-size: 34px;
    border: 1px solid rgba(255, 255, 255, .22);
    background:
        radial-gradient(circle at 50% 40%, rgba(255, 255, 255, .28), transparent 36%),
        linear-gradient(135deg, rgba(255, 46, 77, .72), rgba(80, 8, 20, .78));
    box-shadow: 0 0 44px rgba(255, 46, 77, .22);
    clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%);
}

.login-logo h1 {
    margin: 0;
    color: var(--white);
    font-size: 25px;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.login-logo p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.form-label {
    color: rgba(245, 247, 251, .82);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .065em;
    text-transform: uppercase;
}

.form-control {
    height: 48px;
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, .17);
    background: rgba(5, 6, 9, .66);
    border-radius: 4px 16px 4px 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}

.form-control:focus {
    color: var(--white);
    background: rgba(8, 9, 13, .86);
    border-color: rgba(255, 46, 77, .86);
    box-shadow: 0 0 0 4px rgba(255, 46, 77, .13), 0 0 30px rgba(255, 46, 77, .16);
}

.btn-login {
    width: 100%;
    height: 50px;
    margin-top: 18px;
    border: 0;
    color: #fff;
    background:
        linear-gradient(135deg, #ff2e4d, #b20d27 56%, #fff 170%);
    border-radius: 4px 18px 4px 18px;
    font-weight: 900;
    letter-spacing: .07em;
    text-transform: uppercase;
    box-shadow: 0 18px 42px rgba(255, 46, 77, .24);
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 22px 52px rgba(255, 46, 77, .34);
    filter: brightness(1.08);
}

.btn-login:disabled {
    opacity: .65;
    cursor: not-allowed;
}

.btn-outline-info {
    color: var(--white);
    border-color: rgba(255, 46, 77, .55);
    background: rgba(255, 46, 77, .06);
    border-radius: 4px 16px 4px 16px;
}

.btn-outline-info:hover {
    color: #fff;
    background: var(--red);
    border-color: var(--red);
}

.login-error {
    display: none;
    margin-top: 14px;
    padding: 10px 12px;
    color: #fff;
    background: rgba(255, 46, 77, .13);
    border: 1px solid rgba(255, 46, 77, .38);
    border-radius: 4px 14px 4px 14px;
    font-size: 13px;
}

.text-muted {
    color: rgba(169, 175, 189, .82) !important;
}

.classification {
    position: fixed;
    z-index: 4;
    left: 22px;
    bottom: 18px;
    color: rgba(245, 247, 251, .52);
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    letter-spacing: .18em;
}

.classification b {
    color: var(--red-soft);
}

@keyframes gridSlide {
    from {
        background-position: 0 0, 0 0, 0 0;
    }

    to {
        background-position: 220px 220px, 58px 58px, 58px 58px;
    }
}

@keyframes slowRotate {
    to {
        transform: rotate(360deg);
    }
}

@keyframes scanLines {
    to {
        transform: translateY(56px);
    }
}

@keyframes hexBreath {
    0%,
    100% {
        transform: scale(.985);
        opacity: .82;
    }

    50% {
        transform: scale(1.025);
        opacity: 1;
    }
}

@keyframes hexPulse {
    0% {
        transform: scale(.8);
        opacity: 0;
    }

    24% {
        opacity: .78;
    }

    100% {
        transform: scale(1.22);
        opacity: 0;
    }
}

@keyframes dashMove {
    to {
        stroke-dashoffset: -60;
    }
}

@keyframes dotPulse {
    0%,
    100% {
        opacity: .34;
        r: 4;
    }

    45% {
        opacity: 1;
        r: 7;
    }
}

@keyframes beamCross {
    0%,
    18% {
        opacity: 0;
        transform: translateX(-18px) rotate(var(--r, 0deg));
    }

    35%,
    58% {
        opacity: .84;
    }

    80%,
    100% {
        opacity: 0;
        transform: translateX(18px) rotate(var(--r, 0deg));
    }
}

@keyframes moduleReveal {
    0%,
    10% {
        opacity: 0;
        transform: translateY(12px);
    }

    22%,
    68% {
        opacity: .92;
        transform: translateY(0);
    }

    82%,
    100% {
        opacity: 0;
        transform: translateY(-10px);
    }
}

@keyframes redBar {
    to {
        transform: scaleY(.42);
        opacity: .55;
    }
}

@keyframes tickerMove {
    to {
        transform: translateX(-100%);
    }
}

@media (max-width: 980px) {
    .hex-field {
        width: 112vw;
        opacity: .34;
    }

    .side-module {
        display: none;
    }

    .login-card {
        padding: 34px 24px 30px;
    }

    .login-card::after {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

html[data-theme="opn_portada"] {
    --bg: #030812;
    --bg2: #081321;
    --panel: rgba(7, 18, 31, 0.86);
    --panel-strong: rgba(10, 24, 40, 0.94);
    --red: #d9a94b;
    --red-soft: #f8d37a;
    --red-dark: #6b4a16;
    --line: rgba(217, 169, 75, 0.28);
}

html[data-theme="opn_portada"] body.login-body {
    background:
        radial-gradient(circle at 16% 18%, rgba(78, 215, 255, 0.18), transparent 28%),
        radial-gradient(circle at 82% 74%, rgba(217, 169, 75, 0.18), transparent 32%),
        linear-gradient(135deg, rgba(2, 6, 14, 0.86), rgba(4, 12, 23, 0.94)),
        url("/static/img/themes/opn-portada/opn-portada-bg.webp") center / cover fixed no-repeat;
}

html[data-theme="opn_portada"] .login-bg-gradient {
    background:
        linear-gradient(115deg, transparent 0 48%, rgba(217, 169, 75, 0.08) 49%, transparent 51% 100%),
        linear-gradient(rgba(78, 215, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(217, 169, 75, 0.045) 1px, transparent 1px);
}

html[data-theme="opn_portada"] .command-bg::before {
    background: conic-gradient(from 90deg at 50% 50%, transparent 0deg, rgba(217, 169, 75, 0.12) 42deg, transparent 86deg, transparent 360deg);
}

html[data-theme="opn_portada"] .hex-field {
    filter: drop-shadow(0 0 30px rgba(78, 215, 255, 0.18));
}

html[data-theme="opn_portada"] #redLine stop:first-child {
    stop-color: #ffffff;
}

html[data-theme="opn_portada"] #redLine stop:nth-child(2) {
    stop-color: #d9a94b;
}

html[data-theme="opn_portada"] #redLine stop:last-child {
    stop-color: #4ed7ff;
}

html[data-theme="opn_portada"] .hex-ring,
html[data-theme="opn_portada"] .route-path {
    stroke: #d9a94b;
}

html[data-theme="opn_portada"] .alert-dot {
    fill: #f8d37a;
}

html[data-theme="opn_portada"] .side-module {
    border-left-color: rgba(217, 169, 75, 0.88);
    background:
        linear-gradient(135deg, rgba(78, 215, 255, 0.10), rgba(217, 169, 75, 0.045)),
        rgba(7, 18, 31, 0.72);
}

html[data-theme="opn_portada"] .login-card {
    border-color: rgba(217, 169, 75, 0.26);
    box-shadow: 0 30px 92px rgba(0, 0, 0, 0.62), 0 0 48px rgba(78, 215, 255, 0.08);
}

html[data-brand="risk"] {
    --bg: #4A0400;
    --bg2: #300300;
    --panel: rgba(74, 4, 0, 0.88);
    --panel-strong: rgba(56, 3, 0, 0.96);
    --red: var(--sev-critical);
    --red-soft: var(--sev-low);
    --red-dark: #4A0400;
    --muted: #D8A9A2;
    --line: rgba(199, 154, 75, 0.32);
    --shadow: 0 26px 80px rgba(35, 2, 0, 0.46);
}

html[data-brand="risk"] body.login-body {
    background: #4A0400;
    font-family: var(--font-ui);
}

html[data-brand="risk"] .login-bg-gradient {
    background:
        linear-gradient(rgba(240, 212, 138, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(240, 212, 138, 0.035) 1px, transparent 1px);
    background-size: 58px 58px;
}

html[data-brand="risk"] .command-bg::before {
    background: conic-gradient(from 90deg at 50% 50%, transparent 0deg, rgba(255, 158, 0, 0.10) 42deg, transparent 86deg, transparent 360deg);
}

html[data-brand="risk"] .hex-field {
    filter: drop-shadow(0 0 28px rgba(255, 158, 0, 0.14));
}

html[data-brand="risk"] #redLine stop:first-child {
    stop-color: #FFFFFF;
}

html[data-brand="risk"] #redLine stop:nth-child(2) {
    stop-color: var(--sev-low);
}

html[data-brand="risk"] #redLine stop:last-child {
    stop-color: var(--sev-critical);
}

html[data-brand="risk"] .hex-ring,
html[data-brand="risk"] .route-path {
    stroke: var(--opn-gold);
}

html[data-brand="risk"] .alert-dot {
    fill: var(--sev-low);
}

html[data-brand="risk"] .side-module {
    border-left-color: var(--opn-gold);
    background: rgba(56, 3, 0, 0.76);
    box-shadow: none;
}

html[data-brand="risk"] .side-module::before,
html[data-brand="risk"] .side-module::after {
    border-color: var(--opn-gold);
}

html[data-brand="risk"] .module-title span:last-child,
html[data-brand="risk"] .ticker-track b,
html[data-brand="risk"] .classification b {
    color: var(--opn-gold-light);
}

html[data-brand="risk"] .login-card {
    background: rgba(56, 3, 0, 0.94);
    border-color: rgba(199, 154, 75, 0.44);
    border-radius: 6px;
    box-shadow: var(--shadow);
}

html[data-brand="risk"] .login-card::before {
    background:
        linear-gradient(90deg, var(--opn-gold), transparent 34%) top left / 100% 2px no-repeat,
        linear-gradient(180deg, var(--opn-gold), transparent 38%) top left / 2px 100% no-repeat;
}

html[data-brand="risk"] .login-card::after {
    content: "CONTROL Y PROTECCIÓN";
    color: var(--opn-gold);
    letter-spacing: 0;
}

html[data-brand="risk"] .login-logo-badge {
    background: transparent;
    border: 0;
    box-shadow: none;
    clip-path: none;
}

html[data-brand="risk"] .login-logo-badge img {
    width: 72px;
    height: 72px;
    object-fit: contain;
}

html[data-brand="risk"] .login-logo h1 {
    color: #FFFFFF;
    letter-spacing: 0;
}

html[data-brand="risk"] .login-logo p {
    color: var(--brand-sidebar-text, #D8A9A2);
}

html[data-brand="risk"] .form-control {
    background: rgba(35, 2, 0, 0.72);
    border-color: rgba(216, 169, 162, 0.34);
    border-radius: 6px;
}

html[data-brand="risk"] .form-control:focus {
    background: rgba(35, 2, 0, 0.90);
    border-color: var(--opn-gold);
    box-shadow: 0 0 0 3px rgba(199, 154, 75, 0.16);
}

html[data-brand="risk"] .btn-login {
    background: var(--sev-critical);
    border: 1px solid var(--sev-critical);
    border-bottom: 2px solid var(--opn-gold);
    border-radius: 6px;
    box-shadow: none;
    letter-spacing: 0;
}

html[data-brand="risk"] .btn-login:hover {
    background: #6F0601;
    box-shadow: none;
    filter: none;
}
