/* ============================================================
   磐石后台 RockAdmin · 设计系统（自研，浅色主题）
   ============================================================ */

:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --line: #e4e8f0;
  --line-strong: #d3d9e6;
  --text: #1c2434;
  --text-2: #525d70;
  --text-3: #8a94a6;
  --accent: #3b5bdb;
  --accent-hover: #364fc7;
  --accent-soft: #eef1fd;
  --green: #2f9e44;
  --green-soft: #ebfbee;
  --red: #e03131;
  --red-soft: #fff5f5;
  --orange: #e8590c;
  --orange-soft: #fff4e6;
  --blue: #1971c2;
  --blue-soft: #e7f5ff;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .14);
  --sidebar-w: 230px;
  --sidebar-w-collapsed: 62px;
  --navbar-h: 52px;
  --surface-2: #f8f9fc;      /* 次级表面：表头/hover/提示 */
  --surface-3: #f5f7fb;      /* 三级表面：标签/禁用/缩略图 */
  --red-line: #f0c6c6;       /* 危险按钮描边 */
  --tree-line: #c3cbdd;      /* 树形连接线 */
  --input-hover-line: #b9c2d4;
  --login-grad-1: #eef2fb;
  --login-grad-2: #f7f9fc;
  --code-bg: #101828;
  --code-text: #e2e8f0;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  /* 图标尺寸（相对字号）：整体想再大/再小，只改这三个值 */
  --icon-size: 1em;
  --icon-size-sm: .85em;
  --icon-size-lg: 1.3em;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
p { margin: 0; }
hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }
/* 图标尺寸跟随字号：正文 14px 下 = 14px（原 18px 偏大），随浏览器缩放 / 系统字号自动变 */
.icon { width: var(--icon-size); height: var(--icon-size); vertical-align: -.15em; flex: none; }
.icon-sm { width: var(--icon-size-sm); height: var(--icon-size-sm); }
.icon-lg { width: var(--icon-size-lg); height: var(--icon-size-lg); }
.mono { font-family: var(--mono); }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
.w-auto { width: auto; }

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(112, 72, 232, .10), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, rgba(59, 91, 219, .12), transparent 60%),
    linear-gradient(160deg, var(--login-grad-1), var(--login-grad-2));
}
.login-card {
  width: 400px;
  max-width: 100%;
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 40px 42px 30px;
}
.login-brand { text-align: center; margin-bottom: 30px; }
.login-brand .brand-mark { width: 46px; height: 46px; font-size: 19px; margin: 0 auto 12px; }
.login-brand h1 { font-size: 20px; }
.login-brand p { color: var(--text-3); font-size: 13px; margin-top: 6px; }
.login-tip { margin-top: 18px; padding: 10px 12px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--text-3); font-size: 12.5px; line-height: 1.7; }
.captcha-box { display: flex; gap: 8px; align-items: center; }
.captcha-box .input { flex: 1; }
.captcha-img { width: 120px; height: 40px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface-3); }

/* ============ 应用框架 ============ */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: width .18s ease;
  z-index: 60;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.brand {
  height: var(--navbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
  overflow: hidden;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7048e8);
  color: #fff;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 800;
  flex: none;
}
.brand-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; }
.sidebar.collapsed .brand-name,
.sidebar.collapsed .menu-title,
.sidebar.collapsed .menu-item span,
.sidebar.collapsed .menu-caret,
.sidebar.collapsed .menu-badge { display: none; }
.sidebar.collapsed .menu-item { justify-content: center; padding: 9px 0; }
.sidebar.collapsed .menu-group { margin-top: 10px; }
.sidebar.collapsed .menu-children { display: none !important; }

