/* ===== 主题令牌:参考调色板(light)===== */
/* 特斯拉官网同款字体:tesla.cn 的「Model Y L」标题用 Universal Sans Display Medium */
@font-face {
  font-family: 'Universal Sans Display';
  src: url('/fonts/Universal-Sans-Display-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --seq-blue-300: #6da7ec;
  --seq-blue-400: #3987e5;
  --seq-blue-500: #256abf;
  --seq-blue-600: #184f95;
  --tile-track: rgba(11, 11, 11, 0.08);
  /* 活动分类色(参考调色板,黄/品红/绿/紫四色全配对校验通过):行驶=黄 充电=青 哨兵=品红 驻车空调=绿 驻车耗电=紫 */
  --cat-drive: #eda100;
  --cat-charge: #1baf7a;
  --cat-sentry: #e87ba4;
  --cat-climate: #008300;
  --cat-idle: #4a3aa7;
  --success: #006300;
}

/* ===== 主题令牌:dark(默认)===== */
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --seq-blue-300: #6da7ec;
  --seq-blue-400: #3987e5;
  --seq-blue-500: #256abf;
  --seq-blue-600: #184f95;
  --tile-track: rgba(255, 255, 255, 0.10);
  --cat-drive: #c98500;
  --cat-charge: #199e70;
  --cat-sentry: #d55181;
  --cat-climate: #008300;
  --cat-idle: #9085e9;
  --success: #0ca30c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --seq-blue-300: #6da7ec;
    --seq-blue-400: #3987e5;
    --seq-blue-500: #256abf;
    --seq-blue-600: #184f95;
    --tile-track: rgba(255, 255, 255, 0.10);
    --cat-drive: #c98500;
    --cat-charge: #199e70;
    --cat-sentry: #d55181;
    --cat-climate: #008300;
    --cat-idle: #9085e9;
    --success: #0ca30c;
  }
}

/* ===== 基础 ===== */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  transition: background 0.25s ease, color 0.25s ease;
  /* 移动端:去掉点按高亮、防止旋转屏幕时 iOS 自动放大字体 */
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 20px 108px; /* 底部留白:避开浮动分页导航栏 */
}

/* ===== 顶栏 ===== */
header { margin-bottom: 8px; }

/* 顶栏主体:左侧一、二行,右侧车图跨两行 */
.header-main {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-left { flex: 1; min-width: 0; }

.header-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

/* 车型图片:右侧跨第一、二行,放大显示 */
.header-main .model-icon {
  flex: none;
  align-self: center;
  height: 84px;
  width: auto;
  display: block;
}

header h1 {
  font-size: 20px;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.01em;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

header h1:hover { color: var(--series-1); }
header h1:active { opacity: 0.55; }

/* 车名:与 TESLA Home 区分 —— 次要色、较小字号,细分隔线 */
.car-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  padding-left: 12px;
}

/* 电量胶囊:图标 + 百分比/续航,点击切换 */
.batt-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-primary);
  background: var(--surface-1);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  font-variant-numeric: tabular-nums;
}

.batt-pill:hover { border-color: var(--text-muted); }

.batt-icon { width: 30px; height: 14px; flex: none; }
.batt-icon .batt-shell { fill: none; stroke: var(--text-muted); stroke-width: 1.4; }
.batt-icon .batt-cap { fill: var(--text-muted); }
.batt-icon .batt-fill { fill: var(--series-3); transition: width 0.5s ease, fill 0.5s ease; }
.batt-pill[data-level="low"] .batt-fill { fill: #fab219; }
.batt-pill[data-level="critical"] .batt-fill { fill: #d03b3b; }
.batt-pill[data-level="unknown"] .batt-fill { fill: var(--text-muted); }

/* 第二行:车型徽章 / 电量 / 状态 / 版本 / 更新时间 */
.header-sub {
  display: flex;
  align-items: center;
  gap: 8px 14px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* 第三行:服务器资源 */
.header-sys {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.acct-entry {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  flex: none;
}
.acct-entry:hover { color: var(--text-primary); border-color: var(--baseline); }
.acct-entry svg { width: 12px; height: 12px; fill: currentColor; }

.car-model-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 550;
  color: var(--text-secondary);
}

/* 车型字样:Model Y L 用官方尾标徽章(官图提取的 PNG 蒙版,
   background: currentColor 随主题变色);其他车型回退为 Universal Sans 文字 */
#car-model {
  font-family: 'Universal Sans Display', system-ui, sans-serif;
  font-weight: 500;
  font-size: 16px;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
}

#car-model-badge[hidden] { display: none; }

#car-model-badge {
  display: block;
  height: 15px;
  width: 134px; /* 徽章比例 701:79 */
  background: currentColor;
  -webkit-mask: url('/model-yl-badge.png') center / contain no-repeat;
  mask: url('/model-yl-badge.png') center / contain no-repeat;
}

/* 服务器资源:可视化仪表条(与 KPI 卡片 meter 同一视觉语言) */
.sys-meters { display: inline-flex; align-items: center; gap: 14px; }

.sys-meters .meter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.sys-meters .meter-track {
  width: 56px;
  height: 6px;
  border-radius: 3px;
  background: var(--tile-track);
  overflow: hidden;
  display: inline-block;
}

.sys-meters .meter-track > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--series-1);
  transition: width 0.6s ease, background 0.6s ease;
}

