/* SPM 物业管理系统 - 自定义样式（深色模式 + 组件 + 兜底） */

/* ============ CSS 变量 ============ */
:root {
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --primary-500: #6366f1;
    --primary-600: #4f46e5;
    --primary-700: #4338ca;

    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    --radius: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow: 0 4px 16px rgba(15,23,42,.08);
    --shadow-lg: 0 10px 30px rgba(15,23,42,.12);
}

.dark {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0f172a;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --border-light: #1e293b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
    --shadow: 0 4px 16px rgba(0,0,0,.4);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
}

/* ============ 基础 ============ */
* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    transition: background-color .3s, color .3s;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(100, 116, 139, .12); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, .45); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, .6); }
/* 深色模式：滚动条轨道/滑块均用深色系，避免白底 */
.dark ::-webkit-scrollbar-track { background: rgba(148, 163, 184, .14); }
.dark ::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .42); }
.dark ::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, .6); }

/* ============ 组件类 ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 15px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all .2s;
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
    color: #fff;
    box-shadow: 0 4px 12px rgba(99,102,241,.35);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(99,102,241,.5); }

.btn-secondary {
    background: rgba(15, 23, 42, .06); /* 白天：文字色 #0f172a 的 6% → 浅灰底，与卡片白区分 */
    color: var(--text);
}
.btn-secondary:hover { background: rgba(15, 23, 42, .10); } /* hover 加深一档 */
/* 夜间模式：文字色 #f1f5f9 透明度叠加，比卡片 #1e293b 亮一档 */
.dark .btn-secondary { background: rgba(241, 245, 249, .06); }
.dark .btn-secondary:hover { background: rgba(241, 245, 249, .10); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--border-light); }

.btn-danger { background: var(--danger); color: #fff; }

.input {
    width: 100%;
    padding: 8px 14px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 14px;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}
.input:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.input::placeholder { color: var(--text-muted); }

/* 原生 select 箭头替换：隐藏浏览器默认箭头，用 SVG 背景图精确控制右侧间距（14px，与左右 padding 一致） */
select.input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 30px; /* 箭头区最小占用（右距14 + 箭头16），窄 select 文字空间最大化 */
    overflow: hidden; /* 文字不溢出 content 区，永不进入箭头区被遮挡 */
    cursor: pointer; /* 下拉选择框：手指光标，提示可点击 */
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%2364748b'%20stroke-width='1.6'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M4.5%206.5l3.5%203.5%203.5-3.5'/%3E%3C/svg%3E"); /* 浅色主题箭头：--text-muted(#64748b) */
    background-repeat: no-repeat;
    background-position: right 14px center; /* 箭头右缘距边框内缘 14px，与上下 padding 视觉一致 */
    background-size: 16px 16px;
    line-height: 1.6; /* appearance:none 后行高回退，与兄弟 input 高度对齐 */
}
/* 深色主题：箭头颜色跟随 --text-muted(#94a3b8) */
.dark select.input {
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%2394a3b8'%20stroke-width='1.6'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M4.5%206.5l3.5%203.5%203.5-3.5'/%3E%3C/svg%3E");
}

.label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}
.badge-green { background: rgba(16,185,129,.12); color: var(--success); }
.badge-red { background: rgba(239,68,68,.12); color: var(--danger); }
.badge-amber { background: rgba(245,158,11,.12); color: var(--warning); }
.badge-blue { background: rgba(59,130,246,.12); color: var(--info); }
.badge-indigo { background: rgba(99,102,241,.12); color: var(--primary-500); }
.badge-slate { background: var(--border-light); color: var(--text-muted); }
/* 标签类（状态/类型徽章）：箭头光标，表示只读不可点击 */
.badge-green, .badge-red, .badge-amber, .badge-blue, .badge-indigo, .badge-slate { cursor: default; }