.menu { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 8px 24px; }
.menu-title {
  font-size: 11.5px;
  color: var(--text-3);
  padding: 12px 10px 6px;
  letter-spacing: .05em;
  white-space: nowrap;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  position: relative;
}
.menu-item:hover { background: var(--accent-soft); color: var(--accent); }
.menu-item.active { background: var(--accent); color: #fff; }
.menu-item.active .menu-caret { color: #fff; }
.menu-item .icon { opacity: .9; width: 1.05em; height: 1.05em; flex: none; }
.menu-item span { overflow: hidden; text-overflow: ellipsis; }

/* 折叠分组头：有子菜单的节点，点一下展开，再点收起。
   :not(.active) 是为了让「自身也是页面」的父节点保持选中态不被展开态盖掉 */
.menu-parent { font-weight: 500; }
.menu-parent.open:not(.active) { color: var(--accent); background: var(--accent-soft); }
.menu-parent.open > .icon { opacity: 1; }
.menu-caret { margin-left: auto; color: var(--text-3); transition: transform .18s; font-size: 11px; flex: none; }
.menu-item.open > .menu-caret { transform: rotate(90deg); }

/* 折叠面板用 grid 0fr/1fr 做高度动画（不依赖固定 max-height，子项多少都自适应） */
.menu-children { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .2s ease; }
.menu-children.open { grid-template-rows: 1fr; }
.menu-sub { overflow: hidden; min-height: 0; }

/* 层级缩进：depth 由 layout.html 渲染时写入，插件三层（总 → 分组 → 页面）也够用 */
.menu-item[data-depth="1"] { padding-left: 26px; font-size: 13.5px; }
.menu-item[data-depth="2"] { padding-left: 44px; font-size: 13px; }
.menu-item[data-depth="3"] { padding-left: 60px; font-size: 13px; }

.menu-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  border-radius: 999px;
  padding: 0 6px;
  line-height: 18px;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.navbar {
  height: var(--navbar-h);
  flex: none;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 6px;
}
.nav-btn {
  height: 34px;
  min-width: 34px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  font: inherit;
}
.nav-btn:hover { background: var(--accent-soft); color: var(--accent); }
.nav-path { color: var(--text-3); font-size: 12.5px; margin-left: 4px; }
.nav-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 700;
  flex: none;
  overflow: hidden;
}

.tabbar {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 7px 10px 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  flex: none;
  min-height: 40px;
}
.tabbar::-webkit-scrollbar { height: 0; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 12px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: var(--surface-3);
  color: var(--text-2);
  cursor: pointer;
  font-size: 12.5px;
  white-space: nowrap;
  max-width: 200px;
}
.tab:hover { color: var(--accent); }
.tab.active { background: var(--panel); color: var(--text); font-weight: 600; border-color: var(--line); position: relative; }
.tab.active::after { content: ''; position: absolute; left: -1px; right: -1px; bottom: -1px; height: 1px; background: var(--panel); }
.tab-close {
  display: inline-grid; place-items: center;
  width: 16px; height: 16px;
  border-radius: 4px;
  font-style: normal;
  color: var(--text-3);
  flex: none;
}
.tab-close:hover { background: var(--red-soft); color: var(--red); }
.tab-home .tab-close { display: none; }

.content { flex: 1; position: relative; min-height: 0; }
.frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
  display: none;
}
.frame.active { display: block; }

