* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #f1f5f9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.dashboard {
    max-width: 1300px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 1.75rem;
    justify-content: center;
}

.dashboard-header {
    text-align: center;
    width: 100%;
    margin-bottom: 20px;
}

.dashboard-header h1 {
    font-size: 2.2rem;
    font-weight: 600;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 1px;
}

.dashboard-header p {
    color: #5a6e8a;
    margin-top: 8px;
    font-size: 0.95rem;
}

.card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(0px);
    border-radius: 2rem;
    box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.02);
    padding: 1.6rem 1.8rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 24px 42px -14px rgba(0, 0, 0, 0.12);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #eef2ff;
    padding-bottom: 0.85rem;
}

.card-header i {
    font-size: 1.8rem;
    color: #3b82f6;
    background: #eef2ff;
    padding: 0.5rem;
    border-radius: 1.2rem;
}

.card-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: #0f172a;
}

.online-badge {
    margin-left: auto;
    font-size: 0.8rem;
    padding: 0.25rem 0.8rem;
    border-radius: 30px;
    background: #e6f7e6;
    color: #0e7b0e;
    font-weight: 500;
}

.offline-badge {
    background: #fee2e2;
    color: #b91c1c;
}

.door-card {
    flex: 1.2;
    min-width: 300px;
    background: linear-gradient(135deg, #ffffff 0%, #fefefe 100%);
}

.dual-status-container {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    gap: 1.5rem;
    padding: 1rem 0 0.6rem;
    flex-wrap: wrap;
}

.status-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    min-width: 100px;
}

.status-icon {
    font-size: 3.5rem;
    transition: all 0.2s ease;
}

.status-text {
    font-size: 0.95rem;
    font-weight: 500;
    background: #f1f5f9;
    padding: 0.4rem 1rem;
    border-radius: 60px;
    color: #1e293b;
    text-align: center;
    min-width: 90px;
}

/* ========== 现代化复选框样式 ========== */
.modern-checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.95rem;
    color: #1e293b;
}

.modern-checkbox-wrapper input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid #cbd5e1;
    border-radius: 0.375rem;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0.9, 0.4, 1);
    position: relative;
    flex-shrink: 0;
}

.modern-checkbox-wrapper input[type="checkbox"]:hover {
    border-color: #3b82f6;
    background-color: #f8fafc;
}

.modern-checkbox-wrapper input[type="checkbox"]:checked {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

.modern-checkbox-wrapper input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0.25rem;
    height: 0.5rem;
    border: solid white;
    border-width: 0 0.125rem 0.125rem 0;
    transform: translate(-50%, -60%) rotate(45deg);
}

.modern-checkbox-wrapper input[type="checkbox"]:focus {
    outline: 2px solid rgba(59, 130, 246, 0.3);
    outline-offset: 2px;
}

.modern-checkbox-wrapper input[type="checkbox"]:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.modern-checkbox-wrapper input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #e2e8f0;
    background-color: #f1f5f9;
}

.modern-checkbox-wrapper .checkbox-label {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.checkbox-hint {
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 400;
}

/* 居中布局的复选框行 */
.checkbox-row {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    padding: 0.6rem 1rem;
    border-radius: 3rem;
    margin: 1rem 0 0.2rem;
    margin-left: auto;
    margin-right: auto;
    width: 10rem;
}

.checkbox-row-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-row-left i {
    color: #3b82f6;
    font-size: 1rem;
}

.btn-door {
    background: #3b82f6;
    border: none;
    padding: 0.9rem 2rem;
    border-radius: 3rem;
    font-weight: 600;
    font-size: 1rem;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, opacity 0.2s;
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.2);
    font-family: inherit;
    margin-top: 0.8rem;
    margin-left: auto;
    margin-right: auto;
    width: 90%;
}

.btn-door:active {
    transform: scale(0.97);
}

.btn-door:hover {
    background: #2563eb;
}

.btn-door:disabled {
    background: #a0aec0;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
}

