/* ==========================================================================
   道路救援 · 设计系统统一层（v3 / 2026-10）
   --------------------------------------------------------------------------
   目的：把历史上两套并行的写法（老版 ui.css 的 page-header / stat-card /
   toolbar / tab-btn / badge，与救援模块 rescue.css 的 r-page-head / r-kpi /
   r-toolbar / r-tab / r-badge）收敛成同一套视觉，改样式只需改这一个文件。

   本文件必须最后加载（在各页面 </head> 前），通过同级选择器 + 后加载覆盖。
   规则约定：
     · 颜色一律走 CSS 变量（支持深色主题）
     · 字号只用 --fs-* 档位，控件高度只用 --ctl-h*
     · 圆角只用 --r-*，间距只用 --sp-*
   禁止在页面里再写 style="color:#xxx" 这类硬编码（语义色用 .text-*）。
   ========================================================================== */

:root {
  /* ---- 品牌色 ---- */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #eef2ff;
  --primary-ink: #4338ca;
  --brand-grad: linear-gradient(120deg, #4f46e5, #7c3aed 62%, #6366f1);

  /* ---- 语义色 ---- */
  --success: #10b981;
  --success-ink: #047857;
  --warning: #f59e0b;
  --warning-ink: #b45309;
  --danger: #ef4444;
  --danger-ink: #b91c1c;
  --info: #0ea5e9;
  --info-ink: #0369a1;

  /* ---- 表面 / 线条 / 文字 ---- */
  --bg: #f5f7fb;
  --card: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --line: #e6eaf2;
  --border: var(--line);
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;

  /* ---- 圆角 / 阴影 / 间距 ---- */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 14px;
  --radius: var(--r-md);
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 18px rgba(15, 23, 42, .05);
  --shadow-hover: 0 10px 26px rgba(79, 70, 229, .12);
  --ring: 0 0 0 3px rgba(99, 102, 241, .16);

  /* ---- 字号 ---- */
  --fs-2xs: 11px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 22px;
  --fs-kpi: 26px;

  /* ---- 控件 ---- */
  --ctl-h: 34px;
  --ctl-h-sm: 28px;
  --topbar-h: 56px;
  --shell-w: 232px;
  --shell-w-mini: 64px;
}

/* ==========================================================================
   1. 基础排版
   ========================================================================== */
body {
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  font-size: var(--fs-md);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5 { font-weight: 700; line-height: 1.3; color: var(--text); letter-spacing: 0; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p { margin: 0; }
small, .text-xs { font-size: var(--fs-xs); }
a { color: var(--primary-ink); text-decoration: none; }
a:hover { color: var(--primary-dark); }
code, kbd, samp {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em;
  background: var(--surface-3);
  color: #334155;
  border-radius: var(--r-xs);
  padding: 1px 5px;
}
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-3) 0; }
.layout, .app-layout { display: flex; min-height: 100vh; }
/* flex 子项默认 min-width:auto，宽表格会把整页撑出横向滚动条 */
.layout > .main, .app-layout > .main { min-width: 0; }
.layout > *, .app-layout > * { min-width: 0; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger-ink); }
.text-warn { color: var(--warning-ink); }
.text-ok { color: var(--success-ink); }
.mono { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   2. 页头（page-header ≡ r-page-head）
   ========================================================================== */
/* 只有「标题+说明」的老页面保持块状堆叠；带操作区的自动变成左右两端对齐 */
.page-header,
.r-page-head {
  display: block;
  margin: 0 0 var(--sp-4);
  padding: 0;
}
.page-header:has(> div),
.r-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-4);
  flex-wrap: wrap;
}
.page-header h1, .page-header h2,
.r-page-head h1, .r-page-head h2 {
  margin: 0;
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.page-header p, .page-header .sub,
.r-page-head p, .r-page-head .sub {
  margin: 5px 0 0;
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.6;
}
.page-header > div:last-child:not(:first-child),
.r-page-head > div:last-child:not(:first-child) { flex: 0 1 auto; max-width: 100%; }
@media (max-width: 720px) {
  .page-header:has(> div), .r-page-head { align-items: flex-start; }
  .page-header > div:last-child:not(:first-child),
  .r-page-head > div:last-child:not(:first-child) { flex: 1 1 100%; }
}
@media (max-width: 720px) {
  .page-header:has(> div), .r-page-head { align-items: flex-start; }
  .page-header h1, .page-header h2, .r-page-head h1, .r-page-head h2 { font-size: var(--fs-xl); }
}

/* ==========================================================================
   3. 卡片
   ========================================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-4) 18px;
  margin: 0 0 var(--sp-3);
  box-shadow: var(--shadow);
}
.card > .card-title:first-child { margin-top: 0; }
.card-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--sp-3);
}
/* 卡片内直接放表格时取消内边距，避免表格四周发虚 */
.card:has(> .r-table-wrap),
.card:has(> .table-wrap) { padding: 0; overflow: hidden; }
/* 同一个 div 既是卡片又是表格容器（老写法 card table-wrap） */
.card.table-wrap, .card.r-table-wrap { padding: 0; overflow: auto; }
.card:has(> .r-table-wrap) > .card-title,
.card:has(> .table-wrap) > .card-title { padding: var(--sp-4) 18px 0; margin-bottom: var(--sp-3); }
.card:has(> .r-table-wrap) > .r-toolbar,
.card:has(> .table-wrap) > .toolbar { padding: 0 18px; }
.card:has(> .r-toolbar) > .card-title { margin-bottom: var(--sp-2); }
.card.drill-card { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.card.drill-card:hover { border-color: #c7d2fe; box-shadow: var(--shadow-hover); }

/* ==========================================================================
   4. 指标卡（stat-card ≡ r-kpi）：统一「标题在上、数值在下、左对齐」
   ========================================================================== */
.r-kpis,
.stat-grid,
.grid-4.auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.stat-card,
.r-kpi {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  box-shadow: none;
  min-width: 0;
  color: inherit;
}
.stat-card .lbl,
.r-kpi .k {
  order: -1;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  margin: 0;
  letter-spacing: .01em;
}
.stat-card .val,
.r-kpi .v {
  font-size: var(--fs-kpi);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin: 0;
}
.r-kpi .v small, .stat-card .val small {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
  letter-spacing: 0;
}
.r-kpi.warn .v, .stat-card.warn .val { color: var(--warning-ink); }
.r-kpi.bad .v, .stat-card.bad .val { color: var(--danger-ink); }
.r-kpi.good .v, .stat-card.good .val { color: var(--success-ink); }
.r-kpi.info .v, .stat-card.info .val { color: var(--info-ink); }
.stat-card.highlight {
  background: var(--brand-grad);
  border-color: transparent;
}
.stat-card.highlight .val, .stat-card.highlight .lbl { color: #fff; }
.stat-card.highlight .lbl { opacity: .9; }
.r-kpi.drill, .stat-card.drill {
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  text-decoration: none;
}
.r-kpi.drill:hover, .stat-card.drill:hover {
  border-color: #c7d2fe;
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}
.r-kpi .drill-arrow, .stat-card .drill-arrow {
  font-style: normal;
  font-size: var(--fs-xs);
  color: var(--primary);
  opacity: .7;
  margin-left: auto;
}
@media (max-width: 560px) {
  .r-kpis, .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card .val, .r-kpi .v { font-size: 22px; }
}

/* ==========================================================================
   5. 工具栏 / 筛选条（toolbar ≡ r-toolbar）
   ========================================================================== */
.toolbar,
.r-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin: 0 0 var(--sp-3);
  padding: 0;
  background: none;
  border: 0;
}
.toolbar > input, .toolbar > select,
.r-toolbar > input, .r-toolbar > select { min-width: 0; }
.toolbar > .grow, .r-toolbar > .grow,
.toolbar > .r-hint:last-child { margin-left: auto; }
.toolbar .r-hint { color: var(--muted); font-size: var(--fs-xs); }
@media (max-width: 720px) {
  .toolbar > input, .toolbar > select,
  .r-toolbar > input, .r-toolbar > select { flex: 1 1 150px; }
}

/* ==========================================================================
   6. 标签页（tab-btn ≡ r-tab）
   ========================================================================== */
.tabs,
.r-tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin: 0 0 var(--sp-3);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar, .r-tabs::-webkit-scrollbar { display: none; }
.tab-btn,
.r-tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 9px 14px;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover,
.r-tab:hover { color: var(--text); }
.tab-btn.active,
.r-tab.active,
.tab-btn.is-on,
.r-tab.is-on {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
}

/* ==========================================================================
   7. 按钮：只保留「实心主色 / 描边次按钮 / 幽灵 / 语义浅色」四级
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--ctl-h);
  min-height: var(--ctl-h);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { border-color: #c7d2fe; color: var(--primary-dark); background: #f8faff; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-outline { background: var(--surface); border-color: var(--line); color: var(--text-2); }
.btn-outline:hover:not(:disabled) { border-color: #c7d2fe; color: var(--primary-dark); background: #f8faff; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--primary-dark); }
.btn-ghost:hover:not(:disabled) { background: var(--primary-light); border-color: transparent; color: var(--primary-ink); }

.btn-success { background: #ecfdf5; border-color: #a7f3d0; color: var(--success-ink); }
.btn-success:hover:not(:disabled) { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }

.btn-warning { background: #fffbeb; border-color: #fde68a; color: var(--warning-ink); }
.btn-warning:hover:not(:disabled) { background: #fef3c7; border-color: #fcd34d; color: #92400e; }

.btn-danger { background: #fef2f2; border-color: #fecaca; color: var(--danger-ink); }
.btn-danger:hover:not(:disabled) { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

.btn-sm {
  height: var(--ctl-h-sm);
  min-height: var(--ctl-h-sm);
  padding: 0 10px;
  font-size: var(--fs-xs);
  border-radius: var(--r-xs);
}
.btn-block { width: 100%; }
td .btn, th .btn { vertical-align: middle; }
td .btn + .btn { margin-left: 6px; }
/* 控制高度统一：表格外一律标准高度，紧凑尺寸只用于表格行内 */
.toolbar .btn-sm,
.r-toolbar .btn-sm,
.r-actions .btn-sm,
.page-header .btn-sm,
.r-page-head .btn-sm,
.drill-bar .btn-sm {
  height: var(--ctl-h);
  min-height: var(--ctl-h);
  padding: 0 14px;
  font-size: var(--fs-sm);
  border-radius: var(--r-sm);
}

/* ==========================================================================
   8. 徽标 / 状态（badge ≡ r-badge）
   ========================================================================== */
.badge,
.r-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  line-height: 1.65;
  white-space: nowrap;
  background: var(--surface-3);
  color: #475569;
}
.badge-gray, .r-badge.gray { background: #f1f5f9; color: #475569; }
.badge-blue, .r-badge.blue { background: #e0e7ff; color: var(--primary-ink); }
.badge-indigo, .r-badge.indigo { background: #e0e7ff; color: var(--primary-ink); }
.badge-green, .r-badge.green { background: #dcfce7; color: #15803d; }
.badge-yellow, .badge-warn, .r-badge.yellow { background: #fef3c7; color: var(--warning-ink); }
.badge-red, .badge-danger, .r-badge.red { background: #fee2e2; color: var(--danger-ink); }
.badge-purple, .r-badge.purple { background: #ede9fe; color: #6d28d9; }
.badge-cyan, .r-badge.cyan { background: #cffafe; color: #0e7490; }
.badge-orange, .r-badge.orange, .r-badge.warn { background: #ffedd5; color: #c2410c; }
.badge-danger, .r-badge.danger { background: #fee2e2; color: var(--danger-ink); }
.r-badge.outline { background: transparent; border: 1px solid var(--line); color: var(--text-2); }

/* 页头操作区：统一为标准高度，避免 btn 与 btn-sm 混排高低不齐 */
.r-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.page-header .r-actions .btn,
.r-page-head .r-actions .btn,
.page-header > div:last-child > .btn,
.r-page-head > div:last-child > .btn {
  height: var(--ctl-h);
  min-height: var(--ctl-h);
  padding: 0 14px;
  font-size: var(--fs-sm);
  border-radius: var(--r-sm);
}

/* ==========================================================================
   9. 表格（table ≡ r-table）
   ========================================================================== */
.table-wrap,
.r-table-wrap {
  overflow: auto;
  border-radius: var(--r-md);
  -webkit-overflow-scrolling: touch;
}
table,
.r-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
th,
.r-table th {
  padding: 10px;
  text-align: left;
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}
td,
.r-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  line-height: 1.55;
}
tbody tr:last-child td,
.r-table tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td,
.r-table tbody tr:hover td,
.r-table tbody tr:hover { background: #f8faff; }
.num, .r-table .num, .r-table td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td a { font-weight: 600; }
td code { white-space: nowrap; }
tr.drill-row { cursor: pointer; }
.r-table tr.hit, table tr.hit { background: #eef2ff !important; box-shadow: inset 3px 0 0 var(--primary); }
/* 表格内次要信息统一为浅灰小字 */
td .r-hint, td .form-hint { font-size: var(--fs-xs); color: var(--muted); }

/* 分页 */
.r-pager {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.r-pager .grow { flex: 1; }
.r-pager button {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-family: inherit;
  cursor: pointer;
}
.r-pager button:hover:not(:disabled) { border-color: #c7d2fe; color: var(--primary-dark); }
.r-pager button.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.r-pager button:disabled { opacity: .4; cursor: default; }
.r-pager select { height: 28px; min-height: 28px; padding: 0 6px; font-size: var(--fs-xs); }

/* ==========================================================================
   10. 表单控件
   ========================================================================== */
input:not([type=checkbox]):not([type=radio]):not([type=file]),
select,
textarea,
.input {
  font-family: inherit;
  font-size: var(--fs-md);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0 10px;
  height: var(--ctl-h);
  min-height: var(--ctl-h);
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 84px; padding: 8px 10px; line-height: 1.6; resize: vertical; }
select { padding-right: 26px; }
input:focus, select:focus, textarea:focus, .input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, .12); }
input::placeholder, textarea::placeholder { color: #94a3b8; }
input[type=checkbox], input[type=radio] { width: 15px; height: 15px; min-height: 0; margin: 0; padding: 0; accent-color: var(--primary); cursor: pointer; vertical-align: -2px; }

label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.form-group { margin-bottom: var(--sp-3); }
.form-group label { display: block; margin-bottom: 5px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.form-group input, .form-group select, .form-group textarea { width: 100%; }
.form-hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; line-height: 1.55; font-weight: 400; }
.req::after { content: ' *'; color: var(--danger); font-weight: 700; }
.field-readonly {
  padding: 0 10px;
  height: var(--ctl-h);
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.field-label { font-size: var(--fs-xs); color: var(--muted); margin-bottom: 4px; font-weight: 600; }

/* 弹层内表单栅格 */
.r-form { display: grid; gap: var(--sp-3); }
.r-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.r-form label.rf, .r-form .r-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  min-width: 0;
}
.r-form label.rf > span:first-child { color: var(--text-2); }
.r-form label.rf.span2, .r-form .r-field.span2 { grid-column: 1 / -1; }
.r-form .r-checks { display: flex; gap: 16px; align-items: center; min-height: var(--ctl-h); }
.r-form .r-checks label { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.ui-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3) var(--sp-4); }
.ui-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ui-field.span2 { grid-column: 1 / -1; }
.ui-field label { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.ui-field-hint { font-size: var(--fs-2xs); color: var(--muted); font-weight: 400; }
@media (max-width: 620px) {
  .ui-form-grid, .r-form .row { grid-template-columns: 1fr; }
}

/* ==========================================================================
   11. 弹层 / 抽屉
   ========================================================================== */
.modal-overlay,
.r-drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .42);
  display: flex;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn .18s;
}
.modal-overlay { align-items: center; justify-content: center; }
.r-drawer-mask { padding: 0; justify-content: flex-end; }
.r-drawer-mask:has(.r-modal) { justify-content: center; align-items: center; padding: 16px; }

.modal, .r-modal {
  position: relative;
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .24);
  max-height: 90vh;
  overflow-y: auto;
  margin: auto;
  animation: slideUp .2s;
  transition: max-width .16s ease, width .16s ease, height .16s ease;
}
.modal { width: 100%; max-width: 560px; }
.r-modal { width: 92vw; max-width: 960px; }
.modal h3, .modal-head h3,
.r-modal-head h2, .r-modal-head h3, .r-modal h2 {
  font-size: var(--fs-lg);
  font-weight: 700;
  margin: 0 0 var(--sp-3);
  color: var(--text);
  letter-spacing: 0;
}
.modal-body { font-size: var(--fs-sm); color: var(--text-2); }
.modal-foot, .r-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}
.r-modal-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.r-modal-head h2 { flex: 1; margin: 0; }
.modal-head { display: flex; align-items: center; gap: var(--sp-2); }
.modal-head h3 { flex: 1; margin: 0 0 var(--sp-3); }

.modal.is-max, .r-modal.is-max {
  width: 96vw !important;
  max-width: 96vw !important;
  height: 92vh;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal.is-max .modal-body, .modal.is-max .ui-form,
.r-modal.is-max .r-form { flex: 1; overflow: auto; align-content: start; }

.r-drawer {
  position: relative;
  width: min(860px, 96vw);
  height: 100%;
  background: var(--card);
  padding: 18px 20px 40px;
  overflow-y: auto;
  box-shadow: -14px 0 40px rgba(15, 23, 42, .18);
  animation: slideRight .2s;
}
.r-drawer.is-max { width: 96vw; }
.r-drawer.is-max .body { max-width: 1280px; margin: 0 auto; width: 100%; }
.r-drawer h2 { margin: 0 0 6px; font-size: var(--fs-lg); font-weight: 700; }
.r-drawer .close-x, .r-modal-head .close-x, .x-btn {
  border: 0;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: var(--r-xs);
  font-family: inherit;
}
.r-drawer .close-x:hover, .r-modal-head .close-x:hover, .x-btn:hover { background: var(--surface-3); color: var(--text); }
.r-drawer .close-x { float: right; }
.win-tools { display: flex; gap: 2px; margin-left: auto; align-items: center; }
.win-tools .wt {
  width: 26px; height: 26px;
  border: 0; border-radius: var(--r-xs);
  background: transparent; color: #94a3b8;
  cursor: pointer; font-size: 14px; line-height: 1;
}
.win-tools .wt:hover { background: var(--surface-3); color: var(--text); }
.ui-max {
  position: absolute; top: 10px; right: 44px; z-index: 3;
  width: 26px; height: 26px; border: 0; border-radius: var(--r-xs);
  background: transparent; color: #94a3b8; cursor: pointer; font-size: 14px; line-height: 1;
}
.ui-max:hover { background: var(--surface-3); color: var(--text); }
@media (max-width: 900px) {
  .r-drawer { width: 100vw; }
  .r-modal { width: 96vw; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ==========================================================================
   12. 空态 / 加载 / 提示
   ========================================================================== */
.empty, .r-empty, .empty-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-sm);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  background: #fcfdff;
}
.empty .icon, .empty-state .icon { font-size: 30px; display: block; margin-bottom: var(--sp-2); }
.empty-state p { font-size: var(--fs-sm); margin: 0; }
.card > .empty, .card > .r-empty, .card > .empty-state { margin: 0; border: 0; border-radius: 0; }

.alert {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-3);
  border: 1px solid transparent;
  line-height: 1.6;
}
.alert-info { background: #eff6ff; color: var(--info-ink); border-color: #bfdbfe; }
.alert-warn { background: #fffbeb; color: var(--warning-ink); border-color: #fde68a; }
.alert-error, .alert-danger { background: #fef2f2; color: var(--danger-ink); border-color: #fecaca; }
.alert-success { background: #ecfdf5; color: var(--success-ink); border-color: #a7f3d0; }

.drill-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  background: linear-gradient(90deg, #eef2ff, #f8fafc);
  border: 1px solid #e0e7ff;
  border-radius: var(--r-md);
  padding: 8px 12px;
  margin-bottom: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--primary-ink);
}
.drill-bar .tag {
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: var(--fs-2xs);
  font-weight: 700;
}
.drill-bar .pos { font-variant-numeric: tabular-nums; font-weight: 600; }
.drill-bar .grow { flex: 1; }
.drill-bar button, .drill-bar a {
  border: 1px solid #c7d2fe;
  background: #fff;
  color: var(--primary-ink);
  border-radius: var(--r-xs);
  padding: 3px 9px;
  font-size: var(--fs-xs);
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.6;
}
.drill-bar button:hover, .drill-bar a:hover { background: var(--primary-light); }

/* ==========================================================================
   13. 列表行（消息 / 待办）
   ========================================================================== */
.notice-list { display: flex; flex-direction: column; }
.notice-row {
  display: flex;
  gap: var(--sp-3);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}
.notice-row:last-child { border-bottom: 0; }
.notice-row:hover { background: #f8faff; }
.notice-row.is-read .nt { color: var(--muted); text-decoration: line-through; text-decoration-color: #cbd5e1; }
.notice-row .nd { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: 0 0 8px; background: var(--primary); }
.notice-row .nd.bad { background: var(--danger); }
.notice-row .nd.warn { background: var(--warning); }
.notice-row .nb { flex: 1; min-width: 0; }
.notice-row .nt { font-size: var(--fs-sm); font-weight: 600; line-height: 1.5; }
.notice-row .ns { font-size: var(--fs-xs); color: var(--text-2); margin-top: 3px; line-height: 1.55; }
.notice-row .nm { display: flex; align-items: center; gap: var(--sp-2); margin-top: 6px; font-size: var(--fs-2xs); color: var(--muted); }
.notice-row .na { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex: 0 0 auto; }
@media (max-width: 720px) {
  .notice-row { flex-wrap: wrap; }
  .notice-row .na { width: 100%; flex-direction: row; justify-content: flex-end; }
}

/* ==========================================================================
   14. 键值详情（r-kv ≡ detail-grid）
   ========================================================================== */
.r-kv { display: grid; gap: 8px 20px; margin-top: var(--sp-2); }
.r-kv.c2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.r-kv .kv-item {
  display: flex;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  line-height: 1.65;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
  min-width: 0;
}
.r-kv .kv-item .k { flex: 0 0 88px; color: var(--muted); }
.r-kv .kv-item .v { flex: 1; min-width: 0; word-break: break-word; }
.r-kv .kv-item.span2 { grid-column: 1 / -1; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-3) var(--sp-4); }
.detail-item { min-width: 0; }
.detail-item.full { grid-column: 1 / -1; }
.detail-item .detail-val { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.65; word-break: break-word; white-space: pre-wrap; }
.detail-item .detail-label, .detail-item > label { font-size: var(--fs-xs); color: var(--muted); }
.detail-section { grid-column: 1 / -1; margin-top: 6px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: var(--fs-xs); font-weight: 700; color: var(--muted); }

/* ==========================================================================
   15. 图表 / 进度 / 时间轴
   ========================================================================== */
.r-bars { display: flex; flex-direction: column; gap: var(--sp-2); }
.r-bar-row { display: grid; grid-template-columns: 132px 1fr 64px; gap: var(--sp-2); align-items: center; font-size: var(--fs-xs); }
.r-bar-row > span:first-child { color: var(--muted); }
.r-bar-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.r-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #8b5cf6); }
.r-bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

.r-timeline { list-style: none; margin: 0; padding: 0; }
.r-timeline li {
  position: relative;
  padding: 0 0 14px 20px;
  border-left: 2px solid var(--line);
  margin-left: 6px;
  font-size: var(--fs-sm);
}
.r-timeline li::before {
  content: '';
  position: absolute; left: -6px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #cbd5e1;
}
.r-timeline li.done::before { background: var(--primary); }
.r-timeline .t { color: var(--muted); font-size: var(--fs-xs); }

.r-flag { font-size: var(--fs-xs); font-weight: 600; }
.r-flag.ok { color: var(--success-ink); }
.r-flag.yellow { color: var(--warning-ink); }
.r-flag.red, .r-flag.diff { color: var(--danger-ink); }
.r-step {
  padding: 5px 10px;
  border-radius: var(--r-xs);
  border: 1px dashed #cbd5e1;
  background: var(--surface);
  font-size: var(--fs-xs);
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
}
.r-step:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-light); }
.r-quick-range { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.r-quick-range .btn.is-on { background: var(--primary-light); border-color: #c7d2fe; color: var(--primary-ink); font-weight: 700; }
.progress-bar-wrap { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 999px; }

/* ==========================================================================
   16. 深色主题
   ========================================================================== */
html[data-theme="dark"] {
  --bg: #0b1220;
  --card: #121c2e;
  --surface: #121c2e;
  --surface-2: #16233a;
  --surface-3: #1e2b42;
  --line: #24324a;
  --border: var(--line);
  --text: #e2e8f0;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] .card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .r-kpi,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .r-modal,
html[data-theme="dark"] .r-drawer,
html[data-theme="dark"] .empty,
html[data-theme="dark"] .r-empty,
html[data-theme="dark"] .empty-state { background: var(--card); border-color: var(--line); color: var(--text); }
html[data-theme="dark"] th,
html[data-theme="dark"] .r-table th { background: var(--surface-2); color: var(--muted); }
html[data-theme="dark"] td,
html[data-theme="dark"] .r-table td { color: var(--text-2); }
html[data-theme="dark"] tbody tr:hover td,
html[data-theme="dark"] .r-table tbody tr:hover td,
html[data-theme="dark"] .r-table tbody tr:hover { background: #1a2740; }
html[data-theme="dark"] .btn { background: var(--surface-2); border-color: var(--line); color: var(--text-2); }
html[data-theme="dark"] .btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
html[data-theme="dark"] .btn-outline { background: transparent; }
html[data-theme="dark"] .btn-outline:hover:not(:disabled),
html[data-theme="dark"] .btn:hover:not(:disabled) { background: var(--surface-3); color: #e0e7ff; }
html[data-theme="dark"] input:not([type=checkbox]):not([type=radio]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { background: #0f1a2b; color: var(--text); border-color: var(--line); }
html[data-theme="dark"] code { background: var(--surface-3); color: #cbd5e1; }
html[data-theme="dark"] .notice-row:hover { background: #1a2740; }
html[data-theme="dark"] .drill-bar { background: #1b2440; border-color: #2f3b60; color: #c7d2fe; }
html[data-theme="dark"] .drill-bar button,
html[data-theme="dark"] .drill-bar a { background: #16233a; border-color: #2f3b60; color: #c7d2fe; }

/* ==========================================================================
   17. 打印
   ========================================================================== */
@media print {
  body { background: #fff; }
  .card, .r-kpi, .stat-card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .toolbar, .r-toolbar, .r-tabs, .tabs, .btn, .r-pager { display: none !important; }
  th, .r-table th { position: static; }
}

/* ==========================================================================
   18. 密度
   ========================================================================== */
body.density-compact { --ctl-h: 30px; --ctl-h-sm: 26px; --fs-md: 13px; --fs-sm: 12px; --fs-kpi: 22px; }
body.density-compact .card { padding: 12px 14px; }
body.density-compact td, body.density-compact th,
body.density-compact .r-table td, body.density-compact .r-table th { padding: 7px 9px; }
body.density-compact .r-kpi, body.density-compact .stat-card { padding: 10px 12px; }

/* ==========================================================================
   通用分页条（ui.js enhancePager 自动挂载，任何模块都有分页）
   ========================================================================== */
.ui-pager {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 10px 2px 2px; font-size: var(--fs-sm); color: var(--text-2);
}
.ui-pager .g { flex: 1; }
.ui-pager b { color: var(--text); font-weight: 600; }
.ui-pager select {
  height: 28px; border: 1px solid var(--border-strong); border-radius: var(--r-xs);
  background: var(--surface); color: var(--text); font-size: var(--fs-sm); padding: 0 6px;
}
.ui-pager button {
  min-width: 28px; height: 28px; padding: 0 8px;
  border: 1px solid var(--border-strong); border-radius: var(--r-xs);
  background: var(--surface); color: var(--text-2); font-size: var(--fs-sm);
  cursor: pointer; line-height: 1; transition: var(--tr-fast);
}
.ui-pager button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.ui-pager button.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.ui-pager button:disabled { opacity: .45; cursor: not-allowed; }
@media print { .ui-pager { display: none !important; } }
