/* ==========================================================================
   森林火情监测系统 · 设计系统实现
   依据：MASTER.md（UIUX Pro Max + Apple HIG）
   结构：1 token / 2 基础 / 3 布局 / 4 组件 / 5 页面网格 / 6 响应式 / 7 可访问性
   ========================================================================== */

/* ---------- 1. Design Tokens ---------- */
:root {
  /* 中性色 */
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-muted: #f2f2f7;
  --surface-sunken: #ebebf0;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;        /* 仅大字号/装饰 */
  --border: rgba(60, 60, 67, 0.12);
  --border-strong: #c7c7cc;
  --control-border: #8e8e93;
  --separator: #e5e5ea;

  /* 品牌与语义 */
  --accent: #ff3b30;               /* 图形/大字 */
  --accent-strong: #d70015;        /* 按钮/链接/AA 红字 */
  --accent-hover: #b80012;
  --accent-active: #a3000f;
  --accent-soft: #ffe5e3;
  --accent-text: #b3261e;
  --success: #1f7a33;
  --success-soft: #e7f8ec;
  --warning: #8a5a00;
  --warning-soft: #fff4cc;
  --info: #0066cc;
  --info-soft: #e8f1ff;
  --focus: #007aff;

  /* 排版 */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 28px;
  --text-4xl: 34px;
  --kpi-xl: 44px;

  /* 间距（8pt） */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* 圆角 / 阴影 */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 999px;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 24px 80px rgba(0, 0, 0, 0.18);

  /* 动效 */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 300ms;

  --sidebar-w: 264px;
  --topbar-h: 56px;
  --page-max: 1440px;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--info); text-underline-offset: 3px; }
a:hover { text-decoration: underline; }

h1, h2, h3, p, dl, dd, dt, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { letter-spacing: -0.01em; }
.muted { color: var(--text-secondary); }
.divider { height: 1px; background: var(--separator); border: 0; }

/* 状态圆点（全局） */
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.dot.hollow { background: transparent; border: 1.5px solid currentColor; }

/* 焦点：键盘可见，鼠标不打扰 */
:where(a, button, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:where(input, select, textarea):focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.18);
}

/* 屏幕阅读器专用 */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  transform: translateY(-160%);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: var(--shadow-md);
  transition: transform var(--dur-fast) var(--ease);
}
.skip-link:focus { transform: translateY(0); text-decoration: none; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.16);
  border-radius: var(--radius-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 3. 布局骨架 ---------- */
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 20px;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.brand-mark svg { width: 20px; height: 20px; color: var(--accent); }
.brand-name { display: block; font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.brand-sub {
  display: block;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-top: 2px;
}

.nav { flex: 1; overflow-y: auto; padding: 0 12px 12px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  color: #3a3a3c;
  text-decoration: none;
  font-size: var(--text-base);
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-item:hover { background: var(--surface-muted); text-decoration: none; }
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: 0.75; }
.nav-item[aria-current="page"] { background: var(--surface-muted); color: var(--text); font-weight: 600; }
.nav-item[aria-current="page"] svg { opacity: 1; color: var(--accent); }
.nav-item .nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: auto;
  background: var(--accent);
}

.sidebar-foot { padding: 12px 12px 20px; }
.sidebar-status {
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  padding: 12px 14px;
}
.sidebar-status .row { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: #3a3a3c; }
.sidebar-status .meta { margin-top: 6px; font-size: var(--text-2xs); color: var(--text-secondary); line-height: 1.6; }

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}
.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--sp-8);
}

