/* ==========================================================================
   车辆保养助手 · 设计令牌
   两套主题：浅色商务 / 深色科技
   data-theme 由 app.js 在首屏前写入（跟随系统或手动指定），CSS 里只认具体值，
   不用 media query 分叉，避免两处维护同一份深色变量。
   ========================================================================== */

/* 配色 / 字号 / 圆角 / 间距全部来自《UI检查报告》第九章，全站只用这套令牌，
   组件里不再出现裸色值和裸字号。 */
:root,
:root[data-theme="light"] {
  color-scheme: light;

  /* 背景灰 #f1f5f9 / 卡片白 #ffffff / 边框灰 #e2e8f0 */
  --bg: #f1f5f9;
  --bg-grad: none;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  /* 文字主色 #1e293b / 次色 #64748b / 最小文字用更浅一档 */
  --text: #1e293b;
  --text-2: #64748b;
  --text-3: #94a3b8;

  /* 主色 #2563eb，主色浅 #dbeafe */
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-soft: #dbeafe;
  --on-brand: #ffffff;

  /* 成功绿 #16a34a / 浅底 #dcfce7 */
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --ok-line: #bbf7d0;

  /* 警告橙 #ea580c / 浅底 #ffedd5 */
  --warn: #ea580c;
  --warn-soft: #ffedd5;
  --warn-line: #fed7aa;

  /* 危险红 #dc2626 / 浅底 #fee2e2 */
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --danger-line: #fecaca;

  --shadow-1: 0 1px 3px rgba(15, 23, 42, .1);
  --shadow-2: 0 4px 16px rgba(15, 23, 42, .12);
  --toast-bg: #1e293b;
  --toast-text: #ffffff;
  --scrim: rgba(15, 23, 42, .35);

  /* 圆角：卡片 12 / 按钮输入框 8 / 弹窗 16 */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  /* 间距统一 8 的倍数 */
  --pad: 16px;
  /* 外壳宽度：顶栏内容、内容区、底部导航共用一条线，桌面端才不会各走各的
     （≥768px 在文件末尾改成 1200px） */
  --shell: 720px;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  /* 深色是同一套语义色在暗底上的派生，保持对比度与浅色一致 */
  --bg: #0f172a;
  --bg-grad: none;
  --surface: #1e293b;
  --surface-2: #273449;
  --surface-3: #334155;
  --line: #334155;
  --line-strong: #475569;

  --text: #e2e8f0;
  --text-2: #94a3b8;
  --text-3: #64748b;

  --brand: #3b82f6;
  --brand-strong: #60a5fa;
  --brand-soft: #1e3a8a;
  --on-brand: #ffffff;

  --ok: #4ade80;
  --ok-soft: #14532d;
  --ok-line: #166534;

  --warn: #fb923c;
  --warn-soft: #431407;
  --warn-line: #7c2d12;

  --danger: #f87171;
  --danger-soft: #450a0a;
  --danger-line: #7f1d1d;

  --shadow-1: 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-2: 0 6px 22px rgba(0, 0, 0, .45);
  --toast-bg: #e2e8f0;
  --toast-text: #1e293b;
  --scrim: rgba(0, 0, 0, .6);

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --pad: 16px;
  /* 外壳宽度：顶栏内容、内容区、底部导航共用一条线，桌面端才不会各走各的 */
  --shell: 720px;
}

/* ============================ 基础 ============================ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  /* 正文 16px —— 报告 9.2 字体层级：24 / 18 / 16 / 14 / 12，不出现其它字号 */
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }

.num, .kpi b, .stat b, .hero-km, .list-due, table td.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ============================ 顶栏 ============================ */

/* 顶栏（页标题 + 副标题 + 退出）整条去掉（2026-09-21 需求）：
   落地页 / 登录页本来就不显示它，登录后各页也不再要这条头。
   DOM 保留——JS 还在往 #title / #subtitle 里写字，退出逻辑也还挂在 #logoutBtn 上，
   直接删节点会出空引用；真退出入口挪到了 设置页 →「个人账号管理」。 */
