:root {
    --bg: #08111f;
    --panel: rgba(8, 17, 31, 0.82);
    --panel-border: rgba(104, 129, 162, 0.24);
    --text: #e8f0ff;
    --muted: #8fa6c2;
    --ok: #1fd18a;
    --warning: #f5b53d;
    --critical: #ff5d6c;
    --card-radius: 22px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(31, 209, 138, 0.12), transparent 24%),
        radial-gradient(circle at bottom right, rgba(53, 126, 255, 0.16), transparent 28%),
        linear-gradient(180deg, #07101b 0%, #0b1728 100%);
    color: var(--text);
}

body {
    min-width: 320px;
}

.eyebrow {
    margin: 0 0 10px;
    color: #87d7ff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.28em;
    text-transform: uppercase;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 560px);
    padding: 36px;
    border-radius: 30px;
    border: 1px solid var(--panel-border);
    background: rgba(8, 17, 31, 0.88);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(14px);
}

.login-card h1,
.topbar h1 {
    margin: 0;
    font-size: clamp(34px, 4vw, 44px);
    line-height: 1.05;
}

.login-copy,
.subtitle {
    margin: 14px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.login-form {
    margin-top: 28px;
    display: grid;
    gap: 14px;
}

.login-form label {
    font-size: 14px;
    color: var(--muted);
}

.login-form input {
    width: 100%;
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid rgba(123, 146, 179, 0.28);
    background: rgba(15, 27, 45, 0.9);
    color: var(--text);
    font-size: 16px;
}

.login-form button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 22px;
    border: 0;
    border-radius: 18px;
    background: linear-gradient(135deg, #1dd0ff, #3f8cff);
    color: #051221;
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    cursor: pointer;
}

.form-error {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 93, 108, 0.35);
    background: rgba(90, 14, 22, 0.5);
    color: #ffc4cb;
}

.app-shell {
    min-height: 100vh;
    padding: 18px;
    display: grid;
    gap: 16px;
    grid-template-rows: auto 1fr auto;
}

.topbar,
.board-panel {
    border-radius: 28px;
    border: 1px solid var(--panel-border);
    background: var(--panel);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(14px);
}