.sys-meters .meter[data-level="warn"] .meter-track > i { background: #fab219; }
.sys-meters .meter[data-level="critical"] .meter-track > i { background: #d03b3b; }
.sys-meters .meter-val { font-variant-numeric: tabular-nums; min-width: 3.2ch; }

#sys-stats { font-variant-numeric: tabular-nums; white-space: nowrap; }

#sw-version, #updated-at { white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 550;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--surface-1);
}

.badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.badge[data-state="driving"]  .dot { background: var(--series-1); }
.badge[data-state="charging"] .dot { background: var(--series-3); }
.badge[data-state="online"]   .dot { background: var(--series-2); }

.icon-btn {
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.icon-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }

/* 移动端:按钮禁用双击缩放,保证点按即时响应 */
button { touch-action: manipulation; }

/* ===== 车辆总览:Model Y 俯视图(玻璃顶=能量显示区)+ 两侧图例 + 四轮胎压 ===== */
/* 布局约束:图例与信息永远分列车辆两侧,任何宽度下都不许换行堆到下面 */
.carview {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  align-items: stretch;
}

/* 中央列:俯视图舞台(车头朝上) */
.car-mid {
  flex: 1 1 300px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.car-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 500px;
}

.car-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* 车内温度曲线:直接画在玻璃上(温度读数下方) */
.car-tpms-tire {
  font-size: 11.5px;
  font-weight: 650;
  text-anchor: middle;
  dominant-baseline: central;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  user-select: none;
}



/* 车辆顶部:本周期平均能耗细长条(官方能耗为标点) */
.car-eff {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 236px;
  margin: 0 auto;
  padding: 0 4px 11px;
  box-sizing: border-box;
}

.car-eff-label { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; }

.car-eff-track {
  position: relative;
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--tile-track);
}

.car-eff-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 3px;
  opacity: 0.8;
}

.car-eff-official {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  border-radius: 1px;
  background: var(--text-primary);
  opacity: 0.85;
}