.topbar {
  display: none;
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 12px var(--pad);
}
.topbar-in {
  max-width: var(--shell); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
/* 大标题 24px / 700 */
.topbar h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.01em; line-height: 1.3; }
.topbar .sub { font-size: 14px; color: var(--text-2); margin-top: 2px; }

.page { padding: 16px var(--pad) 96px; max-width: var(--shell); margin: 0 auto; }

/* ==================== 登录 / 注册布局 ====================
   报告 4.1（已选定方案）：纯居中卡片 + 浅灰渐变背景，不做左右分栏；
   登录页与注册页是两个独立页面，Logo 与标题放在卡片内，不用顶部品牌块。 */

.brand { min-width: 0; }
.brand-mark { display: none; }
.brand-feats { display: none; }

body.is-auth {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px var(--pad);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 52%);
}
body.is-auth .topbar { display: none; }
body.is-auth .page {
  flex: 0 0 auto; width: 100%; max-width: 100%; padding: 0;
  display: flex; justify-content: center;
  /* 抵消桌面端给侧边栏让位的 margin-left:208px，否则卡片会整体偏右 */
  margin-left: 0;
}
body.is-auth .auth-card {
  width: 100%; max-width: 400px; margin: 0;
  padding: 28px 24px 20px; border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
}
body.is-auth .auth-card .field { margin-bottom: 14px; }
body.is-auth .auth-hint {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px; line-height: 1.7;
}

/* 卡片头部：Logo + 标题（大标题 24 / 700） */
.auth-head { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 15px;
  background: var(--brand); color: var(--on-brand);
  box-shadow: 0 10px 22px -10px var(--brand);
}
.auth-title { font-size: 24px; font-weight: 700; margin: 0; }
.auth-foot { display: flex; justify-content: center; margin-top: 12px; }
.linkbtn {
  border: 0; background: none; color: var(--brand); font-family: inherit;
  font-size: 14px; padding: 8px; cursor: pointer;
}
.linkbtn:hover { text-decoration: underline; }

/* 带图标的输入框：图标绝对定位在输入框内左侧 */
span.ipt { position: relative; display: block; }
span.ipt > input { padding-left: 40px; }
span.ipt > svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-2); pointer-events: none;
}
.ipt-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--text-2); cursor: pointer;
  padding: 8px; display: inline-flex; border-radius: var(--r-sm);
}
.ipt-eye:hover { color: var(--text); }
/* 覆盖 label.field > span 的标签样式（这里的 span.ipt 是输入框容器） */
label.field > span.ipt { display: block; margin-bottom: 0; font-size: 16px; color: var(--text); }

/* ============================ 卡片 ============================ */

/* 卡片：白底、圆角 12、阴影 0 1px 3px rgba(0,0,0,.1)、内边距 16 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
}
/* 卡片标题 18px / 600 */
.card h2 {
  font-size: 18px; font-weight: 600; margin: 0 0 16px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.card h3 { font-size: 16px; font-weight: 600; margin: 16px 0 8px; color: var(--text-2); }

.muted { color: var(--text-2); font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }

/* 小节标题：最小文字 12px */
.sec-label {
  font-size: 12px; font-weight: 600; color: var(--text-3);
  letter-spacing: .04em; margin: 24px 2px 8px;
}

/* ==================== 车辆主卡 + 状态环 ==================== */

.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
  display: flex; align-items: center; gap: 16px;
}
.hero-main { flex: 1; min-width: 0; }
.hero-plate {
  font-size: 24px; font-weight: 700; letter-spacing: .02em;
  margin: 0; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hero-sub { font-size: 14px; color: var(--text-2); margin-top: 2px; }
.hero-meta { font-size: 12px; color: var(--text-3); margin-top: 8px; }
.hero-acts { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* 状态环：直径 96、环内留白足够，文字 16/12 不会顶到圆环（修 BUG-006） */
.ringwrap { position: relative; width: 96px; height: 96px; flex: 0 0 auto; }
.ringwrap svg { display: block; }
.ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.ring-num { font-size: 16px; font-weight: 600; line-height: 1; color: var(--brand); }
.ring-cap { font-size: 12px; color: var(--text-3); margin-top: 4px; letter-spacing: .02em; }

/* ============================ KPI ============================ */

.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }

/* 状态卡片：文字与数字都在卡片内水平居中（修 BUG-005） */
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--shadow-1);
  text-align: center;
}
.kpi span { display: block; font-size: 12px; color: var(--text-3); }
.kpi b { display: block; font-size: 24px; font-weight: 700; line-height: 1.25; margin-top: 4px; color: var(--text); }

