* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background: #090d0e;
    color: #e8f1ef;
    font-family: "Inter", sans-serif;
    transition: background 0.3s ease, color 0.3s ease;
}

/* =====================================================
   CUSTOM SCROLLBAR
===================================================== */

/* Firefox - Dark Mode (default) */
html,
body,
* {
    scrollbar-width: thin;
    scrollbar-color: #3dd9bd #0d1514;
}

/* Webkit browsers (Chrome, Edge, Safari) - Dark Mode (default) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #0d1514;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #2a4a45;
    border-radius: 4px;
    border: 1px solid #1c2525;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: #3dd9bd;
}

/* Firefox - Light Mode */
body.light-mode,
body.light-mode *,
body.light-mode html {
    scrollbar-width: thin;
    scrollbar-color: #8a9d9a #e8eaed;
}

/* Webkit - Light Mode - Override ALL scrollbar properties */
body.light-mode ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

body.light-mode ::-webkit-scrollbar-track {
    background: #e8eaed;
    border-radius: 4px;
}

body.light-mode ::-webkit-scrollbar-thumb {
    background: #b8c7c4;
    border-radius: 4px;
    border: 1px solid #d0d7d5;
    transition: background 0.2s ease;
}

body.light-mode ::-webkit-scrollbar-thumb:hover {
    background: #3dd9bd;
}

/* =====================================================
   LIGHT MODE
===================================================== */

body.light-mode {
    background: #f5f7f9;
    color: #1a1f23;
}

body.light-mode .sidebar {
    background: linear-gradient(180deg, #ffffff, #f8f9fb);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
}

body.light-mode .logo {
    background: #f0f2f5;
    color: #3dd9bd;
    box-shadow:
        inset 2px 2px 5px #d4d6d9,
        inset -2px -2px 5px #ffffff;
}

body.light-mode .nav-item {
    color: #8a9199;
}

body.light-mode .nav-item:hover {
    color: #1a1f23;
    background: #eceef1;
}

body.light-mode .nav-item.active {
    color: #3dd9bd;
    background: #e8f7f4;
    box-shadow:
        0 0 15px rgba(61, 217, 189, 0.15),
        inset 0 0 10px rgba(61, 217, 189, 0.1);
}

body.light-mode .live-log {
    background: #f8f9fb;
    box-shadow:
        inset 2px 2px 5px #e0e2e5,
        inset -2px -2px 5px #ffffff;
}

body.light-mode .log-item {
    border-bottom: 1px solid #e5e7ea;
}

body.light-mode .log-item strong {
    color: #2a3238;
}

body.light-mode .log-item small {
    color: #8a9199;
}

body.light-mode .topbar {
    background: #f5f7f9ee;
}

body.light-mode .breadcrumb span {
    color: #8a9199;
}

body.light-mode .breadcrumb b {
    color: #bcc1c7;
}

body.light-mode .telemetry,
body.light-mode .esp-status,
body.light-mode .notification,
body.light-mode .theme-toggle,
body.light-mode .mode-toggle {
    background: #ffffff;
    color: #5a6269;
    box-shadow:
        inset 1px 1px 3px #e0e2e5,
        inset -1px -1px 3px #ffffff;
}

body.light-mode .esp-status {
    color: #3dd9bd;
}

body.light-mode .avatar {
    background: #ffffff;
    color: #3dd9bd;
    box-shadow:
        inset 1px 1px 3px #e0e2e5,
        inset -1px -1px 3px #ffffff;
}

body.light-mode .mobile-menu-btn {
    background: #ffffff;
    color: #5a6269;
    box-shadow:
        inset 1px 1px 3px #e0e2e5,
        inset -1px -1px 3px #ffffff;
}

body.light-mode .mobile-menu-btn:hover {
    background: #f5f7f9;
    color: #3dd9bd;
}

body.light-mode .breadcrumb strong {
    color: #2a3439;
}

body.light-mode .card {
    background: #ffffff;
    box-shadow:
        5px 8px 20px rgba(0, 0, 0, 0.06),
        inset 1px 1px 3px #f5f7f9,
        inset -1px -1px 3px #e8eaed;
}

body.light-mode .card:hover {
    transform: translateY(-3px);
    box-shadow:
        8px 12px 28px rgba(0, 0, 0, 0.1),
        inset 1px 1px 3px #f5f7f9,
        inset -1px -1px 3px #e8eaed,
        0 0 20px rgba(61, 217, 189, 0.15);
}

body.light-mode .camera {
    background: radial-gradient(
        circle at 55% 45%,
        #d4e8e5,
        #e8eeec 48%,
        #f0f2f4
    );
}

body.light-mode .camera-text {
    color: #7a8690;
}

body.light-mode .camera-text strong {
    color: #3a4248;
}

body.light-mode .live {
    background: #ffffffcc;
    color: #3dd9bd;
}

body.light-mode .device-row {
    border-bottom: 1px solid #e8eaed;
}

body.light-mode .switch {
    background: #d8dce0;
}

body.light-mode .switch::after {
    background: #8a9199;
}

body.light-mode .switch.on {
    background: #c8f0e8;
    box-shadow: 0 0 10px rgba(61, 217, 189, 0.3);
}

body.light-mode .switch.on::after {
    background: #3dd9bd;
}

body.light-mode .ghost-button,
body.light-mode .secondary-button {
    background: #f0f2f5;
    color: #5a6269;
    box-shadow:
        inset 1px 1px 3px #d8dce0,
        inset -1px -1px 3px #ffffff;
}

body.light-mode .primary-button {
    background: #3dd9bd;
    color: #ffffff;
    box-shadow: 0 0 15px rgba(61, 217, 189, 0.25);
}

body.light-mode .danger-button {
    background: #ffe5e5;
    color: #ff6b6b;
}

body.light-mode .card-title {
    color: #6a7279;
}

body.light-mode .big-number small {
    color: #8a9199;
}

body.light-mode .sparkline {
    color: #3dd9bd;
}

body.light-mode .room-device span:last-child {
    color: #3dd9bd;
}

body.light-mode .good {
    color: #3dd9bd;
}

body.light-mode .ac-level {
    background: #e8eaed;
    color: #6a7279;
}

body.light-mode .ac-level.active {
    background: #c8f0e8;
    color: #2ab89f;
}

body.light-mode .device-state {
    color: #3dd9bd;
}

body.light-mode .table-card {
    background: #ffffff;
}

body.light-mode .table-header {
    background: #f8f9fb;
    color: #8a9199;
}

body.light-mode .table-row {
    border-top: 1px solid #e8eaed;
    color: #5a6269;
}

body.light-mode .fingerprint-circle {
    background: #e8f7f4;
    color: #3dd9bd;
    box-shadow:
        0 0 20px rgba(61, 217, 189, 0.15),
        inset 0 0 15px rgba(240, 250, 247, 0.5);
}

body.light-mode .telegram-icon {
    background: #e8f7f4;
    color: #3dd9bd;
}

body.light-mode .telegram-status {
    border-bottom: 1px solid #e8eaed;
}

body.light-mode .big-rule {
    color: #3dd9bd;
}

body.light-mode .floating-dock {
    background: #ffffffee;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.1),
        inset 1px 1px 3px #f5f7f9;
}

body.light-mode .dock-user small {
    color: #8a9199;
}

body.light-mode .media-control {
    color: #6a7279;
}

body.light-mode .media-control button {
    color: #3a4248;
}

body.light-mode .media-control .play {
    background: #3dd9bd;
    color: #ffffff;
}

body.light-mode .modal {
    background: rgba(0, 0, 0, 0.3);
}

body.light-mode .modal-content {
    background: #ffffff;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.15),
        inset 1px 1px 3px #f5f7f9;
}

body.light-mode .modal-content input,
body.light-mode .modal-content select,
body.light-mode .modal-content textarea {
    background: #f8f9fb;
    color: #2a3238;
    border: 1px solid #e5e7ea;
}

/* Scene Modal Light Mode */
body.light-mode .modal-content h3 {
    color: #374151 !important;
}

body.light-mode .modal-content .form-group label {
    color: #4b5563;
}

body.light-mode .modal-content small {
    color: #6b7280 !important;
}

body.light-mode .action-row {
    background: #f9fafb !important;
    border: 1px solid #e5e7eb !important;
}

body.light-mode .action-row:hover {
    background: #f3f4f6 !important;
    border-color: #d1d5db !important;
}

body.light-mode .remove-action-btn {
    color: #ef4444 !important;
}

body.light-mode .remove-action-btn:hover {
    color: #dc2626 !important;
    background: #fee2e2 !important;
}

body.light-mode .modal-buttons {
    background: #f9fafb !important;
    border-top: 1px solid #e5e7eb !important;
}

body.light-mode .edit-modal-actions-scroll::-webkit-scrollbar-thumb {
    background: #d1d5db;
}

body.light-mode .edit-modal-actions-scroll::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

body.light-mode .form-group[style*="border-top"] {
    border-top: 1px solid #e5e7eb !important;
}

body.light-mode #toast {
    background: #ffffff;
    color: #2a3238;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}


/* =====================================================
   SCENE ACTION CONTROLS - CUSTOM DROPDOWN STYLING
===================================================== */

/* Custom Dropdown Container */
.custom-dropdown {
    position: relative;
    width: 100%;
}

/* Disabled dropdown */
.custom-dropdown[data-disabled="true"] {
    opacity: 0.5;
    pointer-events: none;
}

/* Selected display area */
.custom-dropdown-selected {
    width: 100%;
    padding: 8px 12px;
    background: #0d1514;
    border: 1px solid #1c2525;
    border-radius: 8px;
    color: #e8f1ef;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.custom-dropdown-selected span {
    flex: 1;
}

.custom-dropdown-chevron {
    color: #8a9d9a;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

/* Hover state */
.custom-dropdown-selected:hover {
    border-color: #2a3635;
    background: #111a19;
}

/* Open state */
.custom-dropdown.open .custom-dropdown-selected {
    border-color: #4ecdc4;
    background: #111a19;
}

.custom-dropdown.open .custom-dropdown-chevron {
    transform: rotate(180deg);
}

/* Dropdown menu */
.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #0d1514;
    border: 1px solid #1c2525;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.custom-dropdown.open .custom-dropdown-menu {
    display: block;
}

/* Dropdown option */
.custom-dropdown-option {
    padding: 10px 12px;
    color: #e8f1ef;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease;
    user-select: none;
}

.custom-dropdown-option:hover {
    background: #111a19;
}

.custom-dropdown-option.selected {
    background: #0f1a19;
    color: #4ecdc4;
}

/* Scrollbar for dropdown menu */
.custom-dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.custom-dropdown-menu::-webkit-scrollbar-track {
    background: #0d1514;
    border-radius: 0 8px 8px 0;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb {
    background: #1c2525;
    border-radius: 3px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #2a3635;
}

/* Number input for window angle */
.action-value[type="number"] {
    width: 100%;
    padding: 8px 12px;
    background: #0d1514;
    border: 1px solid #1c2525;
    border-radius: 8px;
    color: #e8f1ef;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.action-value[type="number"]:hover {
    border-color: #2a3635;
    background: #111a19;
}

.action-value[type="number"]:focus {
    outline: none;
    border-color: #3dd9bd;
    background: #0f1a19;
    box-shadow: 0 0 0 3px rgba(61, 217, 189, 0.1);
}

/* Legacy styles removed - now using custom dropdown component */

/* =====================================================
/* Legacy styles removed - now using custom dropdown component */

/* Light Mode - Custom Dropdown */
body.light-mode .custom-dropdown-selected {
    background: #f8f9fb;
    border: 1px solid #d0d7d5;
    color: #1a2421;
}

body.light-mode .custom-dropdown-selected:hover {
    background: #f0f3f5;
    border-color: #b0b7b5;
}

body.light-mode .custom-dropdown.open .custom-dropdown-selected {
    border-color: #3dd9bd;
    background: #f0f3f5;
}

body.light-mode .custom-dropdown-menu {
    background: #f8f9fb;
    border: 1px solid #d0d7d5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.light-mode .custom-dropdown-option {
    color: #1a2421;
}

body.light-mode .custom-dropdown-option:hover {
    background: #f0f3f5;
}

body.light-mode .custom-dropdown-option.selected {
    background: #e8f5f3;
    color: #0a8f7e;
}

body.light-mode .action-value[type="number"] {
    background: #f8f9fb;
    border: 1px solid #d0d7d5;
    color: #1a2421;
}

body.light-mode .action-value[type="number"]:hover {
    border-color: #a0b0ad;
    background: #ffffff;
}

body.light-mode .action-value[type="number"]:focus {
    border-color: #3dd9bd;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(61, 217, 189, 0.15);
}

/* =====================================================
   CUSTOM DROPDOWN (Scene Actions)
===================================================== */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.custom-dropdown[data-disabled="true"] {
    opacity: 0.5;
    pointer-events: none;
}

.custom-dropdown-selected {
    background: #1a2421;
    border: 1px solid #2a3835;
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    color: #d4e4e1;
    transition: all 0.2s ease;
}

.custom-dropdown-selected:hover {
    border-color: #3a4845;
    background: #1f2926;
}

.custom-dropdown.open .custom-dropdown-selected {
    border-color: #4fd1c5;
    background: #1f2926;
}

.custom-dropdown-chevron {
    color: #8a9d9a;
    transition: transform 0.2s ease;
}

.custom-dropdown.open .custom-dropdown-chevron {
    transform: rotate(180deg);
}

.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #1a2421;
    border: 1px solid #2a3835;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-height: 240px;
    overflow-y: auto;
    display: none;
}

.custom-dropdown.open .custom-dropdown-menu {
    display: block;
}

.custom-dropdown-option {
    padding: 10px 12px;
    font-size: 13px;
    color: #d4e4e1;
    cursor: pointer;
    transition: all 0.15s ease;
}

.custom-dropdown-option:hover {
    background: #1f2926;
    color: #4fd1c5;
}

.custom-dropdown-option.selected {
    background: #1f2926;
    color: #4fd1c5;
    font-weight: 500;
}

.custom-dropdown-option:first-child {
    border-radius: 6px 6px 0 0;
}

.custom-dropdown-option:last-child {
    border-radius: 0 0 6px 6px;
}

/* Scrollbar for dropdown menu */
.custom-dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

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

.custom-dropdown-menu::-webkit-scrollbar-thumb {
    background: #2a3835;
    border-radius: 3px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #3a4845;
}

/* Light mode */
body.light-mode .custom-dropdown-selected {
    background: #ffffff;
    border-color: #d1d5db;
    color: #1a2421;
}

body.light-mode .custom-dropdown-selected:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}

body.light-mode .custom-dropdown.open .custom-dropdown-selected {
    border-color: #4fd1c5;
    background: #f9fafb;
}

body.light-mode .custom-dropdown-chevron {
    color: #6b7280;
}

body.light-mode .custom-dropdown-menu {
    background: #ffffff;
    border-color: #d1d5db;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.light-mode .custom-dropdown-option {
    color: #1a2421;
}

body.light-mode .custom-dropdown-option:hover {
    background: #f3f4f6;
    color: #059669;
}

body.light-mode .custom-dropdown-option.selected {
    background: #f3f4f6;
    color: #059669;
}

body.light-mode .custom-dropdown-menu::-webkit-scrollbar-thumb {
    background: #d1d5db;
}

body.light-mode .custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* =====================================================
   SCENE ICON SELECTOR
===================================================== */
.scene-icon-selector {
    position: relative;
    display: inline-block;
}

.scene-icon-preview {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #141b1c;
    border: 1px solid #1c2525;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.scene-icon-preview:hover {
    border-color: #4fd1c5;
    background: #1a2525;
}

.scene-icon-preview .material-symbols-outlined {
    font-size: 32px;
    color: #4fd1c5;
}

