/* ==========================================================================
   场站运维管理系统 (Web 版) —— 布局与组件样式
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.icon { flex: none; display: inline-block; vertical-align: -3px; }

/* --------------------------------------------------------------------------
   外壳: 侧边栏 + 工作区
   -------------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  background: var(--side-bg);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--side-border);
}

/* 徽标与标题并列一行 (标题 / 版本号上下排在文字块内) */
.brand {
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--side-border);
}
/* 企业徽标: 只约束高度与最大宽度, 宽度按原图比例自适应, 不拉伸变形。
   浅色模式用深色版徽标, 深色模式用浅色版 —— 同尺寸同位置, 只显示其中一个。 */
.brand-logo { display: block; height: 28px; width: auto; max-width: 45%; flex: none; }
.brand-logo.is-for-dark { display: none; }
[data-theme="dark"] .brand-logo.is-for-light { display: none; }
[data-theme="dark"] .brand-logo.is-for-dark { display: block; }
.brand-text { min-width: 0; flex: 1; }
.brand-title { color: var(--side-text-strong); font-size: 14px; font-weight: 650; letter-spacing: .2px; white-space: nowrap; }

/* 侧栏收起按钮 (徽标行右侧, 箭头朝左) */
.side-toggle {
  margin-left: auto; flex: none; display: grid; place-items: center;
  width: 26px; height: 26px; padding: 0; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent; color: var(--side-text-dim);
  cursor: pointer; transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.side-toggle:hover { background: var(--side-hover-bg); color: var(--side-text-strong); border-color: var(--side-border); }
.side-toggle .icon { transform: rotate(180deg); }

.nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--side-text-strong) 14%, transparent); border-radius: 8px; }

/* ---- 侧边栏下拉菜单: 分组标题即下拉触发器 ---- */
.nav-group { margin-bottom: 4px; }
.nav-group-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; margin: 1px 0; padding: 9px 12px;
  background: transparent; border: 0; border-radius: var(--r-sm);
  font-family: inherit; font-size: 11px; font-weight: 650;
  letter-spacing: 1.2px; text-transform: uppercase; text-align: left;
  color: var(--side-text-dim); cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.nav-group-title:hover { background: var(--side-hover-bg); color: var(--side-text-strong); }
.nav-group-title.is-active { color: var(--side-text-strong); }
.nav-group-title .chev { display: flex; opacity: .6; transition: transform .2s ease, opacity .16s ease; }
.nav-group-title:hover .chev { opacity: 1; }
.nav-group-title .chev.is-open { transform: rotate(90deg); opacity: 1; }
/* 展开/收起: 用 grid-template-rows 的 0fr ↔ 1fr 过渡实现高度动画 (无需测量内容高度) */
.nav-items { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .22s ease; }
.nav-items.is-closed { grid-template-rows: 0fr; }
/* 内层做 overflow 裁剪, 同时用左右负外边距抵消内边距,
   使 .nav-link 的位置与此前一致 (当前项的左侧高亮竖条位于裁剪区内, 不被切掉)。 */
.nav-items-inner { overflow: hidden; min-height: 0; padding: 0 12px; margin: 0 -12px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin: 1px 0;
  border-radius: var(--r-sm);
  color: var(--side-text); font-size: 13.5px;
  position: relative; transition: background .16s ease, color .16s ease;
}
.nav-link:hover { background: var(--side-hover-bg); color: var(--side-text-strong); text-decoration: none; }
.nav-link.is-active { background: var(--side-active-bg); color: var(--side-text-strong); font-weight: 600; }
.nav-link.is-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--gold-500);
}
.nav-link .icon { color: var(--side-text-dim); }
.nav-link.is-active .icon, .nav-link:hover .icon { color: var(--gold-400); }

.sidebar-foot {
  padding: 12px 16px 16px; border-top: 1px solid var(--side-border);
  font-size: 11.5px; color: var(--side-text-dim); display: flex;
  justify-content: space-between; gap: 8px;
}

/* --------------------------------------------------------------------------
   工作区
   -------------------------------------------------------------------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 26px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar-heading { display: flex; flex-direction: column; justify-content: center; gap: 1px; min-width: 0; }
.topbar-title {
  font-size: 17px; font-weight: 700; letter-spacing: -.2px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-sub { font-size: 12px; color: var(--text-3); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* 消息中心: 铃铛右上角的红色未读角标 (0 条时隐藏) + 下拉消息列表 */
.msg-wrap { position: relative; display: inline-flex; }
.msg-btn { position: relative; }
.msg-ico { position: relative; display: inline-flex; }
.msg-badge {
  position: absolute; top: -6px; right: -9px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center;
  border-radius: 999px; border: 2px solid var(--surface);
  background: var(--danger); color: #fff;
  font-family: var(--font-num); font-size: 10px; font-weight: 700; line-height: 1;
  pointer-events: none;
}
.msg-badge.is-empty { display: none; }
.msg-panel {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 70;
  width: min(380px, calc(100vw - 28px)); max-height: min(70vh, 560px);
  overflow-y: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); animation: modal-rise .16s ease;
}
.msg-panel-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.msg-panel-title { font-size: 13px; font-weight: 650; color: var(--text); }
.msg-panel-actions { margin-left: auto; display: flex; gap: 6px; }
.msg-panel .msg-list { padding: 8px; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(140deg, var(--brand-600), var(--brand-800));
  color: #fff; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; letter-spacing: .3px;
}
.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  transition: border-color .18s ease, background .18s ease;
}
/* 顶栏用户区: 头像+用户名 链接到"我的账号"页。
   悬浮时整块胶囊提亮 (边框 + 底纹), 文字由次级色提到正文色 ——
   深色主题下不再用高饱和蓝作为文字悬浮色 (原效果生硬刺眼)。 */
.user-link { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; }
.user-link .dim { transition: color .18s ease; }
.user-chip:has(.user-link:hover),
.user-chip:has(.user-link:focus-visible) {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.user-link:hover .dim, .user-link:focus-visible .dim { color: var(--text); }
.user-link:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 999px; }

