/* ============================================================
   ConOrg Admin - 设计系统
   参考：统一支付集成中台设计风格
   ============================================================ */

/* ========== 1. 设计令牌（Design Tokens） ========== */
:root {
  /* 背景层级 */
  --bg: #f3f4f9;
  --bg2: #fff;
  --bg3: #eceef5;

  /* 卡片 */
  --card: rgba(255, 255, 255, 0.82);
  --card-hover: rgba(255, 255, 255, 0.96);
  --card-solid: #fff;

  /* 边框 */
  --border: rgba(0, 0, 0, 0.08);
  --border-light: rgba(0, 0, 0, 0.14);

  /* 文字 */
  --text: #1a1d29;
  --text2: #555c70;
  --text3: #8e95a8;

  /* 主色 */
  --accent: #6c5ce7;
  --accent2: #0891b2;
  --accent3: #db2777;
  --accent-glow: rgba(108, 92, 231, 0.28);
  --accent2-glow: rgba(8, 145, 178, 0.25);

  /* 状态色 */
  --success: #059669;
  --warning: #d97706;
  --error: #dc2626;
  --info: #0891b2;
  --success-bg: rgba(5, 150, 105, 0.1);
  --warning-bg: rgba(217, 119, 6, 0.1);
  --error-bg: rgba(220, 38, 38, 0.08);
  --info-bg: rgba(8, 145, 178, 0.1);

  /* 布局元素 */
  --sidebar-bg: rgba(255, 255, 255, 0.88);
  --topbar-bg: rgba(243, 244, 249, 0.85);
  --input-bg: rgba(0, 0, 0, 0.03);
  --hover-bg: rgba(0, 0, 0, 0.045);
  --inner-bg: rgba(0, 0, 0, 0.025);

  /* 滚动条 */
  --scrollbar: rgba(0, 0, 0, 0.12);
  --scrollbar-hover: rgba(0, 0, 0, 0.22);

  /* 字体 */
  --font: "Inter", -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Consolas, monospace;

  /* 圆角 */
  --r: 14px;
  --r2: 10px;
  --r3: 8px;
  --r-full: 999px;

  /* 尺寸 */
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 60px;

  /* 阴影 */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 24px var(--accent-glow);

  /* 过渡 */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== 暗色主题 ========== */
[data-theme="dark"] {
  --bg: #08090f;
  --bg2: #0d0f18;
  --bg3: #12151f;
  --card: rgba(255, 255, 255, 0.035);
  --card-hover: rgba(255, 255, 255, 0.06);
  --card-solid: #12151f;
  --border: rgba(255, 255, 255, 0.07);
  --border-light: rgba(255, 255, 255, 0.12);
  --text: #e8eaf0;
  --text2: #9ca3b8;
  --text3: #5c6378;
  --accent: #7c6cf0;
  --accent2: #06b6d4;
  --accent3: #f472b6;
  --accent-glow: rgba(124, 108, 240, 0.35);
  --accent2-glow: rgba(6, 182, 212, 0.3);
  --success: #34d399;
  --warning: #fbbf24;
  --error: #f87171;
  --info: #06b6d4;
  --success-bg: rgba(52, 211, 153, 0.1);
  --warning-bg: rgba(251, 191, 36, 0.1);
  --error-bg: rgba(248, 113, 113, 0.1);
  --info-bg: rgba(6, 182, 212, 0.1);
  --sidebar-bg: rgba(13, 15, 24, 0.88);
  --topbar-bg: rgba(8, 9, 15, 0.88);
  --input-bg: rgba(255, 255, 255, 0.05);
  --hover-bg: rgba(255, 255, 255, 0.06);
  --inner-bg: rgba(255, 255, 255, 0.025);
  --scrollbar: rgba(255, 255, 255, 0.12);
  --scrollbar-hover: rgba(255, 255, 255, 0.22);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ========== 2. 基础重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }

/* 滚动条 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* ========== 3. 布局框架 ========== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-slow);
}

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .nav-text,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-group-title,
.sidebar.collapsed .sidebar-footer-user { display: none; }

.logo {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.logo-icon {
  width: 36px; height: 36px;
  border-radius: var(--r2);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.logo-text {
  font-size: 16px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

/* 导航 */
.nav-menu {
  flex: 1;
  padding: 12px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-group { margin-bottom: 8px; }

.nav-group-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r3);
  color: var(--text2);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  margin-bottom: 2px;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.nav-item i {
  font-size: 18px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--error);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--r-full);
  min-width: 18px;
  text-align: center;
}