/* ============ 页面通用 ============ */
.page { padding: 16px 18px; max-width: 1280px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-title { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.page-desc { color: var(--text-3); font-size: 12.5px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex: none; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card-header {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.toolbar .spacer { flex: 1; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 600;
  background: var(--surface-2);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  user-select: none;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table .sortable { cursor: pointer; }
.table .sortable:hover { color: var(--accent); }
.table .sortable::after { content: '⇅'; opacity: .3; margin-left: 4px; font-size: 11px; }
.table .sortable.asc::after { content: '↑'; opacity: 1; color: var(--accent); }
.table .sortable.desc::after { content: '↓'; opacity: 1; color: var(--accent); }
.row-check { width: 36px; text-align: center; }
.row-ops { white-space: nowrap; }
.row-ops .btn-text + .btn-text { margin-left: 2px; }
.tree-cell { display: flex; align-items: center; gap: 6px; }
.tree-line { color: var(--tree-line); font-family: var(--mono); flex: none; }

/* ============ 表单 ============ */
.form-item { display: flex; margin-bottom: 16px; }
.form-item:last-child { margin-bottom: 0; }
.form-label {
  width: 112px;
  flex: none;
  padding-top: 7px;
  text-align: right;
  color: var(--text-2);
  padding-right: 14px;
}
.form-label .req { color: var(--red); margin-right: 3px; }
.form-value { flex: 1; min-width: 0; padding-right: 20px; }
.form-tip { color: var(--text-3); font-size: 12px; margin-top: 5px; line-height: 1.6; }
.form-error { color: var(--red); font-size: 12px; margin-top: 5px; }

.input, .select, .textarea {
  width: 100%;
  padding: 7px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--panel);
  transition: border-color .15s, box-shadow .15s;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--input-hover-line); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input[disabled] { background: var(--surface-3); color: var(--text-3); }
.textarea { min-height: 100px; resize: vertical; line-height: 1.6; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.input-sm, .select-sm { padding: 5px 9px; font-size: 12.5px; }
.form-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-inline .input, .form-inline .select { width: auto; min-width: 150px; }
.form-actions {
  padding: 13px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* 单选/复选/开关 */
.radio, .checkbox { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 8px 4px 0; }
.radio input, .checkbox input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.checkbox-group, .radio-group { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.switch { position: relative; display: inline-block; width: 38px; height: 20px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: #ccd3e0;
  border-radius: 999px;
  transition: .18s;
  cursor: pointer;
}
.switch .slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: var(--panel);
  border-radius: 50%;
  transition: .18s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { color: var(--red); border-color: var(--red-line); background: var(--panel); }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-success { color: var(--green); border-color: #bfe3c6; }
.btn-success:hover { background: var(--green); border-color: var(--green); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-text { border-color: transparent; background: transparent; padding: 4px 8px; color: var(--accent); }
.btn-text:hover { background: var(--accent-soft); }
.btn-text.danger { color: var(--red); }
.btn-text.danger:hover { background: var(--red-soft); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn .icon { width: 1.05em; height: 1.05em; }

/* ============ 分页 ============ */
.pagination { display: flex; align-items: center; gap: 4px; padding: 12px 16px; justify-content: flex-end; flex-wrap: wrap; }
.page-btn {
  min-width: 30px; height: 30px;
  display: inline-grid; place-items: center;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  background: var(--panel);
  font-size: 13px;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn.disabled { opacity: .45; pointer-events: none; }
.page-ellipsis { color: var(--text-3); padding: 0 2px; }
.page-jump { color: var(--text-3); font-size: 12.5px; margin-left: 8px; }

/* ============ 标签 / 徽章 ============ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 21px;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-red { background: var(--red-soft); color: var(--red); }
.tag-orange { background: var(--orange-soft); color: var(--orange); }
.tag-blue { background: var(--blue-soft); color: var(--blue); }
.tag-accent { background: var(--accent-soft); color: var(--accent); }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: grid; place-items: center;
  z-index: 500;
  padding: 24px;
  animation: fade-in .15s ease;
}
.modal-mask[hidden] { display: none; }
.modal {
  background: var(--panel);
  border-radius: 14px;
  width: 600px;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease;
}
.modal-sm { width: 420px; }
.modal-lg { width: 760px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  flex: none;
}
.modal-body { padding: 18px; overflow: auto; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex: none; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ============ 轻提示 ============ */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 9px 16px;
  font-size: 13.5px;
  animation: toast-in .2s ease;
  max-width: 460px;
  pointer-events: auto;
}
.toast.success { border-left-color: var(--green); }
.toast.success .icon { color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.error .icon { color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
.toast.leaving { opacity: 0; transition: opacity .25s; }

/* ============ 下拉 ============ */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  padding: 6px;
  display: none;
  z-index: 200;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text-2);
  background: none; border: none; font: inherit; font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--accent-soft); color: var(--accent); }
.dropdown-menu .divider { height: 1px; background: var(--line); margin: 5px 0; }

/* ============ 统计卡片 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  display: flex;
  gap: 13px;
  align-items: center;
  box-shadow: var(--shadow);
}
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat-icon .icon { width: 21px; height: 21px; }
.stat-value { font-size: 21px; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }

/* ============ CSS 柱图 ============ */
.chart { display: flex; align-items: flex-end; gap: 12px; height: 150px; padding: 10px 4px 0; }
.chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.chart .bar {
  width: 72%; max-width: 36px;
  background: linear-gradient(180deg, var(--accent), #7048e8);
  border-radius: 5px 5px 2px 2px;
  min-height: 3px;
  transition: height .35s ease;
}
.chart .bar-num { font-size: 11px; color: var(--text-2); }
.chart .bar-label { font-size: 11px; color: var(--text-3); }

/* ============ 系统信息表 ============ */
.kv-table { width: 100%; border-collapse: collapse; }
.kv-table th, .kv-table td { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; vertical-align: top; }
.kv-table th { color: var(--text-2); font-weight: 500; width: 130px; text-align: left; }
.kv-table tr:last-child th, .kv-table tr:last-child td { border-bottom: none; }

/* ============ 附件网格 ============ */
.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 12px; padding: 16px; }
.attach-item { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel); position: relative; }
.attach-item.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.attach-thumb { height: 96px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); overflow: hidden; }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-thumb .icon { width: 30px; height: 30px; opacity: .55; }
.attach-meta { padding: 7px 9px; font-size: 12px; }
.attach-name { font-weight: 500; }
.attach-sub { color: var(--text-3); margin-top: 2px; }
.attach-ops { position: absolute; top: 6px; right: 6px; display: none; gap: 4px; }
.attach-item:hover .attach-ops { display: flex; }
.attach-ops .btn { padding: 3px 7px; background: var(--panel); box-shadow: var(--shadow); }
.attach-ops .icon { width: 13px; height: 13px; }

/* ============ 配置中心 ============ */
.config-layout { display: grid; grid-template-columns: 170px 1fr; gap: 14px; align-items: start; }
.config-nav { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); position: sticky; top: 16px; }
.config-nav a { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: var(--radius-sm); color: var(--text-2); font-size: 13.5px; }
.config-nav a:hover { background: var(--accent-soft); color: var(--accent); }
.config-nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
@media (max-width: 860px) { .config-layout { grid-template-columns: 1fr; } .config-nav { position: static; display: flex; overflow-x: auto; } }

/* ============ 插件卡片 ============ */
.addon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.addon-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.addon-card .head { display: flex; align-items: center; gap: 10px; }
.addon-card .addon-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.addon-card .name { font-weight: 700; }
.addon-card .desc { color: var(--text-2); font-size: 12.5px; line-height: 1.6; flex: 1; }
.addon-card .foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 10px; }

/* ============ 代码块 / 文档 ============ */
.code-block {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  overflow-x: auto;
  line-height: 1.75;
  white-space: pre;
}
.code-block .c-key { color: #7dd3fc; }
.code-block .c-str { color: #86efac; }
.code-block .c-com { color: #94a3b8; }
.doc-section + .doc-section { margin-top: 18px; }
.doc-section h3 { font-size: 14.5px; margin-bottom: 8px; display: flex; align-items: center; gap: 7px; }
.doc-section p { color: var(--text-2); font-size: 13px; line-height: 1.8; }

/* ============ 生成器 ============ */
.gen-layout { display: grid; grid-template-columns: 300px 1fr; gap: 14px; align-items: start; }
@media (max-width: 980px) { .gen-layout { grid-template-columns: 1fr; } }
.field-table th, .field-table td { padding: 7px 10px; font-size: 12.5px; }
.field-table .input, .field-table .select { padding: 4px 8px; font-size: 12.5px; }
.step-bar { display: flex; gap: 6px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--text-3); font-size: 13px; }
.step.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.step.done { background: var(--green-soft); border-color: #b2dfbc; color: var(--green); }
.step-arrow { color: var(--text-3); }

/* ============ 空状态 ============ */
.empty { padding: 52px 16px; text-align: center; color: var(--text-3); }
.empty .icon { width: 42px; height: 42px; opacity: .45; margin-bottom: 10px; }
.empty p { font-size: 13px; }

/* ============ 错误页 ============ */
.error-page { min-height: 60vh; display: grid; place-items: center; text-align: center; padding: 40px; }
.error-page .code { font-size: 64px; font-weight: 800; color: var(--accent); opacity: .25; }
.error-page h2 { font-size: 20px; margin: 10px 0 8px; }
.error-page p { color: var(--text-3); margin-bottom: 20px; }

/* ============ 上传区 ============ */
.upload-drop {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 30px 16px;
  text-align: center;
  color: var(--text-3);
  cursor: pointer;
  transition: all .15s;
  background: var(--surface-2);
}
.upload-drop:hover, .upload-drop.dragover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.upload-drop .icon { width: 30px; height: 30px; margin-bottom: 8px; }
.upload-progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.upload-progress > div { height: 100%; background: var(--accent); transition: width .2s; }
.uploader-inline { display: flex; gap: 8px; align-items: flex-start; }
.uploader-inline .input { flex: 1; }
.file-preview { width: 56px; height: 56px; border: 1px solid var(--line); border-radius: var(--radius-sm); display: grid; place-items: center; overflow: hidden; background: var(--surface-2); flex: none; }
.file-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ============ 安装向导 ============ */
.install-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, var(--login-grad-1), var(--login-grad-2)); }
.install-card { width: 640px; max-width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
.install-head { padding: 26px 32px 20px; border-bottom: 1px solid var(--line); }
.install-body { padding: 24px 32px; }
.install-foot { padding: 16px 32px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; }
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13.5px; }
.check-row .icon { flex: none; }
.check-row.pass .icon { color: var(--green); }
.check-row.fail { border-color: var(--red-line); background: var(--red-soft); }
.check-row.fail .icon { color: var(--red); }
.check-row .grow { color: var(--text-2); }

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c9d2e0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #aeb9cc; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; width: var(--sidebar-w); }
  .sidebar.collapsed { width: var(--sidebar-w); }
  .form-item { flex-direction: column; gap: 4px; }
  .form-label { width: auto; text-align: left; padding-right: 0; }
  .form-value { padding-right: 0; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .gen-layout { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr !important; }
}

/* ============ 仪表盘栅格 ============ */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

/* ============ 富文本编辑器 ============ */
.editor { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.editor-toolbar button {
  min-width: 30px; height: 28px; padding: 0 7px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 6px;
  color: var(--text-2); cursor: pointer; font: inherit; font-size: 13px;
}
.editor-toolbar button:hover { background: var(--accent-soft); color: var(--accent); }
.editor-toolbar .sep { width: 1px; background: var(--line); margin: 4px 5px; }
.editor-body { min-height: 220px; max-height: 560px; overflow-y: auto; padding: 12px 14px; outline: none; line-height: 1.75; font-size: 13.5px; }
.editor-body:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.editor-body img { max-width: 100%; border-radius: 6px; }
.editor-body blockquote { margin: 10px 0; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; color: var(--text-2); }
.editor-body pre { background: var(--code-bg); color: var(--code-text); padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; }
.editor-body h2 { font-size: 17px; margin: 14px 0 8px; }
.editor-body h3 { font-size: 15px; margin: 12px 0 6px; }
.editor-body a { text-decoration: underline; }

/* ============ 附件选择弹窗 ============ */
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; max-height: 46vh; overflow-y: auto; }
.picker-item { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; background: #fff; }
.picker-item:hover, .picker-item.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.picker-item .thumb { height: 78px; display: grid; place-items: center; background: var(--surface-3); overflow: hidden; }
.picker-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.picker-item .name { padding: 6px 8px; font-size: 11.5px; color: var(--text-2); }

/* ============ 规则树 / 菜单树 ============ */
.rule-tree { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.rule-tree-group { border-bottom: 1px solid var(--line); }
.rule-tree-group:last-child { border-bottom: none; }
.rule-tree-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--text-2);
  cursor: pointer; user-select: none;
}
.rule-tree-head:hover { background: var(--accent-soft); }
.rule-tree-head .count { font-weight: 400; color: var(--text-3); font-size: 12px; }
.rule-tree-head .caret { transition: transform .15s; color: var(--text-3); flex: none; }
.rule-tree-group.collapsed .caret { transform: rotate(-90deg); }
.rule-tree-group.collapsed .rule-tree-body { display: none; }
.rule-tree-body { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 10px 12px 10px 30px; }
.rule-tree-body .checkbox { font-size: 13px; }
.tree-actions { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.tree-actions .muted { font-size: 12px; }
.menu-tree-table td { vertical-align: middle; }
.menu-tree-table .tree-cell { font-size: 13.5px; }
.menu-tree-table .tree-node-name { font-weight: 500; }
.menu-tree-table .tree-children-note { color: var(--text-3); font-size: 12px; margin-left: 6px; }
.menu-tree-ops { white-space: nowrap; }

/* 节点代码样式（权限规则等） */
.node-code {
  font-family: var(--mono); font-size: 12.5px; color: var(--accent);
  background: var(--accent-soft); padding: 2px 7px; border-radius: 5px;
}

/* ============ 图标选择器 ============ */
.icon-picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px;
  max-height: 220px; overflow-y: auto; padding: 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
}
.icon-picker-item {
  height: 38px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
  color: var(--text-2); transition: all .12s;
}
.icon-picker-item:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.icon-picker-item.selected { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.icon-picker-item .icon { width: 15px; height: 15px; }
.icon-preview {
  width: 38px; height: 38px; display: inline-grid; place-items: center; flex: none;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2);
}
.icon-preview .icon { width: 15px; height: 15px; }
.icon-field { display: flex; align-items: center; gap: 8px; }
.icon-field .input { max-width: 200px; }

/* ============ 配置中心 ============ */
.config-layout { display: grid; grid-template-columns: 220px 1fr; gap: 14px; align-items: start; }
.config-nav { padding: 8px; position: sticky; top: 0; }
.config-nav-title { font-size: 12px; color: var(--text-3); padding: 6px 10px 8px; font-weight: 600; }
.config-nav-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border-radius: var(--radius-sm); color: var(--text-2); font-size: 13.5px;
  text-decoration: none; transition: all .12s;
}
.config-nav-item:hover { background: var(--accent-soft); color: var(--accent); }
.config-nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.config-nav-item .icon { flex: none; width: 1.1em; height: 1.1em; }
.config-nav-name { display: block; }
.config-nav-desc { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.config-nav-item.active .config-nav-desc { color: var(--accent); opacity: .75; }
@media (max-width: 900px) { .config-layout { grid-template-columns: 1fr; } .config-nav { position: static; } }

/* ============ 日志详情弹窗 ============ */
.detail-grid { display: grid; grid-template-columns: 90px 1fr; gap: 8px 14px; font-size: 13.5px; }
.detail-label { color: var(--text-3); text-align: right; }
.detail-pre {
  margin: 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-family: var(--mono); font-size: 12px;
  white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow-y: auto; color: var(--text-2);
}


/* ============ 个人中心 ============ */
.profile-head { display: flex; align-items: center; gap: 18px; padding: 20px; }
.profile-avatar-lg {
  width: 72px; height: 72px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: var(--surface-3); color: var(--text-3); border: 1px solid var(--line);
}
.profile-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 17px; font-weight: 700; display: flex; align-items: center; }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; align-items: start; }
@media (max-width: 900px) { .profile-grid { grid-template-columns: 1fr; } }
.profile-grid .card { padding: 16px; }
.profile-grid .card-header { padding: 0 0 12px; margin-bottom: 4px; }


/* ============ 暗色主题 ============ */
[data-theme="dark"] {
  --bg: #0f1420;
  --panel: #171e2e;
  --surface-2: #1c2536;
  --surface-3: #222d42;
  --line: #27334a;
  --line-strong: #36445f;
  --text: #e9eef7;
  --text-2: #aeb9d0;
  --text-3: #7f8ca6;
  --accent: #5c7cfa;
  --accent-hover: #4263eb;
  --accent-soft: rgba(92, 124, 250, .16);
  --green: #40c057;
  --green-soft: rgba(64, 192, 87, .16);
  --red: #ff6b6b;
  --red-soft: rgba(255, 107, 107, .16);
  --red-line: rgba(255, 107, 107, .38);
  --orange: #ffa94d;
  --orange-soft: rgba(255, 169, 77, .16);
  --blue: #4dabf7;
  --blue-soft: rgba(77, 171, 247, .16);
  --tree-line: #3d4c68;
  --input-hover-line: #45557a;
  --login-grad-1: #141b2b;
  --login-grad-2: #0d121d;
  --code-bg: #0b101b;
  --code-text: #d7e0f0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .28);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
/* 暗色下微调（变量覆盖不了的地方） */
[data-theme="dark"] .login-wrap {
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(92, 124, 250, .14), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, rgba(112, 72, 232, .16), transparent 60%),
    linear-gradient(160deg, var(--login-grad-1), var(--login-grad-2));
}
[data-theme="dark"] .brand-mark { background: linear-gradient(135deg, var(--accent), #9775fa); }
[data-theme="dark"] img { filter: brightness(.88); }
[data-theme="dark"] .table th { color: var(--text-2); }
[data-theme="dark"] ::placeholder { color: var(--text-3); opacity: 1; }