.scene-icon-dropdown {
    position: absolute;
    top: 0;
    left: calc(100% + 12px);
    width: 420px;
    background: #141b1c;
    border: 1px solid #1c2525;
    border-radius: 8px;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.scene-icon-dropdown.open {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* Responsive: fallback to below on narrow screens */
@media (max-width: 1200px) {
    .scene-icon-dropdown {
        width: 360px;
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 900px) {
    .scene-icon-dropdown {
        width: 300px;
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 768px) {
    .scene-icon-dropdown {
        top: calc(100% + 8px);
        left: 0;
        width: 280px;
        grid-template-columns: repeat(5, 1fr);
        transform: translateY(-10px);
    }

    .scene-icon-dropdown.open {
        transform: translateY(0);
    }
}

.scene-icon-option {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f1415;
    border: 1px solid #1c2525;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.scene-icon-option:hover {
    border-color: #4fd1c5;
    background: #1a2525;
    transform: scale(1.08);
}

.scene-icon-option .material-symbols-outlined {
    font-size: 24px;
    color: #8a9d9a;
}

.scene-icon-option:hover .material-symbols-outlined {
    color: #4fd1c5;
}

.scene-icon-option.selected {
    border-color: #4fd1c5;
    background: #1a2525;
}

.scene-icon-option.selected .material-symbols-outlined {
    color: #4fd1c5;
}

/* Light mode */
body.light-mode .scene-icon-preview {
    background: #f9fafb;
    border-color: #d1d5db;
}

body.light-mode .scene-icon-preview:hover {
    border-color: #059669;
    background: #f3f4f6;
}

body.light-mode .scene-icon-preview .material-symbols-outlined {
    color: #059669;
}

body.light-mode .scene-icon-dropdown {
    background: #ffffff;
    border-color: #d1d5db;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.light-mode .scene-icon-option {
    background: #f9fafb;
    border-color: #e5e7eb;
}

body.light-mode .scene-icon-option:hover {
    border-color: #059669;
    background: #f3f4f6;
}

body.light-mode .scene-icon-option .material-symbols-outlined {
    color: #6b7280;
}

body.light-mode .scene-icon-option:hover .material-symbols-outlined {
    color: #059669;
}

body.light-mode .scene-icon-option.selected {
    border-color: #059669;
    background: #f3f4f6;
}

body.light-mode .scene-icon-option.selected .material-symbols-outlined {
    color: #059669;
}

/* =====================================================
   CUSTOM TOGGLE SWITCH (Timer)
===================================================== */
.timer-toggle-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.timer-toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    background: #1a2421;
    border: 1px solid #2a3835;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.timer-toggle-switch.active {
    background: #4fd1c5;
    border-color: #4fd1c5;
}

.timer-toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #8a9d9a;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.timer-toggle-switch.active .timer-toggle-slider {
    left: 26px;
    background: #ffffff;
}

.timer-toggle-label {
    font-size: 14px;
    color: #d4e4e1;
    cursor: pointer;
    user-select: none;
}

/* Light mode */
body.light-mode .timer-toggle-switch {
    background: #e5e7eb;
    border-color: #d1d5db;
}

body.light-mode .timer-toggle-switch.active {
    background: #059669;
    border-color: #059669;
}

body.light-mode .timer-toggle-slider {
    background: #9ca3af;
}

body.light-mode .timer-toggle-switch.active .timer-toggle-slider {
    background: #ffffff;
}

body.light-mode .timer-toggle-label {
    color: #1a2421;
}

/* =====================================================
   SCENE MODAL - LIGHT MODE OVERRIDES
===================================================== */

/* Modal footer buttons area */
body.light-mode .modal-buttons {
    background: #ffffff;
    border-top-color: #e5e7eb;
}

/* Form group labels */
body.light-mode .form-group label {
    color: #374151;
}

/* Edit modal scrollable actions */
body.light-mode .edit-modal-actions-scroll::-webkit-scrollbar-track {
    background: #f3f4f6;
}

body.light-mode .edit-modal-actions-scroll::-webkit-scrollbar-thumb {
    background: #d1d5db;
}

body.light-mode .edit-modal-actions-scroll::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Modal scrollable content scrollbar */
body.light-mode .modal-scrollable-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
}

body.light-mode .modal-scrollable-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Action row styling - overrides inline styles */
body.light-mode .action-row {
    background: #f9fafb !important;
    border: 1px solid #e5e7eb !important;
}

/* Action row labels and helper text */
body.light-mode .action-row label,
body.light-mode .action-row strong {
    color: #6b7280 !important;
}

/* Section headings in modals */
body.light-mode .edit-modal-left h3,
body.light-mode .edit-modal-right h3 {
    color: #374151 !important;
}

/* Timer section border */
body.light-mode .form-group[style*="border-top"] {
    border-top-color: #e5e7eb !important;
}

/* Timer section styling */
body.light-mode .edit-modal-left .form-group small {
    color: #6b7280 !important;
}

/* Timer labels */
body.light-mode label[for*="timer"] {
    color: #6b7280 !important;
}

/* Timer inputs - override inline styles */
body.light-mode input[id*="timer-minutes"],
body.light-mode input[id*="timer-seconds"],
body.light-mode input[id*="wake-home-timer-minutes"],
body.light-mode input[id*="wake-home-timer-seconds"] {
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
    color: #1f2937 !important;
}

body.light-mode input[id*="timer-minutes"]:disabled,
body.light-mode input[id*="timer-seconds"]:disabled,
body.light-mode input[id*="wake-home-timer-minutes"]:disabled,
body.light-mode input[id*="wake-home-timer-seconds"]:disabled {
    background: #f3f4f6 !important;
    border-color: #e5e7eb !important;
    color: #9ca3af !important;
}

/* Remove action button */
body.light-mode .action-row button[onclick*="removeActionRow"] {
    color: #ef4444 !important;
}

body.light-mode .action-row button[onclick*="removeActionRow"]:hover {
    color: #dc2626 !important;
}

/* =====================================================
   MATERIAL ICONS
===================================================== */

.material-symbols-outlined {
    font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
    vertical-align: middle;
    display: inline-block;
    font-size: inherit;
}

.logo .material-symbols-outlined {
    font-size: 24px;
}

.nav-item .material-symbols-outlined {
    font-size: 22px;
}

.device-icon .material-symbols-outlined {
    font-size: 30px;
}

.room-icon .material-symbols-outlined,
.large-room-icon .material-symbols-outlined {
    font-size: inherit;
}

.scene-icon .material-symbols-outlined {
    font-size: 35px;
}

.telegram-icon .material-symbols-outlined {
    font-size: 28px;
}

.log-item .material-symbols-outlined {
    font-size: 10px;
    vertical-align: middle;
}

.card-title .material-symbols-outlined,
.telemetry .material-symbols-outlined {
    font-size: 14px;
    vertical-align: middle;
    margin-right: 4px;
}

.notification .material-symbols-outlined {
    font-size: 18px;
}

.media-control .material-symbols-outlined {
    font-size: 14px;
}

.play .material-symbols-outlined {
    font-size: 16px;
}


/* =====================================================
   SIDEBAR
===================================================== */

.sidebar {

    position: fixed;

    left: 0;
    top: 0;
    bottom: 0;

    width: 82px;

    padding: 22px 14px;

    background:
        linear-gradient(
            180deg,
            #0d1213,
            #090d0e
        );

    display: flex;
    flex-direction: column;

    z-index: 10;

    transition: width 0.3s ease;
}

.sidebar:hover {
    width: 230px;
}


/* LOGO */

.logo {

    width: 46px;
    height: 46px;

    margin: auto;
    margin-bottom: 25px;

    border-radius: 15px;

    display: grid;
    place-items: center;

    background: #151d1e;

    color: #4de7c9;

    font-size: 24px;

    box-shadow:
        inset 3px 3px 8px #080b0c,
        inset -3px -3px 8px #202b2c;
}


/* NAVIGATION */

.navigation {

    display: flex;

    flex-direction: column;

    gap: 9px;

    align-items: flex-start;

    width: 100%;
}


.nav-item {

    width: 50px;
    height: 50px;

    border: none;

    border-radius: 17px;

    background: transparent;

    color: #65716f;

    cursor: pointer;

    font-size: 21px;

    transition: all 0.3s ease;

    position: relative;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;
}

.sidebar:hover .nav-item {
    width: 100%;
    justify-content: flex-start;
    padding-left: 14px;
}


.nav-item label {

    display: none;
    margin-left: 14px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
    color: inherit;
}

.sidebar:hover .nav-item label {
    display: block;
}


.nav-item:hover {

    color: #d8e5e2;

    background: #141c1d;
}


.nav-item.active {

    color: #52e9cc;

    background: #162e2d;

    box-shadow:
        0 0 25px #28d9b01c,
        inset 0 0 15px #36d9bd16;
}


/* =====================================================
   LIVE LOG
===================================================== */

.live-log {

    margin-top: auto;

    background: #111819;

    border-radius: 19px;

    padding: 12px 10px;

    box-shadow:
        inset 2px 2px 7px #080a0a,
        inset -2px -2px 7px #202a2b;

    min-height: 220px;

    overflow: hidden;
}


.log-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 9px;

    font-size: 9px;

    font-weight: 700;

    letter-spacing: 0.12em;
}


.log-header small {

    color: #4ee4c7;

    font-size: 8px;
}


.online-dot {

    display: inline-block;

    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: #48e2c5;

    box-shadow:
        0 0 9px #48e2c5;
}


.log-item {

    padding: 7px 3px;

    border-bottom: 1px solid #1b2425;

    font-size: 9px;
}


.log-item time {

    display: block;

    color: #5e6b69;

    font-size: 8px;
}


.log-item strong {

    display: block;

    margin: 3px 0;

    color: #cbd5d3;

    font-weight: 500;
}


.log-item small {

    color: #768381;

    font-size: 8px;
}


/* =====================================================
   MAIN
===================================================== */

.main {

    margin-left: 82px;

    padding: 0 28px 180px;

    transition: margin-left 0.3s ease;
}


/* =====================================================
   TOP BAR
===================================================== */

.topbar {

    height: 78px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    position: sticky;

    top: 0;

    z-index: 5;

    background: #090d0edc;

    backdrop-filter: blur(14px);
}


.breadcrumb {

    display: flex;

    gap: 10px;

    align-items: center;

    font-size: 12px;
}


.breadcrumb span {

    color: #697673;
}


.breadcrumb b {

    color: #364140;
}


.header-right {

    display: flex;

    align-items: center;

    gap: 9px;
}


.telemetry,
.esp-status,
.notification,
.theme-toggle,
.mode-toggle {

    border: none;

    background: #141b1c;

    color: #b9c8c5;

    border-radius: 14px;

    padding: 9px 13px;

    font-size: 10px;

    box-shadow:
        inset 1px 1px 4px #080a0a,
        inset -1px -1px 4px #202829;

    transition: all 0.3s ease;
}

.notification,
.theme-toggle {
    cursor: pointer;
    font-size: 17px;
    position: relative;
}

/* ปุ่มสลับ Manual / Automation - มี label จึงกว้างกว่าปุ่มไอคอนอื่น */
.mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    letter-spacing: .04em;
}

/* Hide mobile navigation elements on desktop */
.mobile-menu-btn {
    display: none;
}

.mobile-sidebar-backdrop {
    display: none;
}

.mobile-close-btn {
    display: none;
}

.mode-toggle .material-symbols-outlined {
    font-size: 17px !important;
}

.mode-toggle .mode-label {
    font-size: 9px;
}

/* โหมดอัตโนมัติ - เน้นสีให้เห็นชัดว่าระบบคุมเองอยู่ */
.mode-toggle.auto {
    background: #3dd9bd;
    color: #06231f;
    box-shadow:
        0 0 14px rgba(61, 217, 189, .35),
        inset 1px 1px 4px rgba(0, 0, 0, .12);
}

.mode-toggle:disabled {
    opacity: .55;
    cursor: wait;
}

.notification:hover,
.theme-toggle:hover,
.mode-toggle:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow:
        0 8px 20px rgba(78, 232, 195, 0.25),
        inset 1px 1px 4px #080a0a,
        inset -1px -1px 4px #202829,
        0 0 15px rgba(78, 232, 195, 0.4);
}

.mode-toggle.auto:hover:not(:disabled) {
    box-shadow:
        0 8px 20px rgba(61, 217, 189, .45),
        0 0 18px rgba(61, 217, 189, .55);
}

body.light-mode .notification:hover,
body.light-mode .theme-toggle:hover,
body.light-mode .mode-toggle:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow:
        0 8px 20px rgba(61, 217, 189, 0.25),
        inset 1px 1px 3px #e0e2e5,
        inset -1px -1px 3px #ffffff,
        0 0 15px rgba(61, 217, 189, 0.4);
}

body.light-mode .mode-toggle.auto,
body.light-mode .mode-toggle.auto:hover:not(:disabled) {
    background: #3dd9bd;
    color: #06231f;
    box-shadow:
        0 0 14px rgba(61, 217, 189, .35);
}


.avatar {

    width: 36px;
    height: 36px;

    border-radius: 50%;

    display: grid;
    place-items: center;

    color: #56e5c8;

    font-weight: 700;

    background: #141b1c;

    box-shadow:
        inset 1px 1px 4px #080a0a,
        inset -1px -1px 4px #202829;
}


.avatar.large {

    width: 40px;
    height: 40px;
}


/* =====================================================
   TITLES
===================================================== */

.title-row,
.page-header {

    display: flex;

    justify-content: space-between;

    align-items: flex-end;

    margin: 25px 0 22px;
}


.back-button {
    border: none;
    background: #1a2223;
    color: #82908d;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
    box-shadow:
        inset 1px 1px 4px #080a0a,
        inset -1px -1px 4px #273131;
}

.back-button:hover {
    transform: translateX(-5px);
    color: #4ee8ca;
    box-shadow:
        0 5px 15px rgba(78, 232, 195, 0.3),
        inset 1px 1px 4px #080a0a,
        inset -1px -1px 4px #273131,
        0 0 15px rgba(78, 232, 195, 0.3);
}

body.light-mode .back-button {
    background: #f0f2f5;
    color: #5a6269;
    box-shadow:
        inset 1px 1px 3px #d8dce0,
        inset -1px -1px 3px #ffffff;
}

body.light-mode .back-button:hover {
    transform: translateX(-5px);
    color: #3dd9bd;
    box-shadow:
        0 5px 15px rgba(61, 217, 189, 0.3),
        inset 1px 1px 3px #d8dce0,
        inset -1px -1px 3px #ffffff,
        0 0 15px rgba(61, 217, 189, 0.3);
}


.eyebrow {

    font-size: 10px;

    letter-spacing: 0.18em;

    color: #4dd9c0;

    font-weight: 700;

    margin-bottom: 7px;
}


h1 {

    font-size: 31px;

    margin: 0;

    letter-spacing: -0.04em;
}


h2,
h3,
p {

    margin-top: 0;
}


.subtitle {

    color: #697673;

    font-size: 12px;

    margin-top: 8px;
}


/* =====================================================
   CARD
===================================================== */

.card {

    background: #141b1c;

    border-radius: 20px;

    padding: 18px;

    box-shadow:

        5px 6px 18px #030606,

        inset 1px 1px 4px #202a2b,

        inset -1px -1px 4px #090c0d;

    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow:
        8px 10px 25px #030606,
        inset 1px 1px 4px #202a2b,
        inset -1px -1px 4px #090c0d,
        0 0 20px rgba(78, 232, 195, 0.15);
}


/* =====================================================
   DASHBOARD GRID
===================================================== */

.dashboard-grid {

    display: grid;

    grid-template-columns:
        repeat(12, 1fr);

    gap: 14px;

    row-gap: 14px;
}


/* =====================================================
   HERO
===================================================== */

.hero-card {

    grid-column: span 10;

    min-height: 240px;

    padding: 20px;

    display: grid;

    grid-template-columns:
        1.6fr 1fr;

    gap: 20px;

    overflow: hidden;
}