.kpi.danger { background: var(--danger-soft); border-color: var(--danger-line); }
.kpi.danger span, .kpi.danger b { color: var(--danger); }
.kpi.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.kpi.warn span, .kpi.warn b { color: var(--warn); }
.kpi.ok { background: var(--ok-soft); border-color: var(--ok-line); }
.kpi.ok span, .kpi.ok b { color: var(--ok); }
.kpi.zero { background: var(--surface); border-color: var(--line); opacity: .6; }
.kpi.zero span, .kpi.zero b { color: var(--text-3); }

/* ======================= 最紧急的一件事 ======================= */

.urgent {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-1);
}
.urgent.overdue { border-left-color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
.urgent.soon { border-left-color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }

.urgent-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.urgent-tag {
  font-size: 12px; font-weight: 600; letter-spacing: .05em;
  color: var(--text-3); text-transform: none;
}
.urgent.overdue .urgent-tag { color: var(--danger); }
.urgent.soon .urgent-tag { color: var(--warn); }
.urgent-days { font-size: 14px; font-weight: 600; color: var(--text-2); }
.urgent.overdue .urgent-days { color: var(--danger); }
.urgent.soon .urgent-days { color: var(--warn); }
.urgent-name { font-size: 18px; font-weight: 600; color: var(--text); }
.urgent-name .spec { font-weight: 400; font-size: 14px; color: var(--text-2); margin-left: 6px; }
.urgent-meta { font-size: 14px; color: var(--text-2); margin-top: 4px; }
.urgent-acts { display: flex; gap: 8px; margin-top: 16px; }

/* ============================ 统计 ============================ */

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px; box-shadow: var(--shadow-1);
}
.stat span { display: block; font-size: 12px; color: var(--text-3); }
.stat b { display: block; font-size: 18px; font-weight: 600; margin-top: 4px; color: var(--text); }
.stat .unit { font-size: 12px; font-weight: 400; color: var(--text-3); margin-left: 3px; }
.stat .stat-sub { display: block; font-size: 12px; font-style: normal; color: var(--text-3); margin-top: 2px; }

/* ============================ 年历式选月器 ============================ */

.monpick { padding: 12px 14px; }
.mon-head { display: flex; align-items: center; gap: 8px; }

/* 头部是可点按钮：主行显示当前月份，次行是该月汇总，右侧箭头提示可展开 */
.mon-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text); cursor: pointer; text-align: left;
}
.mon-toggle:hover { background: var(--surface-2); }
.mon-toggle > span { display: block; min-width: 0; }
.mon-title { font-size: 15px; font-weight: 600; }
.mon-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.mon-caret {
  margin-left: auto; align-self: center; font-size: 11px; color: var(--text-3);
  transition: transform .18s ease;
}
.mon-navs { display: flex; gap: 6px; flex: 0 0 auto; }
.mon-navs .mon-nav { min-width: 38px; font-size: 17px; line-height: 1; padding: 6px 9px; }

.mon-year { display: flex; align-items: center; gap: 8px; }
.mon-year .mon-nav { min-width: 38px; font-size: 17px; line-height: 1; padding: 6px 9px; }
.mon-year-mid { flex: 1; text-align: center; }
.mon-year-mid b { display: block; font-size: 14px; }
.mon-year-mid .muted { font-size: 12px; }

.mon-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin-top: 12px;
}
.mon-cell {
  height: 50px; padding: 0; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 13.5px; line-height: 1.1;
}
.mon-cell small { font-size: 12px; line-height: 1; color: var(--text-3); }
.mon-cell.dim { color: var(--text-3); background: var(--surface-2); }
.mon-cell.on {
  background: var(--brand); border-color: var(--brand);
  color: var(--on-brand); font-weight: 600;
}
.mon-cell.on small { color: var(--on-brand); opacity: .82; }

