/* ============================================================
   电商客服服务助手 - 公共样式 common.css
   极简白底 + 品牌蓝 #2563EB
   包含：CSS 变量、按钮、Toast、Modal、通用布局、通用标签
   P01 专用样式保留在 styles.css
   ============================================================ */

:root {
  --font-sans: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-latin: Inter, "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --brand: #2563EB;
  --brand-hover: #1D4ED8;
  --brand-light: #EFF6FF;
  --brand-border: #BFDBFE;
  --text: #0F172A;
  --text-1: #0F172A;
  --text-2: #475569;
  --text-3: #94A3B8;
  --border: #E2E8F0;
  --border-soft: #F1F5F9;
  --bg: #FFFFFF;
  --bg-soft: #F8FAFC;
  --panel: #FFFFFF;
  --panel-2: #F8FAFC;
  --danger: #DC2626;
  --danger-hover: #B91C1C;
  --success: #16A34A;
  --warn: #D97706;
  /* 客户消息气泡（亮色默认；P01 聊天区引用，暗色在 html[data-theme='dark'] 覆盖） */
  --customer-msg-bg: #FFFFFF;
  --customer-msg-text: #1F2937;
  --customer-msg-meta: #64748B;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea,
.ant-layout, .ant-menu, .ant-btn, .ant-input, .ant-select,
.ant-table, .ant-tag, .ant-dropdown-menu, .ant-popover {
  font-family: var(--font-sans);
}

/* ============ 全局信息层级（大项3 第一批） ============ */
html body h2:not(.page-title),
body .app .module-title,
body .module-title,
body .ui-section-title,
body .ui-card-title,
body .session-list-title,
body .panel-title,
body .card-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
}
body .ui-text,
body .body-text { font-size: 14px; font-weight: 400; }
body .ui-text-sm,
body .ui-text-muted,
body .module-range,
body .module-note,
body .module-foot { font-size: 12px; font-weight: 400; }

/* ============ 按钮组件 ============ */
.btn {
  height: 34px;
  padding: 0 18px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }

.btn-secondary { background: var(--bg); border-color: var(--brand); color: var(--brand); }
.btn-secondary:hover:not(:disabled) { background: var(--brand-light); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); border-color: var(--danger-hover); }

.btn-outline { background: var(--bg); border-color: var(--border); color: var(--text-2); }
.btn-outline:hover:not(:disabled) { background: var(--bg-soft); }

.btn-block { width: 100%; }
.btn-lg { height: 44px; font-size: 15px; }