/* =====================================================
   SMART HOME OVERVIEW
===================================================== */

.overview-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.overview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.overview-header h2 {
    font-size: 20px;
    margin: 0;
    letter-spacing: 0.05em;
    color: #4ee8ca;
}

.system-status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1a2e2d;
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #5fe6cb;
}

.overview-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stat-card {
    background: #0f1516;
    border-radius: 14px;
    padding: 12px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    box-shadow:
        inset 2px 2px 4px #080a0a,
        inset -2px -2px 4px #1a2223;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #1a2e2d;
    display: grid;
    place-items: center;
    color: #4ee8ca;
    font-size: 20px;
    flex-shrink: 0;
}

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

.stat-content small {
    font-size: 8px;
    letter-spacing: 0.1em;
    color: #687572;
    font-weight: 600;
}

.stat-content strong {
    font-size: 16px;
    color: #d8e5e2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-badge {
    font-size: 8px;
    color: #7a8684;
    background: #141b1c;
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
    width: fit-content;
}

.stat-badge.active-badge {
    background: #1a2e2d;
    color: #5fe6cb;
}

.stat-badge.success-badge {
    background: #1a2e2d;
    color: #5fe6cb;
}

.system-connections {
    background: #0f1516;
    border-radius: 14px;
    padding: 12px;
    box-shadow:
        inset 2px 2px 4px #080a0a,
        inset -2px -2px 4px #1a2223;
}

.system-connections > small {
    font-size: 8px;
    letter-spacing: 0.1em;
    color: #687572;
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
}

.connection-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.connection-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
}

.connection-item.connected {
    color: #5fe6cb;
}

.connection-item.disconnected {
    color: #7a4a4a;
}

.connection-item.disconnected .online-dot {
    background: #ff6b6b;
    box-shadow: 0 0 9px #ff6b6b;
}

.connection-item span {
    font-weight: 600;
    color: #d8e5e2;
}

.connection-item small {
    margin-left: auto;
    font-size: 8px;
    color: inherit;
}

/* PIR SENSORS - compact horizontal card, separate from SYSTEM CONNECTIONS
   but reusing its card shell (background/radius/shadow) for visual consistency */
.pir-sensors {
    margin-top: 4px;
    padding: 10px 12px;
}

.pir-sensors > small {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.pir-sensors > small .material-symbols-outlined {
    font-size: 14px;
    margin-right: 4px;
    color: #687572;
}

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

.pir-room {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 10px;
}

.pir-room-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #d8e5e2;
}

.pir-room small {
    font-size: 8px;
    letter-spacing: 0.02em;
    padding-left: 13px;
}

.pir-room.pir-clear small {
    color: #7a8582;
}

.pir-room.pir-clear .online-dot {
    background: #4a5552;
    box-shadow: none;
}

.pir-room.pir-motion small {
    color: #5fe6cb;
}

.pir-room.pir-motion .online-dot {
    background: #48e2c5;
    box-shadow: 0 0 9px #48e2c5;
    animation: pir-pulse 1.6s ease-in-out infinite;
}

@keyframes pir-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.overview-scenes {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.overview-scenes h3 {
    font-size: 11px;
    margin: 0;
    letter-spacing: 0.08em;
    color: #87938f;
}

.quick-scene-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scene-quick-btn {
    background: #141b1c;
    border: none;
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #c8d4d1;
    font-size: 11px;
    font-weight: 600;
    box-shadow:
        inset 1px 1px 3px #080a0a,
        inset -1px -1px 3px #202a2b;
}

.scene-quick-btn:hover {
    transform: translateX(5px);
    background: #1a2223;
    color: #4ee8ca;
    box-shadow:
        0 5px 15px rgba(78, 232, 195, 0.2),
        inset 1px 1px 3px #080a0a,
        inset -1px -1px 3px #202a2b;
}

.scene-quick-btn.active {
    background: #1a2e2d;
    color: #4ee8ca;
    box-shadow:
        0 0 20px rgba(78, 232, 195, 0.2),
        inset 0 0 15px rgba(78, 232, 195, 0.1);
}

.scene-quick-btn span:last-child {
    flex: 1;
    text-align: left;
}

body.light-mode .overview-header h2 {
    color: #3dd9bd;
}

body.light-mode .system-status-badge {
    background: #e8f7f4;
    color: #2ab89f;
}

body.light-mode .stat-card {
    background: #f8f9fb;
    box-shadow:
        inset 1px 1px 3px #e0e2e5,
        inset -1px -1px 3px #ffffff;
}

body.light-mode .stat-icon {
    background: #e8f7f4;
    color: #3dd9bd;
}

body.light-mode .stat-content strong {
    color: #2a3238;
}

body.light-mode .stat-badge {
    background: #ffffff;
    color: #8a9199;
}

body.light-mode .stat-badge.active-badge,
body.light-mode .stat-badge.success-badge {
    background: #e8f7f4;
    color: #2ab89f;
}

body.light-mode .system-connections {
    background: #f8f9fb;
    box-shadow:
        inset 1px 1px 3px #e0e2e5,
        inset -1px -1px 3px #ffffff;
}

body.light-mode .connection-item.connected {
    color: #3dd9bd;
}

body.light-mode .connection-item span {
    color: #2a3238;
}

body.light-mode .pir-room-name span {
    color: #2a3238;
}

body.light-mode .pir-sensors > small .material-symbols-outlined {
    color: #8a9490;
}

body.light-mode .pir-room.pir-clear small {
    color: #9aa3a0;
}

body.light-mode .pir-room.pir-clear .online-dot {
    background: #c4cac8;
    box-shadow: none;
}

body.light-mode .pir-room.pir-motion small {
    color: #2fae95;
}

body.light-mode .scene-quick-btn {
    background: #ffffff;
    color: #5a6269;
    box-shadow:
        inset 1px 1px 3px #e0e2e5,
        inset -1px -1px 3px #ffffff;
}

body.light-mode .scene-quick-btn:hover {
    background: #f0f2f5;
    color: #3dd9bd;
}

body.light-mode .scene-quick-btn.active {
    background: #e8f7f4;
    color: #2ab89f;
    box-shadow:
        0 0 20px rgba(61, 217, 189, 0.2),
        inset 0 0 15px rgba(61, 217, 189, 0.1);
}

body.light-mode .media-artwork {
    background: rgba(61, 217, 189, 0.08);
    box-shadow:
        inset 2px 2px 5px rgba(0, 0, 0, 0.05),
        inset -2px -2px 5px rgba(255, 255, 255, 0.8);
}

body.light-mode .media-btn {
    background: #f0f2f5;
    color: #3dd9bd;
    box-shadow:
        3px 3px 8px rgba(0, 0, 0, 0.1),
        -3px -3px 8px #ffffff;
}

body.light-mode .media-btn:hover {
    box-shadow:
        5px 5px 12px rgba(0, 0, 0, 0.15),
        -5px -5px 12px #ffffff,
        0 0 20px rgba(61, 217, 189, 0.3);
}

body.light-mode .media-btn:active {
    box-shadow:
        inset 2px 2px 5px rgba(0, 0, 0, 0.1),
        inset -2px -2px 5px #ffffff;
}

body.light-mode .media-btn-play {
    background: linear-gradient(135deg, #3dd9bd, #2fb89e);
    color: #ffffff;
}

body.light-mode .progress-bar {
    background: #e8eaed;
    box-shadow:
        inset 2px 2px 4px rgba(0, 0, 0, 0.08),
        inset -2px -2px 4px #ffffff;
}


.camera {

    position: relative;

    border-radius: 18px;

    overflow: hidden;

    display: grid;

    place-items: center;

    background:

        radial-gradient(
            circle at 55% 45%,
            #1e3937,
            #101718 48%,
            #0a0e0f
        );
}


.camera::before {

    content: "";

    position: absolute;

    width: 220px;
    height: 220px;

    border-radius: 50%;

    background: #42d8bd16;

    filter: blur(35px);
}


.camera-text {

    text-align: center;

    color: #687875;

    letter-spacing: 0.16em;

    font-size: 11px;

    z-index: 1;
}


.camera-text strong {

    display: block;

    color: #b4c5c1;

    font-size: 25px;
}


.live {

    position: absolute;

    top: 12px;
    left: 12px;

    z-index: 2;

    color: #5fe6cb;

    background: #0c1515cc;

    padding: 7px 9px;

    border-radius: 10px;

    font-size: 9px;
}


/* HERO CONTROL */

.hero-controls {

    padding: 17px;
}


.room-title {

    display: flex;

    align-items: center;

    gap: 11px;

    margin-bottom: 18px;
}


.room-title .icon {

    font-size: 30px;
}


.room-title h2 {

    font-size: 18px;

    margin-bottom: 3px;
}


.device-row {

    display: flex;

    justify-content: space-between;

    align-items: center;

    padding: 12px 0;

    border-bottom: 1px solid #1c2525;

    font-size: 11px;
}


/* =====================================================
   SWITCH
===================================================== */

.switch {

    width: 43px;
    height: 23px;

    border-radius: 20px;

    background: #27302f;

    position: relative;

    cursor: pointer;

    transition: all 0.3s ease;
}

.switch:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(78, 232, 195, 0.3);
}

body.light-mode .switch:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(61, 217, 189, 0.3);
}


.switch::after {

    content: "";

    width: 16px;
    height: 16px;

    border-radius: 50%;

    background: #6d7876;

    position: absolute;

    top: 3.5px;
    left: 3px;

    transition: 0.2s;
}


.switch.on {

    background: #2d7e71;

    box-shadow:
        0 0 14px #35dbc066;
}


.switch.on::after {

    left: 24px;

    background: #5cf0d3;
}


/* =====================================================
   ROOM CARDS
===================================================== */

.room-card {

    grid-column: span 4;

    min-height: 200px;

    cursor: pointer;

    transition: all 0.3s ease;

    padding: 18px;
}

.room-card:hover {
    transform: translateY(-5px);
    box-shadow:
        10px 15px 35px #030606,
        inset 1px 1px 5px #202a2b,
        inset -1px -1px 5px #090c0d,
        0 0 20px rgba(78, 232, 195, 0.25);
}

body.light-mode .room-card:hover {
    transform: translateY(-5px);
    box-shadow:
        5px 12px 30px rgba(0, 0, 0, 0.12),
        inset 1px 1px 3px #f5f7f9,
        inset -1px -1px 3px #e8eaed,
        0 0 20px rgba(61, 217, 189, 0.25);
}


.room-header {

    display: flex;

    align-items: center;

    gap: 11px;
}


.room-icon {

    font-size: 28px;
}


.room-header h3 {

    font-size: 14px;

    margin: 0;
}


.room-header small {

    color: #6e7a78;

    font-size: 9px;
}


.room-arrow {

    margin-left: auto;

    color: #4ee1c4;
}


/* Dashboard Room Selector */

.dashboard-room-selector {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
}

.dashboard-room-selector-trigger {
    display: flex;
    align-items: center;
    gap: 11px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: inherit;
    font-family: inherit;
    text-align: left;
    width: 100%;
    transition: all 0.2s ease;
}

.dashboard-room-selector-trigger:hover {
    opacity: 0.9;
}

.dashboard-room-selector-trigger:focus {
    outline: 2px solid #4ee1c4;
    outline-offset: 2px;
    border-radius: 8px;
}

.dashboard-room-selector-label {
    flex: 1;
}

.dashboard-room-selector-label h3 {
    font-size: 14px;
    margin: 0;
}

.dashboard-room-selector-label small {
    color: #6e7a78;
    font-size: 9px;
}

.dashboard-room-selector-arrow {
    font-size: 20px;
    color: #8a9d9a;
    transition: transform 0.2s ease;
}

.dashboard-room-selector-trigger[aria-expanded="true"] .dashboard-room-selector-arrow {
    transform: rotate(180deg);
}

.dashboard-room-selector-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #141b1c;
    border-radius: 12px;
    box-shadow:
        5px 6px 18px #030606,
        inset 1px 1px 3px #202a2b,
        inset -1px -1px 3px #090c0d;
    overflow: hidden;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    pointer-events: none;
}

.dashboard-room-selector-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.dashboard-room-selector-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: none;
    border: none;
    border-bottom: 1px solid #1c2525;
    color: #b8c7c4;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

.dashboard-room-selector-option:last-child {
    border-bottom: none;
}

.dashboard-room-selector-option:hover {
    background: #1a2221;
    color: #e8f1ef;
}

.dashboard-room-selector-option.active {
    background: #1e2828;
    color: #4ee1c4;
}

.dashboard-room-selector-option .room-icon {
    font-size: 22px;
}

/* Light mode */

body.light-mode .dashboard-room-selector-label small {
    color: #8a9199;
}

body.light-mode .dashboard-room-selector-arrow {
    color: #6a7279;
}

body.light-mode .dashboard-room-selector-menu {
    background: #ffffff;
    box-shadow:
        5px 8px 20px rgba(0, 0, 0, 0.12),
        inset 1px 1px 3px #f5f7f9,
        inset -1px -1px 3px #e8eaed;
}

body.light-mode .dashboard-room-selector-option {
    color: #5a6269;
    border-bottom: 1px solid #e8eaed;
}

body.light-mode .dashboard-room-selector-option:hover {
    background: #f8f9fb;
    color: #1a1f23;
}

body.light-mode .dashboard-room-selector-option.active {
    background: #e8f5f1;
    color: #00a67e;
}


.room-devices {

    margin: 17px 0;

    display: flex;

    flex-direction: column;

    gap: 8px;
}


.room-device {

    display: flex;

    justify-content: space-between;

    color: #9eaba8;

    font-size: 10px;
}


.room-device span:last-child {

    color: #55d9c1;
}


.ghost-button,
.secondary-button,
.primary-button,
.danger-button {

    border: none;

    border-radius: 12px;

    padding: 9px 12px;

    font-size: 9px;

    font-weight: 700;

    letter-spacing: 0.08em;

    cursor: pointer;

    transition: all 0.3s ease;
}

.ghost-button:hover,
.secondary-button:hover {
    transform: translateY(-3px);
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.3),
        inset 1px 1px 4px #080a0a,
        inset -1px -1px 4px #273131,
        0 0 15px rgba(78, 232, 195, 0.3);
}

body.light-mode .ghost-button:hover,
body.light-mode .secondary-button:hover {
    transform: translateY(-3px);
    box-shadow:
        0 8px 20px rgba(61, 217, 189, 0.2),
        inset 1px 1px 3px #d8dce0,
        inset -1px -1px 3px #ffffff,
        0 0 15px rgba(61, 217, 189, 0.3);
}


.ghost-button,
.secondary-button {

    background: #1a2223;

    color: #82908d;

    box-shadow:
        inset 1px 1px 4px #080a0a,
        inset -1px -1px 4px #273131;
}


.primary-button {

    background: #3fd9bd;

    color: #07100f;

    box-shadow:
        0 0 20px #39d6ba26;
}

.primary-button:hover {
    transform: translateY(-3px);
    box-shadow:
        0 12px 30px rgba(61, 217, 189, 0.4),
        0 0 25px rgba(61, 217, 189, 0.5);
}


.danger-button {

    background: #442325;

    color: #ff9d9d;
}

.danger-button:hover {
    transform: translateY(-3px);
    box-shadow:
        0 8px 20px rgba(255, 107, 107, 0.3),
        0 0 15px rgba(255, 107, 107, 0.4);
    background: #5a2f32;
}

body.light-mode .danger-button:hover {
    transform: translateY(-3px);
    box-shadow:
        0 8px 20px rgba(255, 107, 107, 0.3),
        0 0 15px rgba(255, 107, 107, 0.4);
    background: #ffcccc;
}


/* =====================================================
   SENSOR CARDS
===================================================== */

.sensor-card {

    grid-column: span 4;

    min-height: 200px;

    padding: 18px;
}