.topbar {
    display: grid;
    grid-template-columns: minmax(280px, 1.6fr) minmax(300px, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 16px 18px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.summary-card {
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(123, 146, 179, 0.18);
    background: rgba(14, 24, 40, 0.78);
    text-decoration: none;
    color: var(--text);
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.summary-card:hover {
    transform: translateY(-1px);
    border-color: rgba(157, 213, 255, 0.3);
    box-shadow: 0 10px 24px rgba(4, 10, 20, 0.25);
}

.summary-card-active {
    background: rgba(26, 46, 74, 0.95);
    border-color: rgba(157, 213, 255, 0.48);
    box-shadow:
        inset 0 0 0 1px rgba(157, 213, 255, 0.12),
        0 12px 26px rgba(7, 15, 28, 0.24);
}

.summary-card span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
}

.summary-card strong {
    display: block;
    margin-top: 6px;
    font-size: 24px;
}

.summary-card-ok {
    border-color: rgba(31, 209, 138, 0.4);
    background: linear-gradient(180deg, rgba(9, 50, 38, 0.92), rgba(12, 29, 35, 0.94));
    box-shadow: inset 0 0 0 1px rgba(31, 209, 138, 0.08);
}

.summary-card-warning {
    border-color: rgba(245, 181, 61, 0.42);
    background: linear-gradient(180deg, rgba(70, 46, 8, 0.92), rgba(37, 27, 17, 0.94));
    box-shadow: inset 0 0 0 1px rgba(245, 181, 61, 0.08);
}

.summary-card-critical {
    border-color: rgba(255, 93, 108, 0.5);
    background: linear-gradient(180deg, rgba(82, 12, 24, 0.94), rgba(42, 16, 24, 0.96));
    box-shadow:
        inset 0 0 0 1px rgba(255, 93, 108, 0.12),
        0 0 24px rgba(255, 93, 108, 0.12);
}

.summary-card-ok span,
.summary-card-ok strong {
    color: #dcfff1;
}

.summary-card-warning span,
.summary-card-warning strong {
    color: #ffe8b8;
}

.summary-card-critical span,
.summary-card-critical strong {
    color: #ffd4d9;
}

.board-panel {
    padding: 12px;
    overflow: auto;
}

.topbar-actions {
    display: grid;
    gap: 10px;
    justify-items: end;
}

.refresh-indicator {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 16px;
    border-radius: 16px;
    border: 1px solid rgba(97, 220, 255, 0.28);
    background: rgba(8, 39, 56, 0.72);
    color: #d6f7ff;
    font-size: 13px;
    box-shadow: inset 0 0 0 1px rgba(97, 220, 255, 0.06);
}

.refresh-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: rgba(97, 220, 255, 0.14);
    color: #8de7ff;
    font-size: 16px;
    animation: spinPulse 2.8s linear infinite;
}

.device-grid {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 10px;
}

.device-card {
    min-height: 88px;
    padding: 12px;
    border-radius: 18px;
    border: 1px solid rgba(123, 146, 179, 0.18);
    background: linear-gradient(180deg, rgba(19, 33, 52, 0.96), rgba(10, 18, 32, 0.98));
}

.device-toggle[open] {
    min-height: 178px;
}

.device-summary {
    list-style: none;
    cursor: pointer;
}

.device-summary::-webkit-details-marker {
    display: none;
}

.device-summary-side {
    display: flex;
    align-items: center;
    gap: 8px;
}

.expand-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid rgba(123, 146, 179, 0.24);
    color: var(--muted);
    font-size: 15px;
    line-height: 1;
    flex: 0 0 auto;
}

.device-toggle[open] .expand-indicator {
    transform: rotate(45deg);
}

.device-card.ok {
    border-color: rgba(31, 209, 138, 0.32);
    box-shadow: inset 0 0 0 1px rgba(31, 209, 138, 0.08);
}

.device-card.warning {
    border-color: rgba(245, 181, 61, 0.65);
    background:
        linear-gradient(180deg, rgba(88, 58, 10, 0.96), rgba(32, 23, 14, 0.97)),
        linear-gradient(180deg, rgba(19, 33, 52, 0.96), rgba(10, 18, 32, 0.98));
    box-shadow:
        inset 0 0 0 1px rgba(245, 181, 61, 0.16),
        0 0 0 1px rgba(245, 181, 61, 0.08),
        0 0 24px rgba(245, 181, 61, 0.14);
}

.device-card.critical {
    border-color: rgba(255, 93, 108, 0.75);
    background:
        linear-gradient(180deg, rgba(72, 14, 24, 0.98), rgba(22, 10, 18, 0.98)),
        linear-gradient(180deg, rgba(19, 33, 52, 0.96), rgba(10, 18, 32, 0.98));
    box-shadow:
        inset 0 0 0 1px rgba(255, 93, 108, 0.18),
        0 0 0 1px rgba(255, 93, 108, 0.1),
        0 0 26px rgba(255, 93, 108, 0.2);
}

.device-card.critical .device-head h2 {
    color: #fff3f5;
}

.device-card.critical .device-head p {
    color: #ffc2c9;
}

.device-card.critical .expand-indicator {
    border-color: rgba(255, 93, 108, 0.45);
    color: #ffd5da;
}

.device-card.warning .device-head h2 {
    color: #fff2d2;
}

.device-card.warning .device-head p {
    color: #ffdca1;
}

.device-card.warning .expand-indicator {
    border-color: rgba(245, 181, 61, 0.42);
    color: #ffe8b8;
}

.device-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
}

.device-head > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
}

