/* ==========================================================
   企业数据分析与统计上报系统 · 统一主题
   浅色（白底黑字） / 深色（黑底白字）双主题 + 全端自适应
   主题由 <html data-theme="light|dark"> 控制，默认浅色
   ========================================================== */
:root,
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f2f5fa;
  --bg-soft: #f8fafd;
  --card: #ffffff;
  --card-2: #f7f9fd;
  --hover: #f8fbff;
  --field: #ffffff;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --line: #e4e9f2;
  --line-2: #eff3f9;

  --blue: #2563eb;
  --blue-strong: #1d4ed8;
  --blue-bg: #eaf1ff;
  --blue-line: #c7d7f5;
  --green: #059669;
  --green-text: #047857;
  --green-bg: #e6f8f0;
  --green-line: #a7e3c8;
  --orange: #d97706;
  --orange-text: #b45309;
  --orange-bg: #fff4e3;
  --red: #dc2626;
  --red-text: #b91c1c;
  --red-bg: #fdecec;
  --red-line: #f3c6c6;
  --purple: #7c3aed;
  --purple-text: #6d28d9;
  --purple-bg: #f1ecff;
  --cyan: #0891b2;
  --cyan-text: #0e7490;
  --cyan-bg: #e6f7fb;
  --pink: #db2777;
  --pink-bg: #fdeaf4;
  --gray-bg: #f3f4f6;
  --gray-text: #4b5563;
  --chip-bg: #f1f5fb;
  --chip-text: #334155;
  --chip-line: #e6ecf5;

  --warn-bg: #fffbeb;
  --warn-line: #fde68a;
  --warn-text: #92400e;

  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 4px 14px rgba(17, 24, 39, .05);
  --shadow-hover: 0 4px 10px rgba(17, 24, 39, .07), 0 12px 28px rgba(17, 24, 39, .08);
  --focus-ring: rgba(37, 99, 235, .12);

  --radius: 12px;
  --header-h: 62px;
}

/* ---------------- 深色主题 ---------------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b111c;
  --bg-soft: #0f1725;
  --card: #141d2c;
  --card-2: #1a2434;
  --hover: #1b2434;
  --field: #111a28;
  --text: #e8eef8;
  --text-2: #c3cddd;
  --muted: #8d9bb0;
  --line: #253143;
  --line-2: #1d2736;

  --blue: #3b82f6;
  --blue-strong: #60a5fa;
  --blue-bg: #16294a;
  --blue-line: #2b4a7d;
  --green: #10b981;
  --green-text: #34d399;
  --green-bg: #0f2f26;
  --green-line: #1d5c49;
  --orange: #f59e0b;
  --orange-text: #fbbf24;
  --orange-bg: #33260e;
  --red: #ef4444;
  --red-text: #fca5a5;
  --red-bg: #3a1a1d;
  --red-line: #5c2a2e;
  --purple: #8b5cf6;
  --purple-text: #c4b5fd;
  --purple-bg: #291a44;
  --cyan: #06b6d4;
  --cyan-text: #67e8f9;
  --cyan-bg: #0d2f39;
  --pink: #ec4899;
  --pink-bg: #3a1626;
  --gray-bg: #1f2937;
  --gray-text: #b9c4d3;
  --chip-bg: #1c2738;
  --chip-text: #cfd8e6;
  --chip-line: #2a3648;

  --warn-bg: #33280f;
  --warn-line: #57431a;
  --warn-text: #fcd34d;

  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 16px rgba(0, 0, 0, .28);
  --shadow-hover: 0 6px 14px rgba(0, 0, 0, .4), 0 16px 34px rgba(0, 0, 0, .38);
  --focus-ring: rgba(59, 130, 246, .22);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color .18s ease, color .18s ease;
}

/* 内容较少时让页脚也贴到页面底部（登录页自带居中布局，排除） */
body:not(.login-page) {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
body:not(.login-page) > .container { flex: 1 0 auto; width: 100%; }

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

input, select, textarea, button { font-family: inherit; }
input[type=date], input[type=datetime-local], input[type=time] { color-scheme: inherit; }
select option { background: var(--card); color: var(--text); }

/* 主题切换时避免大面积闪烁 */
.theme-anim, .theme-anim * {
  transition: background-color .18s ease, border-color .18s ease, color .18s ease !important;
}

/* ---------------- 顶部栏 ---------------- */
.app-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -1px;
}
.brand .txt { min-width: 0; }
.brand h1 { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: .5px; }
.brand .en { font-size: 11px; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; }
.header-right { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-2); flex: 0 0 auto; }
.header-right .divider { width: 1px; height: 20px; background: var(--line); }
.header-right .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.clock { font-family: Consolas, Monaco, monospace; color: var(--text-2); font-size: 13px; }