.car-eff-official-val {
  position: absolute;
  top: 8px;
  transform: translateX(-50%);
  font-size: 9px;
  line-height: 1;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.car-eff-dot {
  position: absolute;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 1.5px solid var(--surface-1);
}

.car-eff-val {
  font-size: 11px;
  font-weight: 650;
  color: var(--text-primary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.car-body-base { fill: var(--tile-track); }

/* 玻璃区域(挡风玻璃 / 全景玻璃顶):两种主题下都是深色玻璃 */
.car-glazing, .car-glass-base { fill: #12161d; }

.car-glass-line {
  fill: none;
  stroke: var(--baseline);
  stroke-width: 1.5;
  opacity: 0.55;
}

.car-mirror { fill: var(--tile-track); stroke: var(--baseline); stroke-width: 1.2; }

/* 车头微光:白色低透明度罩层,两种主题下都只是一点光泽 */
.car-sheen { fill: #fff; opacity: 0.05; }

/* 机盖缝线 */
.car-seam {
  fill: none;
  stroke: var(--baseline);
  stroke-width: 1.2;
  opacity: 0.35;
}

/* 前风挡:当前电量横向填充(左→右) */
.car-ws-fill {
  fill: var(--series-1);
  opacity: 0.85;
  transition: width 0.6s ease;
}

/* 能量占比环:围绕玻璃顶一圈,各段用 dasharray 沿环分布 */
.carring {
  fill: none;
  stroke-width: 13;
  cursor: pointer;
  transition: stroke-dasharray 0.6s ease, stroke-dashoffset 0.6s ease, opacity 0.25s ease;
}

.carring-remaining { stroke: var(--series-1); }
.carring-drive { stroke: var(--cat-drive); }
.carring-sentry { stroke: var(--cat-sentry); }
.carring-climate { stroke: var(--cat-climate); }
.carring-idle { stroke: var(--cat-idle); }

/* 分段点选联动:未选中的环段压暗 */
.car-svg .carring.dim { opacity: 0.22; }

/* 未充部分:斜纹(pattern 内元素用类以便随主题变色) */
.hatch-bg { fill: var(--surface-1); }
.hatch-line { stroke: var(--baseline); stroke-width: 1.6; opacity: 0.85; }

/* HUD 角标 / 轮胎 / 车身描边 */
.car-hud {
  fill: none;
  stroke: var(--baseline);
  stroke-width: 1.5;
  opacity: 0.75;
}

.car-tire { fill: var(--baseline); opacity: 0.85; }

.car-body-line {
  fill: none;
  stroke: var(--baseline);
  stroke-width: 2;
  stroke-linejoin: round;
}

/* 车身上的读数文字(居中、等宽数字) */
.car-svg text { text-anchor: middle; font-variant-numeric: tabular-nums; }

.car-odo-label { fill: var(--text-muted); font-size: 9px; }
.car-odo-val { fill: var(--text-primary); font-size: 15px; font-weight: 650; }

/* 深色玻璃上的文字固定浅色 */
.car-batt-val { fill: #fff; font-size: 14px; font-weight: 650; }
.car-temp-val { fill: var(--series-1); font-size: 11px; font-weight: 600; }
.car-center-model { fill: #f5f5f3; font-size: 15px; font-weight: 600; letter-spacing: 3.5px; }

/* 非 Y L 车型的字标文字:Tesla 字标风格(全大写 + 宽字距) */
#car-model-text {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--text-primary);
}
.car-center-temp { fill: var(--series-2); font-size: 12px; font-weight: 600; }

/* 陪伴天数(玻璃顶徽章下方,点击设置提车日期) */
.car-companion {
  fill: rgba(255, 255, 255, 0.62);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
}
.car-companion:hover { fill: rgba(255, 255, 255, 0.9); }
.car-companion.is-empty { fill: var(--series-1); text-decoration: underline; }

/* 提车日期设置弹层 */
.companion-pop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.companion-pop[hidden] { display: none; }
.companion-card {
  width: min(300px, calc(100vw - 48px));
  padding: 20px;
  border-radius: 16px;
  background: var(--surface-1);
  border: 1px solid var(--tile-track, rgba(255, 255, 255, 0.12));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.companion-card h3 { margin: 0; font-size: 15px; color: var(--text-primary); }
.companion-card input[type="date"] {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--tile-track, rgba(255, 255, 255, 0.14));
  background: var(--surface-2, rgba(255, 255, 255, 0.06));
  color: var(--text-primary);
  font-size: 14px;
  color-scheme: dark;
}
[data-theme="light"] .companion-card input[type="date"] { color-scheme: light; }
.companion-actions { display: flex; gap: 8px; justify-content: flex-end; }
.companion-actions button {
  padding: 8px 16px;
  border-radius: 10px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--series-1);
  color: #fff;
}
.companion-actions button.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--tile-track, rgba(255, 255, 255, 0.14));
}
.companion-actions button:disabled { opacity: 0.5; cursor: default; }

/* 两侧图例:左列里程统计+电池健康(不可点选),右列全部电耗分段 */
.car-legend {
  flex: 0 0 178px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 10px;
}

.cl-item {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

/* 里程统计项:仅展示,不参与点选联动 */
.cl-item.cl-stat { cursor: default; }

/* 点选高亮:选中项描边发光,其余项压暗(统计项不参与) */
.cl-item.on {
  border-color: var(--cl-c, var(--baseline));
  box-shadow: 0 0 0 1px var(--cl-c, var(--baseline));
}

.carview.has-sel .cl-item[data-k]:not(.on) { opacity: 0.55; }

.cl-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-top: 4px;
}

.cl-dot.dot-hatch {
  background: repeating-linear-gradient(45deg,
    var(--baseline) 0 1.5px, var(--surface-1) 1.5px 4.5px);
  border: 1px solid var(--baseline);
}

.cl-item b {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-secondary);
}

.cl-val {
  display: block;
  font-size: 16px;
  font-weight: 650;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.cl-sub {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

/* 充电周期横条:横向滑动点选每次充电 */
.cycle-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  margin: 2px 0 8px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.cyc-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  appearance: none;
  font: inherit;
  text-align: left;
  min-width: 112px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 10px 8px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.cyc-chip b {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.cyc-chip .cyc-merged { font-weight: 400; color: var(--text-muted); font-size: 10px; }
.cyc-chip .cyc-active-tag { color: var(--series-1); font-size: 10px; }

.cyc-chip .cyc-bar {
  display: block;
  height: 3px;
  border-radius: 2px;
  background: var(--tile-track);
  margin-top: 5px;
  overflow: hidden;
}

.cyc-chip .cyc-bar i {
  display: block;
  height: 100%;
  background: var(--series-1);
}

.cyc-chip.on { border-color: var(--series-1); }
.cyc-chip.on b { color: var(--text-primary); }

/* 电池健康(独立模块) */

/* ===== 过滤器行 ===== */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 16px;
}

.seg {
  display: inline-flex;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  padding: 5px 14px;
  border-radius: 7px;
  cursor: pointer;
}

.seg button:hover { background: var(--tile-track); color: var(--text-primary); }

.seg button.on {
  background: var(--series-1);
  color: #fff;
}

/* 卡片内的小型切换控件(电量 / 里程) */
.seg.mini { border-radius: 8px; padding: 2px; }
.seg.mini button {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.card-head-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.pane-head h3 { margin: 0; }

.filter-row .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ===== 图表网格 ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  min-width: 0;
}

.card h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 4px;
}

.card .card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.col-6 { grid-column: span 6; }
.col-5 { grid-column: span 5; }
.col-7 { grid-column: span 7; }
.col-12 { grid-column: span 12; }

.chart { width: 100%; height: 300px; }

/* ===== 卡片头部:标题 + 右侧控件 ===== */
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

/* ===== 活动分类色片 ===== */
.chip, .ev-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.chip::before, .ev-chip::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.chip.cat-drive::before, .ev-chip.cat-drive::before { background: var(--cat-drive); }
.chip.cat-charge::before, .ev-chip.cat-charge::before { background: var(--cat-charge); }
.chip.cat-sentry::before, .ev-chip.cat-sentry::before { background: var(--cat-sentry); }
.chip.cat-idle::before, .ev-chip.cat-idle::before { background: var(--cat-idle); }

.chip-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 2px;
}

/* ===== 顶部活动时间线 ===== */
.chart-activity { height: 380px; }

/* ===== 哨兵双栏 ===== */
.sentry-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.sentry-pane { min-width: 0; } /* 网格子项允许收缩,防止图表溢出 */

.sentry-pane h3 {
  font-size: 12px;
  font-weight: 550;
  color: var(--text-muted);
  margin: 0 0 2px;
}

.mini-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-stat {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.mini-stat b { color: var(--text-primary); font-weight: 600; }

/* 折叠卡(充电详情/停车费)头部的缩略统计:整组靠右贴箭头,
   芯片统一宽度、内容两端分布,上下两张卡的芯片才能逐列对齐 */
.card.collapsible .mini-stats { margin-left: auto; }

.card.collapsible .mini-stat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 140px;
}

/* ===== 活动事件列表 ===== */
.day-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}

.day-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.day-head:hover { background: var(--tile-track); }

.day-head .date {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
}

.day-head .summary {
  margin-left: auto;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.day-head .chev {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex: none;
}

.day-group.open .chev { transform: rotate(180deg); }

.day-body {
  display: none;
  border-top: 1px solid var(--gridline);
}

.day-group.open .day-body { display: block; }

/* 折叠日组头部右侧的小型环状耗电图(展开后隐藏,明细里已有逐条数值) */
.day-donut {
  width: 32px;
  height: 32px;
  flex: none;
}

.day-donut circle { fill: none; stroke-width: 5; }

.day-donut .donut-track { stroke: var(--tile-track); }

.day-donut .seg-drive { stroke: var(--cat-drive); }

.day-donut .seg-sentry { stroke: var(--cat-sentry); }

.day-donut .seg-climate { stroke: var(--cat-climate); }

.day-donut .seg-idle { stroke: var(--cat-idle); }

.day-group.open .day-donut { display: none; }

/* 可折叠卡片(充电详情/停车费):头部整行可点,默认折叠;
   子项垂直居中,缩略统计与箭头在同一水平线上 */
.card.collapsible > .card-head { cursor: pointer; align-items: center; }

.card-chev {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  align-self: center;
  flex: none;
}

.card.collapsible.open .card-chev { transform: rotate(180deg); }

#cs-card:not(.open) .cs-list,
#cs-card:not(.open) .cg-divider,
#cs-card:not(.open) .cg-list { display: none; }

/* 充电记录内「电池电量估算」条形图 */
.cs-batt-chart { height: 200px; margin-top: 4px; }

/* 停车费卡同样整卡可折叠,默认收起 */
#pk-card:not(.open) .pk-form,
#pk-card:not(.open) .pk-list { display: none; }

/* 充电桩统计并入充电详情卡后的分隔小标题 */
.cg-divider {
  margin: 14px 4px 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.cg-divider span { font-weight: 400; font-size: 12px; color: var(--text-muted); margin-left: 8px; }

/* ===== 停车费 ===== */
.pk-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 2px 10px;
}

.pk-form input, .pk-form select {
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 0;
}

.pk-form input:focus, .pk-form select:focus {
  outline: 2px solid var(--series-1);
  outline-offset: -1px;
}

#pk-cost { width: 110px; }
#pk-date { width: 140px; }
#pk-days { width: 130px; }
#pk-note { flex: 1 1 140px; }

#pk-add {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--seq-blue-500);
  border: 0;
  border-radius: 8px;
  padding: 7px 18px;
}
#pk-add:hover { background: var(--seq-blue-600); }

.pk-list { display: flex; flex-direction: column; }

.pk-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--gridline);
  font-size: 13px;
}
.pk-row:last-child { border-bottom: 0; }
.pk-date-t { color: var(--text-secondary); font-variant-numeric: tabular-nums; flex: none; }
.pk-days-t {
  flex: none; font-size: 11px; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 5px;
}
.pk-note-t { flex: 1; min-width: 0; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-cost-t { font-weight: 650; font-variant-numeric: tabular-nums; flex: none; }
.pk-del {
  flex: none; cursor: pointer; background: none; border: 0;
  color: var(--text-muted); font-size: 14px; padding: 0 2px;
}
.pk-del:hover { color: #d03b3b; }

.ev-row {
  display: grid;
  grid-template-columns: 150px 90px 1fr 66px 84px 76px 76px;
  gap: 10px;
  align-items: baseline;
  padding: 8px 14px;
  font-size: 13px;
}

/* 列头:与数据行同一栅格 */
.ev-head {
  padding-top: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--gridline);
}

.ev-head span {
  color: var(--text-muted);
  font-size: 11px;
}

.ev-row + .ev-row { border-top: 1px solid var(--gridline); }

.ev-time {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.ev-desc { color: var(--text-muted); }

/* 数值列:电量 / 度数 / 里程 / 电费,右对齐等宽数字 */
.ev-num {
  text-align: right;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ev-num.up { color: var(--success); }

.events-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== 充电费用表 ===== */
.cost-input {
  width: 92px;
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text-primary);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

.cost-input:hover { border-color: var(--text-muted); }

.cost-input:focus { border-color: var(--series-1); box-shadow: 0 0 0 2px rgba(57, 135, 229, 0.18); }

.cost-input:disabled { opacity: 0.55; }

.cost-input::placeholder { color: var(--text-muted); }

/* ===== 充电详情(卡片式,纵向布局,适配手机) ===== */
.cs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cs-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px 12px;
  background: var(--page);
}

.cs-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}

.cs-time {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.cs-time b { font-weight: 600; }

.cs-time-sub { font-size: 11px; color: var(--cat-charge); }

.cs-charger {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
  min-width: 0;
}

.cs-charger input {
  font: inherit;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  outline: none;
  text-align: right;
  max-width: 200px;
  padding: 2px 6px;
}

.cs-charger input:hover { border-color: var(--border); }

.cs-charger input:focus {
  border-color: var(--series-1);
  background: var(--page);
}

.cs-charger input:disabled { opacity: 0.55; }

.cs-charger input::placeholder { color: var(--text-muted); }

.cs-name-input { font-size: 14px; font-weight: 600; }

/* 地点:充电桩名称下方的小字 */
.cs-loc-input { font-size: 11px; color: var(--text-muted); }

/* 品牌:名称与地点之间的小字(与地点同视觉层级) */
.cs-brand-input { font-size: 11.5px; color: var(--text-secondary); }

.cs-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 16px;
}

.cs-field {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  padding: 3px 0;
}

.cs-label { color: var(--text-muted); flex-shrink: 0; }

.cs-val {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.cs-inline {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.cs-unit { font-size: 11px; color: var(--text-muted); }

.cs-tag {
  font-size: 10px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 4px;
  line-height: 1.5;
}

.cs-tag-manual { color: var(--cat-charge); border-color: var(--cat-charge); }

.cs-item .cost-input { width: 84px; padding: 3px 6px; }

@media (max-width: 600px) {
  .cs-item { padding: 9px 10px 10px; }
  .cs-head { flex-direction: column; gap: 6px; }
  .cs-charger { align-items: stretch; width: 100%; }
  .cs-charger input { text-align: left; max-width: none; }
  .cs-fields { gap: 4px 8px; }
  .cs-field { font-size: 12px; gap: 6px; }
  .cs-item .cost-input { width: 56px; padding: 3px 4px; font-size: 12px; }
  .cs-inline { gap: 3px; }
  .cs-tag { font-size: 9px; padding: 0 3px; }
}

/* ===== 充电桩统计 ===== */
.cg-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cg-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  background: var(--page);
}

.cg-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.cg-arrow {
  flex: none;
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.cg-item.open .cg-arrow { transform: rotate(90deg); }

.cg-detail {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.cg-brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

.cg-brand-input {
  font: inherit;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  outline: none;
  width: 180px;
}

.cg-brand-input:hover { border-color: var(--text-muted); }

.cg-brand-input:focus { border-color: var(--series-1); }

.cg-brand-input:disabled { opacity: 0.55; }

.cg-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.cg-brand {
  font-size: 10px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 4px;
  line-height: 1.5;
}

.cg-line {
  display: flex;
  flex-direction: column;
  padding: 3px 0;
  font-size: 12px;
}

.cg-line b { font-variant-numeric: tabular-nums; font-weight: 550; }

.cg-line-sub { color: var(--text-muted); font-variant-numeric: tabular-nums; }

.cg-head {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cg-head b { font-size: 14px; font-weight: 600; }

.cg-loc { font-size: 11px; color: var(--text-muted); }

.cg-stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cg-chip {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.cg-chip b { color: var(--text-primary); font-weight: 600; }

.cg-loss-low b { color: var(--cat-charge); }

.cg-loss-high b { color: #fab219; }

@media (max-width: 600px) {
  .cg-row { flex-wrap: wrap; }
  .cg-stats { justify-content: flex-start; }
  .cg-brand-input { width: 100%; flex: 1; }
}

/* ===== 地图轨迹列表 ===== */
#routes-list { margin-top: 10px; }

.rt-row {
  display: grid;
  grid-template-columns: 76px 1fr 84px 64px 20px;
  gap: 10px;
  align-items: baseline;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
}

.rt-row:hover { background: var(--tile-track); }

.rt-row.open { background: var(--tile-track); }

.rt-row + .rt-row, .rt-row + .rt-detail + .rt-row { border-top: 1px solid var(--gridline); }

.rt-time { font-variant-numeric: tabular-nums; }

.rt-names {
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rt-dist, .rt-dur { text-align: right; font-variant-numeric: tabular-nums; }

.rt-chev {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  text-align: center;
}

.rt-row.open .rt-chev { transform: rotate(180deg); }

.rt-detail {
  display: none;
  padding: 6px 14px 10px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px dashed var(--gridline);
}

.rt-row.open + .rt-detail { display: block; }

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== 地图 ===== */
#map { width: 100%; height: 420px; border-radius: 10px; }

/* 深色主题:对 OSM 亮色瓦片做反色滤镜(轨迹等在 overlayPane,不受影响) */
:root[data-theme="dark"] #map .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.88) saturate(0.35);
}
/* 系统深色且未显式选浅色时同样生效 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #map .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.88) saturate(0.35);
  }
}

.map-legend {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  flex-wrap: wrap;
}

.map-legend .swatch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.map-legend .swatch i {
  width: 16px;
  height: 4px;
  border-radius: 2px;
  display: inline-block;
}

/* ===== 页脚 ===== */
footer {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  flex-wrap: wrap;
}

footer .footer-text { flex: 1 1 480px; }

footer a { color: var(--text-muted); }

/* ===== 功能分页:内容页 + 底部液态玻璃导航 ===== */
/* 内容分页:仅当前页可见,图表在隐藏页为 0 尺寸,切页时由 app.js resize */
.page { display: none; }
.page.active { display: block; }

/* 底部居中浮动 Tab 栏(iOS 26 液态玻璃风格):
   高通透 + 强模糊/饱和度/亮度提升 + 顶部边缘高光 + 斜向镜面扫光 + 选中气泡滑动回弹 */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  gap: 2px;
  padding: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface-1) 40%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(200%) brightness(1.1);
  backdrop-filter: blur(24px) saturate(200%) brightness(1.1);
  border: 0.5px solid color-mix(in srgb, var(--text-primary) 16%, transparent);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.38),
              inset 0 1px 1px rgba(255, 255, 255, 0.30),
              inset 0 -1px 1px rgba(0, 0, 0, 0.18);
}
/* 斜向镜面扫光(液态玻璃的反射高光) */
.tabbar::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.03) 28%, transparent 45%);
}
:root[data-theme="light"] .tabbar {
  background: color-mix(in srgb, var(--surface-1) 52%, transparent);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.16),
              inset 0 1px 1px rgba(255, 255, 255, 0.85),
              inset 0 -1px 1px rgba(0, 0, 0, 0.05);
}
:root[data-theme="light"] .tabbar::before {
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.12) 28%, transparent 45%);
}

