:root {
    --navy-950: #052f26;
    --navy-900: #0a4a3d;
    --navy-800: #0d6955;
    --teal-600: #099a74;
    --teal-500: #0cb386;
    --sky-500: #34c79b;
    --lime-500: #79d9bb;
    --rose-500: #c6487e;
    --warning-500: #e79b3d;
    --danger-500: #d85d5d;
    --surface: #ffffff;
    --surface-soft: #f0faf7;
    --surface-line: #d6e8e1;
    --text-main: #14392f;
    --text-muted: #648178;
    --shadow: 0 18px 40px rgba(10, 74, 61, 0.12);
    --radius-lg: 22px;
    --radius-md: 16px;
    --topbar-control-size: 54px;
    --app-shell-top-offset: 102px;
    --menu-popup-height: clamp(560px, 78vh, 760px);
    --menu-popup-width: min(720px, calc(100vw - 32px));
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-main);
    background: linear-gradient(180deg, #eaf6f1 0%, #f8fcfb 100%);
}

body.login-page {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(6, 62, 50, 0.7) 0%, rgba(10, 107, 89, 0.58) 45%, rgba(18, 162, 127, 0.52) 100%),
        radial-gradient(circle at top left, rgba(121, 217, 187, 0.18), transparent 22%),
        url("../images/login-smart-home-bg.jpg") center center / cover no-repeat;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font: inherit;
}

@keyframes flash-hover {
    0% {
        filter: brightness(1);
        box-shadow: inherit;
    }
    35% {
        filter: brightness(1.16);
    }
    70% {
        filter: brightness(1.05);
    }
    100% {
        filter: brightness(1.1);
    }
}

@keyframes flash-press {
    0% {
        filter: brightness(1.08);
    }
    100% {
        filter: brightness(1.22);
    }
}

@keyframes tech-button-scan {
    0% {
        transform: translate3d(-160%, 0, 0) skewX(-18deg);
    }
    100% {
        transform: translate3d(220%, 0, 0) skewX(-18deg);
    }
}

@keyframes tech-button-grid {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(14px);
    }
}

@keyframes tech-button-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(160, 255, 229, 0.18);
        opacity: 0.8;
    }
    50% {
        box-shadow: 0 0 0 8px rgba(160, 255, 229, 0);
        opacity: 1;
    }
}

@keyframes tech-button-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes login-error-shake {
    0%,
    100% {
        transform: translateX(0);
    }
    18% {
        transform: translateX(-7px);
    }
    36% {
        transform: translateX(6px);
    }
    54% {
        transform: translateX(-4px);
    }
    72% {
        transform: translateX(3px);
    }
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: var(--app-shell-top-offset) 28px 36px;
    width: 100%;
    overflow-x: clip;
}

.login-shell {
    min-height: 100vh;
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 22px;
    padding: 36px;
    align-items: stretch;
}