.content { padding: 16px 26px 40px; flex: 1; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.3px; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* --------------------------------------------------------------------------
   卡片
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 18px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 20px; border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; }
.card-head .card-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 20px; }
.card-body.tight { padding: 12px 14px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* grid 内卡片间距由 gap 控制; 取消 .card + .card 的堆叠外边距, 否则同排第 2 张起的卡片
   会被顶下 18px, 导致第一张卡片比其它高、同排图表高低不齐 */
.grid > .card { margin-top: 0; }

/* ---- 窄屏抽屉导航: 遮罩默认不出现在桌面端; 菜单按钮在宽屏用于折叠侧栏 ---- */
/* 按钮同时带 .btn 类, 而 .btn 在文件更靠后的位置才设 display: inline-flex,
   同优先级下靠后者生效 —— 故此处用 .topbar .nav-toggle 提高优先级, 确保始终可见 */
.topbar .nav-toggle { display: inline-flex; }
.nav-backdrop { display: none; }

/* ---- 侧栏折叠 (宽屏): 收起的侧栏改为固定层滑出画面, 内容区随之铺满 ----
   折叠后左侧留 8px 唤出热区, 鼠标移上去侧栏临时滑出 (覆盖内容, 不挤压布局)。
   临时唤出只看 .nav-peek 类 (由脚本在进入热区时加、离开侧栏时去掉),
   不能在侧栏自身上用 :hover —— 点「收起菜单」时鼠标还在侧栏位置, 会立刻把它显示回来。 */
.nav-edge { display: none; }
@media (min-width: 821px) {
  .sidebar { transition: transform .24s ease, visibility .24s ease; }
  html.nav-hidden .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60;
    transform: translateX(-102%); visibility: hidden;
    box-shadow: 0 0 36px rgba(0, 0, 0, .3);
  }
  html.nav-hidden.nav-peek .sidebar {
    transform: none; visibility: visible;
  }
  html.nav-hidden .nav-edge {
    display: block; position: fixed; left: 0; top: 0; bottom: 0; width: 8px; z-index: 59;
  }
}

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  /* 侧栏改为左侧抽屉: 常驻会占掉大半手机屏宽, 而整块隐藏会让手机端完全没有导航入口 ——
     由顶栏的汉堡按钮 (nav-toggle) 唤出, 点遮罩收起。 */
  .sidebar {
    position: fixed; left: 0; width: min(82vw, 320px); z-index: 60;
    /* 收起时用 visibility: hidden 一并挡掉点击与键盘焦点 (visibility 参与过渡:
       展开时立即可见, 收起时等滑出动画结束才隐藏) */
    transform: translateX(-102%); visibility: hidden;
    transition: transform .24s ease, visibility .24s ease;
    box-shadow: 0 0 36px rgba(0, 0, 0, .3);
  }
  .sidebar.is-open { transform: none; visibility: visible; }
  .topbar .nav-toggle { display: inline-flex; }
  .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .42); }
  .content { padding: 18px 14px 32px; }
  .topbar { padding: 0 14px; }
}

/* ---- KPI 数值卡 ---- */
/* 压缩高度; 用 flex 垂直居中, 使网格拉伸出的多余高度在上下平分 —— 保证上下外间距相等 */
.kpi {
  padding: 12px 16px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
}
.kpi::after {
  content: ""; position: absolute; inset: auto -30px -40px auto; width: 130px; height: 130px;
  border-radius: 50%; background: var(--primary-100); opacity: .65;
}
.kpi-label { font-size: 12px; color: var(--text-3); letter-spacing: .3px; line-height: 1.4; }
.kpi-value {
  font-family: var(--font-num); font-size: 22px; font-weight: 700;
  letter-spacing: -.5px; line-height: 1.2; margin-top: 4px; color: var(--brand-700);
}
[data-theme="dark"] .kpi-value { color: var(--text); }
.kpi-value .unit { font-size: 12px; font-weight: 600; color: var(--text-3); margin-left: 4px; letter-spacing: 0; }
.kpi-foot { margin-top: 6px; font-size: 11.5px; line-height: 1.45; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.kpi.accent .kpi-value { color: var(--gold-500); }

/* ---- 仪表盘: 场站分布地图 + 运营 KPI 左右并列 ----
   目标: 地图尽可能大, 且整个仪表盘单屏内完整显示 (无页面滚动)。
   做法: 首页把视口高度锁死 (body 不滚动), 顶栏与内容区用 flex 分配剩余高度,
        中间容器一律 min-height:0, 让地图与 KPI 网格按可用高度收缩而不是撑出滚动条。 */
.dash-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: 18px; }
/* KPI 列: 两列铺满; grid-auto-rows 用 minmax(0,1fr) 让卡片等高且能随屏幕高度收缩
   (1fr 的最小值是内容高度, 屏幕偏矮时会顶出滚动条) */
.dash-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
/* 无地图 (台账缺经纬度) 时: KPI 独占整行, 按自然高度显示 */
.dash-split-solo { grid-template-columns: minmax(0, 1fr); }
.dash-split-solo .dash-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* 首页锁定视口高度: 不再用 calc(100vh - 顶栏) 拼高度 (差 1px 就会出滚动条) */
.page-home { overflow: hidden; }
.page-home .app-shell { height: 100vh; min-height: 0; }
.page-home .main { height: 100vh; min-height: 0; }
.page-home .content {
  display: flex; flex-direction: column;
  height: auto; min-height: 0; overflow: hidden;
}
.page-home .dash-split { flex: 1; min-height: 0; }
.page-home .dash-split-solo { flex: 0 0 auto; }
/* 地图卡: 卡片头固定, 图表撑满剩余高度 (flex 会解析成具体像素, ECharts 可正常测量) */
.page-home .dash-map { display: flex; flex-direction: column; min-height: 0; }
.page-home .dash-map .card-body { flex: 1; min-height: 0; display: flex; }
.page-home .chart-map { flex: 1; height: auto; min-height: 0; }

@media (max-width: 1180px) {
  /* 窄屏: 解除视口锁定, 恢复纵向流式排版并允许滚动, 地图退回固定高度 */
  .page-home { overflow: auto; }
  .page-home .app-shell, .page-home .main { height: auto; }
  .page-home .content { display: block; height: auto; min-height: 0; overflow: visible; }
  .page-home .dash-split { min-height: 0; }
  .page-home .dash-map .card-body { display: block; }
  .page-home .chart-map { flex: none; height: 520px; }
  .dash-split { grid-template-columns: minmax(0, 1fr); }
  .dash-kpi, .dash-split-solo .dash-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .dash-kpi, .dash-split-solo .dash-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --------------------------------------------------------------------------
   按钮
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 560; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .1s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }

.btn-primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-600));
  border-color: transparent; color: #fff;
}
.btn-primary:hover { background: linear-gradient(180deg, var(--primary), var(--primary-600)); filter: brightness(1.06); }

.btn-gold {
  background: linear-gradient(180deg, var(--gold-400), var(--gold-500));
  border-color: transparent; color: var(--gold-ink); font-weight: 650;
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 34%, var(--border)); }
.btn-danger:hover { background: var(--danger-100); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.2px; }
.btn-lg { height: 40px; padding: 0 20px; font-size: 14px; }
.btn-icon { width: 32px; height: 32px; padding: 0; }
.btn-block { width: 100%; }

/* --------------------------------------------------------------------------
   表单
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-3); }
.req::after { content: " *"; color: var(--danger); }

.input, .select, .textarea {
  width: 100%; min-width: 0;
  height: 34px; padding: 0 11px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { height: auto; padding: 9px 11px; line-height: 1.6; resize: vertical; }
.select { appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a909b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }

/* 原生下拉选项需显式着色, 否则深色模式下弹出层仍是浅色底 (与界面不匹配) */
.select option, table.data select.cell option { background: var(--surface); color: var(--text); }

/* 单元格控件 (frag_data_cell): 表格内由 table.data 规则覆盖为紧凑无边框样式;
   表格外 (如录入页表单网格) 显示为常规控件 */