/* 侧边栏底部 */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--r3);
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-user:hover { background: var(--hover-bg); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--accent3), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 14px;
  flex-shrink: 0;
}

.sidebar-footer-user { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text3); }

/* 主内容区 */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  transition: margin-left var(--transition-slow);
  min-height: 100vh;
}

.sidebar.collapsed ~ .main-wrapper { margin-left: var(--sidebar-w-collapsed); }

/* 顶部栏 */
.topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.sidebar-toggle {
  width: 36px; height: 36px;
  border-radius: var(--r3);
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
  transition: var(--transition);
  font-size: 18px;
}

.sidebar-toggle:hover { background: var(--hover-bg); color: var(--text); }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text3);
}

.breadcrumb .current {
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
}

.breadcrumb i { font-size: 14px; }

.topbar-center { flex: 1; display: flex; justify-content: center; }

.global-search {
  width: 100%;
  max-width: 400px;
  position: relative;
}

.global-search input {
  width: 100%;
  padding: 8px 14px 8px 38px;
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: var(--r3);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: var(--transition);
}

.global-search input:focus {
  border-color: var(--accent);
  background: var(--card-solid);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.global-search i {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 16px;
}

.search-kbd {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text3);
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--mono);
}

.topbar-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--r3);
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
  transition: var(--transition);
  font-size: 18px;
  position: relative;
}

.icon-btn:hover { background: var(--hover-bg); color: var(--text); }

.icon-btn .dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: var(--error);
  border-radius: var(--r-full);
  border: 2px solid var(--bg2);
}

/* 内容区 */
.page-content {
  padding: 24px;
  min-height: calc(100vh - var(--topbar-h));
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--text3); margin-top: 4px; }

.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ========== 4. 卡片 ========== */
.card {
  background: var(--card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow); }

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--accent); }

.card-body { padding: 20px; }
.card-body.no-padding { padding: 0; }

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 统计卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: 0;
  transition: var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card:hover::before { opacity: 1; }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--r2);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.stat-icon.purple { background: var(--accent-glow); color: var(--accent); }
.stat-icon.cyan { background: var(--accent2-glow); color: var(--accent2); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.red { background: var(--error-bg); color: var(--error); }
.stat-icon.orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon.pink { background: rgba(219, 39, 119, 0.1); color: var(--accent3); }

.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--text3); margin-top: 2px; }
.stat-trend { font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--error); }

/* ========== 5. 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r3);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn i { font-size: 15px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--card-solid);
  color: var(--text);
  border-color: var(--border-light);
}

.btn-secondary:hover { background: var(--hover-bg); border-color: var(--accent); color: var(--accent); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { opacity: 0.9; }

.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.btn-ghost { color: var(--text2); }
.btn-ghost:hover { background: var(--hover-bg); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-sm i { font-size: 13px; }

.btn-lg { padding: 10px 24px; font-size: 14px; }

.btn-block { width: 100%; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ========== 6. 标签 ========== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
}

.tag::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: var(--r-full);
  background: currentColor;
}

.tag-green { background: var(--success-bg); color: var(--success); }
.tag-yellow { background: var(--warning-bg); color: var(--warning); }
.tag-red { background: var(--error-bg); color: var(--error); }
.tag-blue { background: var(--info-bg); color: var(--info); }
.tag-purple { background: var(--accent-glow); color: var(--accent); }
.tag-gray { background: var(--bg3); color: var(--text3); }

/* ========== 7. 表格 ========== */
.table-wrapper { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 12px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
  background: var(--inner-bg);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background: var(--hover-bg); }
.data-table tbody tr:last-child td { border-bottom: none; }

.cell-primary { font-weight: 600; }
.cell-secondary { color: var(--text2); font-size: 12.5px; }
.cell-mono { font-family: var(--mono); font-size: 12px; color: var(--text2); }

.cell-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* ========== 8. 表单 ========== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text2); }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 14px;
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: var(--r3);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  background: var(--card-solid);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-textarea { resize: vertical; min-height: 80px; font-family: var(--mono); font-size: 12px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ========== 9. 弹窗 ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }

.modal {
  background: var(--card-solid);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.large { max-width: 880px; }
.modal.xlarge { max-width: 1100px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.modal-title i { color: var(--accent); }

.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--r3);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
  font-size: 20px;
  transition: var(--transition);
}

.modal-close:hover { background: var(--hover-bg); color: var(--text); }