/* 选中项滑动气泡:玻璃透镜质感,切换时带回弹滑动(iOS 26 式) */
.tab-bubble {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: 0;
  border-radius: 999px;
  pointer-events: none;
  background: color-mix(in srgb, var(--series-1) 26%, transparent);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.38),
              inset 0 -1px 1px rgba(0, 0, 0, 0.08),
              0 4px 16px color-mix(in srgb, var(--series-1) 42%, transparent);
  transition: left 0.45s cubic-bezier(0.22, 1.35, 0.36, 1),
              width 0.45s cubic-bezier(0.22, 1.35, 0.36, 1);
}
.tab-bubble.no-anim { transition: none; }

.tabbar .tab {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 64px;
  padding: 7px 12px 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 11px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.18s ease, transform 0.12s ease;
}
.tabbar .tab svg { width: 21px; height: 21px; display: block; }
.tabbar .tab:hover { color: var(--text-primary); }
.tabbar .tab:active { transform: scale(0.92); }
.tabbar .tab.on { color: var(--text-primary); font-weight: 600; }

/* ===== 车辆控制分页 ===== */
/* 车辆当前状态条 */
.ctl-state {
  display: flex;
  gap: 10px 22px;
  flex-wrap: wrap;
  align-items: center;
  padding: 10px 14px;
  margin: 4px 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--page);
  font-size: 13px;
  color: var(--text-secondary);
}
.ctl-state:empty { display: none; }
.ctl-state .badge { font-size: 12px; }
.ctl-state b { color: var(--text-primary); font-weight: 600; }
.ctl-state .ctl-sleep-hint { color: var(--series-4); width: 100%; font-size: 12px; }

