/* =====================================================================
   衡眠纪后台 · 全局样式
   参考 NewLife 用户中心（ACE 主题）的版式语言：
   - 深色侧栏 + 浅色顶栏，导航与内容分层
   - 底部 ≪ / ≫ 折叠开关
   - 当前项高亮 + 左侧色条
   配色沿用：深海军蓝 #001529 侧栏 + 青绿 #5eead4 强调色
   ===================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1f2329;
  background: #f0f2f5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 滚动条：低调顺滑 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(31, 35, 41, 0.18); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(31, 35, 41, 0.3); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 首屏加载 / 资源失败兜底 ---------- */
.boot-loading, .boot-error {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  color: #6b7280; font-size: 14px; text-align: center; padding: 24px;
}
.boot-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(15, 118, 110, 0.2);
  border-top-color: #0f766e;
  animation: boot-spin 0.8s linear infinite;
}
@keyframes boot-spin { to { transform: rotate(360deg); } }
.boot-error h3 { font-size: 18px; color: #1f2329; }
.boot-error code {
  background: #f0f2f5; padding: 2px 6px; border-radius: 4px;
  font-family: Consolas, Monaco, monospace; color: #0f766e;
}
.boot-error .tip { color: #8a919f; font-size: 13px; line-height: 1.8; }

/* ---------- 应用根节点 ----------
   模板迁到 app.js 后多了一层 <div class="app-root">。
   必须给它确定高度：否则里面 .login-body 的 height:100% 找不到参照，
   渐变背景只跟着内容高度走，表现为「登录页背景只显示半截」。 */
.app-root { height: 100%; }

/* ---------- 登录页 ---------- */
.login-body {
  height: 100%;
  background: linear-gradient(135deg, #0f766e 0%, #0e7490 45%, #1d4ed8 100%);
}
.login-wrap {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 420px;
  max-width: 100%;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  padding: 40px 36px 32px;
  animation: card-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.brand .logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #0f766e, #1d4ed8);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.28);
}
.brand .title { font-size: 20px; font-weight: 600; color: #1f2329; }
.brand .subtitle { font-size: 12px; color: #8a919f; margin-top: 2px; letter-spacing: 0.4px; }
.welcome { font-size: 13px; color: #8a919f; margin: 18px 0 20px; }
.login-btn { width: 100%; height: 42px; font-size: 15px; letter-spacing: 4px; }
.row-between { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 18px; }
.tip { margin-top: 18px; font-size: 12px; color: #b0b6bf; text-align: center; line-height: 1.6; }

/* ---------- 主框架 ---------- */
.layout { height: 100vh; }
.body-col { min-width: 0; }

.aside {
  background: #001529;
  display: flex; flex-direction: column;
  border-right: none;
  position: relative;
  z-index: 3;
}
.aside-brand {
  height: 60px; display: flex; align-items: center; gap: 10px;
  padding: 0 18px; color: #fff; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex: none; overflow: hidden; white-space: nowrap;
}
.aside-brand .logo {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #0f766e, #1d4ed8);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.32);
}
.aside-brand .name { font-size: 16px; font-weight: 600; letter-spacing: 1px; }
.aside .el-menu { border-right: none; flex: 1; background: #001529; overflow-x: hidden; overflow-y: auto; }

/* 侧栏菜单高度收紧：大类标题（el-sub-menu__title）56→46，子项（el-menu-item）50→40
   覆盖 Element Plus 默认变量，height/line-height 等联动属性一并生效 */
.aside .el-menu {
  --el-menu-item-height: 46px;
  --el-menu-sub-item-height: 40px;
}

.header {
  height: 60px; background: #fff; display: flex; align-items: center;
  justify-content: space-between; padding: 0 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  position: relative; z-index: 2;
}
.header-left { display: flex; align-items: center; min-width: 0; }
.crumb { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumb-cat { font-size: 13px; color: #8a919f; white-space: nowrap; }
.crumb-sep { font-size: 11px; color: #c5cad3; }
.crumb-cur {
  font-size: 17px; font-weight: 600; color: #1f2329; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.header-right { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 8px; cursor: pointer;
  color: #5a6270; font-size: 17px;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.icon-btn:hover { background: #f0f2f5; color: #0f766e; }
.icon-btn:active { transform: scale(0.92); }

.user-box {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 5px 10px 5px 5px; border-radius: 20px; outline: none;
  transition: background 0.18s ease;
}
.user-box:hover { background: #f0f2f5; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #0f766e, #1d4ed8); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.user-name {
  font-size: 14px; color: #1f2329; max-width: 120px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-caret { font-size: 12px; color: #a8aeb8; }

.main { background: #f0f2f5; padding: 18px; overflow: auto; }
.section-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-card {
  flex: 1; min-width: 160px; border-radius: 12px;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(31, 35, 41, 0.10); }
.stat-title { font-size: 13px; color: #8a919f; }
.stat-value { font-size: 28px; font-weight: 700; color: #0f766e; margin-top: 8px; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.page-card {
  background: #fff; border-radius: 12px; padding: 16px;
  transition: box-shadow 0.22s ease;
}
.page-card:hover { box-shadow: 0 6px 20px rgba(31, 35, 41, 0.07); }

/* ---------- 侧栏当前项小图标（区分「正在看的子功能」） ---------- */
.aside .menu-label { display: flex; align-items: center; gap: 7px; }
.aside .menu-mark {
  font-size: 11px; color: #5eead4; opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s cubic-bezier(0.22, 1, 0.36, 1), transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.aside .menu-mark.on { opacity: 1; transform: scale(1); }
/* 当前子项的完整选中样式见下方「三层选中反馈」 */

/* 侧栏菜单整体微调：更柔和的悬浮与选中 */
.aside .el-menu-item, .aside .el-sub-menu__title { transition: background-color 0.18s ease, color 0.18s ease; }

/* ---------- 侧栏收起 / 展开（参考 NewLife 用户中心） ---------- */
.aside { width: 220px; transition: width 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
.aside .aside-brand { transition: padding 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
.aside.collapsed { width: 60px; }
.aside.collapsed .aside-brand { padding: 0 14px; }
.aside.collapsed .aside-brand .name { display: none; }

/* 收起态：大类图标快捷栏 */
.nav-rail { flex: 1; padding: 8px 0; overflow-y: auto; }
.rail-item {
  height: 48px; display: flex; align-items: center; justify-content: center;
  font-size: 19px; color: #c5cad3; cursor: pointer;
  transition: color 0.18s ease, background-color 0.18s ease;
}
.rail-item:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
/* .rail-item.on 的完整样式见下方「三层选中反馈」 */

/* 收起 / 展开开关（底部 ≪ / ≫） */
.nav-toggle {
  height: 44px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #c5cad3; cursor: pointer; flex: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  transition: color 0.18s ease, background-color 0.18s ease;
}
.nav-toggle:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

/* ---------- 手机版式微调（侧栏已默认收起为图标栏） ---------- */
@media (max-width: 768px) {
  .header { padding: 0 12px; }
  .crumb-cat, .crumb-sep { display: none; }
  .crumb-cur { font-size: 15px; max-width: 42vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .main { padding: 12px; }
  .user-name { display: none; }
}
@media (max-width: 480px) {
  .header-right .icon-btn:first-child { display: none; } /* 超小屏隐藏「刷新」，避免挤压 */
  .user-box { padding: 4px; }
}

/* ---------- Element Plus 细节微调 ---------- */
.el-dropdown-menu__item { display: flex; align-items: center; gap: 8px; }
.el-dropdown-menu__item .el-icon { font-size: 15px; color: #8a919f; }
.el-dropdown-menu__item:hover .el-icon { color: #0f766e; }
.el-dialog { border-radius: 12px; }

/* =====================================================================
   Element Plus 质感统一（参考 NewLife / ACE 的现代中性设计令牌）
   - 圆角 6px / 卡片 10px、边框 #e4e6e9、表头 #f5f8fc、行 hover #f0f6fb
   - 过渡统一 0.15s~0.22s，触感顺滑
   ===================================================================== */

/* ---- 圆角与阴影体系 ---- */
.layout {
  --hm-radius: 6px;
  --hm-radius-lg: 10px;
  --hm-border: rgba(31, 35, 41, 0.08);
  --hm-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
  --hm-shadow-lg: 0 6px 20px rgba(31, 35, 41, 0.10), 0 2px 6px rgba(31, 35, 41, 0.05);
}
.el-button { border-radius: var(--hm-radius); transition: all 0.18s cubic-bezier(0.22, 1, 0.36, 1); }
.el-button:hover { transform: translateY(-1px); }
.el-button:active { transform: translateY(0) scale(0.98); }
.el-tag { border-radius: 4px; }

/* ---- 卡片：浅边框 + 柔和阴影（ACE 白卡片语言） ---- */
.el-card {
  border: 1px solid var(--hm-border);
  border-radius: var(--hm-radius-lg);
  box-shadow: var(--hm-shadow);
  transition: box-shadow 0.22s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.el-card:hover { box-shadow: var(--hm-shadow-lg); }
.el-card__header { border-bottom-color: rgba(31, 35, 41, 0.06); font-weight: 600; }

/* ---- 表格：卡片化（圆角外框 + 表头底色 + 行 hover） ---- */
.el-table {
  border-radius: var(--hm-radius-lg);
  --el-table-border-color: #eaeef3;
  --el-table-header-bg-color: #f5f8fc;
  --el-table-header-text-color: #4a5568;
  --el-table-row-hover-bg-color: #f0f6fb;
  --el-table-tr-bg-color: #fff;
}
.el-table th.el-table__cell {
  background: #f5f8fc !important;
  font-weight: 600;
  font-size: 13px;
}
.el-table td.el-table__cell { font-size: 13px; }
.el-table td.el-table__cell,
.el-table th.el-table__cell { border-bottom-color: #eaeef3 !important; }
.el-table--border::after,
.el-table--group::after { background: #e9edf1 !important; }
.el-table tr.current-row > td.el-table__cell { background: #e6f4fb !important; }
.el-table .el-table__empty-text { color: #a1a8b3; font-size: 13px; }
/* 表格内操作按钮：紧凑、柔和 */
.el-table .el-button + .el-button { margin-left: 6px; }
.el-table .el-button.is-text { padding: 4px 8px; }

/* ---- 表单控件：圆角与聚焦 ---- */
.el-input__wrapper, .el-textarea__inner, .el-select__wrapper {
  border-radius: var(--hm-radius);
  box-shadow: 0 0 0 1px #dcdfe5 inset;
  transition: box-shadow 0.18s ease;
}
.el-input__wrapper:hover { box-shadow: 0 0 0 1px #c3c9d2 inset !important; }

/* ---- 分页 ---- */
.el-pagination { justify-content: flex-end; }
.el-pager li, .el-pagination button { border-radius: var(--hm-radius); transition: all 0.15s ease; }

/* ---- 标签页 ---- */
.el-tabs__item { transition: color 0.15s ease; }
.el-tabs__active-bar { transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1); }

/* ---- 侧栏：三层选中反馈（参考 ACE：一级色条/字重、二级底色+色条） ---- */
.aside .el-sub-menu__icon-arrow { transition: transform 0.2s ease, color 0.2s ease; color: #7a8598; }
.aside .el-sub-menu.is-opened > .el-sub-menu__title .el-sub-menu__icon-arrow { color: #5eead4; }
.aside .el-sub-menu.is-opened > .el-sub-menu__title { color: #e6ebf2; font-weight: 600; }
.aside .el-sub-menu.is-active > .el-sub-menu__title { color: #5eead4; }
/* 二级当前项：浅色底 + 青色文字 + 600 字重 + 左侧色条 */
.aside .el-menu-item.is-active {
  background-color: rgba(94, 234, 212, 0.10) !important;
  color: #5eead4;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #5eead4;
}
/* 图标快捷栏当前项（收起态） */
.rail-item.on {
  color: #5eead4; background: rgba(94, 234, 212, 0.10);
  box-shadow: inset 3px 0 0 #5eead4; font-weight: 600;
}
/* 二级菜单悬浮：柔和浅色 */
.aside .el-menu-item:hover { background-color: rgba(255, 255, 255, 0.05) !important; }

/* =====================================================================
   可视化分析 · 呼吸灯监测面板（深色大屏风格，嵌在设备管理内）
   - 离床 / 无人（rt_status=0 或无数据）→ va-empty：灰暗、缓慢呼吸
   - 床上有人（rt_status=1/2/3）        → va-occupied：青绿、活跃呼吸
   ===================================================================== */
.va-wrap { display: flex; flex-direction: column; gap: 16px; }

.va-monitor {
  position: relative;
  border-radius: 16px;
  background:
    radial-gradient(900px 420px at 50% -20%, rgba(45, 212, 191, 0.16), transparent 60%),
    linear-gradient(180deg, #0b1626 0%, #0c1c2e 100%);
  border: 1px solid rgba(94, 234, 212, 0.18);
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.55), 0 8px 28px rgba(8, 18, 32, 0.35);
  padding: 20px 22px 26px;
  overflow: hidden;
}
.va-monitor::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(94, 234, 212, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(94, 234, 212, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: radial-gradient(900px 420px at 50% 30%, #000 30%, transparent 75%);
  mask-image: radial-gradient(900px 420px at 50% 30%, #000 30%, transparent 75%);
  pointer-events: none;
}
.va-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.va-title { font-size: 18px; font-weight: 600; color: #e6fbff; letter-spacing: 1px; display: flex; align-items: center; gap: 10px; }
.va-title .dot { width: 9px; height: 9px; border-radius: 50%; background: #5eead4; box-shadow: 0 0 10px #5eead4; }
.va-sub { font-size: 12px; color: #7f93a8; }

.va-stage { position: relative; display: flex; flex-direction: column; align-items: center; padding: 22px 0 8px; }

/* 中央床位呼吸灯 */
.va-bed {
  width: 200px; height: 200px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.02) 70%);
  border: 2px solid var(--va-glow);
  color: #eafffb;
}
.va-bed .va-bed-icon { font-size: 42px; }
.va-bed .va-bed-label { font-size: 20px; font-weight: 700; letter-spacing: 2px; }
.va-bed .va-bed-hint { font-size: 12px; color: #9fb3c8; }

/* 体征呼吸灯组 */
.va-rings { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; margin-top: 22px; }
.va-light {
  width: 118px; height: 118px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; text-align: center;
  background: radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.02) 72%);
  border: 2px solid var(--va-glow);
  color: #eafffb;
}
.va-light .va-light-val { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.va-light .va-light-unit { font-size: 11px; color: #9fb3c8; }
.va-light .va-light-name { font-size: 12px; color: #cfe9ec; margin-top: 2px; }

/* 占用 / 无人 两套呼吸光配色 */
.va-monitor.va-occupied { --va-glow: rgba(45, 212, 191, 0.9); --va-ring: rgba(45, 212, 191, 0.55); }
.va-monitor.va-empty    { --va-glow: rgba(124, 138, 156, 0.5); --va-ring: rgba(124, 138, 156, 0.28); }

.va-occupied .va-bed,
.va-occupied .va-light { animation: va-breathe 2.6s ease-in-out infinite; }
.va-empty .va-bed,
.va-empty .va-light { animation: va-breathe-slow 4.6s ease-in-out infinite; opacity: 0.72; }

@keyframes va-breathe {
  0%, 100% { box-shadow: 0 0 12px 2px var(--va-glow), inset 0 0 16px 3px var(--va-ring); transform: scale(1); }
  50%      { box-shadow: 0 0 38px 14px var(--va-glow), inset 0 0 28px 7px var(--va-ring); transform: scale(1.045); }
}
@keyframes va-breathe-slow {
  0%, 100% { box-shadow: 0 0 6px 1px var(--va-glow), inset 0 0 10px 2px var(--va-ring); transform: scale(1); }
  50%      { box-shadow: 0 0 16px 5px var(--va-glow), inset 0 0 16px 4px var(--va-ring); transform: scale(1.02); }
}

.va-note { position: relative; text-align: center; font-size: 12px; color: #7f93a8; margin-top: 16px; }
.va-note b { color: #5eead4; }

/* 实时波形 */
.va-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 768px) { .va-charts { grid-template-columns: 1fr; } }
.va-chart-card { background: #0c1c2e; border: 1px solid rgba(94, 234, 212, 0.16); border-radius: 12px; padding: 10px 12px; }
.va-chart-card h4 { margin: 0 0 6px; font-size: 13px; color: #bfe9e4; font-weight: 600; }
.va-chart { width: 100%; height: 200px; }