.card-title {

    display: flex;

    justify-content: space-between;

    align-items: center;

    color: #87938f;

    font-size: 10px;
}

.icon-button {
    background: none;
    border: none;
    color: #8a9199;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.icon-button:hover {
    background: rgba(61, 217, 189, 0.1);
    color: #3dd9bd;
    transform: scale(1.1);
}

.icon-button .material-symbols-outlined {
    font-size: 18px !important;
}

body.light-mode .icon-button {
    color: #8a9199;
}

body.light-mode .icon-button:hover {
    background: rgba(61, 217, 189, 0.1);
    color: #3dd9bd;
}


.big-number {

    font-size: 31px;

    font-weight: 600;

    margin: 13px 0;

    font-variant-numeric: tabular-nums;
}


.big-number small {

    font-size: 13px;

    color: #687572;
}


.sparkline {

    color: #4bdac1;

    opacity: 0.7;

    letter-spacing: 3px;
}


/* =====================================================
   SYSTEM CARD
===================================================== */

.system-card {

    grid-column: span 3;

    min-height: 160px;

    display: flex;

    flex-direction: column;

    justify-content: space-between;

    padding: 18px;
}


.system-status {

    margin: 15px 0;

    font-size: 11px;
}


.system-card p {

    color: #697673;

    font-size: 9px;
}


/* =====================================================
   QUICK SCENE
===================================================== */

.quick-scene {

    grid-column: span 3;

    min-height: 160px;

    display: flex;

    flex-direction: column;

    justify-content: space-between;

    padding: 18px;
}


.quick-scene button + button {

    margin-top: 8px;
}


/* =====================================================
   MEDIA CONTROL
===================================================== */

.media-control-card {
    grid-column: span 7;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    padding: 18px;
}

/* =====================================================
   LIVE LOG CARD (Dashboard)
===================================================== */

.live-log-card {
    grid-column: span 5;
    /* ล็อคความสูงไม่ให้ยืดตามจำนวน log - ถ้าปล่อยให้เนื้อหากำหนดความสูง
       การ์ดจะยาวขึ้นเรื่อยๆ แล้วดัน grid row ทั้งแถวสูงตาม */
    min-height: 300px;
    padding: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* height: 0 + flex-grow ทำให้ความสูงของเนื้อหาไม่ไปดัน grid row
   การ์ดจึงสูงเท่าแถว (หรือ min-height ถ้าอยู่แถวเดียว) แล้ว log ที่เกิน
   ถูก overflow:hidden ตัดทิ้ง - ตัวใหม่ unshift ไว้บนสุด ตัวเก่าไหลลงล่าง */
#dashboard-log-container {
    flex: 1 1 0;
    height: 0;
    min-height: 0;
    overflow: hidden;
    /* ไล่เฟดขอบล่าง ให้แถวที่ถูกตัดครึ่งดูเป็นเจตนา ไม่ใช่ดูเหมือนพัง */
    -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 78%, transparent 100%);
}

.live-log-card .log-item {
    padding: 7px 3px;
    border-bottom: 1px solid #1b2425;
    font-size: 9px;
}

.live-log-card .log-item time {
    display: block;
    color: #5e6b69;
    font-size: 8px;
}

.live-log-card .log-item strong {
    display: block;
    margin: 3px 0;
    color: #cbd5d3;
    font-weight: 500;
}

.live-log-card .log-item small {
    color: #768381;
    font-size: 8px;
}

body.light-mode .live-log-card .log-item {
    border-bottom: 1px solid #e5e7ea;
}

body.light-mode .live-log-card .log-item strong {
    color: #2a3238;
}

body.light-mode .live-log-card .log-item small {
    color: #8a9199;
}


/* =====================================================
   DOOR LOCK CARD (Dashboard)
===================================================== */

.door-lock-card {
    grid-column: span 2;
    min-height: 240px;
    padding: 18px;
    display: flex;
    flex-direction: column;
}

/* การ์ดแคบ (2/12 คอลัมน์) จึงเรียงตั้งแทนแนวนอน */
.door-lock-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex: 1;
    margin-top: 12px;
    text-align: center;
}

.door-lock-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    flex-shrink: 0;
    border-radius: 14px;
    background: rgba(78, 228, 199, 0.1);
    border: 1px solid rgba(78, 228, 199, 0.25);
    transition: background .25s, border-color .25s;
}

.door-lock-icon .material-symbols-outlined {
    font-size: 30px !important;
    color: #4ee4c7;
    transition: color .25s;
}

.door-lock-icon.unlocked {
    background: rgba(255, 217, 61, 0.12);
    border-color: rgba(255, 217, 61, 0.35);
}

.door-lock-icon.unlocked .material-symbols-outlined {
    color: #ffd93d;
}

.door-lock-status {
    min-width: 0;
    width: 100%;
}

.door-lock-status strong {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #cbd5d3;
    line-height: 1.35;
}

.door-lock-status small {
    display: block;
    margin-top: 3px;
    font-size: 9px;
    color: #768381;
}

.door-lock-status .door-countdown {
    font-size: 40px;
    line-height: 1.05;
    color: #ffd93d;
    font-variant-numeric: tabular-nums;
}

.door-unlock-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    flex-shrink: 0;
    margin-top: auto;
    padding: 11px 12px;
    border: none;
    border-radius: 10px;
    background: #3dd9bd;
    color: #06231f;
    font-size: 10px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: filter .2s, transform .1s;
}

.door-unlock-btn .material-symbols-outlined {
    font-size: 17px !important;
}

.door-unlock-btn:hover:not(:disabled) {
    filter: brightness(1.1);
}

.door-unlock-btn:active:not(:disabled) {
    transform: scale(.97);
}

.door-unlock-btn:disabled,
.door-unlock-btn.counting {
    background: #2a3a38;
    color: #7d8b89;
    cursor: not-allowed;
}

body.light-mode .door-lock-status strong {
    color: #2a3238;
}

body.light-mode .door-lock-status small {
    color: #8a9199;
}

body.light-mode .door-unlock-btn:disabled,
body.light-mode .door-unlock-btn.counting {
    background: #e5e7ea;
    color: #9aa1a9;
}

.auto-settings-card {
    grid-column: span 2;
    min-height: 240px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    margin-top: 24px;
}

.auto-settings-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
    margin-top: 12px;
}

.auto-settings-field label {
    display: block;
    font-size: 9px;
    color: #768381;
    margin-bottom: 6px;
}

.auto-settings-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.auto-settings-time-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.auto-settings-input-row input {
    width: 70px;
    padding: 8px 10px;
    border: 1px solid rgba(78, 228, 199, 0.25);
    border-radius: 8px;
    background: rgba(78, 228, 199, 0.06);
    color: #cbd5d3;
    font-family: inherit;
    font-size: 13px;
    text-align: center;
}

.auto-settings-input-row input:focus {
    outline: none;
    border-color: #4ee4c7;
}

.auto-settings-input-row span {
    font-size: 10px;
    color: #768381;
}

.auto-settings-apply-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: auto;
    padding: 11px 12px;
    border: none;
    border-radius: 10px;
    background: #3dd9bd;
    color: #06231f;
    font-size: 10px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: filter .2s, transform .1s;
}

.auto-settings-apply-btn:hover {
    filter: brightness(1.1);
}

.auto-settings-apply-btn:active {
    transform: scale(.97);
}

body.light-mode .auto-settings-field label,
body.light-mode .auto-settings-input-row span {
    color: #8a9199;
}

body.light-mode .auto-settings-input-row input {
    background: #f0f2f1;
    color: #1a2422;
    border-color: rgba(78, 228, 199, 0.4);
}

.spotify-login-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    text-align: center;
    min-height: 250px;
}

.spotify-icon {
    font-size: 64px !important;
    color: #3dd9bd;
    margin-bottom: 15px;
    opacity: 0.8;
}

.spotify-login-prompt h3 {
    margin: 10px 0;
    font-size: 20px;
}

.spotify-login-prompt p {
    color: #8a9199;
    margin: 5px 0 20px 0;
    font-size: 14px;
}

.spotify-login-prompt .primary-button {
    display: flex;
    align-items: center;
    gap: 8px;
}

.media-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.media-artwork {
    width: 80px;
    height: 80px;
    background: rgba(61, 217, 189, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 2px 2px 5px rgba(0, 0, 0, 0.3),
        inset -2px -2px 5px rgba(255, 255, 255, 0.05);
}

.media-artwork .material-symbols-outlined {
    font-size: 48px !important;
    color: #3dd9bd;
    opacity: 0.7;
}

.media-details h3 {
    margin: 0 0 5px 0;
    font-size: 18px;
}

.media-details p {
    margin: 0;
    color: #8a9199;
    font-size: 14px;
}

.media-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
}

.media-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: #0d1415;
    color: #3dd9bd;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow:
        5px 5px 15px #030606,
        -5px -5px 15px #17201f;
}

.media-btn:hover {
    transform: translateY(-3px);
    box-shadow:
        7px 7px 20px #030606,
        -7px -7px 20px #17201f,
        0 0 20px rgba(61, 217, 189, 0.3);
}

.media-btn:active {
    transform: translateY(0);
    box-shadow:
        inset 3px 3px 8px #030606,
        inset -3px -3px 8px #17201f;
}

.media-btn-play {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #3dd9bd, #2fb89e);
    color: #090d0e;
}

.media-btn-play:hover {
    box-shadow:
        7px 7px 20px #030606,
        -7px -7px 20px #17201f,
        0 0 30px rgba(61, 217, 189, 0.5);
}

.media-btn .material-symbols-outlined {
    font-size: 28px !important;
}

.media-btn-play .material-symbols-outlined {
    font-size: 32px !important;
}

.media-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.media-progress small {
    color: #8a9199;
    font-size: 12px;
    min-width: 35px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: #0d1415;
    border-radius: 3px;
    overflow: hidden;
    box-shadow:
        inset 2px 2px 5px #030606,
        inset -2px -2px 5px #17201f;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3dd9bd, #2fb89e);
    border-radius: 3px;
    transition: width 0.3s ease;
}


/* =====================================================
   MINIMIZED SPOTIFY PLAYER
===================================================== */

.spotify-mini-player {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;

    display: flex;
    align-items: center;
    gap: 12px;

    background: #131a1bdf;
    backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 12px 16px;

    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(61, 217, 189, 0.15),
        inset 1px 1px 3px #232d2d;

    cursor: pointer;
    transition: all 0.3s ease;

    max-width: 320px;
}

.spotify-mini-player:hover {
    transform: translateY(-3px);
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(61, 217, 189, 0.25),
        inset 1px 1px 3px #232d2d;
}

.spotify-mini-album {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    background: rgba(61, 217, 189, 0.1);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spotify-mini-album .material-symbols-outlined {
    font-size: 28px !important;
    color: #3dd9bd;
    opacity: 0.7;
}

.spotify-mini-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.spotify-mini-info strong {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spotify-mini-info small {
    font-size: 11px;
    color: #8a9199;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spotify-mini-play-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #3dd9bd, #2fb89e);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
    box-shadow:
        0 4px 12px rgba(61, 217, 189, 0.4);
}

.spotify-mini-play-btn:hover {
    transform: scale(1.1);
    box-shadow:
        0 6px 16px rgba(61, 217, 189, 0.6);
}

.spotify-mini-play-btn:active {
    transform: scale(0.95);
}

.spotify-mini-play-btn .material-symbols-outlined {
    font-size: 28px !important;
}

/* Light Mode */
body.light-mode .spotify-mini-player {
    background: #ffffffee;
    backdrop-filter: blur(16px);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.15),
        0 0 20px rgba(61, 217, 189, 0.2),
        inset 1px 1px 3px #f5f7f9;
}

body.light-mode .spotify-mini-player:hover {
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.2),
        0 0 30px rgba(61, 217, 189, 0.3),
        inset 1px 1px 3px #f5f7f9;
}

body.light-mode .spotify-mini-info strong {
    color: #1a1f23;
}

body.light-mode .spotify-mini-info small {
    color: #6a7279;
}


/* =====================================================
   PAGE GRID
===================================================== */

.room-grid,
.scene-grid,
.device-grid,
.settings-grid,
.telegram-grid {

    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap: 16px;
}


/* =====================================================
   ROOM PAGE
===================================================== */

.large-room {

    min-height: 330px;

    cursor: pointer;

    transition: all 0.3s ease;
}

.large-room:hover {
    transform: translateY(-5px);
    box-shadow:
        10px 15px 35px #030606,
        inset 1px 1px 5px #202a2b,
        inset -1px -1px 5px #090c0d,
        0 0 20px rgba(78, 232, 195, 0.25);
}

body.light-mode .large-room:hover {
    transform: translateY(-5px);
    box-shadow:
        5px 12px 30px rgba(0, 0, 0, 0.12),
        inset 1px 1px 3px #f5f7f9,
        inset -1px -1px 3px #e8eaed,
        0 0 20px rgba(61, 217, 189, 0.25);
}


.large-room-icon {

    font-size: 45px;
}


.room-preview {

    display: flex;

    flex-direction: column;

    gap: 9px;

    margin: 20px 0;
}


.room-preview div {

    display: flex;

    justify-content: space-between;

    font-size: 10px;
}


.room-preview b {

    color: #58dcc4;
}


/* =====================================================
   DEVICE PAGE
===================================================== */

.device-card {

    min-height: 220px;

    transition: all 0.3s ease;
    cursor: pointer;
}

.device-card:hover {
    transform: translateY(-5px);
    box-shadow:
        10px 15px 35px #030606,
        inset 1px 1px 5px #202a2b,
        inset -1px -1px 5px #090c0d,
        0 0 20px rgba(78, 232, 195, 0.25);
}

body.light-mode .device-card:hover {
    transform: translateY(-5px);
    box-shadow:
        5px 12px 30px rgba(0, 0, 0, 0.12),
        inset 1px 1px 3px #f5f7f9,
        inset -1px -1px 3px #e8eaed,
        0 0 20px rgba(61, 217, 189, 0.25);
}


.device-top {

    display: flex;

    justify-content: space-between;

    align-items: center;
}


.device-icon {

    font-size: 30px;
}


.device-card h3 {

    margin-top: 17px;

    margin-bottom: 5px;

    font-size: 15px;
}


.device-card small {

    color: #6d7977;

    font-size: 9px;
}


.ac-levels {

    display: flex;

    gap: 5px;

    margin-top: 20px;
}


.ac-level {

    flex: 1;

    padding: 9px 5px;

    border: none;

    border-radius: 9px;

    background: #202827;

    color: #75817f;

    font-size: 8px;

    cursor: pointer;

    transition: all 0.3s ease;
}

.ac-level:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(78, 232, 195, 0.3);
    background: #2a3230;
}

body.light-mode .ac-level:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(61, 217, 189, 0.3);
    background: #f0f2f5;
}


.ac-level.active {

    background: #2c7d70;

    color: #8af2dc;
}


.servo-buttons {

    display: flex;

    gap: 8px;

    margin-top: 20px;
}


.device-state {

    margin-top: 20px;

    color: #55d9c1;

    font-size: 10px;
}


/* =====================================================
   SCENE
===================================================== */

.scene-card {

    min-height: 190px;

    display: flex;

    flex-direction: column;

    transition: all 0.3s ease;
    cursor: pointer;
}

.scene-card:hover {
    transform: translateY(-5px);
    box-shadow:
        10px 15px 35px #030606,
        inset 1px 1px 5px #202a2b,
        inset -1px -1px 5px #090c0d,
        0 0 20px rgba(78, 232, 195, 0.25);
}

body.light-mode .scene-card:hover {
    transform: translateY(-5px);
    box-shadow:
        5px 12px 30px rgba(0, 0, 0, 0.12),
        inset 1px 1px 3px #f5f7f9,
        inset -1px -1px 3px #e8eaed,
        0 0 20px rgba(61, 217, 189, 0.25);
}


.scene-icon {

    font-size: 35px;
}

