/* ============================================================
   聚力工具业务系统 · 样式
   🔴 设计 token 与组件样式对齐《话龙点睛 UI 设计系统》
      （惠顿项目 WEB/public/design-system.html 为基准，不要自行发挥配色与圆角）
   ============================================================ */
:root {
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --heading: var(--sans);
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --background: oklch(0.985 0.002 75);
  --foreground: oklch(0.145 0.005 50);
  --card: oklch(1 0 0);
  --primary: oklch(0.145 0.005 50);
  --primary-foreground: oklch(0.985 0.002 75);
  --secondary: oklch(0.97 0.001 75);
  --secondary-foreground: oklch(0.25 0.005 50);
  --muted: oklch(0.97 0.001 75);
  --muted-foreground: oklch(0.556 0.01 60);
  --destructive: oklch(0.577 0.245 27.325);
  --success: oklch(0.62 0.17 150);
  --warning: oklch(0.75 0.16 75);
  --info: oklch(0.6 0.14 250);
  --input: oklch(0.922 0.004 60);
  --ring: oklch(0.145 0.005 50);
  --border: oklch(0.922 0.004 60);

  --radius: 0.5rem;
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.5rem;
  --radius-2xl: 0.75rem;

  --sidebar: oklch(1 0 0);
  --sidebar-foreground: oklch(0.145 0.005 50);
  --sidebar-accent: oklch(0.97 0.001 75);
  --sidebar-accent-foreground: oklch(0.25 0.005 50);
  --sidebar-border: oklch(0.922 0.004 60);

  --card-shadow: 0 2px 8px rgba(28, 25, 23, 0.04), 0 8px 24px rgba(28, 25, 23, 0.06);
  --shadow-lg: 0 12px 32px rgba(28, 25, 23, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
svg { flex: none; }

/* ---------- 布局 ---------- */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: 15rem; flex: none; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--sidebar); color: var(--sidebar-foreground);
  border-right: 1px solid var(--sidebar-border);
}
.sidebar-header { padding: 16px 14px; }
.brand { display: flex; align-items: center; gap: 12px; height: 44px; }
.brand-logo {
  width: 40px; height: 40px; flex: none; border-radius: var(--radius-md);
  background: #000; color: #fff; display: flex; align-items: center; justify-content: center;
}
.brand-logo svg { width: 22px; height: 22px; }
.brand-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.brand-name { font-size: 16px; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.brand-sub { font-size: 12px; line-height: 1.1; color: var(--muted-foreground); white-space: nowrap; }

.sidebar-content { flex: 1; overflow-y: auto; padding: 0 8px 16px; }
.nav-group { margin-top: 8px; }
.nav-group-label {
  display: flex; align-items: center; height: 36px; padding: 0 8px;
  font-size: 14px; font-weight: 700; color: var(--foreground);
}
.nav-list { list-style: none; margin: 0; padding: 0 0 0 4px; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px;
  border-radius: var(--radius-md); font-size: 14px; line-height: 1.25;
  color: var(--sidebar-foreground); cursor: pointer; transition: background .15s, color .15s;
}
.nav-link svg { width: 16px; height: 16px; opacity: .85; }
.nav-link:hover { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); }
.nav-link.active { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); font-weight: 500; }
.sidebar-footer {
  border-top: 1px solid color-mix(in oklab, var(--sidebar-border) 60%, transparent);
  padding: 12px 14px; font-size: 12px; color: var(--muted-foreground);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 64px; padding: 0 28px;
  background: color-mix(in oklab, var(--background) 86%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar-title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.topbar-title b { font-size: 16px; font-weight: 600; font-family: var(--heading); }
.topbar-title small { font-size: 12px; color: var(--muted-foreground); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.topbar-user img { width: 28px; height: 28px; border-radius: 999px; }
.topbar-user .who { display: flex; flex-direction: column; line-height: 1.25; }
.topbar-user .who small { color: var(--muted-foreground); font-size: 12px; }
.content { padding: 28px clamp(20px, 2.2vw, 44px) 80px; }

/* ---------- 区块标题 ---------- */
.section-head { margin-bottom: 16px; }
.section-head h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; font-family: var(--heading); }
.section-head p { margin: 0; font-size: 13px; color: var(--muted-foreground); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius-md);
  box-shadow: 0 0 0 1px var(--border), var(--card-shadow);
  margin-bottom: 20px; overflow: hidden;
}
.card-body { padding: 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card-head .t { font-size: 15px; font-weight: 600; }
.card-head .d { font-size: 13px; color: var(--muted-foreground); margin-top: 2px; }

/* 统计块 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
  background: var(--card); border-radius: var(--radius-md); padding: 18px 20px;
  box-shadow: 0 0 0 1px var(--border), var(--card-shadow);
}
.stat .l { font-size: 13px; color: var(--muted-foreground); }
.stat .n { font-size: 28px; font-weight: 600; font-family: var(--heading); line-height: 1.3; }
.stat .s { font-size: 12px; color: var(--muted-foreground); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border: 1px solid transparent; border-radius: var(--radius-lg);
  font-family: inherit; font-size: 14px; font-weight: 500; white-space: nowrap;
  cursor: pointer; transition: all .15s; outline: none; background: transparent; color: inherit;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { pointer-events: none; opacity: .5; }
.btn svg { width: 16px; height: 16px; }
.btn-default { background: var(--primary); color: var(--primary-foreground); }
.btn-default:hover { background: color-mix(in oklab, var(--primary) 85%, var(--background)); }
.btn-outline { border-color: var(--border); background: var(--background); }
.btn-outline:hover { background: var(--muted); }
.btn-ghost:hover { background: var(--muted); }
.btn-destructive { background: color-mix(in oklab, var(--destructive) 10%, transparent); color: var(--destructive); }
.btn-destructive:hover { background: color-mix(in oklab, var(--destructive) 20%, transparent); }
.btn-sm { height: 28px; padding: 0 10px; font-size: .8rem; border-radius: var(--radius-md); }
.btn-xs { height: 24px; padding: 0 8px; font-size: 12px; border-radius: var(--radius-md); }
.btn-lg { height: 40px; padding: 0 20px; font-size: 15px; }

/* ---------- 表单 ---------- */
.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 14px; border: 1px solid var(--input);
  border-radius: var(--radius-2xl); background: var(--card); color: var(--foreground);
  font-family: inherit; font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted-foreground); }