.cell {
  width: 100%; min-width: 0; height: 34px; padding: 0 11px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.cell:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
select.cell { appearance: none; -webkit-appearance: none; padding-right: 28px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a909b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
select.cell option { background: var(--surface); color: var(--text); }

/* 录入页: 顶部公共字段条 (风场 / 日期) */
.form-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.form-bar > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.card-body > .form-bar:last-child { margin-bottom: 0; }
/* 录入页: 标签在上、输入在下的四列网格 */
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 16px; }
.fg { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fg > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
@media (max-width: 1180px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
/* 录入页: 分组标题 (双细则考核的 功率预测 / AGC / AVC) */
.form-group + .form-group { margin-top: 20px; }
.form-group-title { font-size: 13px; font-weight: 650; color: var(--text); margin-bottom: 10px; }
.cell::placeholder { color: var(--text-3); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.toolbar .field { margin-bottom: 0; }
.toolbar .field-grow { flex: 1; min-width: 160px; }
/* 页面顶部的筛选条: 与下方内容 (KPI 卡片等) 留出间距 */
.filter-bar { margin-bottom: 18px; }

.checkbox { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.checkbox input { width: 15px; height: 15px; accent-color: var(--primary); }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong);
  position: relative; transition: background .18s ease; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs); transition: transform .18s ease;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }

/* --------------------------------------------------------------------------
   表格
   -------------------------------------------------------------------------- */
.table-wrap { overflow: auto; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); }
.table-wrap.flush { border: 0; border-radius: 0; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.8px; }
table.data thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-3); color: var(--text-2);
  font-family: var(--font); font-size: 12.8px;
  font-weight: 640; text-align: left; white-space: nowrap;
  padding: 9px 11px; border-bottom: 1px solid var(--border);
}
table.data tbody td { padding: 8px 11px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.is-selected { background: var(--primary-100); }
/* 表头统一使用正文字体; 数值列表头只做右对齐, 不换成等宽字体 (保持全表表头一致) */
table.data thead th.num { font-family: var(--font); text-align: right; }
/* 数值列表头默认右对齐; 列名较长者 (如 "损失电量 (兆瓦时)") 靠左对齐更易读。
   保留 num 类是为了让可排序表仍按数值比较 (app.js 以 th.num 判定数值列)。 */
table.data thead th.num.head-left { text-align: left; }
table.data td.num { text-align: right; font-family: var(--font-num); }
/* 日志详情 / 目标对象列: 单行显示, 超长省略, 悬浮 (title) 查看完整内容 */
table.data td.wrap-ellipsis { max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.data td.actions { white-space: nowrap; text-align: right; }
/* 台账列表 (场站 / 机组 / 部件): 表头与内容全部居中对齐 */
table.data.is-center thead th,
table.data.is-center tbody td { text-align: center; }
table.data.is-center thead th.num,
table.data.is-center td.num { text-align: center; }
table.data.is-center td.actions { text-align: center; }
table.data.is-center .actions-row { justify-content: center; }
/* 机组台账: 列多且需要完整显示 —— 表头可用 <br> 折成多行以压缩列宽,
   数据格一律单行不折行 (日期 / 状态徽标 / 按钮不会被挤成竖排), 内边距略收紧。 */
table.data.unit-ledger thead th { padding: 9px 7px; line-height: 1.4; vertical-align: middle; white-space: normal; }
table.data.unit-ledger tbody td { padding: 8px 7px; white-space: nowrap; }
/* 操作列里可能同时有按钮与表单 (表单默认块级, 会另起一行):
   统一用一个 flex 行把它们排在同一行并右对齐。 */
.actions-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
/* 可排序表头: 点击切换 升序/降序/原始 顺序, 右侧显示方向指示 */
table.data thead th[data-sort] { cursor: pointer; user-select: none; }
table.data thead th[data-sort]::after { content: "⇅"; margin-left: 6px; font-size: 11px; opacity: .28; }
table.data thead th[data-sort]:hover::after { opacity: .6; }
table.data thead th[data-sort][aria-sort="ascending"]::after { content: "▲"; opacity: .85; }
table.data thead th[data-sort][aria-sort="descending"]::after { content: "▼"; opacity: .85; }
table.data.compact tbody td { padding: 5px 9px; }
table.data input.cell, table.data select.cell {
  width: 100%; height: 28px; padding: 0 7px; font-size: 12.5px;
  border: 1px solid transparent; border-radius: var(--r-xs);
  background: transparent; color: inherit; font-family: inherit;
}
table.data input.cell:hover { border-color: var(--border-strong); background: var(--surface); }
table.data input.cell:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: var(--ring); }
/* 表格内下拉: 去掉原生外观, 与 .select 及 input.cell 保持一致的悬停/聚焦表现 */
table.data select.cell { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a909b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center; }
table.data select.cell:hover { border-color: var(--border-strong); background-color: var(--surface); }
table.data select.cell:focus { outline: none; border-color: var(--primary); background-color: var(--surface); box-shadow: var(--ring); }
.table-scroll-y { max-height: 62vh; overflow: auto; }
/* 数据编辑: 风场列按最长风场名预留宽度 (表头内隐藏文本撑开), 完整显示不换行 */
table.data th.col-farm, table.data td.col-farm { white-space: nowrap; }
table.data th.col-farm .col-size { visibility: hidden; font-weight: inherit; }

/* --------------------------------------------------------------------------
   日报表 (Daily Generation Report): 横向 Daily / MTD / YTD 三组, 每组
   Target / Actual / Deviation; 偏差按正负着色。
   -------------------------------------------------------------------------- */
.dgr-wrap { overflow-x: auto; }
table.dgr { font-size: 12px; }
table.dgr thead th { text-align: center; vertical-align: middle; white-space: nowrap; }
table.dgr th, table.dgr td { padding: 6px 7px; }
table.dgr .dgr-param { text-align: left; }
table.dgr .dgr-titlerow th { font-size: 14px; font-weight: 700; color: var(--text); }
table.dgr .dgr-title { text-align: left; }
table.dgr .dgr-date { text-align: right; }
table.dgr .dgr-grouphdr th { background: var(--surface-2); }
table.dgr .dgr-name { text-align: left; }
table.dgr .dgr-head2 th {
  text-align: left; background: var(--surface-2);
  border-top: 1px solid var(--border-strong); border-bottom: 1px solid var(--border);
}
table.dgr .dgr-head2 th.num { text-align: right; }
/* 当日 / 本月累计 / 本年累计 三大块之间的纵向分割线 */
table.dgr .dgr-sep { border-left: 1px solid var(--border-strong); }
table.dgr td.is-pos { background: rgba(34, 197, 94, .14); color: #15803d; font-weight: 640; }
table.dgr td.is-neg { background: rgba(239, 68, 68, .14); color: #b91c1c; font-weight: 640; }
table.dgr td.is-zero { background: rgba(100, 116, 139, .12); color: var(--text-2); }
[data-theme="dark"] table.dgr td.is-pos { color: #4ade80; }
[data-theme="dark"] table.dgr td.is-neg { color: #f87171; }
.dgr-note { margin-top: 10px; font-size: 12px; line-height: 1.6; color: var(--text-2); }

/* --------------------------------------------------------------------------
   说明页: 计算公式列表
   -------------------------------------------------------------------------- */
.help-item { padding: 9px 0; border-bottom: 1px dashed var(--border); }
.help-item:first-child { padding-top: 0; }
.help-item:last-child { padding-bottom: 0; border-bottom: 0; }
.help-name { font-size: 13px; font-weight: 650; color: var(--text); margin-bottom: 6px; }
.help-eq {
  font-family: var(--font-num); font-size: 12.5px; line-height: 1.75;
  background: var(--surface-2); border-left: 3px solid var(--primary);
  padding: 8px 12px; border-radius: var(--r-xs); color: var(--text-2);
  white-space: pre-wrap; overflow-x: auto;
}
.help-note { margin-top: 6px; font-size: 12px; line-height: 1.7; color: var(--text-3); }

/* --------------------------------------------------------------------------
   徽标 / 标签
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 620; letter-spacing: .2px;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);
}
.badge.ok { background: var(--success-100); color: var(--success); border-color: transparent; }
.badge.warn { background: var(--warn-100); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--danger-100); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-100); color: var(--info); border-color: transparent; }
.badge.gold { background: var(--gold-100); color: var(--text-2); border-color: transparent; }
[data-theme="dark"] .badge.gold { color: var(--gold-400); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text-2);
}
.chip.is-on { background: var(--primary-100); border-color: transparent; color: var(--primary-600); font-weight: 600; }
/* 可点击的 chip (指标切换等) */
a.chip { color: var(--text-2); cursor: pointer; }
a.chip:hover { text-decoration: none; border-color: var(--border-strong); color: var(--text); }
a.chip.is-on { color: var(--primary-600); }

/* --------------------------------------------------------------------------
   标签页
   -------------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab {
  padding: 9px 15px; font-size: 13.2px; font-weight: 570; color: var(--text-3);
  border-bottom: 2px solid transparent; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0;
  font-family: inherit;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--brand-700); border-bottom-color: var(--gold-500); font-weight: 660; }
[data-theme="dark"] .tab.is-active { color: var(--text); }

/* --------------------------------------------------------------------------
   提示 / 空态
   -------------------------------------------------------------------------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: var(--r-md); font-size: 13px;
  background: var(--info-100); color: var(--text); border: 1px solid transparent;
}
.alert.ok { background: var(--success-100); }
.alert.warn { background: var(--warn-100); }
.alert.bad { background: var(--danger-100); }
.alert .icon { margin-top: 1px; }

.empty { padding: 46px 20px; text-align: center; color: var(--text-3); }
.empty .icon { color: var(--border-strong); margin-bottom: 10px; }
.empty-title { font-size: 14px; font-weight: 620; color: var(--text-2); }

.toast-stack { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.toast {
  min-width: 220px; max-width: 380px; padding: 11px 15px;
  border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 13px;
  animation: toast-in .22s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   弹窗 (Modal): 台账的新增 / 编辑表单在弹出页面中完成
   遮罩层 z-index 低于提示条 (90), 保证出错提示仍可见。
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 24px; overflow: auto;
  background: rgba(9, 16, 30, .46);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  animation: modal-fade .16s ease;
}
.modal {
  width: 100%; max-width: 760px; margin: auto 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: modal-rise .18s ease;
}
.modal-lg { max-width: 940px; }
/* HTMX 载入弹窗内容的容器: 让内部 .modal 正常铺开并居中 */
.modal-slot { width: 100%; display: flex; justify-content: center; }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; }
.modal-head .modal-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.modal-close {
  flex: none; width: 30px; height: 30px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-3); font-size: 15px; line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-body { padding: 20px; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 820px) {
  .modal-backdrop { padding: 0; }
  .modal { max-width: none; border-radius: 0; min-height: 100%; margin: 0; }
}

/* 消息中心列表 */
.msg-list { display: flex; flex-direction: column; gap: 8px; }
.msg-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: inherit; text-decoration: none;
  transition: border-color .15s ease, background .15s ease;
}
.msg-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.msg-item.is-unread {
  border-color: color-mix(in srgb, var(--danger) 32%, var(--border));
  background: color-mix(in srgb, var(--danger-100) 55%, var(--surface));
}
.msg-dot { flex: none; width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; background: var(--border-strong); }
.msg-dot.is-unread { background: var(--danger); }
.msg-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.msg-title { font-size: 13px; font-weight: 650; color: var(--text); }
.msg-detail { font-size: 12px; color: var(--text-3); }
.msg-time { flex: none; font-family: var(--font-num); font-size: 11px; color: var(--text-3); }
.msg-empty { padding: 26px 0; text-align: center; font-size: 13px; color: var(--text-3); }

/* --------------------------------------------------------------------------
   图表
   -------------------------------------------------------------------------- */
.chart { width: 100%; height: 320px; }
/* 屏幕外图表宿主: 页面隐藏图表但需 ECharts 实例导出 PNG (Word 报告),
   用绝对定位移出视口左侧, 保留完整尺寸且不产生滚动条。 */
.chart-offscreen { position: absolute; left: -10000px; top: 0; width: 880px; pointer-events: none; }
.chart-lg { height: 420px; }
.chart-map { height: 560px; }

/* 图表翻页控件: 数据集分页显示时, 在图表下方给出总数与上下页 */
.chart-pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 8px;
}
.chart-pager-nav { display: flex; align-items: center; gap: 8px; }

/* --------------------------------------------------------------------------
   登录页
   -------------------------------------------------------------------------- */
/* 背景由三层叠加: 底色线性渐变 + 极光光晕(::after) + 细网格(::before)。
   全部按主题分别调色: 浅色为冷白底 + 低饱和光晕 + 浅网格, 深色为深空底 + 高饱和光晕 + 亮网格。 */
.login-page {
  position: relative; overflow: hidden;
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, #f8fafc 0%, #eaeef4 100%);
}
/* 细网格: 中间清晰、四周淡出, 避免整屏条纹显得廉价 */
.login-page::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(15, 23, 42, .055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, .055) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(1150px 680px at 50% 30%, #000 0%, transparent 80%);
  mask-image: radial-gradient(1150px 680px at 50% 30%, #000 0%, transparent 80%);
}
/* 极光光晕: 蓝 / 青 / 紫四团模糊光斑, 缓慢漂移形成流动感 */
.login-page::after {
  content: ""; position: absolute; inset: -24%; pointer-events: none;
  background:
    radial-gradient(620px 480px at 16% 20%, rgba(37, 99, 235, .22), transparent 62%),
    radial-gradient(560px 420px at 84% 24%, rgba(14, 165, 233, .20), transparent 62%),
    radial-gradient(660px 520px at 72% 84%, rgba(139, 92, 246, .20), transparent 64%),
    radial-gradient(520px 420px at 24% 86%, rgba(6, 182, 212, .18), transparent 62%);
  filter: blur(70px) saturate(125%);
  animation: login-aurora 26s ease-in-out infinite alternate;
}
@keyframes login-aurora {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1.04); }
  50%  { transform: translate3d(2%, 2%, 0) scale(1.10); }
  100% { transform: translate3d(-1%, 3%, 0) scale(1.06); }
}
[data-theme="dark"] .login-page {
  background: linear-gradient(160deg, #0a1020 0%, #060b14 100%);
}
[data-theme="dark"] .login-page::before {
  background-image:
    linear-gradient(to right, rgba(148, 163, 184, .10) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(148, 163, 184, .10) 1px, transparent 1px);
}
[data-theme="dark"] .login-page::after {
  background:
    radial-gradient(660px 520px at 16% 18%, rgba(37, 99, 235, .55), transparent 62%),
    radial-gradient(580px 460px at 86% 24%, rgba(14, 165, 233, .45), transparent 62%),
    radial-gradient(700px 560px at 72% 86%, rgba(139, 92, 246, .48), transparent 64%),
    radial-gradient(560px 460px at 22% 88%, rgba(6, 182, 212, .38), transparent 62%);
}
.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 400px; padding: 34px 32px 30px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}
/* 登录页右上角的深色 / 浅色切换 (与登录后顶栏同一个按钮形态) */
.login-theme-toggle {
  position: absolute; top: 22px; right: 24px; z-index: 2;
  width: 38px; height: 38px; padding: 0; display: inline-grid; place-items: center;
  border-radius: 999px; cursor: pointer; color: var(--text-2);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.login-theme-toggle:hover { color: var(--text); background: var(--surface); border-color: var(--border-strong); }
/* 主题图标: 浅色模式显示月亮 (切到深色), 深色模式显示太阳 (切到浅色) */
.theme-icon { display: none; }
.theme-icon.is-for-light { display: inline-flex; }
[data-theme="dark"] .theme-icon.is-for-light { display: none; }
[data-theme="dark"] .theme-icon.is-for-dark { display: inline-flex; }
/* 登录页右上角的中英文切换标签 (在主题按钮左侧, 同一排同一高度) */
.login-lang-toggle {
  position: absolute; top: 22px; right: 70px; z-index: 2;
  height: 38px; padding: 3px; display: inline-flex; align-items: center; gap: 2px;
  border-radius: 999px; border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(10px);
}
.login-lang-opt {
  height: 30px; padding: 0 11px; border: 0; border-radius: 999px;
  font-family: inherit; font-size: 12px; font-weight: 560; line-height: 1;
  color: var(--text-3); background: none; cursor: pointer;
  transition: color .18s ease, background .18s ease;
}
.login-lang-opt:hover { color: var(--text); }
/* 当前语言: 反色实心块 (浅色模式近黑底白字, 深色模式白底深字), 扁平设计不用投影 */
.login-lang-opt.is-active {
  color: var(--text-inv); background: var(--text); font-weight: 650; cursor: default;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
/* 企业徽标 (登录页): 只约束高度, 宽度按原图比例自适应;
   浅色模式用深色版, 深色模式用浅色版 —— 同尺寸同位置, 只显示其中一个。 */
.login-logo { display: block; height: 32px; width: auto; }
.login-logo.is-for-dark { display: none; }
[data-theme="dark"] .login-logo.is-for-light { display: none; }
[data-theme="dark"] .login-logo.is-for-dark { display: block; }
.login-title { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -.2px; }
.login-foot { margin-top: 18px; text-align: center; font-size: 11.5px; color: var(--text-3); }
/* ICP 备案号: 紧跟版权行, 低调但可点击 (工信部备案查询) */
.login-icp { margin-top: 4px; text-align: center; font-size: 11.5px; }
.login-icp a { color: var(--text-3); text-decoration: none; }
.login-icp a:hover { color: var(--text-2); text-decoration: underline; }

/* --------------------------------------------------------------------------
   HTMX 交互状态
   -------------------------------------------------------------------------- */
.htmx-indicator { opacity: 0; transition: opacity .18s ease; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  border: 2px solid color-mix(in srgb, currentColor 26%, transparent);
  border-top-color: currentColor; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 排序 / 小工具 */
.inline { display: flex; align-items: center; gap: 8px; }
.inline.wrap { flex-wrap: wrap; }
.muted { color: var(--text-3); }
.dim { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-num); }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 18px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 18px; }
.center { text-align: center; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.w-100 { width: 100%; }
.hidden { display: none; }

.scroll-y { max-height: 60vh; overflow-y: auto; }

/* --------------------------------------------------------------------------
   机组台账: 概览条 (台账规模 / 状态分布 / 数据一致性)
   -------------------------------------------------------------------------- */
.reg-stat { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.reg-stat .item { display: flex; align-items: baseline; gap: 8px; }
.reg-stat .v {
  font-size: 20px; font-weight: 650; letter-spacing: -.2px;
  font-variant-numeric: tabular-nums;
}
.reg-stat .k { font-size: 12px; color: var(--text-3); }
.reg-stat .v-sm { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.reg-stat .sep { width: 1px; height: 22px; background: var(--border); }


/* 打印: 报表页导出 PDF 时只留正文 */
@media print {
  .sidebar, .topbar, .page-head-actions, .btn, .no-print { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
  .table-wrap { overflow: visible; }
}

/* --------------------------------------------------------------------------
   油样分析: 顶部工具条 / 化验单 / 趋势迷你图
   -------------------------------------------------------------------------- */
.oil-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 0 0 12px; margin-bottom: 16px; border-bottom: 1px solid var(--border);
}
.oil-bar > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.oil-bar-title { font-size: 13px; font-weight: 650; color: var(--text); }
.oil-bar-info { margin-left: auto; }
.oil-bar-sub { border-bottom: 0; padding-bottom: 4px; }
.oil-seg { display: flex; gap: 6px; }
.oil-group-title { font-size: 13px; font-weight: 650; color: var(--text); margin: 16px 0 10px; }

/* 化验单: 左侧记录列表 + 右侧检测报告
   报告高度随内容自适应 (不出现纵向滚动条); 记录列表绝对定位铺满整行高度,
   与报告等高, 记录过多时仅在列表内部滚动。 */
.oil-split {
  position: relative;
  display: block;
  padding-left: 346px;              /* 330px 列表 + 16px 间距 */
  min-height: 0;
}
.oil-split > .card { margin-top: 0; }   /* 间距由左内边距承担, 不叠加 .card+.card 的堆叠外边距 */
.oil-list {
  position: absolute; left: 0; top: 0; bottom: 0; width: 330px;
  display: flex; flex-direction: column;
}
.oil-list > .card-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.oil-list-scroll { flex: 1; min-height: 0; overflow: auto; }
.oil-list-scroll th, .oil-list-scroll td { white-space: nowrap; }   /* 每条记录只占一行 */
.oil-report { display: flex; flex-direction: column; min-width: 0; }   /* 高度由内容决定 */
.oil-report > .card-body { overflow: visible; }          /* 报告不出现纵向滚动条 */
.oil-report-title { text-align: center; font-size: 17px; font-weight: 700; color: var(--text); }
.oil-report-sub { text-align: center; font-size: 11.5px; letter-spacing: 1.2px; color: var(--text-3); margin: 2px 0 16px; }
.oil-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 20px; margin-bottom: 4px; }
.oil-meta-item { display: flex; gap: 6px; min-width: 0; font-size: 12.5px; }
.oil-meta-item > span { flex: none; color: var(--text-3); }
.oil-meta-item > b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 趋势分析: 迷你图卡片 */
.card.mini { padding: 12px 14px 4px; }
.mini-title { font-size: 13px; font-weight: 650; color: var(--text); }
.mini-sub { margin: 2px 0 4px; }
.chart-mini { height: 176px; }

@media (max-width: 1180px) {
  .oil-split { display: flex; flex-direction: column; padding-left: 0; }
  .oil-list { position: static; width: auto; }
  .oil-list-scroll { flex: none; max-height: 60vh; }
  .oil-report > .card-body { overflow: visible; }
}
@media (max-width: 820px) {
  .oil-meta { grid-template-columns: minmax(0, 1fr); }
}

/* --------------------------------------------------------------------------
   日期/时间控件: 用统一的中文占位文案覆盖浏览器自带的格式提示 (如 yyyy/mm/日)
   .date-ph 由 app.js 的 WB.localizeDateInputs 注入并按输入框实际尺寸定位。
   -------------------------------------------------------------------------- */
.date-host { position: relative; }
.date-ph {
  position: absolute; left: 0; top: 0;
  font-size: 13px; color: var(--text-3);
  pointer-events: none; white-space: nowrap; display: none;
}
input.is-empty::-webkit-datetime-edit { color: transparent; }
input.is-empty ~ .date-ph { display: block; }

/* --------------------------------------------------------------------------
   Word 报告预览 (.omw): 类 Word 版式 — 页眉 Logo、主色标题条、现代表格、页脚
   预览固定按"纸面"呈现 (白底深字), 不随深色主题变化, 与导出的 Word 文档观感一致;
   因此在这里把预览区域内的浅色令牌显式覆盖回来 (不再使用主题的深色变量)。
   -------------------------------------------------------------------------- */
.omw {
  --omw-accent: #6d4bc7;
  --omw-accent-soft: #7c5cd6;
  --omw-band: color-mix(in srgb, #7c5cd6 7%, transparent);
  /* 纸面令牌 (强制浅色, 与 tokens.css 的浅色主题一致) */
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --surface-3: #f1f4fa;
  --border: #e4e9f2;
  --border-strong: #d2dae8;
  --text: #16223a;
  --text-2: #47536b;
  --text-3: #7c879e;
  --primary-100: rgba(37, 99, 235, .10);
  --shadow-xs: none;
  --shadow-sm: none;
  --ring: 0 0 0 3px rgba(37, 99, 235, .18);
  padding: 26px 30px 20px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text);
}
/* 页眉: Logo + 右侧标题 + 主色下划线 */
.omw-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding-bottom: 10px; margin-bottom: 18px;
  border-bottom: 2px solid var(--omw-accent-soft);
}
.omw-logo { height: 32px; width: auto; display: block; }
.omw-logo-txt { font-size: 14px; font-weight: 700; color: var(--omw-accent); }
.omw-head-title { font-size: 12px; color: var(--text-3); text-align: right; }
/* 正文 */
.omw-kicker {
  margin: 0 0 4px; font-size: 11px; font-weight: 700;
  letter-spacing: .14em; color: var(--omw-accent);
}
.omw-h1 {
  margin: 0 0 8px; padding-bottom: 6px; font-size: 20px; font-weight: 700; color: var(--text);
  border-bottom: 2px solid var(--omw-accent-soft);
}
.omw-h2 {
  margin: 14px 0 7px; padding-left: 10px; font-size: 14.5px; font-weight: 700;
  color: var(--omw-accent); border-left: 4px solid var(--omw-accent-soft);
}
.omw-h3 {
  margin: 12px 0 6px; font-size: 12.5px; font-weight: 700; color: var(--omw-accent);
}
/* 封面: 整页居中, 顶部留白 (分页由 omw-break 控制) */
.omw-cover {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 10px; padding: 120px 24px 140px;
}
.omw-cover-kicker {
  font-size: 11px; font-weight: 700; letter-spacing: .18em; color: var(--omw-accent);
}
.omw-cover-title { font-size: 30px; font-weight: 700; line-height: 1.35; color: var(--text); }
.omw-cover-sub { font-size: 17px; font-weight: 650; color: var(--omw-accent); }
.omw-cover-meta { margin-top: 4px; font-size: 12px; color: var(--text-3); }
/* 目录 */
.omw-toc { padding: 8px 4px 24px; }
.omw-toc-title {
  margin-bottom: 14px; padding-bottom: 8px; font-size: 22px; font-weight: 700;
  color: var(--text); border-bottom: 2px solid var(--omw-accent-soft);
}
.omw-toc ol { margin: 0; padding-left: 8px; list-style: none; color: var(--text); }
.omw-toc li { font-size: 13.5px; line-height: 2; }
.omw-p { margin: 0 0 7px; font-size: 13px; line-height: 1.7; color: var(--text); }
.omw-meta { margin: 0 0 7px; font-size: 12px; line-height: 1.7; color: var(--text-3); }
.omw-li { margin: 0 0 5px; padding-left: 6px; font-size: 13px; line-height: 1.7; color: var(--text); }
.omw-li::before { content: "▪ "; color: var(--omw-accent); font-weight: 700; }
.omw-blank { margin: 0 0 12px; border-bottom: 1px dotted var(--border-strong); }
/* 分页标记: 仅在 HTML 中占位, 由前端分页逻辑消费, 自身不显示 */
.omw-break { display: none; }
/* 表格: 主色表头 + 斑马纹, 仅横向分隔线 */
.omw-tablewrap { overflow-x: auto; margin: 4px 0 11px; }
.omw-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.omw-table th, .omw-table td {
  border: 0; border-bottom: 1px solid var(--border-strong); padding: 5px 10px;
}
.omw-table thead th {
  background: var(--omw-accent-soft); color: #fff; font-weight: 600; border-bottom: 0;
}
.omw-table tbody tr:nth-child(even) { background: var(--omw-band); }
.omw-table tbody tr:last-child td { border-bottom: 0; }
.omw-table .omw-r { text-align: right; }
.omw-table .omw-c { text-align: center; }
.omw-table .omw-l { text-align: left; }
/* 图表 */
.omw-img { margin: 4px 0 11px; text-align: center; }
/* 报告照片: 两张一组并排; 单张按正文宽度 (完整显示, 不裁切) */
.omw-photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 6px 0 12px; }
.omw-photos.is-single { grid-template-columns: minmax(0, 1fr); }
.omw-photos img {
  width: 100%; height: 240px; object-fit: contain; background: var(--surface-2);
  border-radius: var(--r-xs); box-shadow: var(--shadow-xs);
}
.omw-photos.is-single img { height: auto; max-height: 420px; }
/* 固定按图表的"原生 CSS 宽度"显示 (屏外出图容器 .chart-offscreen 宽 880px, 图表按该宽度排版),
   与导出图片的实际像素数 (受 devicePixelRatio 影响) 解耦:
   否则高分屏/高 dpr 导出时图片像素远超容器宽度, 会被放满容器宽度, 图表内文字显得过大。
   max-width 兜底窄屏, height:auto 保证等比、不拉伸变形。 */
.omw-img img {
  width: 880px; max-width: 100%; height: auto;
  border-radius: var(--r-xs); box-shadow: var(--shadow-xs);
}
.omw-img-tip {
  display: block; padding: 20px 14px; font-size: 12px; color: var(--text-3);
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--r-xs);
}
/* 页脚 */
.omw-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 24px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-3);
}
/* 分页后: 外壳退化为容器, 每页单独成纸 (JS 给 .omw 加 .omw--paginated) */
.omw--paginated {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 0; background: none; border: 0; border-radius: 0; overflow-x: auto;
}
/* A4 纸面 (210mm × 297mm): 预览分页后每页一张; 内容不足整页也保持整页高度 */
.omw-page {
  width: 210mm; height: 297mm; box-sizing: border-box; flex: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm); box-shadow: var(--shadow-sm);
  padding: 16mm 15mm 12mm;
  display: flex; flex-direction: column; overflow: hidden;
}
.omw-page-body { flex: 1 1 auto; min-height: 0; overflow: hidden; }
.omw-page .omw-head { margin-bottom: 12px; }
/* 封面页不显示页眉 (与 Word 封面一致) */
.omw--paginated .omw-page:first-child .omw-head { display: none; }
.omw-page .omw-foot {
  margin: 0; padding-top: 8px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 11px; color: var(--text-3);
}