.device-head h2 {
    margin: 0;
    font-size: clamp(14px, 1vw, 16px);
    line-height: 1.12;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.device-head p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 11px;
    overflow-wrap: anywhere;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    min-height: 26px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border: 1px solid transparent;
    text-align: center;
    flex: 0 0 auto;
}

.badge.ok {
    color: #bdfae2;
    background: rgba(31, 209, 138, 0.12);
    border-color: rgba(31, 209, 138, 0.28);
}

.badge.warning {
    color: #fff0c7;
    background: rgba(245, 181, 61, 0.28);
    border-color: rgba(245, 181, 61, 0.45);
}

.badge.critical {
    color: #ffe3e7;
    background: rgba(255, 93, 108, 0.24);
    border-color: rgba(255, 93, 108, 0.45);
}

.device-body {
    margin-top: 12px;
    display: grid;
    gap: 6px;
}

.device-body p {
    margin: 0;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
}

.device-body span,
.alert-box span {
    color: var(--muted);
}

.alert-box {
    margin-top: 12px;
    padding: 10px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    display: grid;
    gap: 5px;
}

.alert-box strong {
    font-size: 11px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.device-toggle:not([open]) .device-body,
.device-toggle:not([open]) .alert-box {
    display: none;
}

.empty-state {
    min-height: 300px;
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--muted);
}

.empty-state h2 {
    color: var(--text);
}

.brand-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2px 0 8px;
}

.brand-footer-logo {
    width: min(320px, 36vw);
    height: auto;
    opacity: 0.92;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.2));
}

.alert-popup {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 60;
    width: min(420px, calc(100vw - 24px));
    padding: 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 93, 108, 0.4);
    background: rgba(40, 11, 19, 0.94);
    color: #fff1f3;
    box-shadow:
        0 18px 40px rgba(0, 0, 0, 0.34),
        0 0 24px rgba(255, 93, 108, 0.18);
    backdrop-filter: blur(12px);
}

.alert-popup-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.alert-popup-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.alert-popup-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.alert-popup-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(255, 93, 108, 0.18);
}

.alert-popup-close {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffd6db;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.alert-popup-minimize {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffd6db;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.alert-popup-list {
    margin-top: 12px;
    display: grid;
    gap: 8px;
    max-height: 240px;
    overflow: auto;
}

.alert-popup-item {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 12px;
}

.alert-popup-item span {
    color: #ffc4cb;
}

.alert-dock {
    position: fixed;
    right: 76px;
    bottom: 18px;
    z-index: 61;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid rgba(255, 93, 108, 0.35);
    border-radius: 999px;
    background: rgba(40, 11, 19, 0.94);
    color: #fff1f3;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    cursor: pointer;
}

.alert-dock-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: rgba(255, 93, 108, 0.18);
}

.logout-dock {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 61;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 999px;
    border: 1px solid rgba(123, 146, 179, 0.24);
    background: rgba(14, 24, 40, 0.88);
    color: #d6f7ff;
    text-decoration: none;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.logout-dock-icon {
    font-size: 18px;
    line-height: 1;
}

code {
    color: #9fd5ff;
}

@keyframes spinPulse {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1900px) {
    .device-grid {
        grid-template-columns: repeat(9, minmax(0, 1fr));
    }
}

@media (max-width: 1700px) {
    .device-grid {
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }
}

@media (max-width: 1440px) {
    .topbar {
        grid-template-columns: 1fr;
    }

    .topbar-actions {
        justify-items: start;
    }

    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .device-grid {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }
}

@media (max-width: 1100px) {
    .device-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .app-shell {
        padding: 12px;
    }

    .alert-popup {
        right: 12px;
        bottom: 12px;
    }

    .brand-footer-logo {
        width: min(240px, 60vw);
    }

    .summary-grid,
    .device-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .login-card,
    .topbar,
    .board-panel {
        border-radius: 22px;
    }

    .summary-grid,
    .device-grid {
        grid-template-columns: 1fr;
    }
}