.btn-door i {
    color: white !important;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

/* 温湿度卡片 */
.climate-card {
    flex: 1.8;
    min-width: 300px;
}

.metric {
    margin-bottom: 1.8rem;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.metric-name {
    font-weight: 500;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.metric-value {
    font-weight: 700;
    color: #0f172a;
    font-size: 1.1rem;
    background: #f8fafc;
    padding: 0.2rem 0.8rem;
    border-radius: 30px;
}

.progress-track {
    position: relative;
    height: 12px;
    border-radius: 999px;
    background: #e2e8f0;
    width: 100%;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 0.4rem;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 999px;
    clip-path: inset(0 100% 0 0);
    transition: clip-path 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 2;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.05) 40%, transparent 70%);
    border-radius: 999px;
    pointer-events: none;
}

.temp-fill {
    background: linear-gradient(135deg, #00c3ff, #ffff1c);
    box-shadow: 0 0 12px rgba(0, 195, 255, 0.4);
}

.pressure-fill {
    background: linear-gradient(135deg, #00c3ff, #ffff1c);
    box-shadow: 0 0 12px rgba(0, 195, 255, 0.4);
}

.co2-fill {
    background: linear-gradient(135deg, #00c3ff, #ffff1c);
    box-shadow: 0 0 12px rgba(0, 195, 255, 0.4);
}

.humi-fill {
    background: linear-gradient(to right, rgb(86, 204, 242), rgb(47, 128, 237));
    box-shadow: 0 0 12px rgba(47, 128, 237, 0.4);
}

.offline .progress-fill {
    background: #cbd5e1 !important;
    box-shadow: none !important;
    opacity: 0.5;
}

.offline .metric-value {
    color: #94a3b8;
}

.progress-scale {
    position: relative;
    height: 26px;
    width: 100%;
    user-select: none;
    pointer-events: none;
    margin-top: 2px;
}

.scale-mark {
    position: absolute;
    bottom: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.scale-line {
    width: 2px;
    height: 8px;
    background: #6c7894;
    border-radius: 2px;
    opacity: 0.85;
}

.scale-label {
    font-size: 0.65rem;
    color: #9aa5c1;
    margin-top: 2px;
    white-space: nowrap;
    letter-spacing: 0.2px;
    line-height: 1;
}

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

.ac-card {
    flex: 1.6;
    min-width: 280px;
}

.ac-power-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    padding: 0.6rem 1rem;
    border-radius: 2rem;
    margin-bottom: 1.5rem;
}

.power-label {
    font-weight: 600;
    color: #0f172a;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #3b82f6;
}

input:checked+.slider:before {
    transform: translateX(24px);
}

.ac-mode-temp {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.8rem;
    flex-wrap: wrap;
}

.mode-selector {
    background: #f1f5f9;
    border-radius: 2rem;
    padding: 0.3rem;
    display: flex;
    gap: 0.3rem;
}

.mode-btn {
    background: transparent;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    color: #334155;
    font-family: inherit;
}

.mode-btn.active-mode {
    background: white;
    color: #0f172a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.temp-control {
    background: #f1f5f9;
    border-radius: 2rem;
    padding: 0.2rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.temp-control span {
    font-weight: 600;
    color: #0f172a;
}

.temp-adjust {
    background: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ac-fan-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    padding: 0.6rem 1rem;
    border-radius: 2rem;
}

.fan-speed {
    display: flex;
    gap: 0.8rem;
    background: #eef2ff;
    padding: 0.2rem 0.5rem;
    border-radius: 2rem;
}

.fan-btn {
    background: transparent;
    border: none;
    padding: 0.3rem 0.8rem;
    border-radius: 2rem;
    font-weight: 500;
    cursor: pointer;
    color: #334155;
}

.fan-btn.active-fan {
    background: white;
    color: #2563eb;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.ac-status-msg {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #5b6e8c;
    text-align: center;
    background: #f1f5f9;
    border-radius: 2rem;
    padding: 0.4rem;
}

i {
    color: #5b6e8c;
}

.refresh-indicator {
    font-size: 0.75rem;
    text-align: right;
    color: #94a3b8;
    margin-top: 0.8rem;
}

.status-icon.locked-icon {
    color: #475569;
}

.status-icon.unlocked-icon {
    color: #f59e0b;
}

/* 主题切换按钮 */
.theme-toggle {
    position: fixed;
    top: 1.1rem;
    right: 1.1rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    font-size: 1.15rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, background 0.3s ease, color 0.3s ease;
    z-index: 100;
}

.theme-toggle:hover {
    transform: scale(1.08);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* 退出登录按钮（与主题按钮同风格，靠左排列） */
.logout-toggle {
    right: 4.2rem;
}

/* ========== 深色模式（html[data-theme="dark"]，由 JS 手动/跟随系统切换） ========== */
:root {
    /* 门禁状态内联样式变量（浅色默认值，供 JS 使用） */
    --door-status-offline: #e2e8f0;
    --door-status-open: #dbeafe;
    --door-status-closed: #f1f5f9;
    --door-icon-offline: #94a3b8;
    --door-icon-open: #3b82f6;
    --door-icon-closed: #475569;
}

[data-theme="dark"] {
    --door-status-offline: #334155;
    --door-status-open: #1e3a5f;
    --door-status-closed: #273449;
    --door-icon-offline: #64748b;
    --door-icon-open: #60a5fa;
    --door-icon-closed: #94a3b8;
}

[data-theme="dark"] body {
    background: #0f172a;
}

[data-theme="dark"] .dashboard-header h1 {
    background: linear-gradient(135deg, #60a5fa, #93c5fd);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

[data-theme="dark"] .dashboard-header p {
    color: #94a3b8;
}

[data-theme="dark"] .card {
    background: rgba(30, 41, 59, 0.94);
    border: 1px solid rgba(51, 65, 85, 0.7);
    box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .card:hover {
    box-shadow: 0 24px 42px -14px rgba(0, 0, 0, 0.65);
}

[data-theme="dark"] .card-header {
    border-bottom: 2px solid #273449;
}

[data-theme="dark"] .card-header i {
    color: #60a5fa;
    background: #1e3a5f;
}

[data-theme="dark"] .card-header h2 {
    color: #e2e8f0;
}

[data-theme="dark"] .online-badge {
    background: #0f2e1a;
    color: #4ade80;
}

[data-theme="dark"] .offline-badge {
    background: #3f1d1d;
    color: #f87171;
}

[data-theme="dark"] .door-card {
    background: linear-gradient(135deg, #1e293b 0%, #1a2233 100%);
}

[data-theme="dark"] .status-text {
    background: #273449;
    color: #e2e8f0;
}

[data-theme="dark"] .modern-checkbox-wrapper {
    color: #cbd5e1;
}

[data-theme="dark"] .modern-checkbox-wrapper input[type="checkbox"] {
    border-color: #475569;
    background-color: #1e293b;
}

[data-theme="dark"] .modern-checkbox-wrapper input[type="checkbox"]:checked {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

[data-theme="dark"] .checkbox-row {
    background: #273449;
}

[data-theme="dark"] .checkbox-hint {
    color: #94a3b8;
}

[data-theme="dark"] .metric-name {
    color: #cbd5e1;
}

[data-theme="dark"] .metric-value {
    color: #f1f5f9;
    background: #273449;
}

[data-theme="dark"] .progress-track {
    background: #334155;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .scale-line {
    background: #64748b;
}

[data-theme="dark"] .scale-label {
    color: #94a3b8;
}

[data-theme="dark"] .ac-power-row,
[data-theme="dark"] .ac-fan-row {
    background: #273449;
}

[data-theme="dark"] .power-label {
    color: #e2e8f0;
}

[data-theme="dark"] .slider {
    background-color: #475569;
}

[data-theme="dark"] .mode-selector,
[data-theme="dark"] .temp-control {
    background: #273449;
}

[data-theme="dark"] .mode-btn {
    color: #94a3b8;
}

[data-theme="dark"] .mode-btn.active-mode {
    background: #334155;
    color: #f1f5f9;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .temp-control span {
    color: #e2e8f0;
}

[data-theme="dark"] .temp-adjust {
    background: #334155;
    color: #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .fan-speed {
    background: #1e3a5f;
}

[data-theme="dark"] .fan-btn {
    color: #94a3b8;
}

[data-theme="dark"] .fan-btn.active-fan {
    background: #334155;
    color: #60a5fa;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .ac-status-msg {
    color: #94a3b8;
    background: #273449;
}

[data-theme="dark"] i {
    color: #94a3b8;
}

[data-theme="dark"] .refresh-indicator {
    color: #64748b;
}

[data-theme="dark"] .status-icon.locked-icon {
    color: #94a3b8;
}

[data-theme="dark"] .theme-toggle {
    background: #273449;
    color: #e2e8f0;
    border-color: #334155;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}