@media print {
  .omw { border: 0; padding: 0; }
  .omw--paginated { display: block; overflow: visible; }
  .omw-page { border: 0; border-radius: 0; box-shadow: none; break-after: page; }
  .omw-page:last-child { break-after: auto; }
  .omw-head { break-after: avoid; }
  .omw-table { break-inside: avoid; }
  /* 打印只输出右侧报告预览, 不打印左侧编辑区与屏幕外图表。 */
  .om-editor, .chart-offscreen { display: none !important; }
  .om-split { display: block; }
  .om-preview .card { border: 0; }
  .om-preview .card-head { display: none; }
}

/* --------------------------------------------------------------------------
   运维报告: 左侧编辑 (月份 / 主要工作情况 / HSSE) + 右侧 Word 预览
   -------------------------------------------------------------------------- */
.om-split {
  display: grid; grid-template-columns: minmax(380px, 460px) minmax(0, 1fr);
  gap: 16px; align-items: start;
}
.om-split-single { grid-template-columns: minmax(0, 1fr); }
.om-editor {
  position: sticky; top: calc(var(--topbar-h) + 12px);
  max-height: calc(100vh - var(--topbar-h) - 28px); overflow: auto;
  padding-right: 2px;
}
.om-month-form { margin: 0 0 12px; }
.om-editor-form .card { margin-bottom: 12px; }
.om-editor-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px;
}
@media (max-width: 1180px) {
  .om-split { grid-template-columns: 1fr; }
  .om-editor { position: static; max-height: none; overflow: visible; padding-right: 0; }
}

