:root {
    --blue-950: #0a2f47;
    --blue-900: #0c3f61;
    --blue-700: #1f6f99;
    --blue-500: #3f94bf;
    --blue-100: #e9f4fb;
    --orange-500: #f28a2f;
    --orange-600: #e46d1e;
    --orange-200: #ffd7ad;
    --ink: #17354f;
    --muted: #57748b;
    --card: #f7fafc;
    --line: #d9e6ef;
}

* {
    box-sizing: border-box;
}

html {
    width: 100%;
    min-height: 100%;
    background: #071f33;
}

body {
    margin: 0;
    position: relative;
    isolation: isolate;
    width: 100%;
    min-height: 100%;
    font-family: "Trebuchet MS", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--ink);
    overflow-x: hidden;
    background: transparent;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
}

body::before {
    z-index: -2;
    background: url("../imagenes/background.png") center calc(62% + 10px) / cover no-repeat;
    filter: blur(3px) saturate(1.22) brightness(0.96);
    transform: scale(1.02);
}

body::after {
    z-index: -1;
    background:
        radial-gradient(120% 75% at 50% 20%, rgba(66, 191, 255, 0.24), rgba(4, 26, 45, 0.42)),
        linear-gradient(160deg, rgba(0, 126, 255, 0.34) 0%, rgba(3, 56, 94, 0.48) 45%, rgba(0, 162, 255, 0.3) 100%);
}

body.is-redirecting {
    overflow: hidden;
}

.layout {
    min-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(16px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
}

.devices-layout {
    position: relative;
    isolation: isolate;
    width: 100%;
    min-height: 100vh;
    align-items: flex-start;
    padding-left: 8px;
    padding-right: 8px;
}

.devices-layout::before,
.devices-layout::after {
    content: "";
    position: fixed;
    z-index: -1;
    pointer-events: none;
    filter: blur(10px);
}

.devices-layout::before {
    width: 300px;
    height: 300px;
    right: -90px;
    top: -60px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 205, 134, 0.45), rgba(255, 205, 134, 0));
}

.devices-layout::after {
    width: 330px;
    height: 330px;
    left: -120px;
    bottom: -130px;
    border-radius: 50%;
    background: radial-gradient(circle at 60% 40%, rgba(125, 214, 255, 0.35), rgba(125, 214, 255, 0));
}

.card {
    width: min(100%, 460px);
    margin: 0 auto;
    background: linear-gradient(145deg, rgba(250, 253, 255, 0.96), rgba(237, 247, 255, 0.92));
    border: 1px solid rgba(217, 230, 239, 0.82);
    border-radius: 20px;
    box-shadow: 0 18px 32px rgba(7, 38, 59, 0.24);
    backdrop-filter: blur(8px);
}

.login-card {
    position: relative;
    padding: 22px;
    overflow: hidden;
}

.login-card::before {
    content: "";
    position: absolute;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    top: -70px;
    right: -70px;
    background: radial-gradient(circle at 30% 30%, rgba(242, 138, 47, 0.22), rgba(242, 138, 47, 0));
    pointer-events: none;
}

.redirect-layout {
    padding: 24px;
}

.redirect-screen {
    width: min(100%, 360px);
    text-align: center;
    border: 1px solid rgba(227, 240, 249, 0.8);
    border-radius: 22px;
    padding: 28px 24px;
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.94), rgba(236, 247, 255, 0.9));
    box-shadow: 0 22px 38px rgba(7, 38, 59, 0.24);
    backdrop-filter: blur(10px);
}

.redirect-screen-overlay {
    width: min(100%, 320px);
}

.redirect-logo {
    width: 104px;
    height: 104px;
    display: block;
    margin: 0 auto 18px;
    filter: drop-shadow(0 12px 20px rgba(13, 78, 104, 0.18));
    transform-origin: center;
}

.redirect-title {
    margin: 0;
    font-size: 1.28rem;
    font-weight: 700;
    color: #1a5576;
}

.redirect-copy {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.96rem;
}

.redirect-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(8, 34, 53, 0.42);
    backdrop-filter: blur(6px);
}

.redirect-overlay[hidden] {
    display: none;
}

.is-spinning {
    animation: logoSpin 1s linear infinite;
}