/* 移动端顶栏 / 抽屉遮罩（桌面隐藏） */
.mobile-topbar { display: none; }
.drawer-overlay { display: none; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-6);
}
.page-title {
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.page-sub { margin-top: 4px; color: var(--text-secondary); font-size: var(--text-sm); }
.page-actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.page-head > .pill { margin-left: auto; }

/* ---------- 4. 组件 ---------- */

/* 卡片 */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card-clickable { transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.card-clickable:hover { box-shadow: var(--shadow-md); }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.card-title { font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em; }
.card-sub { font-size: var(--text-xs); color: var(--text-secondary); }
.card-body { min-width: 0; }

/* KPI */
.kpi { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; padding: 18px 20px; }
.kpi-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--text-xs); color: var(--text-secondary); }
.kpi-value { font-family: var(--font-mono); font-size: var(--kpi-xl); line-height: 1.05; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: var(--text-2xs); color: var(--text-secondary); }
.kpi-value.is-accent { color: var(--accent-strong); }
.kpi-value.is-warning { color: var(--warning); }
.kpi-value.is-success { color: var(--success); }
.kpi-value.is-info { color: var(--info); }
.kpi-value.is-neutral { color: var(--text-secondary); }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary { background: var(--accent-strong); color: #fff; }
.btn-primary:hover:not([disabled]) { background: var(--accent-hover); }
.btn-primary:active:not([disabled]) { background: var(--accent-active); }

.btn-secondary { background: var(--surface-muted); color: var(--text); }
.btn-secondary:hover:not([disabled]) { background: #e8e8ed; }

.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover:not([disabled]) { background: var(--surface-muted); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not([disabled]) { background: #1a6a2c; }

.btn-selected { background: #1d1d1f; color: #fff; }
.btn-selected:hover:not([disabled]) { background: #000; }

.btn-danger-ghost { background: transparent; color: var(--accent-text); }
.btn-danger-ghost:hover:not([disabled]) { background: var(--accent-soft); }

.btn-sm { min-height: 32px; padding: 0 12px; font-size: var(--text-sm); border-radius: 10px; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; }
.btn-block { width: 100%; }

/* 输入 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: var(--text-xs); font-weight: 500; color: var(--text-secondary); }
.field-hint { font-size: var(--text-xs); color: var(--text-secondary); line-height: 1.6; overflow-wrap: anywhere; }
.field-hint .mono { overflow-wrap: anywhere; word-break: break-word; }
.field-error { font-size: var(--text-xs); color: var(--accent-text); }

.input, .select, .textarea {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-base);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.textarea { padding: 10px 12px; min-height: 96px; resize: vertical; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg fill='none' stroke='%236e6e73' stroke-width='2' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 34px;
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--accent-strong);
}

/* 状态标签 */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill .dot.hollow { background: transparent; border: 1.5px solid currentColor; }
.pill-pending { background: var(--warning-soft); color: var(--warning); }
.pill-confirmed { background: var(--accent-soft); color: var(--accent-text); }
.pill-false { background: var(--surface-muted); color: var(--text-secondary); }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-neutral { background: var(--surface-muted); color: var(--text-secondary); }
.pill-live { background: var(--success-soft); color: var(--success); }
.pill-live .dot { animation: live-pulse 2s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* 提示条 */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: var(--text-sm);
  line-height: 1.6;
}
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-danger { background: var(--accent-soft); color: var(--accent-text); }

/* 表格 */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.table-wrap:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); min-width: 760px; }
.table caption { text-align: left; }
.table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--separator);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid #f0f0f3; vertical-align: middle; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafafc; }
.table .cell-actions { text-align: right; white-space: nowrap; }
.table .cell-actions .btn + .btn { margin-left: 6px; }

/* 缩略图按钮 */
.thumb-btn {
  border: 0;
  padding: 0;
  background: #0b0b0d;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: zoom-in;
  display: block;
}
.thumb-btn img { width: 92px; height: 52px; object-fit: cover; transition: transform var(--dur) var(--ease); }
.thumb-btn:hover img { transform: scale(1.04); }

/* 帧墙 */
.frame-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--sp-3); }
.frame-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0b0b0d;
  text-decoration: none;
}
.frame-thumb:hover { text-decoration: none; }
.frame-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--dur-slow) var(--ease); }
.frame-thumb:hover img { transform: scale(1.04); }
.frame-meta {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 10px 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
  color: #fff;
  font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums;
}
.frame-badge {
  position: absolute;
  top: 8px;
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.frame-badge.left { left: 8px; }
.frame-badge.right { right: 8px; }

/* 空态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
}
.empty-state .empty-title { font-size: var(--text-base); font-weight: 600; color: var(--text); }
.empty-state .empty-hint { font-size: var(--text-sm); color: var(--text-secondary); max-width: 46ch; }
.empty-state svg { width: 32px; height: 32px; color: var(--text-tertiary); margin-bottom: 4px; }

/* 视频 */
.video-shell {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0b0b0d;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-shell img { width: 100%; height: 100%; object-fit: contain; display: none; }
.video-shell.live img { display: block; }
.video-shell.live .video-placeholder { display: none; }
.video-placeholder { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px; text-align: center; color: #c7c7cc; }
.video-placeholder svg { width: 44px; height: 44px; opacity: 0.6; }
.video-placeholder .vp-title { font-size: var(--text-base); color: #e5e5ea; }
.video-placeholder .vp-hint { font-size: var(--text-xs); color: #a1a1a6; max-width: 90%; }

/* 仪表/详情列表 */
.detail-list { display: flex; flex-direction: column; gap: 10px; }
.detail-list .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: var(--text-sm); }
.detail-list dt { color: var(--text-secondary); }
.detail-list dd { font-weight: 500; text-align: right; }

/* 最近检测 / 待确认列表 */
.mini-list { display: flex; flex-direction: column; gap: 8px; }
.mini-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  margin: 0 -6px;
  border-radius: var(--radius-md);
  color: inherit;
  text-decoration: none;
}
.mini-item:hover { background: #fafafc; text-decoration: none; }
.mini-item img { width: 56px; height: 36px; border-radius: var(--radius-sm); object-fit: cover; background: #0b0b0d; flex: none; }
.mini-item .mini-title { font-size: var(--text-sm); font-weight: 500; }
.mini-item .mini-meta { font-size: var(--text-2xs); color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.32);
}
.modal-mask.open { display: flex; }
.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: var(--sp-6);
  box-shadow: var(--shadow-lg);
}
.modal-wide { max-width: 960px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--sp-5); }
.modal-title { font-size: var(--text-lg); font-weight: 600; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: var(--sp-6); }
body.modal-open { overflow: hidden; }

/* Toast */
#toast-wrap {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(92vw, 560px);
  pointer-events: none;
}
.toast {
  background: rgba(29, 29, 31, 0.94);
  color: #fff;
  font-size: var(--text-sm);
  padding: 10px 16px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  animation: toast-in var(--dur) var(--ease);
}
.toast.err { background: rgba(179, 38, 30, 0.96); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* 图表 */
.chart { width: 100%; min-height: 220px; }
.chart-wrap { position: relative; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  pointer-events: none;
}
.chart-empty.show { display: flex; }

/* 表格内置信度 */
.conf { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* 筛选页签 */
.seg { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* 移动端表格滚动提示 */
.table-scroll-hint { display: none; padding: 12px 16px 8px; color: var(--text-secondary); font-size: var(--text-xs); }

/* 电量条 */
.battery { display: flex; align-items: center; gap: 8px; min-width: 96px; }
.battery-track { width: 64px; height: 6px; border-radius: var(--radius-full); background: var(--surface-muted); overflow: hidden; }
.battery-fill { height: 100%; border-radius: var(--radius-full); }
.battery-fill.good { background: var(--success); }
.battery-fill.warn { background: var(--warning); }
.battery-fill.low { background: var(--accent-strong); }

/* ---------- 5. 页面网格 ---------- */
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--sp-5); }
.span-8 { grid-column: span 8; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-12 { grid-column: span 12; }

.kpi-stack { display: grid; grid-template-rows: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); }
.charts-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-5); }
.stats-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-5); }
.stats-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-5); }
.cards-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5); }