/* 未接入横幅(紧凑横条,下方照常展示控制面板预览) */
.ctl-setup { display: none; }
.ctl-setup:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin: 0 0 14px;
  border: 1px dashed color-mix(in srgb, var(--series-4) 55%, transparent);
  background: color-mix(in srgb, var(--series-4) 7%, transparent);
  border-radius: 12px;
}
.ctl-setup-icon { font-size: 22px; flex: none; }
.ctl-setup-text { font-size: 13px; line-height: 1.7; color: var(--text-secondary); flex: 1; min-width: 0; }
.ctl-setup-text b { color: var(--text-primary); }
.ctl-setup-link {
  flex: none;
  font-size: 13px; font-weight: 600; text-decoration: none;
  color: #fff; background: var(--seq-blue-500);
  border-radius: 8px; padding: 7px 14px;
}
.ctl-setup-link:hover { background: var(--seq-blue-600); }

/* 预览态(未接入):按钮半透,点击由 JS 拦截提示 */
#ctl-main.preview .ctl-zone,
#ctl-main.preview .ctl-step,
#ctl-main.preview .ctl-apply,
#ctl-main.preview .ctl-mini,
#ctl-main.preview .ctl-wide,
#ctl-main.preview input[type="range"] { opacity: 0.72; }

/* 布局:左侧车身按钮图,右侧参数面板;窄屏上下堆叠 */
.ctl-layout {
  display: grid;
  grid-template-columns: minmax(0, 370px) 1fr;
  gap: 16px;
  align-items: start;
}
.ctl-carbox {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 12px 12px;
  background: var(--page);
}
.ctl-car { width: 100%; max-width: 330px; height: auto; display: block; }