/* ---------------- 记录页顶部筛选条（FEAT-005）：类型 chips + 月份筛选 ---------------- */

.frow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.frow:first-child { margin-top: 0; }
.flab { flex: 0 0 28px; font-size: 12px; color: var(--text-3); }
.fchips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.fchip {
  font-size: 13px; line-height: 1.2; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  cursor: pointer; font-family: inherit;
}
.fchip:hover { border-color: var(--brand); color: var(--brand); }
.fchip.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
.fsum { flex: 1; min-width: 0; font-size: 12px; }
/* 月份按钮里的下拉箭头：不能沿用 .mon-caret 的 margin-left:auto（会被推到卡片最右边） */
.mon-toggle .mon-caret { margin-left: 6px; align-self: center; }

/* ---------------- 底部分页条：共X条 · 第Y/Z页 ---------------- */

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}
.pager-info { flex: 1; min-width: 0; text-align: center; font-size: 13px; color: var(--text-2); }
.pager .btn { min-width: 74px; }


/* ============================ 计划条 ============================ */

.plan {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
}
/* 已暂停：整体压暗、去掉左侧状态色，一眼能看出它不再提醒 */
.plan.paused { opacity: 0.62; border-left-color: var(--line-strong); }
.plan.paused .plan-name, .plan.paused .name { color: var(--text-2); }
.plan.overdue { border-left-color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
.plan.soon { border-left-color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.plan.ok { border-left-color: var(--ok); }
.plan.unknown { border-left-color: var(--text-3); }

.plan .name { font-weight: 600; font-size: 16px; color: var(--text); }
/* BUG-013：超长项目名截断 + 「展开/收起」，点标题本身切换 */
.plan .name.has-more { cursor: pointer; }
.plan .name.has-more:hover { color: var(--brand); }
.plan .nm-more { margin-left: 6px; font-size: 12px; font-weight: 500; color: var(--brand); white-space: nowrap; }
.plan .name .spec { font-weight: 400; font-size: 14px; color: var(--text-2); margin-left: 6px; }
.plan .meta { font-size: 14px; color: var(--text-2); margin-top: 4px; }
.plan .badge {
  display: inline-block; font-size: 12px; font-weight: 500;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-2);
}
.plan.overdue .badge { color: var(--danger); border-color: var(--danger-line); }
.plan.soon .badge { color: var(--warn); border-color: var(--warn-line); }
.plan.ok .badge { color: var(--ok); border-color: var(--ok-line); }
.plan .reason { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* 保养进度条 */
.progress { margin-top: 10px; }
.progress-track {
  height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 999px; background: var(--brand); }
.plan.ok .progress-fill { background: var(--ok); }
.plan.soon .progress-fill { background: var(--warn); }
.plan.overdue .progress-fill { background: var(--danger); }
.progress-cap { font-size: 12px; color: var(--text-3); margin-top: 8px; display: flex; justify-content: space-between; }

/* ============================ 表单 ============================ */

label.field { display: block; margin-bottom: 16px; }
label.field > span { display: block; font-size: 14px; color: var(--text-2); margin-bottom: 8px; }

/* 输入框：灰边、圆角 8、高度 44、聚焦边框变主色 */
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); font-family: inherit;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { min-height: 76px; resize: vertical; }
input[type=checkbox] { accent-color: var(--brand); }

/* ============================ 按钮 ============================ */

/* 按钮：圆角 8、高度 44；点击有按压效果 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; font-size: 14px; font-weight: 500; font-family: inherit;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  border-radius: var(--r-sm); cursor: pointer;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease, transform .06s ease;
}
.btn:active { transform: translateY(1px); }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-brand); }
.btn.danger { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 12px; min-height: 32px; border-radius: 8px; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:disabled:hover { border-color: var(--line-strong); color: var(--text); }

/* 分段控件（外观 / 识别通道） */
.seg { display: flex; gap: 0; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; }
.seg button {
  flex: 1; border: 0; background: var(--surface); color: var(--text-2);
  font-family: inherit; font-size: 14px; font-weight: 500; padding: 9px 8px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand); color: var(--on-brand); }