.input:focus-visible { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 45%, transparent); }
textarea.input { height: auto; min-height: 76px; padding: 10px 14px; line-height: 1.6; resize: vertical; }
select.input { appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.input.sm { height: 32px; padding: 0 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 14px; font-weight: 500; }
.field-hint { font-size: 12px; color: var(--muted-foreground); line-height: 1.5; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar .grow { flex: 1; }
.toolbar .input { width: auto; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 10px;
  border: 1px solid transparent; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge-default { background: var(--primary); color: var(--primary-foreground); }
.badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge-outline { border-color: var(--border); }
.badge-ghost { color: var(--muted-foreground); }
.badge-success { background: color-mix(in oklab, var(--success) 14%, transparent); color: var(--success); }
.badge-info { background: color-mix(in oklab, var(--info) 14%, transparent); color: var(--info); }
.badge-warning { background: color-mix(in oklab, var(--warning) 18%, transparent); color: color-mix(in oklab, var(--warning) 70%, var(--foreground)); }
.badge-destructive { background: color-mix(in oklab, var(--destructive) 10%, transparent); color: var(--destructive); }

/* ---------- 表格 ---------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto; background: var(--card); }
table.tbl { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
table.tbl thead th {
  height: 40px; padding: 0 12px; text-align: left; font-weight: 600;
  border-bottom: 1px solid var(--border); background: color-mix(in oklab, var(--muted) 40%, transparent);
}
table.tbl tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
/* 省略号靠 table-layout:fixed + overflow 实现。
   ⚠️ 不要加 max-width:1px —— 它会盖住列上设置的 width，列宽变得不可控 */
table.tbl th, table.tbl td { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr { transition: background .15s; }
table.tbl tbody tr:hover { background: color-mix(in oklab, var(--muted) 50%, transparent); }
.tbl .ops { display: flex; gap: 6px; }
.cell-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cell-main img { width: 24px; height: 24px; border-radius: 999px; flex: none; }
.cell-main .sub { color: var(--muted-foreground); font-size: 12px; }
.indent { display: inline-block; }

/* ---------- 空状态 ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 180px; padding: 28px; border: 1px dashed var(--border); border-radius: var(--radius-lg);
  background: color-mix(in oklab, var(--muted) 28%, transparent); text-align: center; color: var(--muted-foreground);
}
.empty-state .state-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md); display: inline-flex;
  align-items: center; justify-content: center; background: var(--background);
  box-shadow: 0 0 0 1px var(--border);
}
.empty-state .state-icon svg { width: 20px; height: 20px; }
.empty-state strong { font-size: 15px; color: var(--foreground); font-weight: 600; }
.empty-state p { margin: 0; max-width: 380px; font-size: 13px; line-height: 1.6; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--muted-foreground); }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; z-index: 9000; background: rgba(28, 25, 23, .45); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; }
.modal { width: 560px; max-width: 100%; max-height: 84vh; display: flex; flex-direction: column; background: var(--card); border-radius: var(--radius-2xl); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal.wide { width: 860px; }
.modal-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-h .t { font-size: 16px; font-weight: 600; font-family: var(--heading); }
.modal-h .x { cursor: pointer; color: var(--muted-foreground); width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-md); }
.modal-h .x:hover { background: var(--muted); }
.modal-b { padding: 20px; overflow: auto; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: color-mix(in oklab, var(--muted) 50%, transparent); }

/* ---------- 提示 ---------- */
#toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius-2xl); background: var(--card); color: var(--foreground); box-shadow: 0 0 0 1px var(--border), var(--shadow-lg); font-size: 14px; animation: rise .18s ease-out; }
.toast.ok { color: var(--success); }
.toast.err { color: var(--destructive); }
@keyframes rise { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

/* ---------- 树（权限勾选） ---------- */
.tree { list-style: none; margin: 0; padding-left: 20px; }
.tree > li { margin: 3px 0; }
.tree label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.perm-code { font-family: var(--mono); font-size: 12px; color: var(--muted-foreground); }

.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted-foreground); }
pre.json { margin: 0; padding: 12px; border-radius: var(--radius-md); background: var(--muted); font-family: var(--mono); font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; max-height: 360px; overflow: auto; }

/* ---------- 登录页 ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--background); }
.login-card { width: 400px; max-width: calc(100vw - 32px); padding: 40px; text-align: center; background: var(--card); border-radius: var(--radius-2xl); box-shadow: 0 0 0 1px var(--border), var(--card-shadow); }
.login-card .brand-logo { width: 52px; height: 52px; margin: 0 auto 18px; }
.login-card .brand-logo svg { width: 28px; height: 28px; }
.login-card h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; font-family: var(--heading); }
.login-card .sub { margin: 0 0 28px; font-size: 13px; color: var(--muted-foreground); }
.login-card .btn { width: 100%; }
.login-msg { min-height: 20px; margin: 16px 0 0; font-size: 13px; color: var(--destructive); }
.login-foot { margin-top: 24px; font-size: 12px; color: var(--muted-foreground); }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 60px; }
  .modal { width: 100%; }
}