/* 车身部位 = 异形按钮;--zc 为该部位主题色。
   按钮边界与车身钣金缝/玻璃边共享曲线,默认不描边——边框由车身自身缝线统一刻画 */
.ctl-zone { cursor: pointer; -webkit-tap-highlight-color: transparent; outline: none; }
.ctl-zone .zone-shape {
  fill: color-mix(in srgb, var(--zc, var(--series-1)) 6%, transparent);
  stroke: none;
  transition: fill 0.2s ease, stroke 0.2s ease, filter 0.2s ease;
}
.ctl-zone:hover .zone-shape,
.ctl-zone:focus-visible .zone-shape {
  fill: color-mix(in srgb, var(--zc, var(--series-1)) 22%, transparent);
  stroke: color-mix(in srgb, var(--zc, var(--series-1)) 70%, transparent);
  stroke-width: 1;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--zc, var(--series-1)) 55%, transparent));
}
.ctl-zone.on .zone-shape {
  fill: color-mix(in srgb, var(--zc, var(--series-1)) 32%, transparent);
  stroke: var(--zc, var(--series-1));
  stroke-width: 1.2;
}
.ctl-zone.busy .zone-shape { animation: ctlzone-pulse 1s ease-in-out infinite; }
@keyframes ctlzone-pulse { 50% { fill: color-mix(in srgb, var(--zc, var(--series-1)) 28%, transparent); } }
.zone-ico { fill: var(--text-primary); opacity: 0.92; transition: fill 0.2s ease, stroke 0.2s ease; }
.zone-ico-stroke { fill: none; stroke: var(--text-primary); stroke-width: 1.8; stroke-linecap: round; }
.zone-lab {
  fill: var(--text-secondary);
  font-size: 10px;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}
