/* ═══════════════════════════════════════════════════════
   速电综合管理平台 — 全局样式系统
   移动端优先 · 零外部依赖 · 暗色侧边栏
   ═══════════════════════════════════════════════════════ */

:root {
  --primary: #4f46e5; --primary-hover: #4338ca; --primary-light: #eef2ff;
  --accent: #06b6d4; --accent-light: #ecfeff;
  --success: #10b981; --danger: #ef4444; --warning: #f59e0b;
  --bg: #f0f2f5; --card: #ffffff; --border: #e5e7eb;
  --text: #111827; --text-secondary: #6b7280; --text-muted: #9ca3af;
  --sidebar-w: 230px; --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08); --shadow-lg: 0 10px 25px rgba(0,0,0,.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }

/* ====== 布局 ====== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: linear-gradient(180deg, #1e1b4b, #312e81);
  color: #fff; flex-shrink: 0; display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform .25s, width .25s; box-shadow: 2px 0 20px rgba(0,0,0,.1);
  overflow-y: auto;
}
.sidebar.collapsed { width: 60px; }
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; transition: margin-left .25s; }
.sidebar.collapsed ~ .main { margin-left: 60px; }

/* 侧边栏内容 */
.sidebar-brand {
  padding: 18px 16px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08); cursor: pointer;
}
.sb-icon { width: 36px; height: 36px; background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0; box-shadow: 0 4px 12px rgba(79,70,229,.4); }
.sb-text { font-size: 15px; font-weight: 700; white-space: nowrap; letter-spacing: .3px; }
.sidebar.collapsed .sb-text { display: none; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-nav a, .sidebar-nav .group-label {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  border-radius: var(--radius-sm); color: rgba(255,255,255,.65);
  font-size: 13.5px; transition: all .2s; white-space: nowrap; margin-bottom: 2px;
  cursor: pointer; text-decoration: none;
}
.sidebar-nav a:hover, .sidebar-nav .group-label:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.sidebar-nav a i { font-style: normal; font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar.collapsed .sidebar-nav a span,
.sidebar.collapsed .sidebar-nav .group-label span { display: none; }
.sidebar.collapsed .sidebar-nav a small { display: none; }

.nav-group { position: relative; }
.group-label .arrow { margin-left: auto; transition: transform .2s; font-size: 10px; opacity: .5; }
.group-label.open .arrow { transform: rotate(90deg); opacity: 1; }
.sidebar-sub { display: none; padding-left: 28px; }
.sidebar-sub.show { display: block; }
.sidebar-sub a { font-size: 13px; padding: 7px 14px; }
.sidebar.collapsed .sidebar-sub { display: none !important; }

.nav-divider { height: 1px; background: rgba(255,255,255,.08); margin: 8px 12px; }
.recharge-link { border: 1px dashed rgba(255,255,255,.2) !important; margin-top: 4px; }
.recharge-link small { font-size: 10px; opacity: .6; }

.sidebar-toggle {
  width: 100%; padding: 14px; background: none; border: none;
  border-top: 1px solid rgba(255,255,255,.08); color: rgba(255,255,255,.4);
  cursor: pointer; font-size: 18px; transition: color .2s;
}
.sidebar-toggle:hover { color: rgba(255,255,255,.7); }

/* ====== 顶部栏 ====== */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 56px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar h1 { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-info { font-size: 13px; color: var(--text-secondary); }
.mobile-menu-btn { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); }

/* ====== 内容区 ====== */
.content-area { padding: 24px; }

/* ====== 卡片 ====== */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px;
  border: 1px solid var(--border);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { font-size: 15px; font-weight: 600; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-row-sm { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.stat-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px 20px; text-align: center; position: relative; overflow: hidden;
  border: 1px solid var(--border);
}
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.stat-card:nth-child(2)::before { background: linear-gradient(90deg, var(--success), var(--accent)); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, var(--warning), #f97316); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg, var(--accent), var(--primary)); }
.stat-val {
  font-size: 28px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 4px; line-height: 1.2;
}
.stat-card:nth-child(2) .stat-val { background: linear-gradient(135deg, var(--success), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat-val-sm { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.stat-lbl { font-size: 12px; color: var(--text-secondary); font-weight: 500; letter-spacing: .5px; }
.stat-card-sm { padding: 18px 14px; }

/* ====== 表格 ====== */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 11px 14px; background: #f9fafb; color: var(--text-secondary);
  font-weight: 600; font-size: 11.5px; letter-spacing: .6px; border-bottom: 2px solid var(--border);
  white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid #f3f4f6; }
tr:hover td { background: #f8fafc; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #eef2ff; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

/* ====== 搜索栏 ====== */
.search-bar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center;
  padding: 14px 16px; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
}

/* ====== 表单 ====== */
input, select, textarea, button { font-family: inherit; }
input[type="text"], input[type="password"], input[type="number"],
input[type="search"], input[type="date"], input[type="tel"], select {
  height: 40px; padding: 0 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; color: var(--text);
  outline: none; background: var(--card); transition: all .2s;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.input-lg { height: 48px !important; font-size: 16px !important; padding: 0 16px !important; }
.input-group { margin-bottom: 14px; }
.input-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.w-auto { width: auto !important; min-width: 120px; }
.w-full { width: 100% !important; }

/* ====== 按钮 ====== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px; padding: 0 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer; border: none;
  transition: all .2s; white-space: nowrap; gap: 6px;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), #6366f1); color: #fff; box-shadow: 0 2px 8px rgba(79,70,229,.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79,70,229,.4); }
.btn-accent { background: linear-gradient(135deg, var(--accent), #22d3ee); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: var(--card); border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f9fafb; border-color: #d1d5db; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 11px; border-radius: 4px; }
.btn-lg { height: 50px; padding: 0 24px; font-size: 16px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ====== 分页 ====== */
.pagination { display: flex; align-items: center; gap: 4px; margin-top: 16px; font-size: 13px; flex-wrap: wrap; }
.pagination button {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); cursor: pointer; font-size: 13px; font-weight: 500; transition: all .15s;
}
.pagination button:hover { background: #f3f4f6; }
.pagination button:disabled { opacity: .4; cursor: default; }
.pagination button.current { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-info { color: var(--text-muted); margin: 0 8px; font-size: 12px; }

/* ====== 状态标签 ====== */
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f3f4f6; color: #6b7280; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.status-dot.green { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.red { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.status-dot.blue { background: #3b82f6; box-shadow: 0 0 6px #3b82f6; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:.4 } }

/* ====== 标签页 ====== */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  padding: 6px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 500;
  cursor: pointer; transition: all .2s; color: var(--text-secondary); background: transparent;
}
.tab:hover { background: #f3f4f6; }
.tab.active { background: var(--primary); color: #fff; }
.quick-filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.qf-item {
  padding: 5px 14px; border-radius: 20px; font-size: 12.5px; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); color: var(--text-secondary);
  transition: all .2s;
}
.qf-item:hover { border-color: var(--primary); color: var(--primary); }
.qf-item.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ====== 标签 ====== */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px;
  background: var(--primary-light); color: var(--primary); }
.tag-sm { padding: 1px 6px; font-size: 10px; }
.tag-green { background: #dcfce7; color: #166534; }

/* ====== 工具类 ====== */
.text-center { text-align: center; }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.fw-bold { font-weight: 600; }
.mono { font-family: "SF Mono", "Fira Code", "Consolas", monospace; font-size: 12px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; }
.ml-2 { margin-left: 8px; }
.p-3 { padding: 16px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 20px; padding-bottom: 20px; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-end { display: flex; align-items: center; justify-content: flex-end; }
.gap-2 { gap: 8px; }
.link { color: var(--primary); cursor: pointer; font-size: 13px; }
.link:hover { text-decoration: underline; }

/* ====== 弹窗 ====== */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.3);
  z-index: 200; pointer-events: none;
}
.modal-overlay.show { display: block; }
.modal-container {
  display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  z-index: 201; width: 90%; max-width: 600px; max-height: 80vh; overflow-y: auto;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.modal-container.show { display: block; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.form-msg { margin: 8px 0; font-size: 13px; min-height: 20px; }

/* ====== 详情网格 ====== */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.detail-item { padding: 8px 0; border-bottom: 1px solid #f3f4f6; }
.detail-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; text-transform: uppercase; }
.detail-value { font-size: 14px; font-weight: 500; }

/* ====== 脚本卡片 ====== */
.script-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.script-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.rule-list { border-top: 1px solid var(--border); padding-top: 8px; }
.rule-item { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 12px; }
.rule-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.switch-label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* ====== 日志 ====== */
.log-list { max-height: 400px; overflow-y: auto; }
.log-item { padding: 10px 12px; border-bottom: 1px solid #f3f4f6; }
.log-item.log-fail { background: #fef2f2; }
.log-item.log-ok { background: #f0fdf4; }

/* ====== 对话框 ====== */
dialog { border: none; border-radius: var(--radius); padding: 0; box-shadow: var(--shadow-lg); max-width: 600px; width: 90%; }
dialog::backdrop { background: rgba(0,0,0,.4); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog-header h3 { font-size: 16px; }
.dialog-body { padding: 20px; max-height: 60vh; overflow-y: auto; }

/* ====== 告警 ====== */
.alert-item { padding: 12px 16px; border-left: 4px solid; margin-bottom: 4px; }
.alert-warning { border-color: var(--warning); background: #fffbeb; }
.alert-error { border-color: var(--danger); background: #fef2f2; }
.alert-info { border-color: #3b82f6; background: #eff6ff; }

/* ═══════════════════════════════════════════════
   组件库样式
   ═══════════════════════════════════════════════ */

/* Loading 组件 */
.comp-loading-overlay {
  display: none; position: fixed; inset: 0; background: rgba(255,255,255,.85);
  z-index: 300; align-items: center; justify-content: center; 
}
.comp-loading-overlay.show { display: flex; }
.comp-loading-spinner { text-align: center; }
.comp-spinner {
  width: 42px; height: 42px; margin: 0 auto 12px;
  border: 3px solid #e5e7eb; border-top: 3px solid var(--primary);
  border-radius: 50%; animation: comp-spin .7s linear infinite;
}
@keyframes comp-spin { to { transform: rotate(360deg); } }
.comp-loading-text { font-size: 14px; color: var(--text-secondary); }

.comp-loading-inline { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px; }
.comp-spinner-sm {
  width: 20px; height: 20px; border: 2px solid #e5e7eb; border-top: 2px solid var(--primary);
  border-radius: 50%; animation: comp-spin .7s linear infinite; flex-shrink: 0;
}
.comp-loading-text-sm { font-size: 13px; color: var(--text-muted); }

/* 骨架屏 */
.comp-skeleton-list { padding: 12px; }
.comp-skeleton-row { display: flex; gap: 12px; margin-bottom: 12px; }
.comp-skeleton-cell { flex: 1; }
.comp-skeleton-bar { height: 16px; background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%); background-size: 200% 100%; animation: skeleton-wave 1.5s ease-in-out infinite; border-radius: 4px; }
@keyframes skeleton-wave { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Toast 组件 */
.comp-toast-container { position: fixed; top: 20px; right: 20px; z-index: 400; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.comp-toast {
  padding: 12px 18px; border-radius: 10px; font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.12); opacity: 0; transform: translateX(20px);
  transition: all .3s; pointer-events: auto; display: flex; align-items: center; gap: 8px;
}
.comp-toast.show { opacity: 1; transform: translateX(0); }
.comp-toast-success { background: #ecfdf5; color: #065f46; border-left: 4px solid var(--success); }
.comp-toast-error { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--danger); }
.comp-toast-info { background: #eff6ff; color: #1e40af; border-left: 4px solid #3b82f6; }
.comp-toast-warning { background: #fffbeb; color: #92400e; border-left: 4px solid var(--warning); }
.comp-toast-icon { font-size: 16px; flex-shrink: 0; }

/* Drawer 组件 */
.comp-drawer-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 250; 
}
.comp-drawer-overlay.show { display: block; }
.comp-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 100vw;
  background: var(--card); z-index: 251; box-shadow: -4px 0 24px rgba(0,0,0,.1);
  transform: translateX(100%); transition: transform .3s; display: flex; flex-direction: column;
}
.comp-drawer.show { transform: translateX(0); }
.comp-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.comp-drawer-title { font-size: 16px; font-weight: 700; margin: 0; }
.comp-drawer-close {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--text-muted); padding: 4px 8px; border-radius: 6px; transition: all .2s;
}
.comp-drawer-close:hover { background: #f3f4f6; color: var(--text); }
.comp-drawer-body { flex: 1; overflow-y: auto; padding: 20px; }

/* StatCard 组件 */
.comp-stat-row {
  display: grid; grid-template-columns: repeat(var(--stat-cols, 4), 1fr); gap: 16px; margin-bottom: 20px;
}
.comp-stat-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--border); position: relative; overflow: hidden;
}
.comp-stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.comp-stat-success::before { background: linear-gradient(90deg, var(--success), var(--accent)); }
.comp-stat-danger::before { background: linear-gradient(90deg, var(--danger), #f97316); }
.comp-stat-warning::before { background: linear-gradient(90deg, var(--warning), #f97316); }
.comp-stat-icon { font-size: 28px; flex-shrink: 0; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: var(--bg); border-radius: 12px; }
.comp-stat-body { flex: 1; min-width: 0; }
.comp-stat-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.comp-stat-value {
  font-size: 24px; font-weight: 800; line-height: 1.2;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.comp-stat-success .comp-stat-value { background: linear-gradient(135deg, var(--success), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.comp-stat-danger .comp-stat-value { background: linear-gradient(135deg, var(--danger), #f97316); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.comp-stat-warning .comp-stat-value { background: linear-gradient(135deg, var(--warning), #f97316); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.comp-stat-trend { font-size: 12px; font-weight: 600; margin-top: 2px; }
.comp-stat-trend.up { color: var(--success); }
.comp-stat-trend.down { color: var(--danger); }

/* DataTable 组件 */
.comp-datatable-wrap { overflow-x: auto; }
.comp-datatable { width: 100%; border-collapse: collapse; font-size: 13px; }
.comp-datatable th {
  text-align: left; padding: 11px 14px; background: #f9fafb; color: var(--text-secondary);
  font-weight: 600; font-size: 11.5px; letter-spacing: .6px; border-bottom: 2px solid var(--border);
  white-space: nowrap; user-select: none;
}
.comp-datatable td { padding: 10px 14px; border-bottom: 1px solid #f3f4f6; }
.comp-datatable tr:hover td { background: #f8fafc; }
.dt-sortable { cursor: pointer; }
.dt-sortable:hover { background: #eef2ff; }
.dt-sort-icon { margin-left: 4px; font-size: 10px; opacity: .3; }
.dt-sort-icon.active { opacity: 1; color: var(--primary); }
.dt-loading-cell { text-align: center; padding: 32px 14px !important; }
.dt-empty-cell { text-align: center; padding: 40px 14px !important; }
.dt-empty { padding: 16px; }
.dt-empty-icon { font-size: 40px; margin-bottom: 8px; }
.dt-empty-text { font-size: 14px; color: var(--text-muted); }
.dt-info { font-size: 12px; color: var(--text-muted); margin-top: 8px; text-align: right; }

/* SearchForm 组件 */
.comp-search-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.comp-search-inline { padding: 14px 16px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 16px; }
.comp-search-field { display: flex; flex-direction: column; gap: 4px; }
.comp-search-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.comp-search-input {
  height: 38px; padding: 0 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; color: var(--text);
  outline: none; background: var(--card); transition: all .2s;
}
.comp-search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.comp-search-actions { display: flex; gap: 8px; align-items: flex-end; padding-bottom: 1px; }

/* 日志详情 */
.comp-log-pre {
  background: #1e293b; color: #e2e8f0; padding: 14px; border-radius: 8px;
  font-family: "SF Mono","Fira Code","Consolas",monospace; font-size: 12px;
  line-height: 1.6; overflow-x: auto; max-height: 300px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all;
}
.comp-log-error { border-left: 3px solid var(--danger); background: #fef2f2; color: #991b1b; }

/* 暗色模式 */
body.dark {
  --bg: #0f172a; --card: #1e293b; --border: #334155;
  --text: #f1f5f9; --text-secondary: #94a3b8; --text-muted: #64748b;
  --shadow: 0 1px 3px rgba(0,0,0,.3); --shadow-lg: 0 10px 25px rgba(0,0,0,.4);
}
body.dark .card { background: var(--card); border-color: var(--border); }
body.dark input, body.dark select, body.dark textarea { background: #1e293b; color: #f1f5f9; border-color: #334155; }
body.dark th { background: #1e293b; border-color: #334155; }
body.dark td { border-color: #1e293b; }
body.dark tr:hover td { background: #1e293b; }
body.dark .topbar { background: #1e293b; border-color: #334155; }
body.dark .search-bar { background: var(--card); border-color: var(--border); }
body.dark .badge-green { background: #064e3b; color: #6ee7b7; }
body.dark .badge-red { background: #7f1d1d; color: #fca5a5; }
body.dark .badge-yellow { background: #78350f; color: #fcd34d; }
body.dark .badge-blue { background: #1e3a5f; color: #93c5fd; }
body.dark .comp-datatable th { background: #1e293b; border-color: #334155; }
body.dark .comp-datatable td { border-color: #1e293b; }
body.dark .comp-datatable tr:hover td { background: #1e293b; }
body.dark .comp-log-pre { background: #0f172a; color: #e2e8f0; }
body.dark .comp-log-error { background: #450a0a; color: #fca5a5; }
body.dark .comp-skeleton-bar { background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%); background-size: 200% 100%; }
body.dark .comp-loading-overlay { background: rgba(15,23,42,.85); }
body.dark .comp-toast-success { background: #064e3b; color: #6ee7b7; }
body.dark .comp-toast-error { background: #7f1d1d; color: #fca5a5; }
body.dark .comp-toast-info { background: #1e3a5f; color: #93c5fd; }
body.dark .comp-toast-warning { background: #78350f; color: #fcd34d; }
body.dark .modal-box { background: #1e293b; border-color: #334155; }
body.dark .modal-header { border-color: #334155; }
body.dark .modal-footer { border-color: #334155; }
body.dark .comp-search-input { background: #1e293b; color: #f1f5f9; border-color: #334155; }
body.dark .btn-outline { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.dark .btn-outline:hover { background: #334155; }
body.dark .pagination button { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.dark .pagination button:hover { background: #334155; }
body.dark .comp-drawer { background: #1e293b; }
body.dark .comp-drawer-header { border-color: #334155; }
body.dark .comp-drawer-close:hover { background: #334155; }
body.dark .comp-stat-card { background: #1e293b; border-color: #334155; }
body.dark .comp-stat-icon { background: #0f172a; }

/* 移动端 Drawer */
@media (max-width: 768px) {
  .comp-drawer { width: 100vw; }
  .comp-toast-container { left: 16px; right: 16px; max-width: none; }
  .comp-stat-row { grid-template-columns: repeat(2, 1fr); }
  .comp-search-form { flex-direction: column; }
  .comp-search-field { width: 100%; }
  .comp-search-input { width: 100%; }
}

/* ====== 简单图表 ====== */
.chart-container { min-height: 250px; position: relative; }
.chart-placeholder { display: flex; align-items: center; justify-content: center; height: 250px; color: var(--text-muted); }
.simple-chart { padding: 10px 0; }
.chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 250px; padding: 0 10px; }
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-val { font-size: 9px; color: var(--text-muted); margin-bottom: 2px; white-space: nowrap; }
.bar-fill { width: 100%; max-width: 30px; min-width: 6px; background: linear-gradient(180deg, var(--primary), var(--accent)); border-radius: 4px 4px 0 0; transition: height .3s; }
.bar-label { font-size: 10px; color: #333; margin-top: 4px; white-space: nowrap; font-weight: 500; }

/* ═══════════════════════════════════════════════
   充值页面（独立布局，免登录）
   ═══════════════════════════════════════════════ */
.recharge-page {
  min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex; flex-direction: column; align-items: center;
  padding: 20px;
}
.recharge-container { width: 100%; max-width: 440px; }
.recharge-header { text-align: center; padding: 30px 0 20px; color: #fff; }
.recharge-logo { font-size: 48px; margin-bottom: 8px; }
.recharge-header h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.recharge-subtitle { font-size: 14px; opacity: .85; }
.recharge-queue {
  background: rgba(255,255,255,.15); color: #fff; border-radius: 10px;
  padding: 12px 16px; margin-bottom: 16px; text-align: center; font-size: 14px;
  backdrop-filter: blur(10px);
}
.recharge-card {
  background: #fff; border-radius: 16px; padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15); margin-bottom: 16px;
}
.recharge-card h3 { font-size: 17px; margin-bottom: 16px; }
.recharge-card h2 { font-size: 22px; margin-bottom: 8px; text-align: center; }
.recharge-footer { color: rgba(255,255,255,.7); font-size: 12px; text-align: center; padding: 20px 0; }

.step-indicator { display: flex; align-items: center; justify-content: center; gap: 0; margin-bottom: 20px; }
.step {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 13px; font-weight: 700;
  background: #e5e7eb; color: #9ca3af; flex-shrink: 0;
}
.step.active { background: var(--primary); color: #fff; }
.step.done { background: var(--success); color: #fff; }
.step-line { width: 40px; height: 2px; background: #e5e7eb; }
.step-line.done { background: var(--success); }

.amount-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.amount-item {
  border: 2px solid var(--border); border-radius: 12px; padding: 16px 12px;
  text-align: center; cursor: pointer; transition: all .2s;
}
.amount-item:hover { border-color: var(--primary); }
.amount-item.active { border-color: var(--primary); background: var(--primary-light); }
.amount-val { font-size: 20px; font-weight: 700; color: var(--text); }
.amount-gift { font-size: 12px; color: var(--success); margin-top: 2px; min-height: 18px; }

.user-info-card { background: #f9fafb; border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.info-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.info-label { color: var(--text-muted); }

.qrcode-container { text-align: center; padding: 20px; }
.qrcode-img { width: 200px; height: 200px; border-radius: 10px; border: 1px solid var(--border); }
.qrcode-placeholder { padding: 40px; color: var(--text-muted); }
.qrcode-img-wrap { display: inline-block; padding: 10px; background: #fff; border-radius: 12px; box-shadow: var(--shadow); }

.done-icon { font-size: 60px; text-align: center; margin-bottom: 12px; }

/* 充值页面输入框和按钮 */
.recharge-card .input-group { display: flex; flex-direction: column; gap: 12px; }
.recharge-card .input-group input { width: 100%; }
.recharge-card .btn-block { margin-top: 4px; }

/* ═══════════════════════════════════════════════
   充值页面 v2 — 完整组件样式
   ═══════════════════════════════════════════════ */

/* 标题 */
.rc-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 20px; color: #333; }

/* 排队横幅 */
.rc-queue-banner { border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; text-align: center; line-height: 1.5; }
.rc-queue-banner.rc-queue-open { background: #e8f5e9; color: #2e7d32; }
.rc-queue-banner.rc-queue-busy { background: #fff3cd; color: #856404; }

/* 输入项 */
.rc-input { width: 100%; height: 48px; padding: 0 14px; border: 2px solid #e0e0e0; border-radius: 12px; font-size: 16px; outline: none; transition: border-color .2s; box-sizing: border-box; }
.rc-input:focus { border-color: #667eea; }
.rc-hint { font-size: 12px; color: #999; margin-top: 4px; }
.rc-err { font-size: 12px; color: #ff4757; margin-top: 4px; display: none; }

/* 按钮 */
.rc-btn { width: 100%; height: 48px; background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; border: none; border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer; margin-top: 8px; transition: opacity .2s; }
.rc-btn:disabled { opacity: .5; cursor: not-allowed; }
.rc-btn-white { background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.3); color: #fff; }
.rc-btn-cancel { background: none; border: 1px solid #ddd; color: #999; padding: 8px 24px; border-radius: 20px; font-size: 13px; cursor: pointer; margin-top: 20px; }
.rc-btn-spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3); border-top: 2px solid #fff; border-radius: 50%; animation: rc-spin .8s linear infinite; vertical-align: middle; margin-right: 6px; }

/* 加载 */
.rc-loading { text-align: center; margin-top: 16px; color: #666; }
.rc-spinner { width: 40px; height: 40px; border: 3px solid #f3f3f3; border-top: 3px solid #667eea; border-radius: 50%; animation: rc-spin 1s linear infinite; margin: 0 auto; }
@keyframes rc-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* 上传区域 */
.rc-upload-area { border: 2px dashed #667eea; border-radius: 12px; padding: 28px; text-align: center; cursor: pointer; background: #f8f9ff; transition: all .3s; margin-top: 8px; }
.rc-upload-area:active { background: #eef0ff; }
.rc-upload-area.rc-upload-ok { background: #e8f5e9; border-color: #4caf50; }
.rc-upload-icon { font-size: 40px; margin-bottom: 8px; }
.rc-upload-text { color: #667eea; font-weight: 500; font-size: 14px; }
.rc-upload-hint { color: #999; font-size: 12px; margin-top: 4px; }
.rc-ocr-warn { font-size: 12px; color: #f57c00; background: #fff3e0; padding: 8px 12px; border-radius: 8px; margin-top: 10px; }

/* OCR结果 */
.rc-ocr-info { background: #f5f6fa; border-radius: 12px; padding: 14px; margin-top: 12px; }
.rc-ocr-ok { font-size: 14px; color: #4caf50; margin-bottom: 10px; }
.rc-ocr-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #eee; font-size: 13px; }
.rc-ocr-row span:first-child { color: #999; }
.rc-ocr-row span:last-child { color: #333; font-weight: 500; }

/* 车队信息 */
.rc-team-box { background: #f5f6fa; border-radius: 12px; padding: 14px; margin-bottom: 16px; }
.rc-team-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.rc-team-row span:first-child { color: #999; }
.rc-team-row span:last-child { color: #333; font-weight: 500; }

/* 金额网格 */
.rc-amount-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.rc-amount-item { border: 2px solid #e0e0e0; border-radius: 12px; padding: 18px 12px; text-align: center; cursor: pointer; transition: all .2s; }
.rc-amount-item:active { transform: scale(.97); }
.rc-amount-item.rc-selected { border-color: #667eea; background: rgba(102,126,234,.1); }
.rc-amount-item.rc-test-tier { border-color: #ff9800; background: #fff8e1; }
.rc-amount-item.rc-test-tier.rc-selected { border-color: #ff9800; background: #fff3cd; }
.rc-amount-val { font-size: 20px; font-weight: 700; }
.rc-amount-gift { font-size: 13px; color: #4caf50; margin-top: 4px; }
.rc-test-badge { display: inline-block; background: #ff9800; color: #fff; padding: 1px 8px; border-radius: 4px; font-size: 11px; margin-left: 6px; vertical-align: middle; }

/* 排队卡片 */
.rc-queue-card { text-align: center; padding: 20px 10px; }
.rc-queue-icon { font-size: 48px; margin-bottom: 12px; }
.rc-queue-label { font-size: 14px; color: #666; }
.rc-queue-pos { font-size: 36px; font-weight: 800; color: #667eea; margin: 6px 0; }
.rc-queue-sub { font-size: 14px; color: #999; }
.rc-queue-bar { height: 8px; background: #f0f0f0; border-radius: 4px; margin: 16px 0; overflow: hidden; }
.rc-queue-fill { height: 100%; background: linear-gradient(90deg, #667eea, #764ba2); border-radius: 4px; transition: width .6s; }
.rc-queue-hint { font-size: 13px; color: #999; }

/* 步骤卡片 */
.rc-steps-card { padding: 10px 0; }
.rc-steps-header { text-align: center; margin-bottom: 16px; }
.rc-steps-title { font-size: 16px; font-weight: 600; margin-top: 10px; color: #333; }
.rc-steps-hint { font-size: 13px; color: #999; margin-top: 2px; }

.rc-step-item { display: flex; align-items: center; padding: 10px 0; }
.rc-step-item + .rc-step-item { border-top: 1px solid #f5f5f5; }
.rc-step-dot { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-right: 12px; font-size: 15px; flex-shrink: 0; transition: all .4s; }
.rc-step-dot.waiting { background: #f5f6fa; color: #ccc; }
.rc-step-dot.active { background: #e3f2fd; color: #2196f3; animation: rc-stepPulse 1.2s infinite; }
.rc-step-dot.done { background: #e8f5e9; color: #4caf50; }
.rc-step-label { flex: 1; font-size: 14px; color: #999; transition: color .3s; }
.rc-step-label.active { color: #333; font-weight: 600; }
.rc-step-label.done { color: #4caf50; }
@keyframes rc-stepPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(33,150,243,.3); } 50% { box-shadow: 0 0 0 8px rgba(33,150,243,0); } }

/* 结果卡片 */
.rc-result-card { text-align: center; padding: 30px 20px; }
.rc-result-icon { font-size: 60px; margin-bottom: 12px; }
.rc-result-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; color: #333; }
.rc-result-desc { font-size: 14px; color: #666; line-height: 1.6; }
.rc-result-tip { background: #fff3cd; border-radius: 8px; padding: 10px; margin-top: 16px; font-size: 13px; color: #856404; line-height: 1.5; }

/* 成功卡片 */
.rc-success-card { background: linear-gradient(135deg, #667eea, #764ba2) !important; color: #fff; text-align: center; padding: 40px 30px; }
.rc-success-icon { font-size: 60px; margin-bottom: 12px; }
.rc-success-title { font-size: 22px; font-weight: 700; color: #fff; margin-bottom: 6px; }
.rc-success-desc { font-size: 14px; color: rgba(255,255,255,.85); margin-bottom: 20px; }

/* 环境检测 */
.rc-env-icon { font-size: 56px; text-align: center; margin-bottom: 12px; }
.rc-env-title { font-size: 18px; font-weight: 700; text-align: center; color: #333; margin-bottom: 6px; }
.rc-env-desc { font-size: 14px; color: #666; text-align: center; }

/* Toast */
.rc-toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.8); color: #fff; padding: 12px 24px; border-radius: 12px; font-size: 14px; z-index: 9999; max-width: 80%; text-align: center; transition: opacity .3s; }

/* ====== 登录页 ====== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2); width: 100%; max-width: 400px;
}
.login-logo { font-size: 48px; text-align: center; margin-bottom: 8px; }
.login-card h2 { text-align: center; font-size: 22px; margin-bottom: 4px; }

/* ═══════════════════════════════════════════════
   响应式：移动端适配
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar.collapsed { width: var(--sidebar-w); transform: translateX(-100%); }
  .main { margin-left: 0 !important; }
  .mobile-menu-btn { display: block; }
  .topbar { padding: 0 16px; }
  .content-area { padding: 16px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-row-sm { grid-template-columns: repeat(2, 1fr); }
  .stat-val { font-size: 22px; }
  .search-bar { flex-direction: column; }
  .search-bar input, .search-bar select { width: 100% !important; }
  .script-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .pagination { justify-content: center; }
  .modal-container { width: 95%; max-height: 85vh; }
  .topbar h1 { font-size: 15px; }
  .amount-grid { grid-template-columns: 1fr 1fr; }
  .topbar-right .btn-accent { display: none; }
}

@media (max-width: 480px) {
  .stat-row { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 16px 12px; }
  .stat-val { font-size: 20px; }
  .recharge-card { padding: 18px 14px; }
  .recharge-header { padding: 20px 0 10px; }
  .recharge-header h1 { font-size: 20px; }
  .amount-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .amount-item { padding: 12px 8px; }
  .amount-val { font-size: 18px; }
}

/* ══════════════════════════════════════════════
   赠送配置页面
   ══════════════════════════════════════════════ */
.gift-tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.gift-tpl-card { padding: 20px; border-left: 4px solid var(--primary); }
.gift-tpl-card h4 { font-size: 16px; margin: 0; }
.gift-tier-list { max-height: 300px; overflow-y: auto; }
.gift-tier-row { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.gift-tier-row .form-input { width: 90px; }
.gift-fleet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; max-height: 200px; overflow-y: auto; }
.gift-fleet-item { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; padding: 6px 8px; border-radius: 6px; background: var(--bg); }
.gift-fleet-item:hover { background: var(--primary-light); }
.gift-fleet-item input[type="checkbox"] { margin: 0; }

/* 弹窗组件（已统一，见上方 .modal-overlay） */
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 17px; margin: 0; }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; outline: none; transition: border-color .2s; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.ml-2 { margin-left: 8px; }
.mr-2 { margin-right: 8px; }
.mx-2 { margin-left: 8px; margin-right: 8px; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.text-sm { font-size: 12px; }
.fw-bold { font-weight: 600; }
.flex-align-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

@media (max-width: 768px) {
  .gift-tpl-grid { grid-template-columns: 1fr; }
  .gift-fleet-grid { grid-template-columns: 1fr 1fr; }
  .modal-box { width: 95%; max-height: 90vh; }
  .gift-tier-row .form-input { width: 70px; }
}