/* 主题切换按钮（位于「设置」左侧） */
.theme-toggle {
  width: 36px; height: 32px; flex: 0 0 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text-2);
  cursor: pointer; padding: 0; line-height: 1;
  transition: all .15s;
}
.theme-toggle:hover { border-color: var(--blue-line); background: var(--bg-soft); color: var(--blue); }
.theme-toggle svg { width: 17px; height: 17px; display: block; }
.theme-toggle .ic-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ic-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .ic-sun { display: none; }

/* 移动端菜单按钮（默认隐藏） */
.nav-toggle {
  display: none;
  width: 34px; height: 34px; flex: 0 0 34px;
  align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text-2);
  cursor: pointer; padding: 0;
}
.nav-toggle svg { width: 19px; height: 19px; }

/* ---------------- 导航 ---------------- */
.tabs {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  position: sticky;
  top: var(--header-h);
  z-index: 19;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 13px 16px 12px;
  color: var(--text-2);
  font-size: 14px;
  border-bottom: 3px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}
.tabs a:hover { color: var(--blue); background: var(--bg-soft); text-decoration: none; }
.tabs a.on { color: var(--blue); border-color: var(--blue); font-weight: 600; }
.tabs-mask { display: none; }

/* ---------------- 容器 ---------------- */
.container { padding: 20px 28px 32px; max-width: 1680px; margin: 0 auto; }

/* ---------------- 统计卡片 ---------------- */
.stats-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.stats-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.stats-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}
.stat-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--blue);
}
.stat-card .lbl { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-card .num {
  font-size: 30px; font-weight: 700; color: var(--text);
  font-family: Consolas, "DIN Alternate", monospace;
  line-height: 1.25; margin-top: 4px;
}
.stat-card .num .unit { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 4px; font-family: inherit; }
.stat-card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-card .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex: 0 0 8px; }

.stat-card.c-blue::before { background: var(--blue); }
.stat-card.c-green::before { background: var(--green); }
.stat-card.c-orange::before { background: var(--orange); }
.stat-card.c-red::before { background: var(--red); }
.stat-card.c-purple::before { background: var(--purple); }
.stat-card.c-cyan::before { background: var(--cyan); }

.stat-card.c-blue .num { color: var(--blue-strong); }
.stat-card.c-green .num { color: var(--green-text); }
.stat-card.c-orange .num { color: var(--orange-text); }
.stat-card.c-red .num { color: var(--red-text); }
.stat-card.c-purple .num { color: var(--purple-text); }
.stat-card.c-cyan .num { color: var(--cyan-text); }

.stat-card.c-blue .dot { background: var(--blue); }
.stat-card.c-green .dot { background: var(--green); }
.stat-card.c-orange .dot { background: var(--orange); }
.stat-card.c-red .dot { background: var(--red); }
.stat-card.c-purple .dot { background: var(--purple); }
.stat-card.c-cyan .dot { background: var(--cyan); }

/* ---------------- 面板 ---------------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 10px;
  display: flex; flex-direction: column;
  min-width: 0;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 6px;
}
.panel-title {
  font-size: 15px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.panel-title::before {
  content: ''; width: 3px; height: 14px; border-radius: 2px; flex: 0 0 3px;
  background: var(--blue);
}
.panel-title.p-green::before { background: var(--green); }
.panel-title.p-orange::before { background: var(--orange); }
.panel-title.p-purple::before { background: var(--purple); }
.panel-title.p-cyan::before { background: var(--cyan); }
.panel-title.p-red::before { background: var(--red); }
.panel-note { font-size: 12px; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }
.chart { width: 100%; flex: 1; min-height: 0; }

.dash-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; }
.dash-grid .panel { height: 318px; }
.dash-grid .panel.tall { height: 360px; }
.panel.span-2 { grid-column: span 2; }

/* ---------------- 筛选区 ---------------- */
.filters {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  box-shadow: var(--shadow);
}
.filters input[type=text], .filters input[type=search], .filters input[type=date],
.filters select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  font-size: 13px;
  color: var(--text);
  background: var(--field);
  font-family: inherit;
}
.filters input[type=text], .filters input[type=search] { min-width: 230px; }
.filters select { min-width: 118px; }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus-ring); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 36px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 8px;
  font-size: 13px; font-family: inherit; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  background: var(--card); color: var(--text-2);
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; filter: brightness(.98); }
:root[data-theme="dark"] .btn:hover { filter: brightness(1.15); }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-strong); }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-danger { background: var(--card); color: var(--red-text); border-color: var(--red-line); }
.btn-danger:hover { background: var(--red-bg); }
.btn-ghost { background: var(--card); color: var(--text-2); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--blue-line); background: var(--bg-soft); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12px; border-radius: 7px; }