.zone-lab-v { font-size: 9.5px; }
.ctl-zone.on .zone-ico { fill: var(--zc, var(--series-1)); opacity: 1; }
.ctl-zone.on .zone-ico-stroke { fill: none; stroke: var(--zc, var(--series-1)); }
.ctl-zone.on .zone-lab { fill: var(--zc, var(--series-1)); }
.ctl-zone .ico-unlocked { display: none; }
.ctl-zone.unlocked .ico-locked { display: none; }
.ctl-zone.unlocked .ico-unlocked { display: block; }

/* 状态胶囊:车身图下方,展示各部位当前状态 */
.ctl-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ctl-chip {
  font-size: 11.5px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--surface-1);
  white-space: nowrap;
}
.ctl-chip b { color: var(--text-primary); font-weight: 600; }
.ctl-chip.on { border-color: color-mix(in srgb, var(--chip-c, var(--series-1)) 45%, transparent); }
.ctl-chip.on b { color: var(--chip-c, var(--series-1)); }
.ctl-legend-hint {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.7;
}

/* 右侧参数面板 */
.ctl-panels { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ctl-wide {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.ctl-wide svg { width: 17px; height: 17px; fill: currentColor; }
.ctl-wide:hover { border-color: var(--baseline); }
.ctl-wide:active { transform: scale(0.98); }
.ctl-wide:disabled { opacity: 0.45; cursor: default; transform: none; }
.ctl-wide.on {
  color: var(--cat-charge);
  border-color: color-mix(in srgb, var(--cat-charge) 50%, transparent);
  background: color-mix(in srgb, var(--cat-charge) 12%, transparent);
}

.ctl-group {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px 12px;
  background: var(--page);
}
.ctl-group h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}


/* 参数行:温度步进 / 充电上限滑杆 */
.ctl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--gridline);
}
.ctl-row-label { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }
.ctl-step {
  width: 32px; height: 32px; flex: none;
  font: inherit; font-size: 18px; line-height: 1;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
}
.ctl-step:active { transform: scale(0.92); }
.ctl-val { font-size: 15px; min-width: 58px; text-align: center; font-variant-numeric: tabular-nums; }
.ctl-apply {
  margin-left: auto;
  font: inherit; font-size: 13px; font-weight: 600;
  color: #fff; background: var(--seq-blue-500);
  border: 0; border-radius: 9px; padding: 7px 16px;
  cursor: pointer;
}
.ctl-apply:hover { background: var(--seq-blue-600); }
.ctl-apply:disabled { opacity: 0.5; cursor: default; }
.ctl-row input[type="range"] {
  flex: 1; min-width: 0;
  accent-color: var(--series-1);
  height: 28px;
}