.login-header,
.login-panel {
    border-radius: 32px;
    box-shadow: 0 28px 56px rgba(3, 31, 26, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(18px);
}

.login-header {
    padding: 22px 24px;
    color: #fff;
    background:
        linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
        radial-gradient(circle at 18% 24%, rgba(123, 218, 189, 0.16), transparent 22%),
        linear-gradient(145deg, rgba(5, 47, 38, 0.92), rgba(8, 86, 69, 0.78));
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.login-brand-mark {
    width: 64px;
    height: 64px;
}

.login-brand-subtitle {
    color: rgba(255, 255, 255, 0.78);
}

.login-panel {
    width: 100%;
    padding: 32px;
    background: rgba(244, 252, 249, 0.95);
}

.login-panel-head {
    margin-bottom: 24px;
}

.login-panel-badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(12, 179, 134, 0.14);
    color: #0a7458;
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 14px;
}

.login-panel h2 {
    margin: 0 0 10px;
    font-size: 2rem;
    color: #0c4337;
}

.login-panel-head p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.6;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.login-validation,
.login-field-error {
    color: #b54141;
    font-size: 0.9rem;
}

.login-validation {
    display: none;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(216, 93, 93, 0.12);
    border: 1px solid rgba(216, 93, 93, 0.28);
    color: #aa3030;
    line-height: 1.5;
}

.login-validation:not(:empty) {
    display: block;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-field label {
    font-weight: 700;
    color: #15463a;
}

.login-input-shell {
    height: 56px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    border-radius: 18px;
    background: #fff;
    border: 1px solid rgba(20, 57, 47, 0.1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.login-input-shell i {
    color: #2f7563;
    transition: color 0.2s ease;
}

.login-input-shell input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: #12382f;
    font: inherit;
}

.login-input-action {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border: 0;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(12, 179, 134, 0.08);
    color: #2f7563;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.login-input-action:hover,
.login-input-action:focus-visible {
    background: rgba(12, 179, 134, 0.16);
    color: #0a7458;
    transform: translateY(-1px);
    outline: none;
}

.login-field.has-error label,
.login-field.has-error .login-field-error {
    color: #b13838;
}

.login-field.has-error .login-input-shell,
.login-input-shell:has(.input-validation-error) {
    border-color: rgba(203, 58, 58, 0.56);
    background: linear-gradient(180deg, rgba(255, 244, 244, 0.98), rgba(255, 236, 236, 0.94));
    box-shadow: 0 0 0 4px rgba(216, 93, 93, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.login-field.has-error .login-textarea-shell,
.login-textarea-shell:has(.input-validation-error) {
    border-color: rgba(203, 58, 58, 0.56);
    background: linear-gradient(180deg, rgba(255, 244, 244, 0.98), rgba(255, 236, 236, 0.94));
    box-shadow: 0 0 0 4px rgba(216, 93, 93, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.login-field.has-error .login-input-shell i,
.login-input-shell:has(.input-validation-error) i,
.login-field.has-error .login-input-shell input,
.login-input-shell:has(.input-validation-error) input,
.login-field.has-error .login-input-shell select,
.login-input-shell:has(.input-validation-error) select,
.login-field.has-error .select-indicator,
.login-input-shell:has(.input-validation-error) .select-indicator,
.login-field.has-error .login-textarea-shell i,
.login-textarea-shell:has(.input-validation-error) i,
.login-field.has-error .login-textarea-shell textarea,
.login-textarea-shell:has(.input-validation-error) textarea {
    color: #b13838;
}

.login-field.has-error .login-input-shell input::placeholder,
.login-input-shell:has(.input-validation-error) input::placeholder,
.login-field.has-error .login-textarea-shell textarea::placeholder,
.login-textarea-shell:has(.input-validation-error) textarea::placeholder {
    color: rgba(177, 56, 56, 0.62);
}

.login-field.has-error .login-input-shell.shake-error {
    animation: login-error-shake 420ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.login-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #386257;
}

.login-checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--teal-500);
}

.login-submit {
    margin-top: 8px;
    height: 56px;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-app-install {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.login-install-feedback {
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 0.92rem;
    line-height: 1.5;
}

.login-install-feedback.info {
    background: rgba(9, 154, 116, 0.1);
    border: 1px solid rgba(9, 154, 116, 0.2);
    color: #0a6c53;
}

.login-install-feedback.success {
    background: rgba(12, 179, 134, 0.12);
    border: 1px solid rgba(12, 179, 134, 0.24);
    color: #0a7458;
}

.login-install-feedback.error {
    background: rgba(216, 93, 93, 0.12);
    border: 1px solid rgba(216, 93, 93, 0.24);
    color: #aa3030;
}

.secondary-button {
    width: 100%;
    min-height: 52px;
    border-radius: 14px;
    border: 1px solid rgba(10, 116, 88, 0.18);
    background: rgba(255, 255, 255, 0.8);
    color: #0d4f40;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.22s ease, background 0.22s ease, box-shadow 0.22s ease;
}

.secondary-button:hover,
.secondary-button:focus-visible {
    background: #ffffff;
    border-color: rgba(10, 116, 88, 0.32);
    box-shadow: 0 16px 28px rgba(10, 74, 61, 0.1);
    outline: none;
}

.secondary-button:disabled {
    cursor: not-allowed;
    opacity: 0.72;
    box-shadow: none;
}

.login-install-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-link {
    color: #fff;
}

.brand-mark {
    width: var(--topbar-control-size);
    height: var(--topbar-control-size);
    border-radius: 18px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 24px rgba(5, 28, 67, 0.16);
}

.brand-copy {
    min-width: 0;
}

.brand-logo {
    width: 76%;
    height: 76%;
    object-fit: contain;
}

.brand-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.brand-subtitle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.78);
}

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0;
    width: 100%;
    padding: 18px 32px;
    border-radius: 0;
    background: linear-gradient(135deg, #0b4f9c 0%, #0a72bf 52%, #13a2cf 100%);
    border: 0;
    box-shadow: 0 14px 34px rgba(11, 79, 156, 0.22);
    backdrop-filter: blur(18px);
    box-sizing: border-box;
}

.topbar-left,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-actions {
    justify-content: flex-end;
}

.menu-launcher {
    border: 0;
    min-height: var(--topbar-control-size);
    border-radius: 18px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(5, 28, 67, 0.16);
}

.menu-launcher:hover {
    background: rgba(255, 255, 255, 0.24);
}

.search-shell {
    flex: 1 1 440px;
    min-width: 240px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 18px;
    height: 54px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.search-shell i {
    color: rgba(255, 255, 255, 0.82);
}

.search-shell input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: #fff;
    font: inherit;
}

.search-shell input::placeholder {
    color: rgba(255, 255, 255, 0.72);
}

.search-toggle {
    display: none;
    width: var(--topbar-control-size);
    height: var(--topbar-control-size);
    border: 0;
    border-radius: 18px;
    place-items: center;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(5, 28, 67, 0.16);
}

.search-toggle:hover {
    background: rgba(255, 255, 255, 0.24);
}

.primary-button {
    width: 100%;
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--teal-500), #7bdabd);
    color: #07271f;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.button-content,
.button-processing {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: opacity 0.24s ease, transform 0.24s ease;
}

.button-processing {
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: translateY(10%);
    color: #ddfff6;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.78rem;
    font-weight: 800;
    pointer-events: none;
}

.button-processing-dot {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid rgba(221, 255, 246, 0.22);
    border-top-color: #ddfff6;
    animation: tech-button-spin 0.7s linear infinite, tech-button-pulse 1.15s ease-in-out infinite;
}

.primary-button.is-processing {
    cursor: progress;
    color: #ddfff6;
    background: linear-gradient(135deg, #072e27 0%, #0b6958 48%, #13a68e 100%);
    box-shadow: 0 0 0 1px rgba(143, 243, 220, 0.16), 0 18px 36px rgba(4, 30, 25, 0.28);
}

.primary-button.is-processing::before,
.primary-button.is-processing::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.primary-button.is-processing::before {
    inset: -30% auto -30% -12%;
    width: 48%;
    background: linear-gradient(90deg, transparent, rgba(195, 255, 240, 0.1), rgba(255, 255, 255, 0.48), rgba(195, 255, 240, 0.1), transparent);
    animation: tech-button-scan 1.15s linear infinite;
}

.primary-button.is-processing::after {
    background-image: linear-gradient(to bottom, rgba(203, 255, 243, 0.12) 1px, transparent 1px);
    background-size: 100% 14px;
    mix-blend-mode: screen;
    opacity: 0.35;
    animation: tech-button-grid 0.9s linear infinite;
}

.primary-button.is-processing .button-content {
    opacity: 0;
    transform: scale(0.96);
}

.primary-button.is-processing .button-processing {
    opacity: 1;
    transform: translateY(0);
}

.primary-button.is-processing:disabled {
    opacity: 1;
}

.menu-launcher,
.search-toggle,
.primary-button,
.user-card,
.menu-nav-button {
    transition: box-shadow 0.22s ease, background 0.22s ease, border-color 0.22s ease;
    will-change: filter;
}

.menu-launcher:hover,
.menu-launcher:focus-visible,
.search-toggle:hover,
.search-toggle:focus-visible,
.primary-button:hover,
.primary-button:focus-visible,
.user-card:hover,
.user-card:focus-visible,
.menu-nav-button:hover,
.menu-nav-button:focus-visible {
    animation: flash-hover 260ms ease-out both;
}

.menu-launcher:active,
.search-toggle:active,
.primary-button:active,
.user-card:active,
.menu-nav-button:active {
    animation: flash-press 120ms ease-out both;
}

.main-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.page-overview {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.crumbs {
    color: var(--text-muted);
    font-size: 0.92rem;
}

.page-title {
    margin: 0;
    font-size: 1.9rem;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    min-height: var(--topbar-control-size);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 24px rgba(5, 28, 67, 0.12);
    cursor: pointer;
    color: inherit;
    text-align: left;
}

.avatar {
    width: calc(var(--topbar-control-size) - 14px);
    height: calc(var(--topbar-control-size) - 14px);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--navy-900), var(--teal-500));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    overflow: hidden;
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name {
    font-weight: 700;
    color: #fff;
}

.user-role {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.88rem;
}

.menu-popup-shell {
    position: fixed;
    inset: 0;
    z-index: 80;
}

.account-popup-shell {
    z-index: 90;
}

.menu-popup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 18, 36, 0.4);
    backdrop-filter: blur(8px);
}

.menu-popup {
    position: fixed;
    width: var(--menu-popup-width);
    height: var(--menu-popup-height);
    padding: 28px;
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(38, 39, 43, 0.96) 0%, rgba(76, 65, 62, 0.94) 100%);
    color: #fff;
    box-shadow: 0 26px 56px rgba(7, 39, 31, 0.32);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.account-popup-modal {
    width: min(420px, calc(100vw - 32px));
    height: auto;
    min-height: 0;
}

.menu-popup-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 0;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    z-index: 2;
}

.menu-popup-heading {
    flex: 1 1 auto;
    min-width: 0;
}

.menu-popup-eyebrow {
    font-size: 0.74rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 6px;
}

.menu-popup-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.menu-nav-button {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    flex: 0 0 auto;
}

.menu-nav-button:hover {
    background: rgba(255, 255, 255, 0.16);
}

.menu-nav-button[hidden] {
    display: none;
}

.account-popup-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding-top: 18px;
}

.account-popup-item {
    min-height: 152px;
    padding: 18px 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.account-popup-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.14);
    transform: translateY(-1px);
}

.account-popup-item.danger {
    color: #ff9a9a;
    background: rgba(113, 17, 17, 0.3);
    border-color: rgba(190, 57, 57, 0.3);
}

.account-popup-item.danger:hover {
    color: #ffc0c0;
    background: rgba(145, 20, 20, 0.42);
    border-color: rgba(223, 81, 81, 0.34);
}

.account-popup-item-icon {
    display: grid;
    place-items: center;
    font-size: 2.3rem;
    color: inherit;
    transition: transform 0.2s ease;
}

.account-popup-item:hover .account-popup-item-icon {
    transform: scale(1.08);
}

.account-popup-item-label {
    line-height: 1.35;
}

.menu-grid-viewport {
    position: relative;
    overflow: hidden;
    padding: 18px 8px 8px;
    margin: 0 -8px -8px;
    min-height: 0;
    flex: 1 1 auto;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    padding: 6px;
    align-content: start;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

.menu-grid::-webkit-scrollbar {
    width: 8px;
}

.menu-grid::-webkit-scrollbar-track {
    background: transparent;
}

.menu-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
}

.menu-grid.is-transition-layer {
    position: absolute;
    inset: 18px 8px 8px 8px;
}

.menu-tile {
    min-height: 156px;
    border: 0;
    border-radius: 22px;
    padding: 18px 12px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    text-align: center;
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease, border-color 0.22s ease;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.menu-tile:hover,
.menu-tile:focus-visible,
.menu-tile.active {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 18px 30px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    outline: none;
}

.menu-tile:active {
    transform: translateY(-2px) scale(0.98);
    background: rgba(255, 255, 255, 0.22);
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.menu-tile-icon {
    display: grid;
    place-items: center;
    font-size: 3.18rem;
    color: #fff;
    transition: transform 0.22s ease, background 0.22s ease, box-shadow 0.22s ease;
}

.menu-tile:hover .menu-tile-icon,
.menu-tile:focus-visible .menu-tile-icon,
.menu-tile.active .menu-tile-icon {
    transform: scale(1.12);
    text-shadow: 0 14px 24px rgba(0, 0, 0, 0.26);
}

.menu-tile:active .menu-tile-icon {
    transform: scale(1.04);
}

.menu-tile-label {
    font-weight: 600;
    line-height: 1.35;
    font-size: 12px;
}

.menu-tile-meta {
    position: absolute;
    right: 14px;
    top: 14px;
    color: rgba(255, 255, 255, 0.72);
}

.content-area {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

body.menu-open {
    overflow: hidden;
}

.hero-panel {
    background: radial-gradient(circle at top right, rgba(52, 199, 155, 0.24), transparent 28%), linear-gradient(135deg, var(--navy-900), #0d5a48 60%, #139675 100%);
    color: #fff;
    border-radius: 28px;
    padding: 30px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.eyebrow {
    font-size: 0.82rem;
    letter-spacing: 0.18em;
    color: rgba(255, 255, 255, 0.7);
}

.hero-panel h2 {
    margin: 8px 0 12px;
    font-size: 2rem;
}

.hero-panel p {
    margin: 0;
    max-width: 650px;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.7;
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 14px;
}

.hero-pill {
    min-width: 210px;
    padding: 16px 18px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
}

.hero-pill span {
    display: block;
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.72);
    margin-bottom: 8px;
}

.hero-pill strong {
    font-size: 1.25rem;
}

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

.metric-card,
.panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid rgba(23, 48, 66, 0.06);
    min-width: 0;
}

.metric-card {
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.24s ease, filter 0.24s ease;
    will-change: filter;
}

.metric-card::after {
    content: "";
    position: absolute;
    inset: auto -20px -24px auto;
    width: 110px;
    height: 110px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
}

.metric-card.online { background: linear-gradient(135deg, var(--teal-500), #7be1c2); color: #082d24; }
.metric-card.alert { background: linear-gradient(135deg, var(--rose-500), #f2a7c6); color: #fff; }
.metric-card.energy { background: linear-gradient(135deg, var(--sky-500), #b0efda); color: #08352b; }
.metric-card.service { background: linear-gradient(135deg, var(--navy-800), #82d9bf); color: #f7fffc; }

.metric-card:hover,
.metric-card:focus-within {
    animation: flash-hover 280ms ease-out both;
    box-shadow: 0 24px 42px rgba(10, 74, 61, 0.22);
    filter: saturate(1.04);
}

.metric-title {
    font-size: 0.95rem;
    opacity: 0.88;
}

.metric-value {
    font-size: 2rem;
    font-weight: 800;
    margin: 8px 0 6px;
}

.metric-note {
    font-size: 0.92rem;
    opacity: 0.9;
}

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

.span-2 {
    grid-column: span 2;
}

.panel {
    padding: 22px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 14px;
    margin-bottom: 18px;
}

.panel-header h3 {
    margin: 0 0 6px;
    font-size: 1.1rem;
}

.panel-header p {
    margin: 0;
    color: var(--text-muted);
}

.chart-canvas {
    width: 100%;
    height: 260px;
    display: block;
    background: linear-gradient(180deg, rgba(12, 179, 134, 0.06), rgba(10, 74, 61, 0.02));
    border-radius: 18px;
}

.chart-legend {
    margin-top: 14px;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.chart-legend i {
    width: 10px;
    height: 10px;
    display: inline-block;
    border-radius: 50%;
    background: var(--teal-500);
    margin-right: 8px;
}

.donut-visual {
    width: 210px;
    height: 210px;
    border-radius: 50%;
    margin: 10px auto 18px;
    position: relative;
    background: conic-gradient(var(--teal-500) 0deg, var(--sky-500) 72deg, var(--navy-800) 144deg, var(--lime-500) 252deg, #9ae9d0 320deg, var(--teal-500) 360deg);
}

.donut-visual::after {
    content: "128\A thiết bị";
    white-space: pre;
    position: absolute;
    inset: 26px;
    border-radius: 50%;
    background: #fff;
    display: grid;
    place-items: center;
    text-align: center;
    font-weight: 800;
    color: var(--navy-900);
    box-shadow: inset 0 0 0 1px rgba(20, 57, 47, 0.06);
}

.donut-list,
.action-list,
.workorders,
.zone-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.donut-item,
.action-item,
.workorder-item {
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--surface-soft);
    border: 1px solid var(--surface-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.action-item,
.workorder-item {
    display: block;
}

.action-title,
.workorder-name,
.zone-title {
    font-weight: 700;
}

.action-note,
.workorder-meta,
.zone-subtitle {
    margin-top: 6px;
    color: var(--text-muted);
    line-height: 1.5;
}

.zone-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 16px 18px;
    background: var(--surface-soft);
    border: 1px solid var(--surface-line);
    border-radius: 18px;
}

.zone-status-block {
    min-width: 280px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
}

.status-tag {
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    background: rgba(12, 179, 134, 0.15);
    color: #0a7458;
}

.progress-track {
    height: 10px;
    border-radius: 999px;
    background: #d9eae4;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--teal-500), var(--sky-500));
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 10px;
    border-bottom: 1px solid #e2eee8;
    text-align: left;
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
}

.priority {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.priority-cao {
    background: rgba(221, 90, 90, 0.14);
    color: #af3535;
}

.priority-trung-bình,
.priority-trung-binh {
    background: rgba(240, 154, 62, 0.16);
    color: #b5640d;
}

.priority-thấp,
.priority-thap {
    background: rgba(33, 191, 150, 0.16);
    color: #117b60;
}

.workorder-code {
    color: var(--teal-600);
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 6px;
}

@media (max-width: 1240px) {
    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 1024px) {
    .hero-panel,
    .zone-item {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar {
        padding: 18px;
        flex-wrap: wrap;
        align-items: center;
        gap: 16px;
    }

    .topbar-left {
        flex: 1 1 auto;
        justify-content: space-between;
    }

    .search-shell {
        flex: 1 1 100%;
        min-width: 0;
        width: 100%;
        order: 3;
    }

    .topbar-actions {
        flex: 0 0 auto;
        justify-content: flex-end;
    }

    .hero-stats,
    .zone-status-block {
        grid-template-columns: 1fr;
        min-width: 0;
    }
}

@media (max-width: 768px), (max-height: 540px) and (orientation: landscape) {
    :root {
        --topbar-control-size: 50px;
        --app-shell-top-offset: 86px;
    }

    .app-shell {
        gap: 18px;
        padding: var(--app-shell-top-offset) 12px 24px;
    }

    .login-shell {
        padding: 18px;
        gap: 18px;
    }

    .login-header,
    .login-panel {
        padding: 22px;
        border-radius: 26px;
    }

    .topbar {
        margin: 0;
        width: 100%;
        max-width: 100%;
        padding: 12px;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        gap: 14px;
        box-sizing: border-box;
    }

    .main-panel {
        gap: 18px;
    }

    .metrics-grid,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    .brand-copy,
    .user-card > div:last-child,
    .menu-launcher span {
        display: none;
    }

    .brand-link {
        width: var(--topbar-control-size);
        height: var(--topbar-control-size);
        justify-content: center;
    }

    .topbar-left,
    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .topbar-actions {
        gap: 10px;
        justify-content: flex-end;
    }

    .menu-launcher {
        min-width: var(--topbar-control-size);
        width: var(--topbar-control-size);
        height: var(--topbar-control-size);
        padding: 0;
        justify-content: center;
        gap: 0;
    }

    .search-toggle {
        display: grid;
    }

    .search-shell {
        grid-column: 1 / -1;
        order: 3;
        min-width: 0;
        width: 100%;
        margin-top: 2px;
        display: none;
    }

    .topbar.search-open .search-shell {
        display: flex;
    }

    .topbar.search-open .search-toggle {
        background: rgba(255, 255, 255, 0.24);
    }

    .user-card {
        padding: 8px;
        min-width: var(--topbar-control-size);
        min-height: var(--topbar-control-size);
        width: var(--topbar-control-size);
        height: var(--topbar-control-size);
        justify-content: center;
    }

    .account-menu-popup {
        min-width: 200px;
    }

    .menu-popup {
        width: calc(100% - 24px);
        max-width: calc(100% - 24px);
        height: min(88vh, 640px);
        padding: 18px;
    }

    .account-popup-modal {
        width: calc(100% - 24px);
        max-width: calc(100% - 24px);
        height: auto;
    }

    .account-popup-actions {
        grid-template-columns: 1fr;
    }

    .menu-grid-viewport {
        padding: 16px 6px 6px;
        margin: 0 -6px -6px;
    }

    .menu-grid {
        gap: 12px;
    }

    .menu-tile {
        min-height: 146px;
    }
}

.page-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 18px;
    font-weight: 600;
}

.page-alert:empty {
    display: none;
}

.page-alert.success,
.page-alert.info {
    background: rgba(12, 179, 134, 0.12);
    border: 1px solid rgba(12, 179, 134, 0.24);
    color: #0b6c53;
}

.page-alert.error {
    background: rgba(216, 93, 93, 0.12);
    border: 1px solid rgba(216, 93, 93, 0.24);
    color: #a83c3c;
}

.account-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.account-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.9fr);
    gap: 18px;
    align-items: start;
}

.account-panel {
    padding: 24px;
}

.account-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.profile-shell {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.avatar-editor {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(9, 154, 116, 0.08), rgba(52, 199, 155, 0.16));
    border: 1px solid rgba(9, 154, 116, 0.18);
}

.profile-avatar {
    width: 116px;
    height: 116px;
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    flex: 0 0 116px;
    background: linear-gradient(135deg, #0b4f9c, #13a2cf);
    color: #fff;
    box-shadow: 0 18px 34px rgba(11, 79, 156, 0.24);
}

.profile-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-fallback {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.is-hidden {
    display: none !important;
}

.avatar-editor-copy {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.avatar-upload-label {
    font-weight: 700;
}

.avatar-upload-input {
    display: block;
    width: 100%;
}

.avatar-editor-copy p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
}

.account-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.account-form-grid.single-column {
    grid-template-columns: 1fr;
}

.field-span-2 {
    grid-column: span 2;
}

.readonly-shell {
    background: linear-gradient(180deg, rgba(240, 250, 247, 0.96), rgba(232, 244, 239, 0.92));
}

.readonly-shell input {
    color: #48685f;
}

.login-input-shell select,
.login-textarea-shell textarea {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: #12382f;
    font: inherit;
}

.login-input-shell select {
    appearance: none;
    cursor: pointer;
}

.select-shell select {
    padding-right: 6px;
}

.select-indicator {
    width: 24px;
    flex: 0 0 24px;
    display: grid;
    place-items: center;
    color: #2f7563;
    pointer-events: none;
}

.login-textarea-shell {
    min-height: 108px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-radius: 18px;
    background: #fff;
    border: 1px solid rgba(20, 57, 47, 0.1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.login-textarea-shell i {
    color: #2f7563;
    padding-top: 2px;
}

.login-textarea-shell textarea {
    resize: vertical;
    min-height: 72px;
}

.account-submit {
    min-height: 54px;
}

.password-submit {
    margin-top: 6px;
}

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

@media (max-width: 768px), (max-height: 540px) and (orientation: landscape) {
    .account-panel {
        padding: 18px;
    }

    .avatar-editor {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .profile-avatar {
        margin: 0 auto;
    }

    .account-form-grid {
        grid-template-columns: 1fr;
    }

    .field-span-2 {
        grid-column: auto;
    }
}