/* ---------------- 表格 ---------------- */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
  margin-top: 14px;
  -webkit-overflow-scrolling: touch;
}
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  background: var(--card-2);
  color: var(--text-2);
  font-weight: 600;
  text-align: left;
  padding: 12px 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1;
}
table.data td {
  padding: 12px;
  border-bottom: 1px solid var(--line-2);
  color: var(--text);
  vertical-align: top;
}
table.data tbody tr:hover td, table.data tr:hover td { background: var(--hover); }
table.data tr:last-child td { border-bottom: 0; }
table.data tfoot td { background: var(--card-2); font-weight: 700; border-top: 1px solid var(--line); }
table.data .name { font-weight: 600; color: var(--text); }
table.data .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.empty { text-align: center; color: var(--muted); padding: 44px 0; font-size: 13px; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }

/* ---------------- 标签 ---------------- */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 20px;
  font-size: 12px; line-height: 1.6; white-space: nowrap;
  background: var(--blue-bg); color: var(--blue-strong);
}
.tag.green { background: var(--green-bg); color: var(--green-text); }
.tag.orange { background: var(--orange-bg); color: var(--orange-text); }
.tag.red { background: var(--red-bg); color: var(--red-text); }
.tag.purple { background: var(--purple-bg); color: var(--purple-text); }
.tag.gray { background: var(--gray-bg); color: var(--gray-text); }
.tag.cyan { background: var(--cyan-bg); color: var(--cyan-text); }
.tag.blue { background: var(--blue-bg); color: var(--blue-strong); }

.chip {
  display: inline-block;
  padding: 1px 7px; margin: 2px 3px 0 0;
  border-radius: 6px;
  background: var(--chip-bg); color: var(--chip-text);
  font-size: 12px;
  border: 1px solid var(--chip-line);
}

/* ---------------- 分页 ---------------- */
.pager { display: flex; gap: 6px; align-items: center; margin-top: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pager a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 32px; padding: 0 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 7px;
  color: var(--text-2); text-decoration: none;
}
.pager a:hover { border-color: var(--blue-line); text-decoration: none; }
.pager a.cur { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }

/* ---------------- 表单 ---------------- */
.form-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.form-card h2 {
  font-size: 15px; font-weight: 600; color: var(--text);
  margin-bottom: 16px; padding-left: 10px; border-left: 3px solid var(--blue);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.field { min-width: 0; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.field label .req { color: var(--red); margin-left: 2px; }
.field input[type=text], .field input[type=password], .field input[type=date],
.field input[type=number], .field input[type=search],
.field select, .field textarea, .form-card textarea, .form-card select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--field);
}
.field input:disabled, .field select:disabled { background: var(--bg-soft); color: var(--muted); }
.field textarea, .form-card textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus,
.form-card select:focus, .form-card textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus-ring);
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .8; }

.opt-group { display: flex; flex-wrap: wrap; gap: 8px; }
.opt-group input { display: none; }
.opt-group span {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2);
  background: var(--field);
  cursor: pointer;
  user-select: none;
  transition: all .12s;
}
.opt-group span:hover { border-color: var(--blue-line); background: var(--bg-soft); }
.opt-group input:checked + span {
  background: var(--blue-bg);
  border-color: var(--blue);
  color: var(--blue-strong);
  font-weight: 600;
}
.opt-group.teal input:checked + span {
  background: var(--cyan-bg); border-color: var(--cyan); color: var(--cyan-text);
}
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check-inline input { width: 17px; height: 17px; accent-color: var(--blue); }

.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 4px; }
.form-actions .btn { height: 40px; padding: 0 26px; font-size: 14px; }