/* ============ 登录页 ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 50%, #1e1b4b 100%);
    position: relative;
    overflow: hidden;
}
.login-page::before,
.login-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: .4;
}
.login-page::before {
    width: 400px; height: 400px;
    background: #6366f1;
    top: -100px; left: -100px;
}
.login-page::after {
    width: 400px; height: 400px;
    background: #8b5cf6;
    bottom: -100px; right: -100px;
}

.login-box {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    background: rgba(255,255,255,.06);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 24px;
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,.4);
}

.login-logo {
    width: 64px; height: 64px;
    margin: 0 auto 16px;
    border-radius: 20px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-size: 32px;
    color: #fff;
    box-shadow: 0 8px 24px rgba(99,102,241,.5);
}
.login-title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}
.login-sub {
    text-align: center;
    font-size: 13px;
    color: rgba(255,255,255,.6);
    margin-bottom: 28px;
}
.login-field { margin-bottom: 18px; }
.login-field .label { color: rgba(255,255,255,.85); }
.login-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.15);
    background: rgba(255,255,255,.08);
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.login-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.25);
}
.login-input::placeholder { color: rgba(255,255,255,.4); }

.login-error {
    background: rgba(239,68,68,.15);
    color: #fca5a5;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ============ 主框架布局 ============ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: background-color .3s;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
}
.sidebar-logo-icon {
    width: 40px; height: 40px;
    border-radius: 14px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    color: #fff;
}
.sidebar-logo-name { font-weight: 700; font-size: 15px; }
.sidebar-logo-sub { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: 2px;
    transition: all .15s;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}
.nav-item:hover { background: var(--border-light); color: var(--text); }
.nav-item.active {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    font-size: 11px;
    color: var(--text-muted);
}

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 60px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-spacer { flex: 1; }

.topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    transition: all .15s;
}
.topbar-btn:hover { background: var(--border-light); }

.topbar-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.content { flex: 1; padding: 24px; cursor: default; }

/* 下拉菜单 */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 50;
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text);
    width: 100%;
    text-align: left;
}
.dropdown-item:hover { background: var(--border-light); }
.dropdown-divider { height: 1px; background: var(--border-light); margin: 6px 0; }

/* ============ 统计卡片 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-icon {
    width: 44px; height: 44px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    color: #fff;
    flex-shrink: 0;
}
.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 2px; }

/* ============ 动画 ============ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .3s ease; }
.slide-up { animation: slideUp .3s ease; }

/* 移动端侧边栏收起 */
@media (max-width: 768px) {
    .sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform .3s; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; }
}

/* ============ 表格 ============ */
.th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}
.td {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid var(--border-light);
}

/* ============ 弹窗（模态框） ============ */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 460px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp .25s ease;
}
.modal-title {
    padding: 18px 20px;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-light);
}
.modal-body { padding: 20px; }
.modal-footer {
    padding: 14px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border-light);
}
.form-item { margin-bottom: 16px; }
.form-item:last-child { margin-bottom: 0; }

/* ============ 小区选择卡片框 ============ */
.community-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.community-picker-card {
    border: none;
    border-radius: 16px;
    padding: 24px 20px;
    text-align: left;
    cursor: pointer;
    color: #fff;
    transition: transform .2s ease, box-shadow .2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.community-picker-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,.22);
}
.community-picker-card:active { transform: scale(.98); }
.community-picker-card.selected {
    outline: 2px solid rgba(255,255,255,.95);
    outline-offset: 2px;
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0,0,0,.25);
}
.cp-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: .5px;
}
.cp-addr {
    font-size: 12px;
    opacity: .85;
    margin-bottom: 12px;
    line-height: 1.5;
    min-height: 36px;
}
.cp-code {
    font-size: 11px;
    opacity: .7;
    letter-spacing: 1px;
    font-family: monospace;
}

/* ============ 自定义下拉（spm-select，替代原生 select：悬停手指、符合 UI） ============ */
.spm-select { position: relative; display: inline-block; vertical-align: middle; }
.spm-select-trigger {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border);
    background: var(--bg-card); color: var(--text); font-size: 14px; line-height: 1.6;
    cursor: pointer; user-select: none; transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}