.scene-icon .scene-emoji {

    font-size: 35px;
    line-height: 1;
    display: inline-block;
}


.scene-card h2 {

    font-size: 16px;

    margin-top: 15px;
}


.scene-card p {

    color: #6d7977;

    font-size: 9px;
}


.scene-actions {

    margin-top: auto;

    display: flex;

    justify-content: flex-end;

    gap: 7px;
}


/* =====================================================
   TABLE
===================================================== */

.table-card {

    padding: 0;

    overflow: hidden;
}


.table-header,
.table-row {

    display: grid;

    grid-template-columns:
        0.6fr 1.4fr 1.2fr 1fr 0.7fr;

    gap: 10px;

    align-items: center;

    padding: 15px 20px;

    font-size: 10px;
}


.table-header {

    color: #5f6d69;

    background: #101617;

    font-size: 8px;

    letter-spacing: 0.1em;
}


.table-row {

    border-top: 1px solid #1b2424;

    color: #aab7b4;
}


.good {

    color: #54dcc4;
}


/* =====================================================
   FINGERPRINT
===================================================== */

.fingerprint-summary {

    display: flex;

    align-items: center;

    gap: 20px;

    margin-bottom: 16px;
}


.fingerprint-circle {

    width: 90px;
    height: 90px;

    border-radius: 50%;

    display: grid;

    place-items: center;

    background: #102220;

    color: #4ee4c7;

    font-size: 35px;

    box-shadow:
        0 0 30px #32d8bc20,
        inset 0 0 20px #060a0a;
}


.fingerprint-actions {

    margin-left: auto;

    display: flex;

    gap: 7px;

    flex-wrap: wrap;

    justify-content: flex-end;
}


/* =====================================================
   FINGERPRINT MANAGEMENT UI REDESIGN
===================================================== */

/* Admin Authorization Card */
.fp-admin-card {
    max-width: 700px;
    margin-bottom: 24px;
}

.fp-admin-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.fp-admin-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #163330;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4ee4c7;
    flex-shrink: 0;
}

.fp-admin-icon .material-symbols-outlined {
    font-size: 28px;
}

.fp-admin-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.fp-admin-subtitle {
    margin: 4px 0 0 0;
    font-size: 13px;
    color: #8a9d9a;
}

.fp-admin-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
}

.fp-admin-locked {
    background: #1a1414;
    color: #e88080;
    border: 1px solid #2d1a1a;
}

.fp-admin-locked .material-symbols-outlined {
    color: #e88080;
    font-size: 20px;
}

.fp-admin-authorized {
    background: #0f1f1c;
    color: #4ee4c7;
    border: 1px solid #1a2e2a;
}

.fp-admin-authorized .material-symbols-outlined {
    color: #4ee4c7;
    font-size: 20px;
}

.fp-admin-details {
    margin-bottom: 20px;
}

.fp-admin-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #1c2525;
}

.fp-admin-detail-row:last-child {
    border-bottom: none;
}

.fp-detail-label {
    font-size: 13px;
    color: #8a9d9a;
}

.fp-detail-value {
    font-size: 14px;
    color: #ffffff;
    font-weight: 500;
}

.fp-countdown {
    font-family: 'Courier New', monospace;
    color: #4ee4c7;
}

.fp-role-badge {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.fp-role-admin {
    background: #1a2a3a;
    color: #6ba3ff;
}

.fp-auth-button,
.fp-logout-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.fp-auth-button .material-symbols-outlined,
.fp-logout-button .material-symbols-outlined {
    font-size: 20px;
}

.fp-auth-message {
    margin-top: 16px;
    font-size: 13px;
    color: #8a9d9a;
    text-align: center;
}

/* Content Grid */
.fp-content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .fp-content-grid {
        grid-template-columns: 1fr;
    }
}

/* Card Titles */
.fp-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    margin: 0 0 20px 0;
}

/* Enrollment Form */
.fp-enrollment-card {
    height: fit-content;
}

.fp-form {
    max-width: 100%;
}

.fp-form-group {
    margin-bottom: 18px;
}

.fp-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #b8c7c4;
    margin-bottom: 8px;
}

.fp-input,
.fp-select {
    width: 100%;
    height: 46px;
    padding: 0 16px;
    background: #0d1514;
    border: 1px solid #1c2525;
    border-radius: 10px;
    color: #ffffff;
    font-size: 14px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.fp-input::placeholder {
    color: #5a6b68;
}

.fp-input:focus,
.fp-select:focus {
    outline: none;
    border-color: #4ee4c7;
    background: #0f1a19;
    box-shadow: 0 0 0 3px rgba(78, 228, 199, 0.1);
}

.fp-input:hover,
.fp-select:hover {
    border-color: #2a3635;
}

.fp-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238a9d9a'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
}

.fp-select option {
    background: #0d1514;
    color: #ffffff;
}

/* Specific styling for Role dropdown to ensure it overrides any browser defaults */
#enroll-role {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 46px;
    padding: 0 40px 0 16px;
    background-color: #0d1514;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238a9d9a'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    border: 1px solid #1c2525;
    border-radius: 10px;
    color: #ffffff;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

#enroll-role:hover {
    border-color: #2a3635;
}

#enroll-role:focus {
    outline: none;
    border-color: #4ee4c7;
    background-color: #0f1a19;
    box-shadow: 0 0 0 3px rgba(78, 228, 199, 0.1);
}

#enroll-role option {
    background: #0d1514;
    color: #ffffff;
}

.fp-enroll-button,
.fp-cancel-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
}

.fp-enroll-button .material-symbols-outlined,
.fp-cancel-button .material-symbols-outlined {
    font-size: 20px;
}

/* Status Card */
.fp-status-card {
    height: fit-content;
}

.fp-status-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.fp-status-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: #0d1514;
    border: 1px solid #1c2525;
    border-radius: 10px;
}

.fp-status-item .material-symbols-outlined {
    font-size: 32px;
    color: #4ee4c7;
}

.fp-status-text {
    flex: 1;
}

.fp-status-label {
    font-size: 12px;
    color: #8a9d9a;
    margin-bottom: 4px;
}

.fp-status-value {
    font-size: 15px;
    font-weight: 500;
    color: #ffffff;
}

/* Enrollment Progress */
.fp-progress-card {
    margin-bottom: 24px;
}

.fp-enrollment-status {
    margin-bottom: 20px;
}

.fp-enrollment-message {
    font-size: 14px;
    color: #b8c7c4;
    margin-bottom: 16px;
}

.fp-progress-bar-container {
    width: 100%;
    height: 8px;
    background: #0d1514;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #1c2525;
}

.fp-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4ee4c7, #3ab8a0);
    width: 0%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Fingerprint List Table */
.fp-list-card {
    margin-bottom: 24px;
}

.fp-table {
    width: 100%;
}

.fp-table-header {
    display: grid;
    grid-template-columns: 70px 1fr 100px 140px 120px;
    gap: 12px;
    padding: 12px 16px;
    background: #0d1514;
    border: 1px solid #1c2525;
    border-radius: 10px 10px 0 0;
    font-size: 12px;
    font-weight: 600;
    color: #8a9d9a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fp-table-body {
    border: 1px solid #1c2525;
    border-top: none;
    border-radius: 0 0 10px 10px;
    overflow: hidden;
}

.fp-table-row {
    display: grid;
    grid-template-columns: 70px 1fr 100px 140px 120px;
    gap: 12px;
    padding: 14px 16px;
    align-items: center;
    border-bottom: 1px solid #1c2525;
    transition: background 0.2s ease;
}

.fp-table-row:last-child {
    border-bottom: none;
}

.fp-table-row:hover {
    background: #0d1514;
}

.fp-col-id {
    font-weight: 600;
    color: #4ee4c7;
}

.fp-col-name {
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
}

.fp-col-role .fp-role-badge {
    display: inline-block;
}

.fp-role-user {
    background: #1a2a1f;
    color: #7ec99c;
}

.fp-col-created {
    font-size: 13px;
    color: #8a9d9a;
}

.fp-col-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.fp-delete-button {
    padding: 6px 14px;
    background: #2d1a1a;
    color: #e88080;
    border: 1px solid #3d2424;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.fp-delete-button:hover {
    background: #3d2424;
    color: #ff9090;
}

.fp-protected-badge {
    padding: 6px 14px;
    background: #1a2a3a;
    color: #6ba3ff;
    border: 1px solid #243a54;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.fp-table-loading {
    padding: 40px 20px;
    text-align: center;
    color: #8a9d9a;
    font-size: 14px;
}

.fp-table-empty {
    padding: 40px 20px;
    text-align: center;
    color: #8a9d9a;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .fp-table-header,
    .fp-table-row {
        grid-template-columns: 60px 1fr 80px;
        gap: 10px;
    }

    .fp-col-created,
    .fp-col-actions {
        display: none;
    }

    .fp-admin-card {
        max-width: 100%;
    }
}

/* =====================================================
   FINGERPRINT MANAGEMENT - LIGHT MODE
===================================================== */

body.light-mode .fp-admin-card,
body.light-mode .fp-enrollment-card,
body.light-mode .fp-status-card,
body.light-mode .fp-progress-card,
body.light-mode .fp-list-card {
    background: #ffffff;
    border: 1px solid #d0d7d5;
}

body.light-mode .fp-card-title {
    color: #1a2421;
}

body.light-mode .fp-admin-title h3 {
    color: #1a2421;
}

body.light-mode .fp-admin-subtitle {
    color: #5a6b68;
}

body.light-mode .fp-admin-icon {
    background: #e8f5f1;
}

body.light-mode .fp-admin-icon .material-symbols-outlined {
    color: #00a67e;
}

body.light-mode .fp-admin-status {
    background: #f5f7f6;
    border: 1px solid #d0d7d5;
}

body.light-mode .fp-admin-locked {
    color: #666;
}

body.light-mode .fp-admin-authorized {
    color: #00a67e;
}

body.light-mode .fp-detail-label {
    color: #666;
}

body.light-mode .fp-detail-value {
    color: #1a2421;
}

body.light-mode .fp-countdown {
    color: #00a67e;
}

body.light-mode .fp-role-badge {
    background: #f0f0f0;
    color: #666;
}

body.light-mode .fp-role-admin {
    background: #e3f2fd;
    color: #1976d2;
}

body.light-mode .fp-role-user {
    background: #f5f5f5;
    color: #666;
}

body.light-mode .fp-auth-message {
    color: #666;
}

body.light-mode .fp-label {
    color: #1a2421;
}

body.light-mode .fp-input,
body.light-mode .fp-select {
    background: #ffffff;
    border: 1px solid #d0d7d5;
    color: #1a2421;
}

body.light-mode .fp-input::placeholder {
    color: #999;
}

body.light-mode .fp-input:focus,
body.light-mode .fp-select:focus {
    border-color: #4ee4c7;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(78, 228, 199, 0.1);
}

body.light-mode .fp-input:hover,
body.light-mode .fp-select:hover {
    border-color: #a0a0a0;
}

body.light-mode .fp-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23666666'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
}

body.light-mode .fp-select option {
    background: #ffffff;
    color: #1a2421;
}

body.light-mode #enroll-role {
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23666666'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    color: #1a2421;
    border: 1px solid #d0d7d5;
}

body.light-mode #enroll-role option {
    background: #ffffff;
    color: #1a2421;
}

body.light-mode .fp-status-label {
    color: #666;
}

body.light-mode .fp-status-value {
    color: #1a2421;
}

body.light-mode .fp-enrollment-message {
    color: #666;
}

body.light-mode .fp-progress-bar-container {
    background: #e0e0e0;
}

body.light-mode .fp-status-item {
    background: #f5f7f6;
    border: 1px solid #d0d7d5;
}

body.light-mode .fp-status-item .material-symbols-outlined {
    color: #00a67e;
}

body.light-mode .fp-table {
    border: 1px solid #d0d7d5;
}

body.light-mode .fp-table-header {
    background: #f5f7f6;
    border-bottom: 2px solid #d0d7d5;
    color: #1a2421;
}

body.light-mode .fp-table-row {
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    color: #1a2421;
}

body.light-mode .fp-table-row:hover {
    background: #f9f9f9;
}

body.light-mode .fp-protected-badge {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

body.light-mode .fp-table-loading,
body.light-mode .fp-table-empty {
    color: #666;
}


/* =====================================================
   TELEGRAM
===================================================== */

.telegram-grid {

    grid-template-columns:
        1.4fr 0.8fr;
}


.telegram-icon {

    width: 58px;
    height: 58px;

    border-radius: 19px;

    display: grid;

    place-items: center;

    background: #163330;

    color: #53e2c6;

    font-size: 28px;
}


.telegram-status {

    display: flex;

    justify-content: space-between;

    padding: 14px 0;

    border-bottom: 1px solid #1c2525;

    font-size: 10px;
}


.big-rule {

    font-size: 72px;

    font-weight: 700;

    color: #50dfc3;

    margin: 30px 0;
}


/* =====================================================
   SETTINGS
===================================================== */

.setting-card {

    display: grid;

    grid-template-columns:
        1fr auto;

    gap: 7px;

    align-items: center;
}


.setting-card small {

    color: #71807c;

    font-size: 9px;
}


/* =====================================================
   DEBUG CONSOLE (ESP32 Automatic Mode telemetry)
===================================================== */

.debug-console-card {

    margin-top: 24px;
}


.debug-console-log {

    max-height: 360px;

    overflow-y: auto;

    display: flex;

    flex-direction: column;

    gap: 6px;

    font-family: "Consolas", "Courier New", monospace;

    font-size: 12px;
}


.debug-log-entry {

    display: flex;

    gap: 10px;

    padding: 6px 10px;

    border-radius: 8px;

    background: #0c1111;

    border-left: 3px solid #3a4a48;
}


.debug-log-time {

    color: #71807c;

    flex-shrink: 0;
}


.debug-log-message {

    color: #d7e2df;

    word-break: break-word;
}


.debug-log-pir {
    border-left-color: #4fd1c5;
}

.debug-log-timer {
    border-left-color: #f6c343;
}

.debug-log-timeout {
    border-left-color: #f0883e;
}

.debug-log-shutdown {
    border-left-color: #f25c54;
}

.debug-log-restore {
    border-left-color: #5cc8f2;
}

.debug-log-mode {
    border-left-color: #a78bfa;
}


body.light-mode .debug-log-entry {
    background: #f0f2f1;
}

body.light-mode .debug-log-message {
    color: #1a2422;
}


/* =====================================================
   FLOATING DOCK
===================================================== */

.floating-dock {

    position: fixed;

    bottom: 18px;

    left: calc(82px + 34px);

    right: 34px;

    max-width: 500px;

    margin: auto;

    background: #131a1bdf;

    backdrop-filter: blur(16px);

    border-radius: 20px;

    padding: 12px 16px;

    box-shadow:
        0 15px 40px #020404,
        inset 1px 1px 5px #232d2d;

    display: flex;

    gap: 16px;

    z-index: 1000;

    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =====================================================
   COMPACT/MINIMIZED STATE
===================================================== */

.floating-dock.dock-minimized {
    max-width: 260px;
    padding: 10px 14px;
    gap: 0;
    border-radius: 32px;
    background: rgba(15, 20, 21, 0.95);
    backdrop-filter: blur(20px);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 1px rgba(61, 217, 189, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.05);
}

.floating-dock.dock-minimized .dock-album-container {
    display: none;
}

.floating-dock.dock-minimized .dock-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 100%;
    padding: 0;
}

.floating-dock.dock-minimized .dock-track-info-top {
    display: none;
}

.floating-dock.dock-minimized .dock-progress-section {
    display: none;
}

.floating-dock.dock-minimized .media-control {
    margin: 0;
    gap: 6px;
    flex: 0;
    justify-content: center;
    align-items: center;
}

.floating-dock.dock-minimized .media-control button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(45, 55, 57, 0.6);
    color: #8a9d9a;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.floating-dock.dock-minimized .media-control button:hover {
    background: rgba(60, 75, 77, 0.8);
    color: #b8c7c4;
    transform: scale(1.05);
}