/* ---------------- 信息展示 ---------------- */
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 20px; font-size: 13.5px; }
.info-grid .k { color: var(--muted); }
.info-grid .v { color: var(--text); font-weight: 500; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline .item { position: relative; padding: 0 0 20px; }
.timeline .item:last-child { padding-bottom: 0; }
.timeline .item::before {
  content: ''; position: absolute; left: -21px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--blue);
}
.timeline .meta { font-size: 12px; color: var(--muted); }
.timeline .txt { font-size: 14px; color: var(--text); margin-top: 3px; }
.timeline .next { font-size: 12.5px; color: var(--orange-text); background: var(--orange-bg); display: inline-block; padding: 2px 8px; border-radius: 6px; margin-top: 6px; }

/* ---------------- 提示条 ---------------- */
.notice,
.notice-warn {
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-text);
  border-radius: 10px; padding: 10px 14px; font-size: 13px;
  margin-bottom: 14px; line-height: 1.8;
}
.notice:last-child { margin-bottom: 0; }
.notice-ok { background: var(--green-bg); border: 1px solid var(--green-line); color: var(--green-text); }
.notice-err { background: var(--red-bg); border: 1px solid var(--red-line); color: var(--red-text); }
.notice-info { background: var(--blue-bg); border: 1px solid var(--blue-line); color: var(--blue-strong); }
.notice-info a { color: var(--blue-strong); text-decoration: underline; }
code { background: var(--chip-bg); color: var(--text-2); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }

/* ---------------- 登录页 ---------------- */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(37,99,235,.10), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(6,182,212,.10), transparent 45%);
  padding: 20px;
}
.login-page .login-card { margin-top: auto; margin-bottom: auto; }
.login-page .site-foot { width: 100%; flex: 0 0 auto; padding-bottom: 18px; }
.login-card {
  width: 420px; max-width: 100%; background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-hover);
}
.login-card .mark {
  width: 46px; height: 46px; border-radius: 12px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff; font-weight: 700; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.login-card h1 { font-size: 20px; text-align: center; color: var(--text); font-weight: 700; }
.login-card .sub { font-size: 12px; color: var(--muted); text-align: center; margin: 6px 0 26px; letter-spacing: .5px; }
.login-card label { display: block; font-size: 13px; color: var(--text-2); margin: 14px 0 6px; font-weight: 500; }
.login-card input {
  width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 9px;
  padding: 0 12px; font-size: 15px; color: var(--text); font-family: inherit;
  background: var(--field);
}
.login-card input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus-ring); }
.login-card button {
  width: 100%; height: 44px; margin-top: 24px;
  border: 0; border-radius: 9px; cursor: pointer;
  background: var(--blue); color: #fff; font-size: 15px; font-weight: 600; font-family: inherit;
}
.login-card button:hover { background: var(--blue-strong); }
.login-card .err { margin-top: 14px; padding: 9px 12px; background: var(--red-bg); color: var(--red-text); border-radius: 8px; font-size: 13px; text-align: center; }
.login-card .tip { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; }
.login-card .alt-link {
  display: block; margin-top: 12px; text-align: center; height: 42px; line-height: 42px;
  border: 1px solid var(--blue-line); border-radius: 9px;
  background: var(--blue-bg); color: var(--blue-strong); font-weight: 600; text-decoration: none;
}
.login-theme { position: fixed; top: 16px; right: 16px; z-index: 5; }

/* ==========================================================
   响应式：大屏 / 平板 / 手机
   ========================================================== */

/* 移动端卡片式表格 */
@media (max-width: 820px) {
  table.data.cards-mobile { display: block; width: 100%; }
  table.data.cards-mobile thead { display: none; }
  table.data.cards-mobile tbody { display: block; }
  table.data.cards-mobile tr {
    display: block;
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--line);
  }
  table.data.cards-mobile tr:last-child { border-bottom: 0; }
  table.data.cards-mobile tr:first-child { padding-top: 6px; }
  table.data.cards-mobile td {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 5px 0;
    border: 0;
    font-size: 13.5px;
    line-height: 1.5;
    max-width: none !important;
    word-break: break-word;
  }
  table.data.cards-mobile td::before {
    content: attr(data-label);
    flex: 0 0 72px;
    color: var(--muted);
    font-size: 12.5px;
    padding-top: 1px;
  }
  table.data.cards-mobile td.cell-title { display: block; padding: 0 0 8px; border-bottom: 1px dashed var(--line-2); margin-bottom: 4px; }
  table.data.cards-mobile td.cell-title::before { display: none; }
  table.data.cards-mobile td.cell-title .name { font-size: 15px; }
  table.data.cards-mobile td.cell-actions { display: block; padding-top: 10px; }
  table.data.cards-mobile td.cell-actions::before { display: none; }
  table.data.cards-mobile td.cell-actions form { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
  table.data.cards-mobile td.cell-actions .btn {
    flex: 1 1 auto; min-width: 72px; height: 34px; font-size: 13px;
  }
  table.data.cards-mobile td.cell-actions a.btn { flex: 1 1 auto; }
  /* 合计行：手机端改为一行标签流，去掉空 data-label 占位 */
  table.data.cards-mobile tfoot { display: block; background: var(--card-2); border-top: 1px solid var(--line); }
  table.data.cards-mobile tfoot tr { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 14px; border-bottom: 0; }
  table.data.cards-mobile tfoot td {
    display: inline-flex; gap: 4px; align-items: baseline; padding: 0; border: 0;
    background: transparent !important; font-size: 12.5px; font-weight: 700; color: var(--text);
  }
  table.data.cards-mobile tfoot td::before {
    content: attr(data-label); font-weight: 400; color: var(--muted); flex: none;
  }
  table.data.cards-mobile tfoot td:empty { display: none; }
  .table-wrap { overflow: visible; background: transparent; border: 0; box-shadow: none; }
  .table-wrap table.data.cards-mobile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
  .hide-mobile { display: none !important; }
}