h1 {
    margin: 0;
    line-height: 1.08;
    font-size: clamp(1.52rem, 7.2vw, 2.05rem);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: #ffb56f;
    letter-spacing: 0.2px;
    overflow-wrap: anywhere;
}

.sub {
    margin: 10px 0 18px;
    color: var(--muted);
    font-size: 0.95rem;
    max-width: 34ch;
}

.devices-panel {
    width: min(100%, 1020px);
    max-width: none;
    padding: 14px;
    border: 1px solid rgba(234, 245, 255, 0.65);
    background:
        linear-gradient(145deg, rgba(250, 253, 255, 0.95), rgba(239, 248, 255, 0.9));
    backdrop-filter: blur(8px);
}

.devices-header {
    width: 100%;
    margin: 0 auto 14px;
}

.options-back-link {
    display: inline-block;
    margin-top: 8px;
    padding: 9px 14px;
    border-radius: 999px;
    border: 1px solid #b7d9ef;
    background: #eef8ff;
    color: #1f5d84;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.8rem;
    box-shadow: 0 6px 12px rgba(17, 71, 103, 0.08);
}

.options-back-link:hover {
    background: #d8ecfb;
}

.eyebrow {
    margin: 0 0 8px;
    display: inline-block;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #1f5d84;
    border: 1px solid #b9d7eb;
    background: #e8f5ff;
}

.devices-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
    margin: 0 auto;
}

@media (min-width: 500px) {
    .devices-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }
}

.device-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid #d9ebf7;
    border-radius: 16px;
    background:
        radial-gradient(130% 100% at 10% 0%, rgba(255, 255, 255, 0.95), transparent 70%),
        linear-gradient(180deg, #ffffff 0%, #f0f8fe 100%);
    padding: 12px;
    box-shadow: 0 10px 20px rgba(17, 71, 103, 0.11);
    animation: deviceFadeUp 0.42s ease both;
}

.device-card:nth-child(2) {
    animation-delay: 0.07s;
}

.device-card:nth-child(3) {
    animation-delay: 0.14s;
}

.device-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 24px rgba(17, 71, 103, 0.18);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.device-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #e1edf6;
}

.device-card h2 {
    margin: 0;
    min-width: 0;
    color: #1f5d84;
    font-size: 1.08rem;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    overflow-wrap: anywhere;
}

.status-dot {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #0f5b38;
    background: #daf5e7;
    border: 1px solid #b5e9cf;
    white-space: nowrap;
}

.status-dot--offline {
    color: #7a2020;
    background: #fde8e8;
    border-color: #f5b8b8;
}