.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ========== 10. 抽屉 ========== */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 900;
  display: none;
}

.drawer-overlay.active { display: block; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 480px;
  max-width: 90vw;
  background: var(--card-solid);
  box-shadow: var(--shadow-lg);
  z-index: 901;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.drawer.active { transform: translateX(0); }
.drawer.large { width: 640px; }

.drawer-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-body { padding: 24px; overflow-y: auto; flex: 1; }

/* ========== 11. Toast ========== */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 400px;
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 13px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.leaving { animation: toastOut 0.25s ease forwards; }
@keyframes toastOut {
  to { opacity: 0; transform: translateX(40px); }
}

.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--error); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

.toast-content { flex: 1; }
.toast-title { font-weight: 600; font-size: 13px; }
.toast-msg { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ========== 12. 日志查看器 ========== */
.log-viewer {
  background: #0d1117;
  border-radius: var(--r2);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  color: #c9d1d9;
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-viewer .log-info { color: #58a6ff; }
.log-viewer .log-warn { color: #d29922; }
.log-viewer .log-error { color: #f85149; }
.log-viewer .log-time { color: #6e7681; }

/* ========== 13. 加载与空状态 ========== */
.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text3);
  gap: 12px;
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: var(--r-full);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-desc { font-size: 13px; color: var(--text3); margin-bottom: 16px; }

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--hover-bg) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r3);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== 14. 筛选工具栏 ========== */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--inner-bg);
  padding: 4px;
  border-radius: var(--r3);
}

.filter-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text2);
  transition: var(--transition);
}

.filter-tab:hover { color: var(--text); }
.filter-tab.active { background: var(--card-solid); color: var(--accent); box-shadow: var(--shadow-sm); }

.search-box {
  position: relative;
  width: 240px;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: var(--r3);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--accent);
  background: var(--card-solid);
}

.search-box i {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 15px;
}

/* ========== 15. 图表容器 ========== */
.chart-container {
  width: 100%;
  height: 300px;
}

.chart-container.small { height: 200px; }
.chart-container.large { height: 400px; }

/* ========== 16. 网格布局 ========== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ========== 17. 工具类 ========== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-secondary { color: var(--text2); }
.text-muted { color: var(--text3); }
.text-mono { font-family: var(--mono); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ========== 18. 响应式 ========== */
@media (max-width: 1024px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-center { display: none; }
  .page-content { padding: 16px; }
  .modal { max-height: 95vh; }
}

/* ========== Compose 栈页面追加样式 ========== */
.log-lines-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.compose-viewer {
  background: #0d1117;
  border-radius: var(--r2);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  color: #c9d1d9;
  max-height: 560px;
  overflow: auto;
  white-space: pre;
}
.cell-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }

/* ========== 日志中心页面 ========== */
.logs-layout {
  display: flex;
  gap: 16px;
  align-items: stretch;
  min-height: calc(100vh - 200px);
}
.logs-sidebar {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.logs-sidebar-head {
  padding: 14px 16px 8px;
}
.logs-sidebar-title {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logs-sidebar-search {
  padding: 0 12px 10px;
}
.logs-container-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}
.logs-container-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r2);
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 2px;
}
.logs-container-item:hover { background: var(--bg2); }
.logs-container-item.selected {
  background: var(--accent-glow);
  color: var(--accent);
}
.logs-container-item i { font-size: 15px; flex-shrink: 0; }
.logs-cname {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12px;
}
.logs-empty-small {
  text-align: center;
  color: var(--text3);
  font-size: 12px;
  padding: 20px 0;
}
.logs-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.logs-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.logs-current-container {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  font-family: var(--mono);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logs-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.logs-line-group {
  display: inline-flex;
  gap: 4px;
}
.logs-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
}
.logs-search-nav {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text2);
  padding: 0 2px;
  font-size: 14px;
}
.logs-search-nav:hover { color: var(--accent); }
.logs-match-count {
  font-size: 11px;
  color: var(--text3);
  min-width: 36px;
  text-align: right;
}
.logs-viewer-wrap {
  flex: 1;
  position: relative;
  min-height: 400px;
  display: flex;
}
.logs-empty-hint {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text3);
  font-size: 14px;
  padding: 60px 20px;
}
.logs-empty-hint i { font-size: 48px; opacity: 0.4; }
.logs-viewer {
  flex: 1;
  background: #1e1e2e;
  padding: 12px 0;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: #cdd6f4;
}
.log-line {
  padding: 0 16px;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-line:hover { background: rgba(255,255,255,0.04); }
.log-lineno {
  display: inline-block;
  width: 44px;
  margin-right: 12px;
  text-align: right;
  color: #585b70;
  user-select: none;
}
mark.log-hl {
  background: #f9e2af;
  color: #1e1e2e;
  border-radius: 2px;
  padding: 0 1px;
}
mark.log-hl.active {
  background: #fab387;
  outline: 1px solid #f9e2af;
}

/* ========== 事件流页面 ========== */
.events-toolbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.events-conn {
  display: inline-flex;
  align-items: center;
  font-size: 12.5px;
  color: var(--text2);
}

.events-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 7px;
}
.events-dot.dot-green { background: var(--success); }
.events-dot.dot-yellow { background: var(--warning); }
.events-dot.dot-red { background: var(--error); }
.events-dot.dot-gray { background: var(--text3); }