/* ============ 通用标签 ============ */
.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  line-height: 18px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill-red { background: #FEE2E2; color: var(--danger); border-color: #FECACA; }
.pill-gold { background: #FEF3C7; color: var(--warn); border-color: #FDE68A; }
.pill-blue { background: var(--brand-light); color: var(--brand); border-color: var(--brand-border); }
.pill-green { background: #DCFCE7; color: var(--success); border-color: #BBF7D0; }
.pill-orange { background: #FFEDD5; color: #EA580C; border-color: #FED7AA; }
.pill-grey { background: #F1F5F9; color: var(--text-2); border-color: #E2E8F0; }
.pill-purple { background: #EDE9FE; color: #7C3AED; border-color: #DDD6FE; }

.tag-new { padding: 1px 8px; border-radius: 10px; background: var(--brand-light); color: var(--brand); font-size: 11px; font-weight: 500; }
.tag-status { padding: 1px 8px; border-radius: 10px; background: #FEF3C7; color: var(--warn); font-size: 11px; font-weight: 500; }

.unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

/* ============ Toast 轻提示 ============ */
.toast {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, .92);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 9999;
  max-width: 70vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ Modal 确认弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}
.modal {
  width: 380px;
  background: var(--bg);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-body { font-size: 13px; color: var(--text-2); margin: 10px 0 20px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ============ 顶部横贯 header（工作台用） ============ */
.top-header {
  height: 56px;
  flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.header-left { display: flex; align-items: center; }
.header-logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: #EAF2FF; color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #D8E6FB;
}
.logo-icon img { display: block; width: 22px; height: 22px; }
.logo-text { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: .01em; }
.header-center { flex: 1; text-align: center; }
.page-title { font-size: 20px; font-weight: 600; line-height: 1.4; color: var(--text); letter-spacing: -.01em; }
.header-right {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2);
}
.stat-item { white-space: nowrap; }
.stat-item strong { color: var(--brand); font-weight: 700; }
.stat-divider { color: var(--text-3); }
.online-dot { color: var(--success); }
.user-name-display { font-size: 13px; font-weight: 500; }
.logout-link {
  margin-left: 8px;
  color: var(--text-3);
  text-decoration: none;
  font-size: 12px;
  cursor: pointer;
}
.logout-link:hover { color: var(--danger); }

/* ============ 站内通知铃铛（所有客服页共用，含 P02/P03/P04 等不加载 styles.css 的页面） ============ */
.notif-wrap { position: relative; }
.notif-bell {
  position: relative;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
}
.notif-bell:hover { border-color: var(--brand); }
.notif-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 16px; height: 16px; line-height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700;
  text-align: center;
}
.notif-panel {
  position: absolute; top: 38px; right: 0;
  width: 320px; max-width: 78vw;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
  z-index: 120;
  overflow: hidden;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 700; color: var(--text);
}
.notif-read-all { border: none; background: none; color: var(--brand); font-size: 12px; cursor: pointer; }
.notif-read-all:hover { text-decoration: underline; }
.notif-list { max-height: 360px; overflow: auto; }
.notif-item { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:hover { background: var(--bg-soft); }
.notif-item.unread { background: var(--brand-light); }
.notif-item-title { font-size: 13px; font-weight: 600; color: var(--text); }
.notif-item-content { font-size: 12px; color: var(--text-2); margin-top: 3px; line-height: 1.5; word-break: break-word; }
.notif-item-time { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.notif-empty { padding: 22px 12px; text-align: center; font-size: 12px; color: var(--text-3); }

/* ============ 左侧窄导航 ============ */
.side-nav {
  width: 180px;
  flex-shrink: 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.side-nav-menu { flex: 1; padding: 12px 8px; }
.side-nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 12px; margin-bottom: 4px;
  border-radius: 8px; color: var(--text-2); font-size: 14px;
  text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s;
}
.side-nav-item:hover { background: var(--bg-soft); color: var(--text); }
.side-nav-item.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.side-nav-icon { font-size: 16px; }
.side-nav-footer { padding: 12px; border-top: 1px solid var(--border); }
.side-user { display: flex; align-items: center; gap: 10px; }
.side-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand-light); color: var(--brand);
  font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.side-user-name { font-size: 13px; font-weight: 600; }
.side-user-status { font-size: 12px; color: var(--success); }
.side-user-role { font-size: 11px; color: var(--text-3); }
.online-dot-small { color: var(--success); font-size: 10px; }

/* ============ 通用应用布局 ============ */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.main-row { display: flex; flex: 1; min-height: 0; }
.empty-tip { padding: 48px 16px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ============ 通用工具 ============ */
.kv-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 4px 0; font-size: 12.5px;
}
.kv-label { color: var(--text-3); flex-shrink: 0; }
.kv-value { color: var(--text); text-align: right; word-break: break-all; }

.context-link {
  display: block; margin-top: 8px;
  font-size: 12px; color: var(--brand);
  text-decoration: none;
}
.context-link:hover { text-decoration: underline; }

/* ============ 输入框通用样式 ============ */
.input-field {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input-field:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}
textarea.input-field {
  height: auto;
  padding: 9px 12px;
  line-height: 1.5;
  resize: none;
}

/* ============ 主题开关（左下角，0815 专项） ============ */
.theme-switch { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.theme-switch .theme-label { display: block; font-size: 11px; color: var(--text-3); margin-bottom: 6px; }
.theme-options { display: flex; gap: 6px; }
.theme-opt {
  flex: 1; height: 24px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text-2); font-size: 11px; cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.theme-opt:hover { border-color: var(--brand); color: var(--brand); }
.theme-opt.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ============ 深色主题（localStorage + prefers-color-scheme，无数据库字段） ============ */
html[data-theme='dark'] {
  --brand: #3B82F6;
  --brand-hover: #60A5FA;
  --brand-light: #1E293B;
  --brand-border: #334155;
  --text: #F8FAFC;
  --text-1: #F8FAFC;
  --text-2: #CBD5E1;
  --text-3: #94A3B8;
  --border: #334155;
  --border-soft: rgba(148, 163, 184, .18);
  --bg: #0F172A;
  --bg-soft: #111827;
  --panel: #182235;
  --panel-2: #202C40;
  --danger: #F87171;
  --danger-hover: #EF4444;
  --success: #4ADE80;
  --warn: #FBBF24;
  /* 客户消息气泡（暗色）：深灰蓝气泡 + 浅色正文 + 浅灰元信息 */
  --customer-msg-bg: #1F2937;
  --customer-msg-text: #F3F4F6;
  --customer-msg-meta: #9CA3AF;
  color-scheme: dark;
}

html[data-theme='dark'] .logo-icon {
  background: rgba(59, 130, 246, .12);
  border-color: rgba(96, 165, 250, .18);
}

html[data-theme='dark'] .pill-red { background: #450A0A; color: #FCA5A5; border-color: #7F1D1D; }
html[data-theme='dark'] .pill-gold { background: #422006; color: #FCD34D; border-color: #78350F; }
html[data-theme='dark'] .pill-green { background: #052E16; color: #86EFAC; border-color: #14532D; }
html[data-theme='dark'] .pill-orange { background: #431407; color: #FDBA74; border-color: #7C2D12; }
html[data-theme='dark'] .pill-grey { background: #334155; color: #CBD5E1; border-color: #475569; }
html[data-theme='dark'] .pill-purple { background: #2E1065; color: #C4B5FD; border-color: #4C1D95; }
html[data-theme='dark'] .tag-status { background: #422006; color: #FCD34D; }
html[data-theme='dark'] .dot-offline { background: #475569; }

/* ============================================================
   管理页 Visual Baseline v2（2026-08-19）
   复用范围：页面头、KPI Overview、筛选 Toolbar、表格 Card、Card footer。
   P10 首次落地；只使用既有主题变量，不建立第二套 Theme。
   ============================================================ */

.ui-page { background: #F3F6FA; }

/* ---------- KPI Overview：图标底 + label + 数值 + helper ---------- */
.ui-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.ui-kpi {
  min-width: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: start;
  column-gap: 15px;
  row-gap: 8px;
  min-height: 128px;
  padding: 11px 14px 9px;
  background: var(--panel);
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .035);
}
.ui-kpi-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--brand-light);
  color: var(--brand);
}
.ui-kpi-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ui-kpi-content { min-width: 0; }
.ui-kpi-label { color: var(--text-2); font-size: 12px; font-weight: 600; line-height: 1.4; }
.ui-kpi-value { margin-top: 3px; color: var(--text); font-size: 32px; font-weight: 700; letter-spacing: -.025em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ui-kpi-helper { margin-top: 5px; overflow: hidden; color: var(--text-3); font-size: 11px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.ui-kpi-meta { grid-column: 1 / -1; min-width: 0; padding: 6px 10px; overflow: hidden; border-radius: 8px; background: #F7F9FC; color: #718096; font-size: 10px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.ui-kpi--blue .ui-kpi-meta { background: #F3F7FF; color: #647A9C; }
.ui-kpi--green .ui-kpi-meta { background: #F2FBF5; color: #5F7F69; }
.ui-kpi--indigo .ui-kpi-meta,
.ui-kpi--amber .ui-kpi-meta { background: #F5F6FF; color: #6E7195; }
.ui-kpi--red .ui-kpi-meta { background: #FFF7F7; color: #8A6B6E; }
.ui-kpi--green .ui-kpi-icon { background: #ECFDF3; color: #15803D; }
.ui-kpi--indigo .ui-kpi-icon,
.ui-kpi--amber .ui-kpi-icon { background: #EEF2FF; color: #4F46E5; }
.ui-kpi--red .ui-kpi-icon { background: #FFF1F2; color: #DC2626; }

/* ---------- Table Card shell ---------- */
.ui-table-card {
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid #DFE6EF;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .035);
}
.ui-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 14px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.ui-card-header-main { min-width: 0; }
.ui-card-title-row { display: flex; align-items: center; gap: 10px; }
.ui-card-title { color: var(--text); font-size: 15px; font-weight: 700; line-height: 1.5; }
.ui-card-desc { margin-top: 3px; color: var(--text-3); font-size: 11px; line-height: 1.55; }
.ui-count-badge { min-width: 24px; padding: 1px 8px; border-radius: 10px; background: var(--brand-light); color: var(--brand); font-size: 11px; font-weight: 700; text-align: center; }
.ui-card-header-meta { flex: 0 0 auto; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.ui-card-header-meta strong { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.ui-table-scroll { min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-color: #CBD5E1 transparent; scrollbar-width: thin; }
.ui-table-scroll:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.ui-table-scroll::-webkit-scrollbar { height: 8px; }
.ui-table-scroll::-webkit-scrollbar-thumb { background: #CBD5E1; border: 2px solid transparent; border-radius: 999px; background-clip: padding-box; }
.ui-table-card .ui-table { border: 0; border-radius: 0; }
.ui-table-card .ui-pager { margin-top: 0; padding: 13px 18px; border-top: 1px solid var(--border); background: var(--panel); }

html[data-theme='dark'] .ui-page { background: #0C1424; }
html[data-theme='dark'] .ui-kpi,
html[data-theme='dark'] .ui-toolbar,
html[data-theme='dark'] .ui-table-card,
html[data-theme='dark'] .ui-card-header,
html[data-theme='dark'] .ui-table-card .ui-pager { background: var(--panel); border-color: var(--border); box-shadow: none; }
html[data-theme='dark'] .ui-kpi--green .ui-kpi-icon { background: rgba(34, 197, 94, .12); color: #86EFAC; }
html[data-theme='dark'] .ui-kpi--indigo .ui-kpi-icon,
html[data-theme='dark'] .ui-kpi--amber .ui-kpi-icon { background: rgba(99, 102, 241, .16); color: #A5B4FC; }
html[data-theme='dark'] .ui-kpi--red .ui-kpi-icon { background: rgba(248, 113, 113, .12); color: #FCA5A5; }
html[data-theme='dark'] .ui-kpi-meta { background: #1D2B42; color: #94A3B8; }
html[data-theme='dark'] .ui-kpi--blue .ui-kpi-meta { background: rgba(59, 130, 246, .09); color: #9CB6DA; }
html[data-theme='dark'] .ui-kpi--green .ui-kpi-meta { background: rgba(34, 197, 94, .08); color: #9AC5A8; }
html[data-theme='dark'] .ui-kpi--indigo .ui-kpi-meta,
html[data-theme='dark'] .ui-kpi--amber .ui-kpi-meta { background: rgba(99, 102, 241, .1); color: #A9AED4; }
html[data-theme='dark'] .ui-kpi--red .ui-kpi-meta { background: rgba(248, 113, 113, .08); color: #D2A7AC; }
html[data-theme='dark'] .ui-table-scroll { scrollbar-color: #475569 transparent; }
html[data-theme='dark'] .ui-table-scroll::-webkit-scrollbar-thumb { background-color: #475569; }
html[data-theme='dark'] .toast { background: rgba(30, 41, 59, .95); }

/* ============ 图表辅助色（P07/P09 内联 SVG 图表共用，主题联动） ============ */
   类名直接由 JS 生成的 SVG 使用，深色模式通过 html[data-theme='dark'] 覆盖，
   避免 JS 内写死颜色。数据系列色（蓝/绿/橙/紫）两主题保持一致，不在此覆盖。 */
.ch-grid { stroke: #EEF2F7; }                       /* 网格线：浅色浅灰 / 深色低对比深灰 */
.ch-base { stroke: #CBD5E1; }                       /* 基线 / 边框线 */
.ch-ax { fill: var(--text-3); }                     /* Y 轴数值 */
.ch-ax2 { fill: #64748B; }                          /* X 轴标签 / 轴标题 */
.ch-ax3 { fill: #475569; }                          /* 图内次要文字（如客服名） */
.ch-t1 { fill: var(--text); }                       /* 图内主文字（如环形图合计） */
.ch-donut-empty { fill: #F1F5F9; }                  /* 环形图空态底色 */
.ch-scroll { margin-top: 6px; padding: 0 40px 0 44px; }  /* X 轴拖动条：左右留出坐标轴边距，与图表对齐 */
html[data-theme='dark'] .ch-grid { stroke: #263040; }
html[data-theme='dark'] .ch-base { stroke: #334155; }
html[data-theme='dark'] .ch-ax2 { fill: #CBD5E1; }
html[data-theme='dark'] .ch-ax3 { fill: #CBD5E1; }
html[data-theme='dark'] .ch-donut-empty { fill: #263040; }

/* ============ 图表自定义 tooltip（深底浅字；替代原生 <title>，两主题通用） ============ */
.chart-tip {
  position: absolute;
  z-index: 80;
  pointer-events: none;
  display: none;
  max-width: 280px;
  background: #0F172A;
  color: #F8FAFC;
  border: 1px solid #334155;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.7;
  white-space: pre-line;
}
html[data-theme='dark'] .chart-tip { background: #202C40; border-color: #334155; color: #F8FAFC; }

/* ============================================================
   公共视觉基线 · 第一批（2026-08-19）
   统一并复用现有 CSS variables（--brand/--bg/--panel/--border/--text 等）。
   仅新增语义化类，不覆盖任何页面内联样式，供 P10 及后续页面复用。
   语义色约定：蓝=主操作/处理中，绿=成功/启用，橙=等待/提醒，
              红=危险/停用，灰=禁用/历史。
   ============================================================ */

/* ---------- Typography ---------- */
.ui-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; padding: 2px 0 20px; }
.ui-page-heading { min-width: 0; max-width: 780px; }
.ui-page-eyebrow { display: block; margin-bottom: 5px; color: var(--brand); font-size: 11px; font-weight: 600; letter-spacing: .05em; }
.ui-title { color: var(--text); font-size: 26px; font-weight: 700; letter-spacing: -.025em; line-height: 1.3; }
.ui-page-desc { margin-top: 6px; color: var(--text-2); font-size: 12px; line-height: 1.65; }
.ui-page-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 0; margin-top: 9px; color: var(--text-3); font-size: 11px; }
.ui-page-meta span { display: inline-flex; align-items: center; white-space: nowrap; }
.ui-page-meta span + span::before { width: 1px; height: 11px; margin: 0 10px; content: ''; background: var(--border); }
.ui-page-meta strong { margin-right: 3px; color: var(--text-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.ui-page-actions { display: flex; align-items: center; flex: 0 0 auto; gap: 10px; padding-bottom: 2px; }
.ui-page-actions .btn { height: 36px; }
.ui-section-title { font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.5; }
.ui-text { font-size: 13px; color: var(--text); }
.ui-text-sm { font-size: 12px; color: var(--text-2); }
.ui-text-muted { font-size: 12px; color: var(--text-3); }

/* ---------- Card / Toolbar ---------- */
.ui-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.ui-toolbar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding: 15px 16px;
  background: var(--panel);
  border: 1px solid #DFE6EF;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .025);
}
.ui-filter-bar { align-items: center; }
.ui-toolbar-main { min-width: 0; flex: 1 1 720px; }
.ui-toolbar-label { margin-bottom: 8px; color: var(--text-2); font-size: 11px; font-weight: 600; }
.ui-toolbar-left { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.ui-toolbar-right { display: flex; align-items: center; flex: 0 1 auto; flex-wrap: wrap; gap: 10px; margin-left: auto; }
.ui-toolbar .input-field { height: 36px; background-color: var(--panel); border-color: var(--border); border-radius: 8px; }
.ui-toolbar select.input-field { width: 132px; padding-right: 30px; }
.ui-toolbar .input-field.kw { width: 248px; border: 0; background: transparent; padding-left: 34px; }
.ui-search-field { position: relative; display: block; width: 248px; height: 36px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.ui-search-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(37, 99, 235, .1); }
.ui-search-icon { position: absolute; z-index: 1; top: 11px; left: 12px; width: 13px; height: 13px; border: 1.7px solid var(--text-3); border-radius: 50%; }
.ui-search-icon::after { position: absolute; right: -4px; bottom: -3px; width: 5px; height: 1.7px; content: ''; background: var(--text-3); transform: rotate(45deg); transform-origin: left center; }
.ui-toolbar-meta { padding-right: 2px; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.ui-toolbar-meta strong { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.ui-btn-icon { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.ui-refresh-icon { width: 12px; height: 12px; border: 1.6px solid currentColor; border-left-color: transparent; border-radius: 50%; }

/* ---------- Table ---------- */
.ui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.ui-table th, .ui-table td { height: 52px; padding: 10px 16px; border-bottom: 1px solid var(--border-soft); color: var(--text-2); text-align: left; vertical-align: middle; }
.ui-table thead th { height: 42px; background: #F8FAFC; color: #64748B; font-size: 11px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.ui-table tbody tr { transition: background .15s; }
.ui-table tbody tr:hover td { background: #F8FAFC; }
.ui-table tbody tr:last-child td { border-bottom: none; }
.ui-table-empty {
  height: 210px;
  padding: 36px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.ui-table-empty > * { display: block; margin-inline: auto; }
.ui-table-empty strong { margin-top: 10px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.ui-table-empty span:last-child { margin-top: 5px; font-size: 11px; }
.ui-empty-icon { position: relative; width: 42px; height: 32px; border: 1.5px solid var(--border); border-radius: 7px; background: var(--bg-soft); }
.ui-empty-icon::before { position: absolute; top: 8px; left: 9px; width: 22px; height: 1px; content: ''; background: var(--border); box-shadow: 0 6px 0 var(--border), 0 12px 0 var(--border); }
.ui-status-tag { display: inline-flex; align-items: center; min-height: 22px; padding: 1px 8px; border: 1px solid transparent; border-radius: 6px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.ui-status-tag--success { background: #ECFDF3; border-color: #D1FADF; color: #15803D; }
.ui-status-tag--disabled { background: #F1F5F9; border-color: #E2E8F0; color: #64748B; }
.ui-online { color: var(--text-2); font-size: 12px; white-space: nowrap; }
.ui-actions { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.ui-action-link { min-height: 28px; padding: 4px 7px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; }
.ui-action-link:hover { background: var(--bg-soft); color: var(--text); }
.ui-action-link--primary { color: var(--brand); }
.ui-action-link--primary:hover { background: var(--brand-light); color: var(--brand-hover); }
.ui-action-link--success { color: #15803D; }
.ui-action-link--success:hover { background: #ECFDF3; color: #166534; }
.ui-action-link--danger { color: var(--danger); }
.ui-action-link--danger:hover { background: #FFF1F2; color: var(--danger-hover); }
.ui-action-more { display: inline-flex; align-items: center; gap: 5px; }
.ui-action-caret { width: 0; height: 0; border-top: 4px solid currentColor; border-right: 3.5px solid transparent; border-left: 3.5px solid transparent; opacity: .65; transition: transform .15s; }
.ui-action-dropdown { position: relative; display: inline-flex; }
.ui-action-dropdown.is-open { z-index: 30; }
.ui-action-dropdown.is-open .ui-action-caret { transform: rotate(180deg); }
.ui-action-dropdown-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 5px);
  right: 0;
  display: none;
  width: 132px;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .12);
}
.ui-action-dropdown-menu--portal { position: fixed; z-index: 120; top: 0; right: auto; left: 0; }
.ui-action-dropdown-item { display: block; width: 100%; min-height: 32px; padding: 6px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font: inherit; font-size: 12px; text-align: left; cursor: pointer; white-space: nowrap; }
.ui-action-dropdown-item:hover { background: var(--bg-soft); color: var(--text); }
.ui-action-dropdown-divider { height: 1px; margin: 4px 5px; background: var(--border-soft); }
.ui-action-dropdown-item--success { color: #15803D; }
.ui-action-dropdown-item--success:hover { background: #ECFDF3; color: #166534; }
.ui-action-dropdown-item--danger { color: var(--danger); }
.ui-action-dropdown-item--danger:hover { background: #FFF1F2; color: var(--danger-hover); }

/* ---------- Pagination ---------- */
.ui-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-2);
}
.ui-pager-summary { color: var(--text-3); font-size: 11px; }
.ui-pager-controls { display: flex; align-items: center; gap: 10px; }
.ui-pager-controls .btn { height: 30px; padding: 0 12px; border-radius: 7px; font-size: 12px; }
.ui-pager-controls > span { min-width: 76px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- Button 语义（补充 .btn-* 家族，复用现有 .btn 基础） ---------- */
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-soft); color: var(--text); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803D; border-color: #15803D; }
.btn-danger-soft { background: var(--bg); border-color: var(--danger); color: var(--danger); }
.btn-danger-soft:hover:not(:disabled) { background: #FEE2E2; }

/* ---------- 状态点（公共 .dot 语义） ---------- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-online { background: #16a34a; }
.dot-busy { background: #d97706; }
.dot-offline { background: #cbd5e1; }

/* 深色模式：层级保持一致（面板/表头/危险/离线点） */
html[data-theme='dark'] .ui-card { background: var(--panel); }
html[data-theme='dark'] .ui-table { background: var(--panel); }
html[data-theme='dark'] .ui-table thead th { background: var(--panel-2); }
html[data-theme='dark'] .ui-table tbody tr:hover td { background: rgba(32, 44, 64, .72); }
html[data-theme='dark'] .ui-toolbar .input-field,
html[data-theme='dark'] .ui-search-field { background-color: var(--panel-2); }
html[data-theme='dark'] .ui-status-tag--success { background: rgba(34, 197, 94, .12); border-color: rgba(74, 222, 128, .18); color: #86EFAC; }
html[data-theme='dark'] .ui-status-tag--disabled { background: rgba(148, 163, 184, .1); border-color: rgba(148, 163, 184, .16); color: #94A3B8; }
html[data-theme='dark'] .ui-action-link--success { color: #86EFAC; }
html[data-theme='dark'] .ui-action-link--success:hover { background: rgba(34, 197, 94, .12); color: #BBF7D0; }
html[data-theme='dark'] .ui-action-link--danger:hover { background: rgba(248, 113, 113, .12); color: #FCA5A5; }
html[data-theme='dark'] .ui-action-dropdown-menu { background: #223149; border-color: #3A4A62; box-shadow: 0 10px 28px rgba(0, 0, 0, .28); }
html[data-theme='dark'] .ui-action-dropdown-item:hover { background: #2A3A53; color: #F8FAFC; }
html[data-theme='dark'] .ui-action-dropdown-divider { background: #3A4A62; }
html[data-theme='dark'] .ui-action-dropdown-item--success { color: #86EFAC; }
html[data-theme='dark'] .ui-action-dropdown-item--success:hover { background: rgba(34, 197, 94, .12); color: #BBF7D0; }
html[data-theme='dark'] .ui-action-dropdown-item--danger:hover { background: rgba(248, 113, 113, .12); color: #FCA5A5; }
html[data-theme='dark'] .ui-empty-icon { background: var(--panel-2); }
html[data-theme='dark'] .btn-ghost:hover:not(:disabled) { background: var(--bg-soft); }
html[data-theme='dark'] .btn-danger-soft { background: transparent; border-color: var(--danger); color: var(--danger); }
html[data-theme='dark'] .btn-danger-soft:hover:not(:disabled) { background: #450A0A; color: #FCA5A5; }
html[data-theme='dark'] .dot-offline { background: #475569; }

@media (max-width: 1440px) {
  .ui-kpis { gap: 12px; }
  .ui-kpi { min-height: 122px; padding: 10px 13px 8px; grid-template-columns: 44px minmax(0, 1fr); column-gap: 12px; row-gap: 7px; }
  .ui-kpi-icon { width: 44px; height: 44px; }
  .ui-kpi-value { font-size: 29px; }
  .ui-toolbar { gap: 12px 16px; padding: 14px; }
  .ui-toolbar-main { flex-basis: 680px; }
  .ui-toolbar .input-field.kw,
  .ui-search-field { width: 224px; }
  .ui-toolbar select.input-field { width: 122px; }
  .ui-table th, .ui-table td { padding-inline: 14px; }
}

@media (max-width: 1280px) {
  .ui-page-head { gap: 20px; padding-bottom: 16px; }
  .ui-title { font-size: 24px; }
  .ui-page-actions { gap: 8px; }
  .ui-kpis { gap: 10px; }
  .ui-kpi { min-height: 116px; padding: 9px 12px 7px; grid-template-columns: 40px minmax(0, 1fr); column-gap: 10px; row-gap: 6px; }
  .ui-kpi-icon { width: 40px; height: 40px; border-radius: 10px; }
  .ui-kpi-icon svg { width: 21px; height: 21px; }
  .ui-kpi-value { font-size: 27px; }
  .ui-kpi-helper { font-size: 10px; }
  .ui-kpi-meta { padding: 5px 8px; }
}