.spm-select-trigger:hover { border-color: var(--primary-500); }
.spm-select-value { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spm-select-placeholder { color: var(--text-muted); }
.spm-select-arrow { color: var(--text-muted); font-size: 11px; flex-shrink: 0; }
.spm-select-panel {
    position: fixed; top: 0; left: 0; z-index: 900;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; padding: 6px;
    animation: slideUp .2s ease;
}
.spm-select-option {
    padding: 8px 12px; border-radius: 8px; font-size: 14px; color: var(--text);
    cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.spm-select-option:hover { background: rgba(99,102,241,.1); }
.spm-select-option-active { background: var(--primary-500); color: #fff; }
.spm-select-option-active:hover { background: var(--primary-500); }
.spm-select-empty { padding: 10px; text-align: center; font-size: 13px; color: var(--text-muted); }
/* 可输入组合框（editable）：透明输入框融合触发框 */
.spm-select-input {
    flex: 1; min-width: 0; border: none; outline: none; background: transparent;
    font-size: 13px; color: var(--text); padding: 0;
}
.spm-select-input::placeholder { color: var(--text-muted); }

/* ============ 日期时间选择器（Windows 日历风格 + 时分秒） ============ */
.spm-date { position: relative; display: inline-block; vertical-align: middle; }
.spm-date-trigger {
    display: flex; align-items: center; gap: 6px; padding: 7px 10px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card);
    cursor: pointer; transition: border-color .15s; font-size: 13px;
}
.spm-date-trigger:hover { border-color: var(--primary-500); }
.spm-date-value { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.spm-date-placeholder { color: var(--text-muted); }
.spm-date-icon { color: var(--text-muted); font-size: 12px; flex-shrink: 0; }
.spm-date-panel {
    position: fixed; top: 0; left: 0; z-index: 900;
    width: 264px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; box-shadow: var(--shadow-lg); padding: 10px;
    animation: slideUp .2s ease;
}
.spm-date-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.spm-date-nav {
    width: 26px; height: 26px; border: none; border-radius: 6px; background: transparent;
    color: var(--text-muted); font-size: 13px; cursor: pointer; line-height: 1;
}
.spm-date-nav:hover { background: rgba(99,102,241,.1); color: var(--text); }
.spm-date-ym { font-size: 13px; font-weight: 600; color: var(--text); }
.spm-date-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; margin-bottom: 4px; }
.spm-date-week span { font-size: 11px; color: var(--text-muted); padding: 4px 0; }
.spm-date-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.spm-date-cell {
    height: 28px; display: flex; align-items: center; justify-content: center;
    font-size: 12px; border-radius: 6px; cursor: pointer; color: var(--text);
    transition: background .12s;
}
.spm-date-cell:hover { background: rgba(99,102,241,.12); }
.spm-date-other { color: var(--text-muted); opacity: .45; }
.spm-date-today { border: 1px solid var(--primary-500); }
.spm-date-selected { background: var(--primary-500); color: #fff; }
.spm-date-selected:hover { background: var(--primary-500); }
.spm-date-time {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-light);
}
.spm-date-time .spm-select-trigger { padding: 5px 6px; border-radius: 6px; font-size: 12px; }
.spm-date-time .spm-select-panel { max-height: 220px; }
.spm-date-colon { color: var(--text-muted); font-size: 12px; }
.spm-date-footer {
    display: flex; justify-content: space-between; gap: 8px; margin-top: 10px;
}

/* ============ Toast 轻提示（替代原生 alert） ============ */
.toast-wrap {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}
.toast-item {
    padding: 10px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    box-shadow: var(--shadow-lg);
    max-width: 80vw;
    word-break: break-all;
    animation: toastIn .25s ease;
}
.toast-success { background: rgba(16,185,129,.95); }
.toast-error { background: rgba(239,68,68,.95); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}
/* 深色主题下加深遮罩文字对比 */
.dark .toast-success { background: rgba(16,185,129,.9); }
.dark .toast-error { background: rgba(239,68,68,.9); }

/* ===== 开关组件（toggle switch） ===== */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #cbd5e1; border-radius: 999px; transition: .25s; }
.switch-slider:before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .25s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .switch-slider { background: #10b981; }
.switch input:checked + .switch-slider:before { transform: translateX(20px); }
.dark .switch-slider { background: #475569; }
.dark .switch input:checked + .switch-slider { background: #10b981; }

/* ===== 拖动排序手柄 ===== */
.drag-handle { cursor: grab; color: #94a3b8; font-size: 15px; user-select: none; letter-spacing: -1px; line-height: 1; }
.drag-handle:hover { color: #6366f1; }
.drag-handle:active { cursor: grabbing; }
.dark .drag-handle { color: #64748b; }

/* ============================================================
   科技监控大屏（工作台）
   支持浅色（白天）/ 深色（夜晚）双模式，跟随全局主题 .dark 切换
   ============================================================ */
.dash-screen {
    --dash-bg: #eef2f7;
    --dash-panel-bg: #ffffff;
    --dash-panel-bg2: #f8fafc;
    --dash-border: rgba(79,70,229,.16);
    --dash-text: #1e293b;
    --dash-muted: #64748b;
    --dash-accent: #4f46e5;
    --dash-cyan: #0284c7;
    --dash-green: #059669;
    --dash-red: #dc2626;
    --dash-orange: #d97706;
    --dash-grid-line: rgba(79,70,229,.06);
    --dash-glow: rgba(79,70,229,.14);
    --dash-scroll-border: rgba(100,116,139,.12);
    position: relative;
    background-color: var(--dash-bg);
    /* 顶层光晕 + 横竖网格线（原 ::after / ::before 合并为自身背景，local 随内容滚动覆盖全内容） */
    background-image:
        radial-gradient(ellipse, var(--dash-glow), transparent 70%),
        linear-gradient(var(--dash-grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--dash-grid-line) 1px, transparent 1px);
    background-size: 720px 240px, 40px 40px, 40px 40px;
    background-position: 50% -120px, 0 0, 0 0;
    background-repeat: no-repeat, repeat, repeat;
    background-attachment: scroll, local, local;
    color: var(--dash-text);
    border-radius: 12px;
    padding: 20px 24px 28px;
    overflow: hidden;
    transition: background-color .3s;
    /* 满屏铺设 + 统一子模块间距 */
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.dash-screen.dash-fullscreen {
    padding: 15px; border-radius: 0; gap: 14px;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
/* 全屏时禁止 flex 子项被压缩：内容超高时自然溢出滚动，否则下方模块会被挤压不可见 */
.dash-screen.dash-fullscreen > * { flex-shrink: 0; }
.dash-screen.dash-fullscreen::-webkit-scrollbar { width: 0; height: 0; }
.content-fullscreen { padding: 0 !important; }
.dark .dash-screen {
    --dash-bg: #0a0e27;
    --dash-panel-bg: rgba(30,41,59,.5);
    --dash-panel-bg2: rgba(15,23,42,.8);
    --dash-border: rgba(0,212,255,.22);
    --dash-text: #e2e8f0;
    --dash-muted: #94a3b8;
    --dash-accent: #00d4ff;
    --dash-cyan: #4f8fff;
    --dash-green: #00ff88;
    --dash-red: #ff4d4f;
    --dash-orange: #ff9f43;
    --dash-grid-line: rgba(0,212,255,.05);
    --dash-glow: rgba(0,212,255,.18);
    --dash-scroll-border: rgba(148,163,184,.1);
}
.dash-screen > * { position: relative; z-index: 1; }

.dash-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid var(--dash-border); }
.dash-header-left { display: flex; align-items: center; gap: 12px; }
.dash-logo { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, #6366f1, var(--dash-cyan)); display: flex; align-items: center; justify-content: center; font-size: 20px; box-shadow: 0 0 16px var(--dash-glow); }
.dash-title { font-size: 20px; font-weight: 700; letter-spacing: 2px; background: linear-gradient(90deg, var(--dash-accent), var(--dash-cyan)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.dash-clock { font-family: 'Consolas', monospace; font-size: 22px; font-weight: 700; color: var(--dash-accent); letter-spacing: 1px; }
.dark .dash-clock { text-shadow: 0 0 12px rgba(0,212,255,.6); }
.dash-date { font-size: 12px; color: var(--dash-muted); text-align: right; }

.dash-kpi-grid { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 12px; }
.dash-kpi-card { position: relative; padding: 14px 12px; border-radius: 10px; background: var(--dash-panel-bg); border: 1px solid var(--dash-border); text-align: center; animation: dashBreath 3s ease-in-out infinite; }
.dash-kpi-card:nth-child(2n) { animation-delay: 1.5s; }
.dash-kpi-icon { font-size: 20px; margin-bottom: 4px; }
.dash-kpi-label { font-size: 12px; color: var(--dash-muted); }
.dash-kpi-value { font-size: 26px; font-weight: 700; color: var(--dash-accent); font-family: 'Consolas', monospace; }
.dark .dash-kpi-value { text-shadow: 0 0 10px rgba(0,212,255,.5); }
.dash-kpi-value.green { color: var(--dash-green); }
.dark .dash-kpi-value.green { text-shadow: 0 0 10px rgba(0,255,136,.5); }
.dash-kpi-value.red { color: var(--dash-red); }
.dark .dash-kpi-value.red { text-shadow: 0 0 10px rgba(255,77,79,.5); }
.dash-kpi-value.orange { color: var(--dash-orange); }
.dark .dash-kpi-value.orange { text-shadow: 0 0 10px rgba(255,159,67,.5); }

.dash-panel { border-radius: 12px; background: var(--dash-panel-bg); border: 1px solid var(--dash-border); padding: 16px; position: relative; overflow: hidden; }
.dash-panel::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 2px; background: linear-gradient(90deg, transparent, var(--dash-accent), transparent); animation: dashFlow 3s linear infinite; }
.dash-panel-title { font-size: 14px; font-weight: 600; color: var(--dash-accent); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.dash-panel-title::before { content: ''; width: 4px; height: 14px; background: var(--dash-accent); border-radius: 2px; }
.dark .dash-panel-title::before { box-shadow: 0 0 8px var(--dash-accent); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.dash-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
/* 第一行四列：消防 / 房屋状态 / 成员类型 / 门禁设备 */
.dash-row-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
/* 第一行面板固定 260px，内容区填满、超高内部滚动 */
.dash-row-4.dash-row-short > .dash-panel {
    height: 260px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.dash-row-4.dash-row-short > .dash-panel .dash-chart {
    flex: 1;
    height: auto;
    min-height: 0;
}
.dash-row-4.dash-row-short > .dash-panel .dash-scroll-list {
    flex: 1;
    height: auto;
    min-height: 0;
    overflow-y: auto;
}
.dash-row-short .dash-chart { height: 190px; }
.dash-row-short .dash-scroll-list { height: 130px; }
.dash-row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
/* 门禁监控两列：左 1/3（门禁设备） + 右 2/3（通行记录） */
.dash-row-door { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.dash-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.dash-chart-wide { grid-column: span 2; }
.dash-chart { height: 280px; width: 100%; }

.dash-fire { border-color: rgba(220,38,38,.4) !important; }
.dark .dash-fire { border-color: rgba(255,77,79,.4) !important; }
.dash-fire.alarm { animation: dashFireFlash 1.2s ease-in-out infinite; }
.dash-fire-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.dash-fire-stat { padding: 12px; border-radius: 10px; background: var(--dash-panel-bg2); border: 1px solid var(--dash-border); text-align: center; }
.dash-fire-stat .num { font-size: 26px; font-weight: 700; font-family: 'Consolas', monospace; color: var(--dash-text); }
.dash-fire-stat .num.alarm { color: var(--dash-red); }
.dark .dash-fire-stat .num.alarm { text-shadow: 0 0 12px rgba(255,77,79,.7); animation: dashFlash .8s ease-in-out infinite; }

.dash-scroll-list { height: 200px; overflow: hidden; }
.dash-panel-fill { display: flex; flex-direction: column; }
.dash-col-fill { display: flex; flex-direction: column; gap: 16px; }
/* 最新动态专用：列表填满父面板剩余空间（min-height:0 允许收缩，不撑开面板高度） */
.dash-scroll-fill { flex: 1; height: auto; min-height: 0; }
.dash-scroll-list ul { list-style: none; margin: 0; padding: 0; animation: dashScrollUp 12s linear infinite; }
.dash-scroll-list.no-scroll ul { animation: none; }
.dash-scroll-list:hover ul { animation-play-state: paused; }
.dash-scroll-list li { display: flex; justify-content: space-between; padding: 10px 4px; font-size: 13px; border-bottom: 1px solid var(--dash-scroll-border); }
.dash-fire-list li { font-size: 16px; }
.dash-scroll-list li .l { color: var(--dash-text); }
.dash-scroll-list li .r { color: var(--dash-accent); font-family: 'Consolas', monospace; }
.dash-scroll-list li .r.red { color: var(--dash-red); }
/* 停车列表：表头 + 多列 grid 行 */
.dash-list-head { display: grid; gap: 8px; padding: 6px 4px 8px; font-size: 12px; font-weight: 600; color: var(--dash-muted); border-bottom: 1px solid var(--dash-scroll-border); }
.dash-list-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-scroll-list li.grid-li { display: grid; gap: 8px; }
.dash-scroll-list li.grid-li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dash-btn-mute { padding: 6px 14px; border-radius: 8px; border: 1px solid var(--dash-border); background: transparent; color: var(--dash-accent); cursor: pointer; font-size: 13px; }
.dash-btn-mute.muted { color: var(--dash-muted); border-color: var(--dash-scroll-border); }

@keyframes dashBreath { 0%,100% { border-color: var(--dash-border); box-shadow: 0 0 0 rgba(0,0,0,0); } 50% { border-color: var(--dash-accent); box-shadow: 0 0 18px var(--dash-glow); } }
@keyframes dashFlow { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes dashFlash { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes dashFireFlash { 0%,100% { border-color: rgba(220,38,38,.4); } 50% { border-color: rgba(220,38,38,.9); box-shadow: 0 0 22px rgba(220,38,38,.3); } }
.dark .dash-fire.alarm { animation-name: dashFireFlashDark; }
@keyframes dashFireFlashDark { 0%,100% { border-color: rgba(255,77,79,.4); } 50% { border-color: rgba(255,77,79,.9); box-shadow: 0 0 22px rgba(255,77,79,.35); } }
@keyframes dashScrollUp { 0% { transform: translateY(0); } 100% { transform: translateY(-50%); } }

/* 大屏响应式布局（窄屏降级，避免拥挤与横向拉伸） */
@media (max-width: 1440px) {
    .dash-kpi-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
    .dash-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .dash-grid { grid-template-columns: minmax(0, 1fr); }
    .dash-fire-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ============ 门禁监控（左列设备列表 + 右列通行记录） ============ */
/* 左列：门禁设备列表（一行一列） */
.dash-door-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 8px;
    max-height: 460px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, .45) rgba(148, 163, 184, .14);
}
/* 门禁设备面板：flex 列，列表填满与同行等高 */
.dash-door-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.dash-door-panel .dash-door-list {
    flex: 1;
    min-height: 0;
    height: auto;
    max-height: none;
    align-content: start;
}
.dash-door-panel .dash-door-empty { align-self: center; margin: auto 0; }
.dash-door-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 8px;
    border: 1px solid var(--border-light, rgba(148,163,184,.12));
    background: var(--panel-bg2, rgba(255,255,255,.02));
    min-width: 0;
}
.dash-door-row:hover { border-color: rgba(0,212,255,.35); }
/* 门状态图标：在线绿色关门 / 离线红色开门 */
.dash-door-state-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.dash-door-state-icon.online { color: var(--dash-green, #00ff88); filter: drop-shadow(0 0 4px rgba(0,255,136,.5)); }
.dash-door-state-icon.offline { color: var(--dash-red, #ff4d4f); filter: drop-shadow(0 0 4px rgba(255,77,79,.5)); }
.dash-door-row-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dash-row-comm { color: var(--text-muted, #94a3b8); font-weight: 500; }
.dash-door-btn-sm {
    flex: 0 0 auto;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid rgba(0,212,255,.35);
    background: rgba(0,212,255,.1);
    color: var(--dash-accent, #00d4ff);
    cursor: pointer;
    transition: all .15s ease;
}
.dash-door-btn-sm:hover { background: rgba(0,212,255,.2); }
.dash-door-empty {
    text-align: center;
    padding: 30px 10px;
    color: var(--text-muted, #94a3b8);
    font-size: 13px;
}

/* 右列：通行记录表格 */
/* 通行记录滚动列表：统一行高与滚动条，置顶/常规分别限制可视行数 */
.dash-pass-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, .45) rgba(148, 163, 184, .14);
}
.dash-pass-list ul { list-style: none; margin: 0; padding: 0; }
/* 置顶区可视 3 行；常规区可视 7 行（保留更多条时滚动查看） */
.dash-pass-pinlist { max-height: 108px; }
.dash-pass-normlist { max-height: 252px; }
.dash-pass-list .grid-li {
    display: grid;
    gap: 8px;
    min-height: 34px;
    box-sizing: border-box;
    align-items: center;
}
.dash-pass-head {
    display: grid;
    gap: 8px;
    padding: 6px 4px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--dash-muted, #94a3b8);
    border-bottom: 1px solid var(--dash-scroll-border, rgba(100,116,139,.12));
    position: sticky;
    top: 0;
    background: inherit;
}
.dash-pass-head span, .dash-pass-list li span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* 置顶：勾选特定人员的通行（高亮区分） */
.dash-pass-list .dash-pass-pin {
    background: rgba(0, 212, 255, .07);
    border-left: 2px solid rgba(0, 212, 255, .55);
}
/* 置顶与常规之间的分隔 */
.dash-pass-gap {
    text-align: center;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--dash-muted, #94a3b8);
    padding: 5px 0 3px;
    border-bottom: 1px dashed var(--dash-scroll-border, rgba(100,116,139,.18));
    margin-bottom: 4px;
}
/* 常规通行行提示：仅房号缺失→黄字；房号+姓名皆缺失→红色半透明底+红字动态闪烁(背景固定) */
.dash-pass-list .grid-li.dash-pass-row.no-room { color: #f5b63e; }
.dash-pass-list .grid-li.dash-pass-row.no-person {
    color: #ff6b6b;
    background: rgba(255, 77, 79, .16);
}
.dash-pass-list .grid-li.dash-pass-row.no-person span {
    animation: dashPassBlink 1.2s ease-in-out infinite;
}
@keyframes dashPassBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: .35; }
}

/* ============ 门禁选择弹窗 ============ */
/* 已选排序区（拖动调整展示顺序） */
.door-sort-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 6px 4px 2px;
    border: 1px dashed var(--border-light, rgba(148, 163, 184, .25));
    border-radius: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, .45) rgba(148, 163, 184, .14);
}
.door-sort-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid var(--border-light, rgba(148, 163, 184, .14));
    border-radius: 8px;
    background: var(--panel-bg2, rgba(255, 255, 255, .03));
    cursor: grab;
    transition: border-color .15s ease, background .15s ease;
}
.door-sort-item:hover { border-color: rgba(0, 212, 255, .45); background: rgba(0, 212, 255, .05); }
.door-sort-item:active { cursor: grabbing; }
.door-sort-remove { border: none; background: transparent; color: var(--text-muted, #94a3b8); cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 4px; flex: 0 0 auto; }
.door-sort-remove:hover { color: var(--dash-red, #ff4d4f); }
.door-picker-list { display: flex; flex-direction: column; gap: 8px; max-height: 400px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, .45) rgba(148, 163, 184, .14); }
.door-picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-light, rgba(148,163,184,.15));
    background: var(--panel-bg, rgba(255,255,255,.03));
    cursor: pointer;
    transition: all .15s ease;
    color: var(--text, #e2e8f0);
}
.door-picker-item:hover { border-color: rgba(0,212,255,.4); }
.door-picker-item.selected { border-color: var(--accent, #00d4ff); background: rgba(0,212,255,.08); }

/* ============ 居中反馈提示 ============ */
.dash-center-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 32px;
    background: rgba(15,23,42,.94);
    color: #ff4d4f;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    z-index: 9999;
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
}
.dash-center-toast.show { opacity: 1; }
.dash-center-toast.ok { color: #00ff88; }

/* ===== 通行抓拍图查看器（卡片式：标题图上方居中、×贴图右上角、工具条在说明下） ===== */
.pass-viewer {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(6, 8, 16, .9);
  display: flex; align-items: center; justify-content: center;
  padding: 30px;
  animation: passViewerFade .18s ease;
}
@keyframes passViewerFade { from { opacity: 0; } to { opacity: 1; } }
.pass-viewer-card {
  display: flex; flex-direction: column; align-items: center;
  max-width: 94vw; max-height: 94vh;
}
.pass-viewer-titlebar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 16px; line-height: 1.3;
}
.pass-viewer-title { color: #f1f5f9; font-size: 15px; font-weight: 600; }
.pass-viewer-seq { color: #64748b; font-size: 13px; font-family: Consolas, monospace; }
.pass-viewer-imgbox {
  position: relative; min-height: 320px; min-width: 40vw;
  display: flex; align-items: center; justify-content: center;
}
.pass-viewer-img {
  display: block; max-width: min(88vw, 1500px); max-height: calc(100vh - 340px);
  border-radius: 8px; box-shadow: 0 12px 48px rgba(0,0,0,.6);
  animation: passViewerZoom .22s ease;
}
@keyframes passViewerZoom { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
/* 右上角关闭：贴图片右上角外侧 */
.pass-viewer-close {
  position: absolute; right: -16px; top: -16px; z-index: 6;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.22); background: #0f172a; color: #fff;
  font-size: 19px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
}
.pass-viewer-close:hover { background: #334155; }
/* 加载/失败提示：覆盖于图片区居中 */
.pass-viewer-state {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #94a3b8; font-size: 14px; line-height: 1.8; text-align: center;
}
.pass-viewer-caption {
  margin-top: 16px; color: #cbd5e1; font-size: 13.5px; text-align: center; line-height: 1.5;
  padding: 7px 16px; border-radius: 8px; background: rgba(255,255,255,.07);
}
.pass-viewer-nav { display: flex; gap: 10px; margin-top: 14px; }
.pass-viewer-btn {
  display: inline-block; border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.08); color: #e2e8f0;
  border-radius: 8px; padding: 7px 16px; font-size: 13px; cursor: pointer;
  text-decoration: none; line-height: 1.4;
}
.pass-viewer-btn:hover { background: rgba(255,255,255,.16); }
.pass-viewer-btn:disabled { opacity: .35; cursor: not-allowed; }