/* HSSE 输入区: 深色分组条 + 浅色字段 (与报告章节一一对应) */
.om-work-fields { display: flex; flex-direction: column; gap: 12px; }
.om-work-module {
  display: flex; flex-direction: column; gap: 6px;
  padding-bottom: 10px; border-bottom: 1px dashed var(--border);
}
.om-work-module:last-child { border-bottom: 0; padding-bottom: 0; }
/* 模块照片: 缩略图网格 + 勾选删除 + 上传控件 */
.om-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.om-photo-item {
  position: relative; display: block; overflow: hidden; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2);
}
.om-photo-item img { display: block; width: 100%; height: 64px; object-fit: cover; }
.om-photo-del {
  display: flex; align-items: center; gap: 4px; padding: 3px 6px;
  font-size: 11px; color: var(--text-3); background: var(--surface-2);
}
.om-photo-item:has(input:checked) { border-color: var(--danger); opacity: .55; }
.om-photo-upload { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--text-3); }
.om-photo-upload .input { padding: 5px; }
.hsse-body { display: flex; flex-direction: column; gap: 14px; }
.hsse-part { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.hsse-part-head {
  padding: 8px 12px; background: var(--brand-700); color: #fff;
  font-size: 12.5px; font-weight: 650; letter-spacing: .2px; line-height: 1.5;
}
.hsse-grid { display: grid; gap: 8px 10px; padding: 10px 12px; }
.hsse-grid + .hsse-grid { padding-top: 0; }
.hsse-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hsse-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hsse-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hsse-field {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  font-size: 11.5px; color: var(--text-3); line-height: 1.45;
}
.hsse-field .input { width: 100%; }
.hsse-field-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
.hsse-field-row > span { flex: 1; min-width: 0; }
.hsse-field-row .input { width: 92px; flex: none; text-align: center; }
.hsse-field-block { padding: 10px 12px; }
.hsse-field-block + .hsse-field-block { border-top: 1px dashed var(--border); }
@media (max-width: 560px) {
  .hsse-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hsse-grid-2 { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   人员考勤: 月历 + 规则说明
   -------------------------------------------------------------------------- */
.cal { display: flex; flex-direction: column; gap: 6px; }
.cal-head,
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head > div { text-align: center; font-size: 11.5px; color: var(--text-3); padding: 2px 0 4px; }
.cal-cell {
  position: relative;
  min-height: 76px; padding: 8px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  text-align: left; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.cal-cell:hover { border-color: var(--border-strong); background: var(--surface-2); }
.cal-cell.is-empty { border: 0; background: transparent; cursor: default; }
.cal-cell.is-weekend { background: var(--surface-2); }
.cal-cell.is-today { border-color: var(--primary-600); box-shadow: inset 0 0 0 1px var(--primary-600); }
.cal-day { font-size: 12px; font-weight: 650; color: var(--text-2); }
.cal-none { font-size: 11.5px; color: var(--text-3); }
.cal-hours { font-size: 10.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cal-rest, .cal-work { position: absolute; top: 6px; right: 7px; font-size: 10px; font-weight: 650; }
.cal-rest { color: var(--success); }
.cal-work { color: var(--danger); }
.cal-appr { font-size: 9.5px; font-weight: 650; padding: 0 3px; border-radius: 3px; max-width: 100%; }
.cal-appr.is-pending { color: var(--warn); background: var(--warn-100); }
.cal-appr.is-rejected { color: var(--danger); background: var(--danger-100); }
/* 管理多个场站的 Site Manager: 单元格里标出该天记录所属场站 */
.cal-site { font-size: 10px; color: var(--text-3); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 考勤分析里只读的月历单元格 (点击明细账号名弹出) */
.cal-cell.is-static { cursor: default; }
.cal-cell.is-holiday { background: var(--surface-2); border-style: dashed; }
.cal-cell .badge { font-size: 10.5px; padding: 1px 6px; }
.cal-legend .chip strong { font-weight: 650; color: var(--text-2); }
.rule-list { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13px; line-height: 1.75; }

@media (max-width: 720px) {
  .cal-cell { min-height: 56px; padding: 6px; gap: 4px; }
  .cal-day { font-size: 11px; }
  .cal-none { font-size: 10px; }
  .cal-cell .badge { font-size: 9.5px; padding: 0 4px; }
}
/* --------------------------------------------------------------------------
   连通性自检结果 (设置页 → 大模型)
   -------------------------------------------------------------------------- */
.check-result-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.check-log {
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  padding: 12px 14px; max-height: 360px; overflow: auto;
}
.check-title { font-family: var(--font-num); font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.check-step { margin: 14px 0 6px; font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.check-step:first-of-type { margin-top: 2px; }
.check-line { display: flex; align-items: baseline; gap: 8px; padding: 2px 0; }
.check-line .badge {
  flex: none; width: 48px; justify-content: center; padding: 1px 0;
  border-radius: 5px; font-size: 10.5px;
}
.check-text {
  font-family: var(--font-num); font-size: 12px; color: var(--text-2);
  word-break: break-word; line-height: 1.65;
}
.check-summary { margin-top: 6px; font-size: 12.5px; font-weight: 650; color: var(--text); }