/* ============================ 底部导航 ============================ */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  max-width: var(--shell); margin: 0 auto;
}
.tabbar button {
  flex: 1; border: 0; background: none; font-family: inherit;
  font-size: 12px; color: var(--text-3); padding: 6px 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border-radius: 8px; transition: color .15s ease, background .15s ease;
}
.tabbar button.active { color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.tabbar .ico { font-size: 17px; line-height: 1; }

/* ============================ 其它 ============================ */

.pill {
  display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2);
}
.pill.on { background: var(--brand-soft); color: var(--brand); font-weight: 500; }

.drop {
  border: 1.5px dashed var(--line-strong); border-radius: var(--r);
  background: var(--surface-2); padding: 26px 14px; text-align: center; cursor: pointer;
  color: var(--text-2); font-size: 14px;
}
.drop:hover { border-color: var(--brand); color: var(--brand); }
.drop.has-image { padding: 10px; border-style: solid; }
.drop img { max-width: 100%; border-radius: var(--r-sm); display: block; margin: 0 auto; }

.guide {
  background: var(--brand-soft); border-radius: var(--r-sm);
  padding: 16px; font-size: 14px; color: var(--text);
  border-left: 3px solid var(--brand);
}
.guide ol { margin: 8px 0 0; padding-left: 20px; }
.guide li { margin-bottom: 4px; }

.item-edit {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 12px; margin-bottom: 10px; background: var(--surface-2);
}

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: var(--toast-bg); color: var(--toast-text);
  padding: 12px 24px; border-radius: 999px; font-size: 14px;
  z-index: 100; max-width: 88%; text-align: center;
  box-shadow: var(--shadow-2);
}
.toast.err { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .toast.err { color: #2a0c0c; }

.hint { font-size: 14px; color: var(--text-2); margin-top: 8px; line-height: 1.55; }
.error-box {
  background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-line);
  border-radius: var(--r-sm); padding: 12px 16px; font-size: 14px; margin-bottom: 16px;
}
/* 空状态：插画 + 引导文案 + 操作按钮（修 BUG-009） */
.empty {
  text-align: center; color: var(--text-2); padding: 24px 16px; font-size: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty-illu { width: 96px; height: 96px; margin-bottom: 8px; opacity: .9; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--text); }
.empty-desc { font-size: 14px; color: var(--text-2); max-width: 28em; }
.empty-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

.spin {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: sp .7s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }

details summary { cursor: pointer; font-size: 13.5px; color: var(--brand); font-weight: 500; }
details[open] summary { margin-bottom: 8px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--text-3); font-weight: 500; font-size: 12px; }
tr:last-child td { border-bottom: 0; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em; background: var(--surface-3); padding: 1px 5px; border-radius: 5px;
}

/* ==================== 弹层 ====================
   替代原生 prompt/confirm —— 那两个在电脑浏览器里固定贴在窗口顶部。
   全站统一一套：移动端底部 Sheet，PC 端（≥768，见文件末尾）居中 Modal。 */

body.modal-open { overflow: hidden; }

/* BUG-027：弹窗一律「垂直+水平居中」，手机端不再是底部弹层。
   所有弹层（确认 / 表单 / 记一笔 / 公告 / 交流群 / 选月）都走同一个 buildModal()，
   所以只改这一处就全局一致，PC 与手机同一套观感。 */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-scrim {
  position: absolute; inset: 0;
  background: var(--scrim);
  animation: modal-fade .16s ease-out;
}
.modal-box {
  position: relative;
  width: 100%; max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 24px;
  max-height: 82vh; overflow-y: auto;
  animation: modal-in .18s cubic-bezier(.2, .8, .3, 1);
}
.modal-title { font-size: 18px; font-weight: 600; margin: 0 0 8px; color: var(--text); }
.modal-body { font-size: 14px; color: var(--text-2); line-height: 1.6; margin-bottom: 16px; }
.modal-box .field { margin-bottom: 16px; }
.modal-box .field:last-of-type { margin-bottom: 16px; }
.modal-acts { display: flex; gap: 8px; }
.modal-acts .btn { flex: 1; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: none; }
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }

.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.sheet-head b { font-size: 18px; }

/* ==================== 骨架屏（替代"加载中…"文字，修 BUG-010） ==================== */

.sk { display: block; margin-bottom: 16px; }
.sk-line, .sk-box, .sk-circle {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: sk-shine 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
.sk-line { height: 14px; margin-bottom: 8px; }
.sk-line.w40 { width: 40%; }
.sk-line.w60 { width: 60%; }
.sk-line.w80 { width: 80%; }
.sk-box { height: 96px; border-radius: var(--r); margin-bottom: 16px; }
.sk-box.sm { height: 64px; }
.sk-circle { width: 96px; height: 96px; border-radius: 50%; flex: 0 0 auto; }
.sk-hero { display: flex; align-items: center; gap: 16px; }
.sk-hero-main { flex: 1; min-width: 0; }
@keyframes sk-shine { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ==================== 数据可视化（修 BUG-011） ==================== */

.chart-card { margin-bottom: 16px; }
.chart-title { font-size: 18px; font-weight: 600; margin: 0 0 16px; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; }
.bar { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar-track { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.bar-fill {
  width: 100%; background: var(--brand); border-radius: 6px 6px 0 0;
  min-height: 2px; transition: height .2s ease;
}
.bar-cap { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.bar-val { font-size: 12px; color: var(--text-2); }

.pie-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.pie {
  width: 128px; height: 128px; border-radius: 50%; flex: 0 0 auto;
  background: conic-gradient(var(--surface-3) 0 100%);
}
.pie-legend { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
.pie-item { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.pie-dot { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.pie-item b { margin-left: auto; color: var(--text); font-weight: 600; }
/* BUG-015：只有一项分类时不画同色大饼，改单行列表 */
.pie-legend-solo { flex: 1; }
.pie-legend-solo .pie-item { padding: 4px 0; }
.pie-pct { color: var(--text-2); font-size: 12px; min-width: 40px; text-align: right; }

/* ==================== 落地页 ==================== */

body.is-landing .topbar { display: none; }
body.is-landing .tabbar { display: none; }
body.is-landing .page { padding: 0; max-width: none; }

.land-hero {
  background: linear-gradient(180deg, var(--brand-soft), var(--bg));
  padding: 24px 16px 40px; text-align: center;
}
.land-nav {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1200px; margin: 0 auto 40px; gap: 16px;
}
.land-brand { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; }
.land-title { font-size: 24px; font-weight: 700; margin: 0 0 8px; }
.land-sub { font-size: 16px; color: var(--text-2); margin: 0 auto 24px; max-width: 32em; }
.land-section { max-width: 1200px; margin: 0 auto; padding: 40px 16px; }
.land-cards { display: grid; grid-template-columns: 1fr; gap: 16px; }
.land-card { text-align: center; }
.land-ico {
  width: 48px; height: 48px; border-radius: 12px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand); font-size: 24px;
}
.land-card h3 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
.land-card p { margin: 0; font-size: 14px; color: var(--text-2); }
.land-trust {
  max-width: 1200px; margin: 0 auto; padding: 0 16px 48px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
}
.land-trust .muted { font-size: 14px; }

/* ==================== 侧边栏（PC 端替代底部 Tab，报告 8.4） ==================== */

.sidebar { display: none; }
/* 品牌小图标：侧边栏和落地页都在用 */
.sb-logo { color: var(--brand); display: inline-flex; }

/* ==================== 产品公告列表（FEAT-003） ====================
   弹窗里的历史公告列表 + 管理台里的公告条目共用这套。 */

.ann-list { max-height: 58vh; overflow-y: auto; margin: 2px 0 14px; }
.ann-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.ann-item:last-child { border-bottom: none; }
.ann-title { font-weight: 600; }
.ann-meta { font-size: 12px; color: var(--text-3); margin: 3px 0 6px; }
.ann-body { white-space: pre-wrap; line-height: 1.7; color: var(--text-2); font-size: 14px; }

/* ==================== 桌面端（≥768px） ====================
   报告 9.5：断点只有 768 一个。移动端 <768 = 单列 + 底部弹窗 + 底部导航；
   桌面 ≥768 = 多列 + 居中弹窗 + 内容最大宽度 1200 居中 + 左侧边栏导航。
   这段必须放文件末尾：同权重下靠后的才生效（之前放中间被 .tabbar 反杀过）。 */

@media (min-width: 768px) {
  :root[data-theme] { --pad: 24px; --shell: 1200px; --rail: 208px; }

  /* BUG-021：内容区最大 1200px 且「居中」，不是贴着侧边栏靠左。
     屏幕够宽时按 (视口 - 1200)/2 居中；不够宽时至少让开侧边栏的 208px，避免被压在栏下面。
     顶栏内层不再自己居中（margin auto），改成与内容区同一条左边缘，三线才对得齐。 */
  .topbar { padding: 16px 24px; margin-left: max(var(--rail), calc((100% - var(--shell)) / 2)); }
  .topbar-in { margin-left: 0; margin-right: auto; }
  .page {
    padding: 24px; padding-bottom: 48px;
    margin-left: max(var(--rail), calc((100% - var(--shell)) / 2));
  }

  /* 底部 Tab → 左侧边栏（报告 8.4） */
  .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 8px;
    position: fixed; left: 0; top: 0; bottom: 0; width: 208px; z-index: 40;
    background: var(--surface); border-right: 1px solid var(--line);
    padding: 16px 12px;
  }
  .sidebar .sb-brand {
    display: flex; align-items: center; gap: 8px;
    font-size: 18px; font-weight: 600; padding: 8px 12px; margin-bottom: 16px;
  }
  .sidebar button {
    display: flex; align-items: center; gap: 12px; width: 100%;
    border: 0; background: none; font-family: inherit; font-size: 16px;
    color: var(--text-2); padding: 12px; border-radius: var(--r-sm);
    cursor: pointer; text-align: left;
    transition: background .15s ease, color .15s ease;
  }
  .sidebar button:hover { background: var(--surface-2); color: var(--text); }
  .sidebar button.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
  .sidebar .ico { font-size: 18px; width: 24px; text-align: center; }

  /* 弹窗：PC 端与手机端同为居中，宽 480（报告 9.3 + BUG-027） */
  .modal { padding: 24px; }
  .modal-box { max-height: 80vh; }

  /* 表单卡两列排布：否则输入框被拉到 1200px 宽 */
  .card.form2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
    align-items: start;
  }
  .card.form2 > h2,
  .card.form2 > .hint,
  .card.form2 > .sec-label,
  .card.form2 > .seg,
  .card.form2 > .row,
  .card.form2 > .guide,
  .card.form2 > #addKey,
  .card.form2 > #barkKeys,
  .card.form2 > #overrides,
  .card.form2 > #extBox,
  .card.form2 > .btn.block { grid-column: 1 / -1; }

  .card.form2 > label.field { grid-column: span 1; margin-bottom: 16px; }
  .card.form2 > .seg { max-width: 460px; }
  /* 小按钮独占一行时别被拉成整宽 */
  .card.form2 > #addKey { justify-self: start; }

  .card.form2 > #extBox {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px;
  }
  .card.form2 > #extBox > label.field { grid-column: span 1; margin-bottom: 16px; }

  .card.form2 > #barkKeys {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px;
  }

  /* 落地页同样没有侧边栏，抵消让位 margin；顶部导航条本身 display:none 无需处理 */
  body.is-landing .page { margin-left: 0; }

  /* 落地页：功能三卡并排 */
  .land-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .land-hero { padding: 32px 24px 56px; }
  .land-section { padding: 56px 24px; }

  /* 登录 / 注册页：桌面端同样是一张居中卡片（报告 4.1：不要左右分栏），
     只把卡片放宽到 400、内边距给足；卡片宽度由上面的 base 规则给出。 */
  body.is-auth .auth-card { max-width: 400px; padding: 32px 28px 24px; }
}

/* 未登录（登录页 / 落地页）时侧边栏一律不出现。
   选择器权重高于上面的 .sidebar，所以写在媒体查询之后也能生效。 */
body.is-auth .sidebar,
body.is-landing .sidebar { display: none; }