.floating-dock.dock-minimized .media-control button.play {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, rgba(61, 217, 189, 0.9), rgba(47, 184, 158, 0.9));
    color: #0a0e0f;
    box-shadow: 0 2px 8px rgba(61, 217, 189, 0.3);
}

.floating-dock.dock-minimized .media-control button.play:hover {
    background: linear-gradient(135deg, #3dd9bd, #2fb89e);
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(61, 217, 189, 0.4);
}

.floating-dock.dock-minimized .media-control .material-symbols-outlined {
    font-size: 20px;
}

.floating-dock.dock-minimized .media-control button.play .material-symbols-outlined {
    font-size: 24px;
}

.floating-dock.dock-minimized .dock-airplay-btn {
    display: none;
}

.floating-dock.dock-minimized .dock-menu-btn {
    display: none;
}

.floating-dock.dock-minimized .dock-expand-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    margin-left: 6px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(61, 217, 189, 0.15);
    color: #3dd9bd;
    border: 1px solid rgba(61, 217, 189, 0.2);
    transition: all 0.2s ease;
    cursor: pointer;
}

.floating-dock.dock-minimized .dock-expand-btn:hover {
    background: rgba(61, 217, 189, 0.25);
    color: #4ee8ca;
    transform: scale(1.05);
    box-shadow: 0 0 12px rgba(61, 217, 189, 0.3);
}

.dock-expand-btn {
    display: none;
}

.dock-album-container {
    flex-shrink: 0;
}

.dock-album-container .avatar.large {
    width: 60px;
    height: 60px;
    border-radius: 12px;
}

.dock-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.dock-track-info-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.dock-track-details {
    flex: 1;
    min-width: 0;
}