.events-timeline {
  position: relative;
  max-height: calc(100vh - 280px);
  min-height: 200px;
  overflow-y: auto;
  padding: 18px 20px 18px 34px;
}

.events-timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--border);
}

.event-item {
  position: relative;
  padding: 9px 0;
}

.event-dot {
  position: absolute;
  left: -21px;
  top: 15px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text3);
  border: 2px solid var(--card);
  z-index: 1;
}
.event-dot.dot-create { background: var(--info); }
.event-dot.dot-start { background: var(--success); }
.event-dot.dot-stop { background: var(--warning); }
.event-dot.dot-destroy,
.event-dot.dot-die { background: var(--error); }
.event-dot.dot-health_status { background: var(--accent); }
.event-dot.dot-other { background: var(--text3); }

.event-content { min-width: 0; }

.event-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.event-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text3);
}

.event-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.event-detail {
  font-size: 12px;
  color: var(--text3);
  margin-top: 3px;
}

.events-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  color: var(--text3);
  gap: 10px;
}
.events-empty .empty-icon { font-size: 36px; opacity: .5; }
.events-empty .empty-desc { font-size: 13px; }

/* ========== 系统清理页面 ========== */
#page-cleanup .page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.cleanup-desc {
  font-size: 13px;
  margin-bottom: 14px;
}

.cleanup-danger-tag {
  display: inline-block;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--error);
  background: var(--error-bg);
  border-radius: var(--r-full);
  vertical-align: middle;
}

.cleanup-estimate {
  min-height: 52px;
  padding: 10px 12px;
  margin-bottom: 16px;
  background: var(--inner-bg);
  border: 1px dashed var(--border-light);
  border-radius: var(--r3);
  font-size: 13px;
}

.cleanup-estimate .cleanup-hint {
  font-size: 12px;
}

.cleanup-est-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text2);
}

.cleanup-est-row i {
  color: var(--text3);
  font-size: 15px;
}

.cleanup-est-space {
  font-weight: 700;
  color: var(--warning);
  font-size: 15px;
}

.cleanup-est-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text3);
}

.cleanup-error {
  color: var(--error);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cleanup-actions {
  display: flex;
  gap: 10px;
}

.cleanup-actions .btn {
  flex: 1;
}

/* 弹窗警告条 */
.cleanup-warn {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--warning);
  background: var(--warning-bg);
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: var(--r3);
}

.cleanup-warn i {
  font-size: 18px;
  flex-shrink: 0;
}

.cleanup-warn-danger {
  color: var(--error);
  background: var(--error-bg);
  border-color: rgba(220, 38, 38, 0.3);
}

.cleanup-confirm-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text2);
}

.cleanup-info-row b {
  color: var(--text);
}

/* 按钮内小 spinner */
.btn .btn-spinner,
.btn-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 4px;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* ========== 操作审计页面 ========== */
.audit-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.audit-toolbar-right .form-input {
  width: auto;
  padding: 8px 12px;
  font-size: 13px;
}
.audit-row { cursor: pointer; }
.audit-action { font-weight: 500; font-size: 13px; }
.audit-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  margin-top: 3px;
  word-break: break-all;
}
.audit-detail-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  margin-left: 6px;
  padding: 0;
}
.audit-detail-btn:hover { text-decoration: underline; }
.audit-detail-row td { background: var(--inner-bg) !important; padding: 10px 16px; }
.audit-detail-pre {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}
.audit-loadmore {
  display: flex;
  justify-content: center;
  padding: 16px;
  border-top: 1px solid var(--border);
}