@media (max-width: 1400px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .stats-grid.cols-5, .stats-grid.cols-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .panel.span-2 { grid-column: span 2; }
  .container { padding: 16px; }
  .app-header { padding: 0 16px; }
  .tabs { padding: 0 10px; }
}

/* ---------- 平板竖屏 / 手机横屏 ---------- */
@media (max-width: 820px) {
  body { font-size: 14px; }

  .app-header {
    height: auto;
    min-height: 56px;
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .brand { gap: 8px; flex: 1 1 auto; }
  .brand .mark { width: 30px; height: 30px; font-size: 14px; border-radius: 8px; flex: 0 0 30px; }
  .brand h1 { font-size: 14px; line-height: 1.35; letter-spacing: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .brand .en { display: none; }
  .header-right { gap: 6px; font-size: 12px; }
  .header-right .divider, .header-right .clock, .header-right .who { display: none; }
  .header-right .btn { height: 32px; padding: 0 10px; font-size: 12.5px; }
  .theme-toggle { width: 32px; height: 32px; flex: 0 0 32px; }
  .nav-toggle { display: inline-flex; }

  /* 导航改为抽屉 */
  .tabs {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 232px; max-width: 78vw;
    padding: 12px 10px 24px;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(-104%);
    transition: transform .22s ease;
    z-index: 60;
    border-bottom: 0;
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-hover);
  }
  .tabs::before {
    content: '功能导航';
    display: block;
    font-size: 12px;
    color: var(--muted);
    padding: 4px 10px 10px;
    letter-spacing: 1px;
  }
  .tabs a {
    padding: 12px 12px;
    border-bottom: 0;
    border-radius: 9px;
    font-size: 14.5px;
    width: 100%;
  }
  .tabs a.on {
    background: var(--blue-bg);
    color: var(--blue-strong);
    border-color: transparent;
  }
  body.nav-open .tabs { transform: translateX(0); }
  .tabs-mask {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(9, 14, 22, .5);
    z-index: 55;
    -webkit-tap-highlight-color: transparent;
  }
  body.nav-open .tabs-mask { display: block; }
  body.nav-open { overflow: hidden; }

  .container { padding: 12px 12px 26px; }

  /* KPI：两列 */
  .stats-grid, .stats-grid.cols-5, .stats-grid.cols-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px 12px 11px; }
  .stat-card .lbl { font-size: 12px; }
  .stat-card .num { font-size: 24px; }
  .stat-card .num .unit { font-size: 12px; }
  .stat-card .icon { width: 24px !important; height: 24px !important; font-size: 12px !important; top: 10px !important; right: 10px !important; border-radius: 7px !important; }

  /* 图表：单列 */
  .dash-grid { grid-template-columns: 1fr; gap: 10px; margin-top: 10px; }
  .panel.span-2 { grid-column: span 1; }
  .dash-grid .panel { height: 300px; padding: 12px 10px 6px; }
  .dash-grid .panel.tall { height: 320px; }
  .panel-head { margin-bottom: 2px; }
  .panel-title { font-size: 14px; }
  .panel-note { font-size: 11px; }

  /* 大屏头部 */
  .dash-head { margin-bottom: 12px !important; gap: 10px !important; align-items: stretch !important; }
  .dash-head .title { font-size: 16px !important; }
  .dash-head .title small { font-size: 11px !important; }
  .dash-tools { width: 100%; gap: 8px; flex-wrap: wrap; }
  .dash-tools select { flex: 1 1 100%; min-width: 0; width: 100%; }
  .dash-tools .btn { flex: 1 1 auto; }

  /* 筛选：两列网格 */
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
  }
  .filters input[type=text], .filters input[type=search], .filters input[type=date] { grid-column: 1 / -1; }
  .filters input, .filters select, .filters .btn { width: 100%; min-width: 0; height: 38px; font-size: 13px; }
  .filters .btn { padding: 0 8px; }
  .filters select { font-size: 13px; }

  .table-wrap { margin-top: 10px; }

  /* 表单 */
  .form-wrap { max-width: none !important; }
  .form-card { padding: 16px 14px; margin-bottom: 12px; }
  .form-card h2 { font-size: 14.5px; margin-bottom: 14px; }
  .form-grid, .form-grid.cols-3, .info-grid { grid-template-columns: 1fr !important; gap: 12px; }
  .field input[type=text], .field input[type=password], .field input[type=date],
  .field select, .field textarea { font-size: 15px; }
  .opt-group { gap: 7px; }
  .opt-group span { padding: 7px 11px; font-size: 12.5px; }
  .form-actions { flex-direction: row-reverse; flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 40%; height: 42px; padding: 0 12px; }
  .form-head { flex-wrap: wrap; gap: 6px; }
  .form-head h1 { font-size: 16px !important; }

  .panel-title, table.data th { font-size: 13px; }
  .pager { justify-content: center; padding-bottom: 6px; }
  .latest-list td, .latest-list th { padding: 8px 6px !important; }
  .notice { font-size: 12.5px; }
}