.monitor-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--sp-5); }
.monitor-main { grid-column: span 8; }
.monitor-side { grid-column: span 4; display: flex; flex-direction: column; gap: var(--sp-5); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.toolbar .spacer { flex: 1; }
.area-group { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 6. 响应式 ---------- */
@media (max-width: 1279px) {
  :root { --sidebar-w: 240px; }
  .grid-12 { gap: var(--sp-4); }
  .span-8, .span-4 { grid-column: span 12; }
  .kpi-stack { grid-template-rows: none; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); }
  .monitor-main, .monitor-side { grid-column: span 12; }
  .charts-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts-row > :last-child { grid-column: span 2; }
  .frame-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page { padding: var(--sp-6); }
}

@media (max-width: 1023px) {
  .sidebar {
    width: 280px;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    transform: translateX(-100%);
    transition: transform var(--dur-slow) var(--ease);
    box-shadow: none;
    z-index: 45;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; padding-top: var(--topbar-h); }
  .mobile-topbar {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--topbar-h);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .mobile-topbar .mobile-title { font-size: var(--text-base); font-weight: 600; }
  .mobile-topbar .mobile-sub { font-size: 10px; letter-spacing: 0.1em; color: var(--text-secondary); text-transform: uppercase; }
  .drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(0, 0, 0, 0.32);
    display: none;
  }
  .drawer-overlay.show { display: block; }
  .btn, .input, .select, .textarea, .nav-item { min-height: 44px; }
  .btn-sm { min-height: 44px; }
  .kpi-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards-2 { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .charts-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts-row > :last-child { grid-column: span 2; }
  .page { padding: var(--sp-5) var(--sp-4); }
  .page-title { font-size: var(--text-2xl); }
}

@media (max-width: 767px) {
  .charts-row { grid-template-columns: 1fr; }
  .charts-row > :last-child { grid-column: auto; }
  .frame-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  .page { padding: var(--sp-4); }
  .page-head { align-items: flex-start; }
  .page-title { font-size: var(--text-2xl); }
  .card { padding: var(--sp-4); }
  .kpi-value { font-size: 34px; }
  .stats-3 { grid-template-columns: 1fr; }
  .stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar .spacer { display: none; }
  .toolbar .toolbar-actions { width: 100%; justify-content: flex-end; }
  .modal { padding: var(--sp-4); }
  .table { min-width: 720px; }
  .table-scroll-hint { display: block; }
}

@media (max-width: 480px) {
  .page-title { font-size: 22px; }
  .kpi-value { font-size: 30px; }
  .kpi { padding: 14px 16px; }
  .btn:not(.btn-sm) { padding: 0 12px; }
  .frame-grid { gap: 8px; }
}

/* ---------- 7. 动效可访问性 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .pill-live .dot { animation: none; }
}