/* 爆闪等小操作按钮 */
.ctl-mini {
  font: inherit; font-size: 12.5px;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.ctl-mini:hover { border-color: var(--baseline); }
.ctl-mini:active { transform: scale(0.94); }
.ctl-mini:disabled { opacity: 0.45; cursor: default; }
.ctl-mini.warn { color: #e86a6a; border-color: color-mix(in srgb, #d03b3b 45%, transparent); }

.ctl-sub-note {
  margin: 8px 2px 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

.ctl-note {
  margin: 14px 2px 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* 控制页底部帮助入口 */
.ctl-help {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--gridline);
  text-align: center;
}
.ctl-help a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.ctl-help a:hover { color: var(--text-primary); border-color: var(--baseline); }
.ctl-help svg { width: 15px; height: 15px; fill: currentColor; }

/* 指令结果 toast(浮在 Tab 栏上方) */
.ctl-toast {
  position: fixed;
  left: 50%;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 74px);
  transform: translateX(-50%) translateY(12px);
  z-index: 1300;
  max-width: min(420px, calc(100vw - 40px));
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-primary);
  background: color-mix(in srgb, var(--surface-1) 82%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.ctl-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.ctl-toast.err { border-color: color-mix(in srgb, #d03b3b 55%, transparent); color: #e86a6a; }

@media (max-width: 900px) {
  .ctl-layout { grid-template-columns: 1fr; }
  .ctl-car { max-width: 290px; }
}

/* ===== 响应式:平板 / 手机 ===== */
@media (max-width: 900px) {
  .wrap { padding: 16px 12px 104px; }

  .col-6, .col-5, .col-7 { grid-column: span 12; }
  .chart { height: 260px; }
  #map { height: 320px; }
  .chart-activity { height: 320px; }
  .sentry-split { grid-template-columns: 1fr; }
  /* 车辆总览:窄屏仍保持左右两列夹车辆的布局,只收窄列宽与间距 */
  .carview { gap: 10px; }
  .car-legend { flex: 0 0 150px; gap: 8px; }
  .car-stage { height: 440px; }
  /* 事件列表:窄屏改为 时间列 + 数值格 2×2(自带小标签),详情独占一行 */
  .ev-head { display: none; }
  .ev-row {
    grid-template-columns: 108px 1fr 1fr;
    grid-template-areas:
      "time batt kwh"
      "time km cost"
      "chip desc desc";
    row-gap: 3px;
    column-gap: 8px;
    align-items: center;
  }
  .ev-row .ev-time { grid-area: time; align-self: start; }
  .ev-row .ev-chip { grid-area: chip; }
  .ev-row .ev-desc { grid-area: desc; }
  .ev-num[data-lab="电量"] { grid-area: batt; }
  .ev-num[data-lab="度数"] { grid-area: kwh; }
  .ev-num[data-lab="里程"] { grid-area: km; }
  .ev-num[data-lab="电费"] { grid-area: cost; }
  .ev-num { text-align: left; display: flex; gap: 5px; align-items: baseline; }
  .ev-num::before { content: attr(data-lab); font-size: 10px; color: var(--text-muted); }
  .day-head .summary { gap: 8px; }

  /* 轨迹列表行:窄屏隐藏时长列,名称列省略 */
  .rt-row { grid-template-columns: 68px 1fr 70px 20px; }
  .rt-row .rt-dur { display: none; }

  /* 筛选栏吸顶,负外边距铺满到屏幕边缘 */
  .filter-row {
    position: sticky;
    top: 0;
    z-index: 40;
    margin: 0 -12px 14px;
    padding: 10px 12px;
    background: var(--page);
    border-bottom: 1px solid var(--border);
  }
}

/* ===== 响应式:手机 ===== */
@media (max-width: 600px) {
  .grid { gap: 10px; }

  /* 分页导航:手机端铺满底宽,标签均分 */
  .tabbar {
    width: calc(100% - 20px);
    gap: 0;
    padding: 5px;
    justify-content: space-between;
  }
  .tabbar .tab { min-width: 0; flex: 1; padding: 7px 4px 6px; font-size: 10.5px; }
  .tabbar .tab svg { width: 20px; height: 20px; }

  /* 顶栏:第一行标题+车名,车图右侧跨一、二行,服务器资源第三行 */
  .header-main { gap: 10px; }
  .header-main .model-icon { height: 58px; }
  header h1 { font-size: 18px; }
  .car-name { font-size: 14px; padding-left: 10px; }
  .badge { font-size: 12px; padding: 3px 9px; }
  .batt-pill { font-size: 12px; padding: 3px 9px; gap: 6px; }
  .batt-icon { width: 26px; height: 12px; }
  #car-model-badge { height: 13px; width: 116px; }
  .sys-meters { gap: 10px; }
  .sys-meters .meter-track { width: 44px; }
  #sw-version { display: none; }
  .icon-btn { padding: 8px 14px; }

  /* 时间范围分段选择器占满一行,自动刷新提示隐藏(卡片内 mini 切换控件保持紧凑) */
  .filter-row .hint { display: none; }
  .filter-row .seg { flex: 1; }
  .filter-row .seg button { flex: 1; padding: 9px 4px; text-align: center; }

  /* 卡片与图表紧凑化 */
  .card { padding: 12px 14px; border-radius: 12px; }
  .card-head-right { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .chart { height: 230px; }
  .chart-activity { height: 290px; }
  #map { height: 300px; }
  .chip-legend { gap: 10px; }
  .mini-stat { padding: 5px 10px; }

  /* 车辆总览:手机端仍两列夹车辆;舞台按车图比例伸缩;
     车图内容整体放大 1.32 倍(裁掉 HUD 角标与四周留白),让车在框内占比更大;
     胎压面板在车图下方一行四格,不再覆盖车身 */
  .carview { gap: 6px; }
  .car-legend { flex: 0 0 88px; gap: 7px; }
  .car-stage { height: auto; aspect-ratio: 340 / 470; overflow: hidden; }
  .car-hud { display: none; }
  #car-zoom {
    transform: scale(1.32);
    transform-origin: 170px 236px;
    transform-box: view-box;
  }
  .cl-item { padding: 7px 8px; gap: 7px; }
  .cl-val { font-size: 15px; }

  /* 事件列表:日期行允许换行,摘要芯片独占一行防溢出 */
  .day-head { flex-wrap: wrap; padding: 9px 10px; }
  .day-head .date { font-size: 13px; }
  .day-head .summary {
    order: 3;
    flex-basis: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }
  .day-head .day-donut { order: 1; margin-left: auto; width: 28px; height: 28px; }
  .day-head .chev { order: 2; margin-left: 0; }
  .ev-row {
    grid-template-columns: 96px 1fr 1fr;
    padding: 8px 10px;
    font-size: 12px;
  }

  footer { font-size: 11px; }
}