/* ---------- 手机 ---------- */
@media (max-width: 480px) {
  .app-header { min-height: 52px; padding: 7px 10px; }
  .brand h1 { font-size: 13px; }
  .brand .mark { width: 28px; height: 28px; flex: 0 0 28px; font-size: 13px; }
  .header-right .btn { height: 30px; padding: 0 8px; font-size: 12px; }
  .theme-toggle, .nav-toggle { width: 30px; height: 30px; flex: 0 0 30px; }

  .stats-grid, .stats-grid.cols-5, .stats-grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 11px 10px 10px; }
  .stat-card .lbl { font-size: 11.5px; }
  .stat-card .num { font-size: 22px; }
  .stat-card .sub { font-size: 11px; }
  .stat-card .icon { display: none; }
  .dash-grid .panel { height: 282px; }
  .dash-head .title { font-size: 15px !important; }
  .dash-head .title small { display: none; }
  .panel-note { display: none; }
  table.data.cards-mobile td::before { flex-basis: 66px; }
  .container { padding: 10px 10px 24px; }
  .site-foot { font-size: 11.5px; line-height: 1.8; padding: 16px 12px 22px; }
  .form-card { padding: 14px 12px; }
  .filters { padding: 10px; }
  .latest-list { font-size: 12px; }
}

/* 移动端图表替代清单 */
.mini-stats { display: none; }
@media (max-width: 820px) {
  .mini-stats { display: block; padding: 4px 4px 0; }
  .mini-stats .grp { margin-bottom: 8px; }
  .mini-stats .grp-t { font-size: 12px; color: var(--muted); margin-bottom: 1px; }
  .mini-stats .row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 0; border-bottom: 1px dashed var(--line-2); font-size: 13.5px;
  }
  .mini-stats .row:last-child { border-bottom: 0; }
  .mini-stats .k { display: flex; align-items: center; gap: 7px; color: var(--text); }
  .mini-stats .k i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
  .mini-stats .v { font-weight: 600; color: var(--text); font-family: Consolas, monospace; }
  .mini-stats .v small { font-weight: 400; color: var(--muted); margin-left: 3px; font-family: inherit; }
}

/* ---------------- 底部版权与备案 ---------------- */
.site-foot {
  text-align: center;
  padding: 20px 16px 28px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.9;
}
.site-foot .bh { margin-top: 1px; }
.site-foot .bh a {
  color: var(--muted);
  text-decoration: none;
  transition: color .15s;
}
.site-foot .bh a:hover { color: var(--blue); text-decoration: underline; }
.site-foot .bh .sep { margin: 0 7px; color: var(--line); opacity: .9; }

@media print {
  .app-header, .tabs, .nav-toggle, .theme-toggle, .tabs-mask { display: none !important; }
  body { background: #fff; }
  .site-foot { color: #6b7280; }
}