.device-card--offline {
    opacity: 0.86;
    border-color: #f2d0d0;
    background:
        radial-gradient(130% 100% at 10% 0%, rgba(255, 255, 255, 0.9), transparent 70%),
        linear-gradient(180deg, #fff8f8 0%, #fdf0f0 100%);
}

.device-card--offline button:disabled {
    background: linear-gradient(135deg, #c0c0c0 0%, #a8a8a8 70%);
    color: #5a5a5a;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

.device-data {
    display: grid;
    gap: 7px;
    margin-bottom: 13px;
}

.device-data p {
    margin: 0;
    border-radius: 9px;
    border: 1px solid #deecf5;
    padding: 8px 9px;
    background: #f7fbff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.device-data strong {
    color: #315671;
    font-size: 0.78rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.device-data span {
    font-weight: 600;
    color: #1f5d84;
    font-family: "Consolas", "Courier New", monospace;
    word-break: break-word;
}

.device-users {
    margin-bottom: 0;
    border-radius: 10px;
    border: 1px solid #deecf5;
    background: #f7fbff;
    padding: 10px;
}

.device-users strong {
    display: block;
    margin-bottom: 8px;
    color: #315671;
    font-size: 0.78rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.device-users-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.device-user-chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid #cddfeb;
    background: #ffffff;
    color: #1f5d84;
    font-size: 0.76rem;
    font-weight: 600;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.device-users-empty {
    margin: 0;
    color: #547086;
    font-size: 0.84rem;
    font-style: italic;
}

form {
    display: grid;
    gap: 11px;
    width: 100%;
    margin-top: 0;
}

.login-card form {
    margin-top: 14px;
}

.pw-field {
    position: relative;
    margin-bottom: 0;
}

.pw-field input {
    padding-right: 44px;
}

.pw-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 4px;
    margin: 0;
    cursor: pointer;
    color: var(--muted);
    box-shadow: none;
    border-radius: 6px;
    transition: color 0.15s;
}

.pw-toggle:hover {
    color: var(--blue-700);
    filter: none;
    transform: translateY(-50%);
}

.pw-toggle:active {
    transform: translateY(-50%);
}

.pw-toggle:focus-visible {
    outline: 2px solid #5fa1cb;
    outline-offset: 2px;
}

.eye-icon,
.eye-off-icon {
    width: 20px;
    height: 20px;
}

input {
    width: 100%;
    display: block;
    border: 1px solid #c8dcea;
    background: var(--blue-100);
    border-radius: 12px;
    padding: 12px 12px;
    font-size: 16px;
    color: #1d4b6e;
    outline: none;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    -webkit-transition: box-shadow 0.2s ease, border-color 0.2s ease;
    -moz-transition: box-shadow 0.2s ease, border-color 0.2s ease;
    -ms-transition: box-shadow 0.2s ease, border-color 0.2s ease;
    -o-transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

input:focus {
    border-color: #65a3ca;
    box-shadow: 0 0 0 3px rgba(61, 131, 174, 0.18), 0 7px 14px rgba(18, 78, 112, 0.13);
}

button {
    width: 100%;
    display: block;
    margin-top: 2px;
    border: 0;
    border-radius: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #f4a258 0%, var(--orange-500) 70%);
    color: #1d3347;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(242, 138, 47, 0.28);
    -webkit-appearance: none;
    appearance: none;
}

button:hover {
    filter: brightness(0.98);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
.options-back-link:focus-visible {
    outline: 2px solid #5fa1cb;
    outline-offset: 2px;
}

pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 12px 0 0;
    border-radius: 10px;
    padding: 10px;
    background: #f2f8fc;
    border: 1px solid #d4e4ef;
    color: #2f5370;
    font-size: 0.84rem;
    min-height: 44px;
}

@keyframes deviceFadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes logoSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@media (min-width: 768px) {
    .layout {
        padding: 38px 26px;
    }

    .devices-layout {
        padding-left: 12px;
        padding-right: 12px;
    }

    .card {
        max-width: 560px;
        border-radius: 24px;
    }

    .login-card {
        padding: 36px;
    }

    .login-card form {
        max-width: 430px;
    }

    h1 {
        font-size: 2.5rem;
    }

    .sub {
        font-size: 1rem;
    }

    .devices-panel {
        width: min(100%, 1120px);
        max-width: 1120px;
        padding: 18px;
        overflow: visible;
    }

    .devices-grid {
        width: 100%;
        gap: 18px;
    }

    .devices-header {
        width: 100%;
        margin-bottom: 18px;
    }

    .device-card {
        padding: 18px;
        min-height: 0;
    }

    .device-users {
        padding: 11px;
    }

    .device-card h2 {
        font-size: 1.14rem;
    }

    .status-dot {
        font-size: 0.74rem;
    }
}

@media (min-width: 1024px) {
    .layout {
        padding: 36px 18px;
    }

    .card {
        border-radius: 26px;
    }

    .login-card {
        padding: 34px;
    }

    .devices-panel {
        width: min(100%, 1200px);
        max-width: 1200px;
        padding: 22px;
    }

    .devices-header {
        width: 100%;
    }

    .devices-grid {
        width: 100%;
        grid-template-columns: repeat(3, minmax(240px, 1fr));
        gap: 20px;
    }

    .device-card {
        border-radius: 18px;
        min-height: 0;
    }

    .device-card h2 {
        font-size: 1.18rem;
    }

    .device-data p {
        min-height: 44px;
    }
}

@media (min-width: 1360px) {
    .devices-panel {
        width: min(100%, 1220px);
        max-width: 1220px;
        padding: 24px;
    }

    .devices-header {
        width: 100%;
    }

    .devices-grid {
        width: 100%;
        gap: 22px;
    }

    .device-card {
        min-height: 0;
    }
}