.dock-track-details strong {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.dock-track-details small {
    display: block;
    font-size: 10px;
    color: #8a9199;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dock-menu-btn,
.dock-airplay-btn {
    background: none;
    border: none;
    color: #8a9199;
    cursor: pointer;
    padding: 4px;
    transition: all 0.3s ease;
}

.dock-menu-btn:hover,
.dock-airplay-btn:hover {
    color: #3dd9bd;
}

.dock-menu-btn .material-symbols-outlined,
.dock-airplay-btn .material-symbols-outlined {
    font-size: 20px;
}

.dock-progress-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-time {
    font-size: 9px;
    color: #8a9199;
    flex-shrink: 0;
    min-width: 32px;
}

.progress-time:first-child {
    text-align: right;
}

.progress-time:last-child {
    text-align: left;
}

.mini-progress-container {
    flex: 1;
    display: block !important;
}

.mini-progress-bar {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3dd9bd, #4ee8ca);
    border-radius: 3px;
    transition: none;
    will-change: width;
}

body.light-mode .mini-progress-bar {
    background: rgba(0, 0, 0, 0.15);
}

body.light-mode .mini-progress-fill {
    background: linear-gradient(90deg, #3dd9bd, #4ee8ca);
}


/* =====================================================
   FINGERPRINT SCAN ANIMATION
===================================================== */

.fingerprint-scan-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(61, 217, 189, 0.3);
    animation: pulse-ring 2s ease-out infinite;
    z-index: 1;
}

@keyframes pulse-ring {
    0% {
        width: 100px;
        height: 100px;
        opacity: 1;
    }
    100% {
        width: 200px;
        height: 200px;
        opacity: 0;
    }
}

.scan-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3dd9bd;
    animation: scan-bounce 1.4s ease-in-out infinite;
}

.scan-dot:nth-child(1) {
    animation-delay: 0s;
}

.scan-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.scan-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes scan-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

.scan-success {
    position: relative;
    overflow: hidden;
}

.scan-success::before {
    content: '';
    position: absolute;
    inset: -3px;
    background: linear-gradient(90deg,
        transparent 0%,
        #4ee8ca 25%,
        transparent 50%,
        #3dd9bd 75%,
        transparent 100%);
    border-radius: inherit;
    animation: border-run 2s linear infinite;
    z-index: -1;
    will-change: transform;
}

@keyframes border-run {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.scan-success::after {
    content: '';
    position: absolute;
    inset: 0;
    background: #0d1415;
    border-radius: inherit;
    z-index: -1;
}

body.light-mode .scan-success::after {
    background: #ffffff;
}

.scan-delete {
    position: relative;
    overflow: hidden;
}

.scan-delete::before {
    content: '';
    position: absolute;
    inset: -3px;
    background: linear-gradient(90deg,
        transparent 0%,
        #ff6b6b 25%,
        transparent 50%,
        #ff4757 75%,
        transparent 100%);
    border-radius: inherit;
    animation: border-run 2s linear infinite;
    z-index: -1;
    will-change: transform;
}

.scan-delete::after {
    content: '';
    position: absolute;
    inset: 0;
    background: #0d1415;
    border-radius: inherit;
    z-index: -1;
}

body.light-mode .scan-delete::after {
    background: #ffffff;
}

.success-checkmark {
    animation: checkmark-pop 0.6s ease-out;
}

@keyframes checkmark-pop {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}


.dock-user {

    display: flex;

    align-items: center;

    gap: 12px;

    flex: 1;

    min-width: 0;
}


.dock-user .avatar.large {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}


.dock-user small {

    display: block;

    color: #71807c;

    font-size: 9px;

    margin-top: 3px;
}

.dock-track-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.dock-track-info strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
}

.dock-track-info small {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mini-progress-container {
    width: 100%;
    margin-top: 5px;
    display: none;
}

.mini-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3dd9bd, #4ee8ca);
    border-radius: 2px;
    transition: none;
    will-change: width;
}

body.light-mode .mini-progress-bar {
    background: rgba(0, 0, 0, 0.1);
}

body.light-mode .mini-progress-fill {
    background: linear-gradient(90deg, #3dd9bd, #4ee8ca);
}


.media-control {

    display: flex;

    align-items: center;

    justify-content: center;

    gap: 14px;

    font-size: 10px;

    color: #91a09c;
}

.dock-track-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.dock-track-info strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dock-track-info small {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-controls {
    display: flex;
    align-items: center;
    gap: 14px;
}

.mini-progress-container {
    width: 100%;
    margin-top: 4px;
    display: none;
}

.mini-progress-bar {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3dd9bd, #4ee8ca);
    border-radius: 2px;
    transition: none;
    will-change: width;
}

body.light-mode .mini-progress-bar {
    background: rgba(0, 0, 0, 0.1);
}

body.light-mode .mini-progress-fill {
    background: linear-gradient(90deg, #3dd9bd, #4ee8ca);
}


.media-control button {

    border: none;

    background: transparent;

    color: #c8d4d1;

    cursor: pointer;

    transition: all 0.3s ease;
}

.media-control button:hover {
    transform: scale(1.15);
    color: #4ee8ca;
    filter: drop-shadow(0 0 8px rgba(78, 232, 195, 0.5));
}

body.light-mode .media-control button:hover {
    transform: scale(1.15);
    color: #3dd9bd;
    filter: drop-shadow(0 0 8px rgba(61, 217, 189, 0.5));
}


.media-control .play {

    width: 30px;
    height: 30px;

    border-radius: 50%;

    background: #3ed9be;

    color: #07100f;
}

.media-control .play:hover {
    transform: scale(1.2);
    box-shadow: 0 0 20px rgba(62, 217, 190, 0.6);
}

body.light-mode .media-control .play:hover {
    transform: scale(1.2);
    box-shadow: 0 0 20px rgba(61, 217, 189, 0.6);
}


/* =====================================================
   MODAL
===================================================== */

.modal {

    position: fixed;

    inset: 0;

    background: #000a;

    backdrop-filter: blur(7px);

    display: grid;

    place-items: center;

    z-index: 1100;
}


.modal.hidden {

    display: none;
}


.modal-content {

    width: min(460px, 92vw);

    background: #141b1c;

    border-radius: 25px;

    padding: 25px;
    padding-bottom: 25px;

    box-shadow:
        0 25px 80px #000,
        inset 1px 1px 5px #232d2d;

    position: relative;

    max-height: calc(100vh - 40px);
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
}

/* Edit Scene Modal - Landscape Layout for Desktop */
.edit-modal-layout {
    display: flex;
    gap: 24px;
    margin-top: 20px;
}

.edit-modal-left {
    flex: 0 0 35%;
    min-width: 0;
}

.edit-modal-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.edit-modal-actions-scroll {
    overflow-y: auto;
    max-height: 400px;
    padding-right: 8px;
}

.edit-modal-actions-scroll::-webkit-scrollbar {
    width: 6px;
}

.edit-modal-actions-scroll::-webkit-scrollbar-track {
    background: #0d1314;
    border-radius: 3px;
}

.edit-modal-actions-scroll::-webkit-scrollbar-thumb {
    background: #1c2525;
    border-radius: 3px;
}

.edit-modal-actions-scroll::-webkit-scrollbar-thumb:hover {
    background: #2a3535;
}

/* Wider modal for Edit Scene on desktop */
body:has(.edit-modal-layout) .modal-content {
    width: min(1100px, calc(100vw - 40px));
}

/* Modal scrollable content wrapper */
.modal-scrollable-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 25px;
    margin: 0 -25px;
}

.modal-scrollable-content::-webkit-scrollbar {
    width: 8px;
}

.modal-scrollable-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-scrollable-content::-webkit-scrollbar-thumb {
    background: #1c2525;
    border-radius: 4px;
}

.modal-scrollable-content::-webkit-scrollbar-thumb:hover {
    background: #2a3535;
}

/* Mobile: stack vertically */
@media (max-width: 768px) {
    .edit-modal-layout {
        flex-direction: column;
    }

    .edit-modal-left {
        flex: 1;
    }

    .edit-modal-actions-scroll {
        max-height: 300px;
    }

    body:has(.edit-modal-layout) .modal-content {
        width: min(460px, 92vw);
    }
}


.modal-content input,
.modal-content select,
.modal-content textarea {

    width: 100%;

    padding: 12px;

    margin: 8px 0;

    border: none;

    border-radius: 12px;

    background: #0d1314;

    color: #dce7e4;

    font-family: inherit;
}

.modal-content textarea {
    resize: vertical;
    min-height: 60px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
    color: #b8c7c4;
}

.modal-buttons {

    display: flex;

    justify-content: flex-end;

    gap: 8px;

    margin-top: 0;

    position: sticky;
    bottom: 0;
    background: #141b1c;
    padding: 16px 0;
    border-top: 1px solid #1c2525;
    z-index: 10;
}


/* =====================================================
   TOAST
===================================================== */

#toast {

    position: fixed;

    right: 30px;

    top: 90px;

    background: #172120;

    color: #d7e5e1;

    padding: 12px 16px;

    border-radius: 13px;

    box-shadow:
        0 12px 35px #0008;

    transform: translateX(130%);

    transition: 0.3s;

    z-index: 200;

    font-size: 11px;
}


#toast.show {

    transform: translateX(0);
}


/* =====================================================
   RESPONSIVE
===================================================== */

@media(max-width:1400px) {

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

    .hero-card {
        grid-column: span 5;
        grid-template-columns: 1fr;
        min-height: auto;
    }

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

    .sensor-card {
        grid-column: span 3;
    }

    .media-control-card {
        grid-column: span 6;
    }

    .quick-scene {
        grid-column: span 3;
    }

    .system-card {
        grid-column: span 3;
    }

    .door-lock-card {
        grid-column: span 1;
    }
}

@media(max-width:1100px) {

    .sidebar {

        width: 82px;
    }

    .live-log {

        display: none;
    }

    .main {

        margin-left: 82px;

        padding: 0 22px 90px;
    }

    .floating-dock {

        left: 110px;

        right: 22px;
    }

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

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

    .door-lock-card {
        grid-column: span 1;
    }

    .room-card,
    .sensor-card,
    .system-card,
    .quick-scene,
    .media-control-card {
        grid-column: span 3;
    }
}


@media(max-width:760px) {

    .sidebar {

        width: 64px;
    }

    .main {

        margin-left: 64px;

        padding: 0 12px 90px;
    }

    .header-right .telemetry,
    .esp-status {

        display: none;
    }

    /* Mobile - Hide label to prevent button crowding */
    .mode-toggle .mode-label {
        display: none;
    }

    .mode-toggle {
        gap: 0;
    }

    .dashboard-grid {

        grid-template-columns: 1fr;
    }

    .hero-card,
    .room-card,
    .sensor-card,
    .system-card,
    .quick-scene {

        grid-column: 1 / -1;
    }

    .door-lock-card {
        grid-column: 1 / -1;
        min-height: auto;
    }

    /* Mobile - Card layout fixes */
    .door-lock-body {
        flex-direction: row;
        text-align: left;
        gap: 16px;
    }

    .door-lock-status {
        flex: 1;
    }

    .door-unlock-btn {
        width: auto;
        margin-top: 0;
        padding: 11px 20px;
        font-size: 11px;
    }

    .hero-card {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .camera {

        height: 210px;
    }

    .room-grid,
    .scene-grid,
    .device-grid,
    .settings-grid,
    .telegram-grid {

        grid-template-columns: 1fr;
    }

    .pir-grid {
        flex-direction: column;
        gap: 8px;
    }

    .floating-dock {

        left: 76px;

        right: 12px;
    }

}


/* ===================================================== HISTORY DASHBOARD */
.history-page-header{display:flex;justify-content:space-between;align-items:flex-end;gap:20px}.history-refresh{display:flex;align-items:center;gap:7px}.history-filters{display:grid;grid-template-columns:1fr 1fr 1.2fr 1.7fr auto;gap:14px;align-items:end;margin-bottom:16px}.history-filter{display:flex;flex-direction:column;gap:7px}.history-filter label{font-size:9px;letter-spacing:.12em;color:#65736f}.history-filter select,.history-search-box{height:42px;border:1px solid #263331;background:#101617;color:#dce7e3;border-radius:9px;padding:0 12px;outline:none;cursor:pointer;transition:border-color 0.2s ease}.history-filter select:hover,.history-search-box:hover{border-color:#3dd9bd}.history-filter select:focus,.history-search-box:focus{border-color:#3dd9bd}.history-filter select option{background:#101617;color:#dce7e3;padding:8px}.history-search-box{display:flex;align-items:center;gap:8px}.history-search-box input{background:transparent;border:0;outline:0;color:inherit;width:100%}.history-clear{height:42px}.history-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-bottom:16px}.history-stat{display:flex;align-items:center;gap:14px;padding:17px}.history-stat>span{font-size:25px;color:#54dcc4}.history-stat small{display:block;color:#687773;font-size:8px;letter-spacing:.1em;margin-bottom:4px}.history-stat strong{font-size:16px;color:#e5efeb}.history-table-grid{grid-template-columns:1.2fr 1.25fr .9fr .9fr 2.4fr!important}.history-badge{display:inline-flex;padding:5px 8px;border-radius:20px;font-size:8px;font-weight:700;letter-spacing:.05em;background:#1d2927;color:#9fb8b0}.type-device-control{background:#163a38;color:#54dcc4}.type-auto-action{background:#3a3116;color:#e7c86c}.type-scene-change{background:#27213d;color:#ae9cff}.type-system-event{background:#24313a;color:#87c9ef}.history-tag{padding:4px 8px;border-radius:6px;background:#18201f;text-transform:capitalize}.history-muted{color:#52605c}.history-message{color:#d5dfdb;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.history-loading,.history-empty,.history-error{padding:45px 20px;text-align:center;display:flex;flex-direction:column;align-items:center;gap:10px;color:#71807b}.history-loading .material-symbols-outlined{animation:historySpin 1s linear infinite}.history-empty span{font-size:34px}.history-error{color:#ff8a8a}@keyframes historySpin{to{transform:rotate(360deg)}}.history-pagination{display:flex;justify-content:space-between;align-items:center;padding:16px 4px;color:#687773;font-size:11px}.history-pagination div{display:flex;gap:6px}.history-pagination button{width:34px;height:30px;border-radius:7px;border:1px solid #2a3734;background:#111817;color:#cbd7d2;cursor:pointer}.history-pagination button:disabled{opacity:.35;cursor:not-allowed}@media(max-width:900px){.history-filters{grid-template-columns:1fr 1fr}.history-search{grid-column:span 2}.history-stats{grid-template-columns:1fr}.history-table-card{overflow-x:auto}.history-table-grid{min-width:760px}.history-page-header{align-items:flex-start;flex-direction:column}}
.history-page-actions{display:flex;flex-direction:row;align-items:center;gap:10px}.history-clear-all{display:flex;align-items:center;gap:7px}.history-refresh,.history-clear-all{white-space:nowrap}

/* ===================================================== CUSTOM SELECT */
.custom-select{position:relative;width:100%}
.custom-select-trigger{height:42px;background:#101617;border:1px solid #263331;border-radius:9px;padding:0 12px;display:flex;align-items:center;justify-content:space-between;cursor:pointer;transition:border-color 0.2s ease}
.custom-select-trigger:hover{border-color:#3dd9bd}
.custom-select.open .custom-select-trigger{border-color:#3dd9bd}
.custom-select-value{color:#dce7e3;font-size:14px;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.custom-select-icon{color:#6b7b77;font-size:20px;transition:transform 0.2s ease}
.custom-select.open .custom-select-icon{transform:rotate(180deg)}
.custom-select-menu{position:absolute;top:calc(100% + 6px);left:0;right:0;background:#0f1413;border:1px solid #263331;border-radius:9px;box-shadow:0 4px 12px rgba(0,0,0,0.3);max-height:240px;overflow-y:auto;z-index:1000;opacity:0;visibility:hidden;transform:translateY(-10px);transition:opacity 0.2s ease,transform 0.2s ease,visibility 0.2s}
.custom-select.open .custom-select-menu{opacity:1;visibility:visible;transform:translateY(0)}
.custom-select-option{padding:10px 14px;color:#d5e0dc;cursor:pointer;transition:background 0.15s ease;font-size:14px}
.custom-select-option:hover{background:rgba(61,217,189,0.15)}
.custom-select-option.selected{background:rgba(61,217,189,0.2);color:#3dd9bd;font-weight:500}
.custom-select-option:first-child{border-radius:8px 8px 0 0}
.custom-select-option:last-child{border-radius:0 0 8px 8px}

/* ===================================================== HISTORY LIGHT MODE */
body.light-mode .history-filter label{color:#6b7b77}
body.light-mode .history-filter select,body.light-mode .history-search-box{background:#ffffff;border:1px solid #d0d7d5;color:#1a2421}
body.light-mode .history-filter select:hover,body.light-mode .history-search-box:hover{border-color:#3dd9bd}
body.light-mode .history-filter select:focus,body.light-mode .history-search-box:focus{border-color:#3dd9bd}
body.light-mode .history-filter select option{background:#ffffff;color:#1a2421}
body.light-mode .history-stat small{color:#6b7b77}
body.light-mode .history-stat strong{color:#1a2421}
body.light-mode .history-badge{background:#e8eeed;color:#5a6a67}
body.light-mode .type-device-control{background:#d4f4ef;color:#1a6b60}
body.light-mode .type-auto-action{background:#f9f2dc;color:#8a6d1a}
body.light-mode .type-scene-change{background:#ebe6f5;color:#6b4fb8}
body.light-mode .type-system-event{background:#dceef8;color:#2a6b8f}
body.light-mode .history-tag{background:#e8eeed;color:#2a3735}
body.light-mode .history-muted{color:#6b7b77}
body.light-mode .history-message{color:#2a3735}
body.light-mode .history-loading,body.light-mode .history-empty,body.light-mode .history-error{color:#6b7b77}
body.light-mode .history-error{color:#d93939}
body.light-mode .history-pagination{color:#6b7b77}
body.light-mode .history-pagination button{background:#ffffff;border:1px solid #d0d7d5;color:#2a3735}
body.light-mode .history-pagination button:hover{background:#f5f7f9}

/* Custom Select Light Mode */
body.light-mode .custom-select-trigger{background:#ffffff;border:1px solid #d0d7d5}
body.light-mode .custom-select-trigger:hover{border-color:#3dd9bd}
body.light-mode .custom-select.open .custom-select-trigger{border-color:#3dd9bd}
body.light-mode .custom-select-value{color:#1a2421}
body.light-mode .custom-select-icon{color:#6b7b77}
body.light-mode .custom-select-menu{background:#ffffff;border:1px solid #d0d7d5;box-shadow:0 4px 12px rgba(0,0,0,0.1)}
body.light-mode .custom-select-option{color:#2a3735}
body.light-mode .custom-select-option:hover{background:rgba(61,217,189,0.1)}
body.light-mode .custom-select-option.selected{background:rgba(61,217,189,0.15);color:#1a6b60;font-weight:500}

/* ===================================================== TELEGRAM REDESIGN */

/* Telegram Settings Grid */
.telegram-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.telegram-rooms-card {
    grid-column: span 2;
}

/* Telegram Card Headers with Icons */
.telegram-settings-grid .card h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.telegram-settings-grid .card h2 .material-symbols-outlined {
    font-size: 24px;
    color: #3dd9bd;
}

/* Telegram Setting Row */
.telegram-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid #1a1f1e;
}

.telegram-setting-row:last-child {
    border-bottom: none;
}

.telegram-setting-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.telegram-setting-info .material-symbols-outlined {
    font-size: 20px;
    color: #6b7b77;
}

.telegram-setting-info span:last-child {
    font-size: 14px;
    color: #d5e0dc;
}

/* Telegram Setting Section */
.telegram-setting-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #1a1f1e;
}

.telegram-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #d5e0dc;
    margin-bottom: 6px;
}

.telegram-help {
    font-size: 12px;
    color: #7a8985;
    margin: 0 0 16px 0;
}

/* Telegram Cooldown Inputs */
.telegram-cooldown-inputs {
    display: flex;
    gap: 16px;
}

.telegram-time-input {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.telegram-time-input label {
    font-size: 12px;
    color: #8a9995;
    font-weight: 500;
}

.telegram-time-input input {
    width: 100%;
    padding: 10px 12px;
    background: #0f1413;
    border: 1px solid #263331;
    border-radius: 8px;
    color: #e8f1ef;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.telegram-time-input input:focus {
    border-color: #3dd9bd;
}

/* Telegram Actions */
.telegram-actions {
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    margin-top: 32px;
}

.telegram-actions button {
    min-width: 180px;
}

.telegram-actions button .material-symbols-outlined {
    font-size: 18px;
    margin-right: 6px;
    vertical-align: middle;
}


/* =====================================================
   MOBILE RESPONSIVE FIXES - 375px-430px viewports
===================================================== */

@media (max-width: 480px) {
    .login-card {
        padding: 26px 20px;
    }
}

/* Extra small phones - 375px and below */
@media (max-width: 375px) {

    .main {
        padding: 0 8px 80px;
    }

    .topbar {
        padding: 0 6px;
    }

    .header-right {
        gap: 4px;
    }

    .hero-card {
        padding: 12px;
        gap: 12px;
    }

    .overview-header h2 {
        font-size: 13px;
    }

    .system-status-badge {
        font-size: 7px;
        padding: 5px 10px;
    }

    .stat-card {
        padding: 8px;
        gap: 8px;
    }

    .greeting {
        font-size: 24px;
    }

    .floating-dock.dock-minimized {
        max-width: 220px;
    }

    .floating-dock.dock-minimized .media-control {
        gap: 4px;
    }

    .floating-dock.dock-minimized .media-control button {
        width: 32px;
        height: 32px;
    }

    .floating-dock.dock-minimized .media-control button.play {
        width: 36px;
        height: 36px;
    }

    .floating-dock.dock-minimized .media-control .material-symbols-outlined {
        font-size: 18px;
    }

    .floating-dock.dock-minimized .media-control button.play .material-symbols-outlined {
        font-size: 22px;
    }
}

/* Toggle Label (existing from previous implementation) */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    width: 44px;
    height: 24px;
    appearance: none;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.toggle-label input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #666;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
}

.toggle-label input[type="checkbox"]:checked {
    background: #3dd9bd;
    border-color: #3dd9bd;
}

.toggle-label input[type="checkbox"]:checked::before {
    background: white;
    left: 22px;
}

.toggle-label span {
    color: #ddd;
    font-size: 14px;
}

/* Compact Toggle (no label) */
.toggle-label-compact {
    cursor: pointer;
    user-select: none;
}

.toggle-label-compact input[type="checkbox"] {
    width: 44px;
    height: 24px;
    appearance: none;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.toggle-label-compact input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #666;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
}

.toggle-label-compact input[type="checkbox"]:checked {
    background: #3dd9bd;
    border-color: #3dd9bd;
}

.toggle-label-compact input[type="checkbox"]:checked::before {
    background: white;
    left: 22px;
}

/* Responsive Design */
@media (max-width: 900px) {
    .telegram-settings-grid {
        grid-template-columns: 1fr;
    }

    .telegram-rooms-card {
        grid-column: span 1;
    }

    .telegram-actions {
        flex-direction: column;
    }

    .telegram-actions button {
        width: 100%;
    }
}

/* ===================================================== TELEGRAM LIGHT MODE */

body.light-mode .telegram-setting-row {
    border-bottom: 1px solid #e5e9e8;
}

body.light-mode .telegram-setting-section {
    border-top: 1px solid #e5e9e8;
}

body.light-mode .telegram-setting-info .material-symbols-outlined {
    color: #6b7b77;
}

body.light-mode .telegram-setting-info span:last-child {
    color: #2a3735;
}

body.light-mode .telegram-label {
    color: #2a3735;
}

body.light-mode .telegram-help {
    color: #6b7b77;
}

body.light-mode .telegram-time-input label {
    color: #5a6a67;
}

body.light-mode .telegram-time-input input {
    background: #ffffff;
    border: 1px solid #d0d7d5;
    color: #1a2421;
}

body.light-mode .telegram-time-input input:focus {
    border-color: #3dd9bd;
}

body.light-mode .toggle-label input[type="checkbox"] {
    background: #e8eeed;
    border: 1px solid #c5cccb;
}

body.light-mode .toggle-label input[type="checkbox"]::before {
    background: #7a8985;
}

body.light-mode .toggle-label input[type="checkbox"]:checked {
    background: #3dd9bd;
    border-color: #3dd9bd;
}

body.light-mode .toggle-label input[type="checkbox"]:checked::before {
    background: white;
}

body.light-mode .toggle-label span {
    color: #2a3735;
}

body.light-mode .toggle-label-compact input[type="checkbox"] {
    background: #e8eeed;
    border: 1px solid #c5cccb;
}

body.light-mode .toggle-label-compact input[type="checkbox"]::before {
    background: #7a8985;
}

body.light-mode .toggle-label-compact input[type="checkbox"]:checked {
    background: #3dd9bd;
    border-color: #3dd9bd;
}

body.light-mode .toggle-label-compact input[type="checkbox"]:checked::before {
    background: white;
}

/* =====================================================
   WEB LOGIN SCREEN
===================================================== */

.login-screen {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #090d0e;
}

.login-screen.auth-hidden {
    display: none;
}

.app.auth-hidden,
.floating-dock.auth-hidden {
    display: none !important;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #141b1c;
    border-radius: 20px;
    padding: 32px 28px;
    box-shadow:
        5px 6px 18px #030606,
        inset 1px 1px 4px #202a2b,
        inset -1px -1px 4px #090c0d;
}

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

.login-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 16px;
    background: #163330;
    color: #4ee4c7;
    font-size: 28px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-header h1 {
    font-size: 24px;
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

.login-header p {
    margin: 0;
    font-size: 13px;
    color: #8a9d9a;
}

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

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

.login-field label {
    font-size: 13px;
    font-weight: 500;
    color: #b8c7c4;
}

.login-field input {
    width: 100%;
    height: 46px;
    padding: 0 16px;
    background: #0d1514;
    border: 1px solid #1c2525;
    border-radius: 10px;
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-field input::placeholder {
    color: #5a6b68;
}

.login-field input:hover {
    border-color: #2a3635;
}

.login-field input:focus {
    outline: none;
    border-color: #4ee4c7;
    box-shadow: 0 0 0 3px rgba(78, 228, 199, 0.1);
}

.login-error {
    padding: 12px 14px;
    border-radius: 10px;
    background: #1a1414;
    border: 1px solid #2d1a1a;
    color: #e88080;
    font-size: 13px;
}

.login-button {
    width: 100%;
    height: 46px;
    border: none;
    border-radius: 10px;
    background: #3fd9bd;
    color: #07100f;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.1s ease;
}

.login-button:hover:not(:disabled) {
    filter: brightness(1.08);
}

.login-button:active:not(:disabled) {
    transform: scale(0.99);
}

.login-button:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Login - Light Mode */
body.light-mode .login-screen {
    background: #f5f7f9;
}

body.light-mode .login-card {
    background: #ffffff;
    box-shadow:
        5px 8px 20px rgba(0, 0, 0, 0.06),
        inset 1px 1px 3px #f5f7f9,
        inset -1px -1px 3px #e8eaed;
}

body.light-mode .login-icon {
    background: #e8f5f1;
    color: #00a67e;
}

body.light-mode .login-header p {
    color: #5a6b68;
}

body.light-mode .login-field label {
    color: #1a2421;
}

body.light-mode .login-field input {
    background: #ffffff;
    border: 1px solid #d0d7d5;
    color: #1a2421;
}

body.light-mode .login-field input::placeholder {
    color: #999;
}

body.light-mode .login-field input:hover {
    border-color: #a0a0a0;
}

body.light-mode .login-error {
    background: #fdeaea;
    border: 1px solid #f5c6c6;
    color: #b33a3a;
}

body.light-mode .login-button {
    background: #3dd9bd;
    color: #ffffff;
}

@media (max-width: 480px) {
    .login-card {
        padding: 26px 20px;
    }
}

/* =====================================================
   USER MANAGEMENT PAGE
===================================================== */

.users-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.users-header-title h2 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 600;
}

.users-header-title p {
    margin: 0;
    font-size: 13px;
    color: #8a9d9a;
}

.btn-primary, .btn-secondary, .btn-danger {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: #3dd9bd;
    color: #0a1514;
}

.btn-primary:hover {
    background: #4ee4c7;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #1c2525;
    color: #b8c7c4;
}

.btn-secondary:hover {
    background: #2a3635;
}

.btn-danger {
    background: #3a1a1a;
    color: #ff6b6b;
}

.btn-danger:hover {
    background: #4a2020;
}

.user-table {
    background: #141b1c;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 5px 6px 18px #030606;
}

.user-table-header {
    display: grid;
    grid-template-columns: 2fr 1.5fr 2fr 1fr 1fr 1.2fr 1.5fr;
    padding: 14px 18px;
    background: #0d1514;
    font-size: 12px;
    font-weight: 600;
    color: #8a9d9a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-table-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 2fr 1fr 1fr 1.2fr 1.5fr;
    padding: 14px 18px;
    border-top: 1px solid #1c2525;
    font-size: 13px;
    align-items: center;
    transition: background 0.2s ease;
}

.user-table-row:hover {
    background: #1a2221;
}

.user-role-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.user-role-badge.admin {
    background: #2a3a38;
    color: #4ee4c7;
}

.user-role-badge.user {
    background: #1c2525;
    color: #8a9d9a;
}

.user-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.user-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.user-status.active .user-status-dot {
    background: #4ee4c7;
}

.user-status.disabled .user-status-dot {
    background: #666;
}

.user-status.disabled {
    color: #666;
}

.user-actions {
    display: flex;
    gap: 8px;
}

.user-action-btn {
    background: none;
    border: none;
    color: #8a9d9a;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.user-action-btn:hover {
    background: #1c2525;
    color: #b8c7c4;
}

.user-action-btn.danger:hover {
    background: #3a1a1a;
    color: #ff6b6b;
}

.modal-small {
    max-width: 400px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

.form-field {
    margin-bottom: 16px;
}

.form-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #b8c7c4;
}

.form-field input,
.form-field select {
    width: 100%;
    padding: 10px 14px;
    background: #0d1514;
    border: 1px solid #1c2525;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-family: inherit;
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: #4ee4c7;
}

.form-field small {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #6a7b77;
}

.modal-error {
    padding: 10px 12px;
    background: #3a1a1a;
    border: 1px solid #4a2020;
    border-radius: 8px;
    color: #ff6b6b;
    font-size: 13px;
    margin-bottom: 16px;
}

/* User Management - Light Mode */
body.light-mode .users-header-title p {
    color: #5a6b68;
}

body.light-mode .btn-primary {
    background: #3dd9bd;
    color: #ffffff;
}

body.light-mode .btn-secondary {
    background: #f0f2f5;
    color: #5a6269;
}

body.light-mode .btn-secondary:hover {
    background: #e8eaed;
}

body.light-mode .btn-danger {
    background: #fdeaea;
    color: #e63946;
}

body.light-mode .btn-danger:hover {
    background: #f5c6c6;
}

body.light-mode .user-table {
    background: #ffffff;
    box-shadow: 5px 8px 20px rgba(0, 0, 0, 0.06);
}

body.light-mode .user-table-header {
    background: #f8f9fb;
    color: #8a9199;
}

body.light-mode .user-table-row {
    border-top: 1px solid #e8eaed;
}

body.light-mode .user-table-row:hover {
    background: #f8f9fb;
}

body.light-mode .user-role-badge.admin {
    background: #e8f5f1;
    color: #00a67e;
}

body.light-mode .user-role-badge.user {
    background: #f0f2f5;
    color: #6a7279;
}

body.light-mode .user-status.disabled {
    color: #999;
}

body.light-mode .user-action-btn {
    color: #6a7279;
}

body.light-mode .user-action-btn:hover {
    background: #f0f2f5;
    color: #2a3238;
}

body.light-mode .user-action-btn.danger:hover {
    background: #fdeaea;
    color: #e63946;
}

body.light-mode .modal-error {
    background: #fdeaea;
    border: 1px solid #f5c6c6;
    color: #e63946;
}

@media (max-width: 1200px) {
    .user-table-header,
    .user-table-row {
        grid-template-columns: 1.5fr 1fr 1.5fr 0.8fr 0.8fr 1fr 1.2fr;
        font-size: 12px;
    }
}

@media (max-width: 900px) {
    .users-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .user-table-header,
    .user-table-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .user-table-header {
        display: none;
    }

    .user-table-row {
        display: block;
        padding: 16px;
    }

    .user-table-row > div {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
    }

    .user-table-row > div::before {
        content: attr(data-label);
        font-weight: 600;
        color: #8a9d9a;
        text-transform: uppercase;
        font-size: 11px;
        letter-spacing: 0.05em;
    }
}


/* =====================================================
   MOBILE RESPONSIVE DESIGN
===================================================== */

/* Tablet & Below (≤768px) */
@media (max-width: 768px) {

    /* Fix title-row layout on mobile */
    .title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .title-row .card {
        width: 100%;
        text-align: left;
    }

    /* App Layout - Single Column */
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "topbar"
            "content";
    }

    /* Hide Desktop Sidebar - Transform to Mobile Drawer */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(280px, 82vw);
        max-width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        display: flex;
        flex-direction: column;
        background: linear-gradient(180deg, #0d1213, #090d0e);
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.6);
        padding: 20px 14px;
        overflow-y: auto;
    }

    /* Remove hover expansion on mobile */
    .sidebar:hover {
        width: min(280px, 82vw);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Mobile Drawer Header - Compact and aligned */
    .sidebar .logo {
        width: 46px;
        height: 46px;
        margin: 0 auto 20px auto;
        border-radius: 15px;
        display: grid;
        place-items: center;
        background: #151d1e;
        color: #4de7c9;
        font-size: 24px;
        box-shadow:
            inset 3px 3px 8px #080b0c,
            inset -3px -3px 8px #202b2c;
        position: relative;
    }

    .sidebar .logo .material-symbols-outlined {
        font-size: 24px;
    }

    /* Mobile Close Button - Positioned in top right corner */
    .mobile-close-btn {
        position: absolute;
        top: 20px;
        right: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        color: #65716f;
        cursor: pointer;
        border-radius: 12px;
        transition: all 0.3s ease;
        z-index: 10;
    }

    .mobile-close-btn:hover {
        background: #141c1d;
        color: #d8e5e2;
    }

    .mobile-close-btn .material-symbols-outlined {
        font-size: 20px;
    }

    /* Mobile Navigation Container */
    .sidebar .navigation {
        padding: 0;
        gap: 9px;
        align-items: flex-start;
        width: 100%;
    }

    /* Mobile Navigation Items - Match desktop expanded state */
    .sidebar .nav-item {
        width: 100%;
        height: 50px;
        padding: 0 14px;
        border-radius: 17px;
        background: transparent;
        color: #65716f;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 14px;
        overflow: visible;
        transition: all 0.3s ease;
    }

    /* Force labels to show on mobile - match desktop expanded state */
    .sidebar .nav-item label {
        display: block;
        margin-left: 0;
        font-size: 13px;
        font-weight: 500;
        letter-spacing: 0.02em;
        white-space: nowrap;
        color: inherit;
        opacity: 1;
        visibility: visible;
    }

    /* Icon sizing on mobile - match desktop */
    .sidebar .nav-item .material-symbols-outlined {
        font-size: 21px;
        flex-shrink: 0;
    }

    /* Hover state on mobile - match desktop */
    .sidebar .nav-item:hover {
        color: #d8e5e2;
        background: #141c1d;
    }

    /* Active state on mobile - match desktop exactly */
    .sidebar .nav-item.active {
        color: #52e9cc;
        background: #162e2d;
        box-shadow:
            0 0 25px #28d9b01c,
            inset 0 0 15px #36d9bd16;
    }

    /* Mobile Sidebar Backdrop */
    .mobile-sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 999;
    }

    .mobile-sidebar-backdrop.active {
        opacity: 1;
        visibility: visible;
    }

    /* Remove sidebar margin from main content */
    .main {
        margin-left: 0;
    }

    /* Mobile Menu Button */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: #141b1c;
        border: none;
        color: #b9c8c5;
        cursor: pointer;
        border-radius: 14px;
        transition: all 0.3s ease;
        flex-shrink: 0;
        box-shadow:
            inset 1px 1px 4px #080a0a,
            inset -1px -1px 4px #202829;
    }

    .mobile-menu-btn:hover {
        background: #1a2322;
        color: #d8e5e2;
    }

    .mobile-menu-btn .material-symbols-outlined {
        font-size: 20px;
    }

    /* Topbar Adjustments */
    .topbar {
        padding: 12px 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        height: auto;
        min-height: 64px;
    }

    .breadcrumb {
        font-size: 14px;
        flex: 1;
        min-width: 0;
        overflow: hidden;
    }

    .breadcrumb span {
        display: none;
    }

    .breadcrumb b {
        display: none;
    }

    .breadcrumb strong {
        font-size: 16px;
        color: #e5efeb;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Header Right - Mobile Actions */
    .header-right {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 6px;
        flex-shrink: 0;
    }

    /* Hide non-essential items on very small screens */
    .telemetry,
    .esp-status {
        display: none;
    }

    .notification {
        display: none;
    }

    /* Normalize all mobile topbar action buttons */
    .mode-toggle,
    .theme-toggle {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        padding: 0;
        margin: 0;
        flex-shrink: 0;
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .mode-toggle .mode-label {
        display: none;
    }

    /* Normalize icon sizing and alignment */
    .mode-toggle .material-symbols-outlined,
    .theme-toggle .material-symbols-outlined {
        font-size: 20px;
        line-height: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .avatar {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 14px;
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }

    /* Content Area */
    .content {
        padding: 16px;
        overflow-x: hidden;
    }

    /* Page Headers */
    .page-header {
        margin-bottom: 20px;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .eyebrow {
        font-size: 10px;
    }

    .subtitle {
        font-size: 13px;
    }

    /* Dashboard Grid - Mobile Single Column Layout */
    .dashboard-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    /* All Dashboard Cards - Full Width Mobile */
    .dashboard-grid > .card {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
    }

    /* Hero Card - Single Column Internal Layout */
    .hero-card {
        grid-column: 1 / -1;
        grid-template-columns: minmax(0, 1fr);
        min-height: auto;
        width: 100%;
        min-width: 0;
    }

    /* Hero Card Children - Full Width */
    .overview-main,
    .overview-scenes {
        width: 100%;
        min-width: 0;
    }

    /* Overview Stats - Stack vertically on mobile */
    .overview-stats {
        grid-template-columns: 1fr;
    }

    /* Room Card */
    .room-card {
        grid-column: 1 / -1;
        padding: 16px;
        width: 100%;
        min-width: 0;
    }

    /* Dashboard Room Selector - Mobile Adjustments */
    .dashboard-room-selector-menu {
        left: 0;
        right: 0;
        max-width: 100%;
    }

    .dashboard-room-selector-option {
        padding: 14px 16px;
        font-size: 14px;
    }

    /* Sensor Cards */
    .sensor-card {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
    }

    /* Door Lock Card */
    .door-lock-card {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
    }

    /* Media Control Card */
    .media-control-card {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
    }

    /* Live Log Card */
    .live-log-card {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
    }

    /* Charts */
    .chart-container {
        height: 200px;
    }

    /* Live Log */
    .live-log {
        max-height: 250px;
    }

    /* Cards Grid */
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Room Grid */
    .rooms-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Device Controls Grid */
    .device-controls {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Scene Grid */
    .scene-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .scene-card {
        padding: 16px;
    }

    /* Fingerprint Grid */
    .fp-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* User Management Table */
    .user-table-header,
    .user-table-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .user-table-header {
        display: none;
    }

    .user-table-row {
        display: block;
        padding: 16px;
    }

    .user-table-row > div {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid #1c2525;
    }

    .user-table-row > div:last-child {
        border-bottom: none;
    }

    .user-table-row > div::before {
        content: attr(data-label);
        font-weight: 600;
        color: #8a9d9a;
        text-transform: uppercase;
        font-size: 11px;
        letter-spacing: 0.05em;
    }

    .user-actions {
        justify-content: flex-start;
        gap: 12px;
    }

    /* Users Header */
    .users-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    /* Forms */
    .form-field input,
    .form-field select {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    /* Modals */
    .modal-content {
        width: min(460px, 95vw);
        padding: 20px;
        border-radius: 20px;
    }

    .modal-content h2 {
        font-size: 20px;
    }

    .modal-small {
        max-width: 350px;
    }

    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }

    .modal-actions button {
        width: 100%;
    }

    /* Buttons */
    .btn-primary,
    .btn-secondary,
    .btn-danger {
        padding: 12px 18px;
        font-size: 14px;
    }

    /* Spotify Section */
    .spotify-section {
        padding: 16px;
    }

    .spotify-controls {
        flex-wrap: wrap;
        gap: 10px;
    }

    .spotify-progress {
        width: 100%;
    }
}

/* Mobile Phones (≤480px) */
@media (max-width: 480px) {

    /* Fix title-row layout on mobile */
    .title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .title-row .card {
        width: 100%;
    }

    /* Content */
    .content {
        padding: 12px;
    }

    /* Page Headers */
    .page-header h1 {
        font-size: 20px;
    }

    /* Dashboard Grid */
    .dashboard-grid {
        gap: 12px;
    }

    /* Cards */
    .card {
        padding: 14px;
        border-radius: 16px;
    }

    /* Room Card */
    .room-card {
        padding: 14px;
    }

    .room-header h3 {
        font-size: 13px;
    }

    .room-header small {
        font-size: 10px;
    }

    .room-icon {
        font-size: 24px;
    }

    /* Dashboard Room Selector */
    .dashboard-room-selector-trigger {
        gap: 10px;
    }

    .dashboard-room-selector-label h3 {
        font-size: 13px;
    }

    .dashboard-room-selector-option {
        padding: 12px 14px;
        font-size: 13px;
    }

    .dashboard-room-selector-option .room-icon {
        font-size: 20px;
    }

    /* Scene Grid - Single Column on Small Phones */
    .scene-grid {
        grid-template-columns: 1fr;
    }

    .scene-card {
        padding: 14px;
    }

    .scene-card h3 {
        font-size: 13px;
    }

    /* Topbar */
    .topbar {
        padding: 10px 12px;
        gap: 8px;
    }

    .breadcrumb {
        font-size: 11px;
    }

    .telemetry,
    .esp-status {
        padding: 6px 10px;
        font-size: 10px;
    }

    .theme-toggle,
    .mode-toggle {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    /* Device Controls */
    .device-card {
        padding: 14px;
    }

    .device-name {
        font-size: 13px;
    }

    .switch {
        width: 44px;
        height: 24px;
    }

    .switch::after {
        width: 18px;
        height: 18px;
    }

    /* Sliders */
    .slider-container {
        padding: 14px;
    }

    /* Buttons */
    .ghost-button,
    .primary-button,
    .secondary-button {
        padding: 10px 14px;
        font-size: 10px;
    }

    /* Live Log */
    .log-item {
        padding: 10px;
        font-size: 11px;
    }

    /* Charts */
    .chart-container {
        height: 180px;
    }

    /* Modals */
    .modal-content {
        width: min(400px, 92vw);
        padding: 18px;
    }

    .modal-content h2 {
        font-size: 18px;
    }

    /* Form Fields */
    .form-field {
        margin-bottom: 14px;
    }

    .form-field label {
        font-size: 12px;
    }

    .form-field input,
    .form-field select {
        padding: 10px 12px;
        font-size: 16px;
    }

    /* User Management */
    .user-role-badge {
        padding: 3px 8px;
        font-size: 10px;
    }

    .user-status {
        font-size: 11px;
    }

    .user-action-btn {
        padding: 6px;
    }

    /* Fingerprint Management */
    .fp-card {
        padding: 14px;
    }

    .fp-card h3 {
        font-size: 14px;
    }

    .fp-list-item {
        padding: 12px;
        font-size: 12px;
    }

    /* Settings */
    .settings-card {
        padding: 16px;
    }

    .settings-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .settings-row label {
        font-size: 13px;
    }
}

/* Large Tablets & Small Desktops (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {

    /* Dashboard Grid - 2 Columns */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .sensor-card {
        grid-column: span 1;
    }

    /* Room Grid */
    .rooms-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Scene Grid */
    .scene-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Device Controls */
    .device-controls {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Fingerprint Grid */
    .fp-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Landscape Orientation Adjustments */
@media (max-width: 768px) and (orientation: landscape) {

    .scene-grid {
        grid-template-columns: repeat(3, 1fr);
    }

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

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

    .sensor-card {
        grid-column: span 1;
    }
}

/* Prevent Horizontal Overflow */
@media (max-width: 768px) {

    /* A/B TEST: Universal selector disabled temporarily
    * {
        max-width: 100%;
        word-wrap: break-word;
    }
    */

    .card,
    .room-card,
    .device-card,
    .scene-card,
    .fp-card,
    .user-table,
    .modal-content {
        overflow-x: hidden;
    }

    img,
    svg,
    canvas {
        max-width: 100%;
        height: auto;
    }
}

/* Light Mode - Mobile Adjustments */
@media (max-width: 768px) {

    body.light-mode .user-table-row > div {
        border-bottom: 1px solid #e8eaed;
    }

    body.light-mode .user-table-row > div::before {
        color: #8a9199;
    }
}

