:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --panel: #ffffff;
  --side: #0b1220;
  --accent: #2f6fed;
  --accent2: #10b981;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --ai: #b45309;
  --ai-bg: #fef3c7;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  /* 落地页需要整页可滚动；工作台的视口限制由 #app-layout 自身负责（见 .layout） */
  overflow-x: hidden;
}
.layout { display: flex; height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 300px; min-width: 300px; background: var(--side); color: #e2e8f0;
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar .brand { padding: 18px 16px; border-bottom: 1px solid #1e293b; font-weight: 700; font-size: 15px; line-height: 1.5; }
.sidebar .brand small { display: block; color: #94a3b8; font-weight: 400; font-size: 12px; margin-top: 4px; }
.role-switch-wrap { padding: 10px 12px; border-bottom: 1px solid #1e293b; }
.role-switch-wrap select { width: 100%; padding: 8px; border-radius: 8px; border: 1px solid #334155; background: #1e293b; color: #e2e8f0; font-size: 13px; }
#sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0 20px; }
.menu-group { margin-bottom: 6px; }
.menu-title { padding: 8px 16px; font-size: 13px; font-weight: 600; color: #94a3b8; letter-spacing: .5px; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 16px 7px 26px; color: #cbd5e1; text-decoration: none; font-size: 13px; cursor: pointer;
}
.menu-item:hover { background: #1e293b; color: #fff; }
.menu-item.active { background: #2f6fed; color: #fff; }
.menu-item .tag { font-style: normal; font-size: 11px; color: #64748b; border: 1px solid #475569; border-radius: 4px; padding: 0 4px; }

/* 主区 */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { background: var(--panel); padding: 12px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.topbar h1 { font-size: 16px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#crumb { font-size: 12px; color: var(--muted); }
.content { flex: 1; overflow-y: auto; background: #f1f5f9; padding: 20px; }
.welcome { background: var(--panel); border-radius: 12px; padding: 40px; text-align: center; }
.welcome h2 { color: var(--accent); margin-bottom: 8px; }
.welcome p { color: var(--muted); margin-bottom: 16px; }
.welcome-stats { display: inline-block; background: var(--bg2); color: #fff; padding: 8px 16px; border-radius: 20px; font-size: 13px; }

/* 工具栏 */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.token-est { font-size: 13px; color: var(--muted); background: #fff; border: 1px solid var(--border); padding: 6px 12px; border-radius: 8px; }
.token-est b { color: var(--accent); font-size: 15px; }

/* 表单外壳（透明，内容由 .section-card 承载） */
.page-form { background: transparent; padding: 0; border: 0; }

/* 表格 */
.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini-table th { background: #f1f5f9; padding: 8px 10px; border: 1px solid var(--border); text-align: left; font-weight: 600; }
.mini-table td { border: 1px solid var(--border); padding: 6px 8px; }
.mini-table .ctrl { padding: 5px 8px; font-size: 12px; }
.list-table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 8px; overflow: hidden; font-size: 13px; margin-top: 4px; }
.list-table th { background: #f8fafc; padding: 10px; border-bottom: 1px solid var(--border); text-align: left; font-weight: 600; }
.list-table td { padding: 10px; border-bottom: 1px solid #f1f5f9; }
.list-table td.empty, td.empty { text-align: center; color: var(--muted); padding: 24px; }

/* 看板卡片 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.card-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: #334155; }
.card-body { font-size: 22px; color: var(--accent); font-weight: 700; }
.card:nth-child(odd) .card-body { color: var(--accent2); }

/* 提示 */
.hint { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.7; }
.hint code { background: #eef2ff; padding: 1px 5px; border-radius: 4px; }
.empty { color: var(--muted); }
.tip-banner {
  background: linear-gradient(90deg, #eff6ff, #f5f3ff);
  border: 1px solid #c7d2fe;
  color: #3730a3;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.6;
}

/* ===== M1 交互演示 ===== */
.token-meter { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); background: #fff; border: 1px solid var(--border); padding: 5px 12px; border-radius: 20px; white-space: nowrap; }
.token-meter b { color: var(--accent); font-size: 15px; }
.token-meter .mode { font-size: 11px; color: #10b981; }
.module-intro { background: #eef2ff; border: 1px solid #c7d2fe; color: #3730a3; border-radius: 8px; padding: 8px 14px; font-size: 13px; margin-bottom: 12px; }
.demo-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.demo-bar .btn { font-size: 12px; }
.hdr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.hdr-grid > div label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.editable-table { border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: #f8fafc; }
.editable-table .addrow { margin-top: 8px; font-size: 12px; }
.list-box { margin-top: 14px; }
.result-box { border: 1px dashed #cbd5e1; border-radius: 8px; padding: 12px; min-height: 48px; background: #f8fafc; font-size: 13px; color: var(--muted); }
.result { border-radius: 6px; padding: 8px 12px; margin-bottom: 8px; font-size: 13px; }
.result.ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.result.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.issue-list { margin-bottom: 8px; }
.issue { font-size: 12px; padding: 5px 10px; border-radius: 6px; margin-bottom: 4px; }
.issue.error { background: #fef2f2; color: #b91c1c; }
.issue.warn { background: #fffbeb; color: #b45309; }
.issue.info { background: #eff6ff; color: #1d4ed8; }
.chk-line { display: flex; flex-wrap: wrap; gap: 14px; }
#toast { position: fixed; top: 16px; right: 16px; background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; opacity: 0; transform: translateY(-8px); transition: all .25s; z-index: 999; pointer-events: none; }
#toast.show { opacity: 1; transform: translateY(0); }

/* ===== 结果增强：条目列表 / 柱状图 ===== */
.item-list { display: grid; gap: 6px; margin-bottom: 8px; }
.item-row { display: flex; gap: 10px; align-items: baseline; background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; font-size: 13px; }
.item-row.error { background: #fef2f2; border-color: #fecaca; }
.item-row.warn { background: #fffbeb; border-color: #fde68a; }
.item-row.ok { background: #ecfdf5; border-color: #a7f3d0; }
.item-title { font-weight: 600; color: #334155; min-width: 120px; }
.item-content { color: #475569; flex: 1; }
.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding: 10px 8px 0; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; margin-top: 8px; }
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 60%; background: linear-gradient(180deg, #3b82f6, #2f6fed); border-radius: 4px 4px 0 0; position: relative; min-height: 4px; }
.bar span { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: #334155; }
.bar-label { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* 工作台总览/模块概览 */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 14px; }
.quick-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px 18px; border-radius: 12px; background: #fff; border: 1px solid var(--border);
  text-decoration: none; color: var(--text); transition: all .2s;
}
.quick-card:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(47,111,237,.12); transform: translateY(-1px); }
.quick-card .qc-icon { font-size: 22px; }
.quick-card .qc-name { font-weight: 600; font-size: 14px; }
.quick-card .qc-go { color: var(--accent); font-size: 12px; }

/* ===== 子页面（page）===== */
.page-wrap { display: flex; flex-direction: column; gap: 16px; }
.page-header {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 22px; box-shadow: 0 2px 8px rgba(15,23,42,.03);
}
.page-header .breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.page-header .breadcrumb a { color: var(--accent); text-decoration: none; }
.page-header .breadcrumb a:hover { text-decoration: underline; }
.page-header .breadcrumb span { color: var(--text); font-weight: 500; }
.page-header-main { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.page-header-main .page-icon {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #eff6ff, #e0e7ff); color: var(--accent);
  display: grid; place-items: center; font-size: 22px; border: 1px solid #dbeafe;
}
.page-header-main .page-title-block { flex: 1; min-width: 0; }
.page-header-main .page-title { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.2; }
.page-header-main .page-desc { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.page-header-main .page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.page-header-main .page-actions .token-est {
  font-size: 12px; color: var(--muted); background: #fffbeb; border: 1px solid #fde68a;
  padding: 5px 12px; border-radius: 999px;
}
.page-header-main .page-actions .token-est b { color: #b45309; }

/* 通用内容卡片（表单/表格/区块） */
.section-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 20px 22px; box-shadow: 0 2px 8px rgba(15,23,42,.03);
}
.section-card + .section-card { margin-top: 14px; }
.section-card .section-title {
  font-size: 14px; font-weight: 700; color: var(--text); margin: 0 0 14px;
  display: flex; align-items: center; gap: 8px;
}
.section-card .section-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.section-card .section-title .sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: auto; }

/* 表单字段美化 */
.field { margin-bottom: 14px; }
.field.ai { border-left: 3px solid var(--ai); padding-left: 12px; background: #fffbf0; border-radius: 6px; }
.flabel { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #334155; margin-bottom: 6px; font-weight: 500; }
.flabel .req { color: #ef4444; }
.ai-badge { display: inline-block; background: var(--ai-bg); color: var(--ai); border: 1px solid #f59e0b; border-radius: 4px; font-size: 11px; padding: 1px 7px; font-weight: 400; }
.ai-badge .tok { background: #f59e0b; color: #fff; border-radius: 3px; padding: 0 4px; margin-left: 3px; }
.ctrl {
  width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; background: #fff; transition: border-color .15s, box-shadow .15s;
}
.ctrl:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,111,237,.12); }
textarea.ctrl { resize: vertical; min-height: 64px; }
.upload { border: 1.5px dashed #cbd5e1; border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); font-size: 13px; background: #f8fafc; transition: border-color .2s; cursor: pointer; }
.upload:hover { border-color: var(--accent); background: #eff6ff; }
.upload input { display: block; margin: 0 auto 6px; }
.chk { display: inline-flex; align-items: center; gap: 5px; margin-right: 14px; font-size: 13px; cursor: pointer; }

/* 按钮升级 */
.btn { display: inline-flex; align-items: center; gap: 5px; border: 0; border-radius: 8px; padding: 8px 16px; font-size: 13px; cursor: pointer; font-weight: 500; transition: all .15s; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #2456c8; }
.btn.ghost { background: #fff; border: 1px solid #d1d5db; color: #334155; }
.btn.ghost:hover { background: #f1f5f9; }
.btn.ai-run { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; box-shadow: 0 2px 8px rgba(245,158,11,.3); }
.btn.ai-run:hover { background: #d97706; transform: translateY(-1px); }

/* ===== 移动端 / iPad 响应式 + 侧边栏抽屉 ===== */
.menu-toggle { display: none; background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; cursor: pointer; color: var(--text); font-size: 16px; line-height: 1; }
.menu-toggle:hover { background: #f1f5f9; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 49; opacity: 0; transition: opacity .2s; }
.sidebar-backdrop.show { display: block; opacity: 1; }
@media (max-width: 1024px) {
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 280px; z-index: 50; transform: translateX(-100%); transition: transform .25s ease; box-shadow: 2px 0 12px rgba(0,0,0,.1); height: 100vh; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-block; }
  .topbar { gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
  .topbar h1 { font-size: 15px; min-width: 0; flex: 1; }
  #token-meter { font-size: 12px; padding: 4px 10px; }
  .content { padding: 14px; }
  .page-header { padding: 14px 16px; }
  .page-header-main { gap: 10px; }
  .page-header-main .page-title { font-size: 17px; }
  .page-header-main .page-icon { width: 38px; height: 38px; font-size: 18px; }
  .section-card { padding: 14px 16px; }
  .page-actions { gap: 6px; }
  .page-actions .btn { padding: 6px 10px; font-size: 12px; }
}
@media (max-width: 720px) {
  .topbar { padding: 8px 10px; }
  .topbar h1 { font-size: 14px; }
  .topbar #crumb { display: none; }
  #token-meter { font-size: 11px; padding: 3px 8px; }
  .topbar .home-link { font-size: 12px; padding: 4px 8px; }
  .page-header-main { flex-direction: column; align-items: flex-start; }
  .page-actions { width: 100%; flex-wrap: wrap; }
  .page-actions .token-est { flex: 1; min-width: 0; text-align: center; }
  .page-actions .btn { flex: 1; min-width: 0; }
  .page-header .breadcrumb { font-size: 11px; }
  .hdr-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr; }
  .demo-bar { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 6px; }
  .demo-bar .btn { flex-shrink: 0; }
  .mini-table, .list-table { font-size: 12px; }
  .list-table th, .list-table td { padding: 6px 4px; }
  .page-form .field .fctrl { font-size: 13px; }
  .bar-chart { gap: 8px; }
}
@media (max-width: 480px) {
  .token-meter .mode { display: none; }
  .page-header-main .page-icon { display: none; }
  .page-header-main .page-title { font-size: 16px; }
}

/* ===== 文件上传组件 ===== */
.upload-card { border: 1.5px dashed #cbd5e1; border-radius: 12px; padding: 24px; text-align: center; background: #f8fafc; transition: all .2s; cursor: pointer; }
.upload-card.dragover { border-color: var(--accent); background: #eff6ff; transform: scale(1.01); }
.upload-card input[type=file] { display: none; }
.upload-card .up-icon { font-size: 32px; margin-bottom: 8px; }
.upload-card .up-text { color: var(--muted); font-size: 13px; }
.upload-card .up-text strong { color: var(--accent); }
.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.file-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #fff; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.file-item .file-thumb { width: 40px; height: 40px; border-radius: 6px; background: #eff6ff; display: grid; place-items: center; color: var(--accent); flex-shrink: 0; overflow: hidden; }
.file-item .file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-item .file-info { flex: 1; min-width: 0; }
.file-item .file-name { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item .file-meta { color: var(--muted); font-size: 11px; }
.file-item .file-del { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 4px; }
.file-item .file-del:hover { color: #ef4444; }
.upload-progress { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.upload-progress .bar { height: 100%; background: linear-gradient(90deg, var(--accent), #06b6d4); transition: width .2s; }

/* ===== 管理员后台 ===== */
.admin-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.admin-tab { padding: 10px 16px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-size: 13px; font-weight: 500; white-space: nowrap; }
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.admin-user-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.admin-user-row .au-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #2f6fed, #06b6d4); color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.admin-user-row .au-name { font-weight: 600; }
.admin-user-row .au-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.admin-user-row .au-status { padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.au-status.pending { background: #fef3c7; color: #b45309; }
.au-status.approved { background: #d1fae5; color: #047857; }
.au-status.rejected { background: #fee2e2; color: #b91c1c; }
.au-status.admin { background: #ede9fe; color: #6d28d9; }
.admin-user-row .au-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.admin-user-row .au-actions .btn { padding: 6px 12px; font-size: 12px; }
.admin-detail { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-top: 14px; }
.admin-detail .detail-row { display: flex; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.admin-detail .detail-row label { width: 110px; color: var(--muted); flex-shrink: 0; }
.admin-detail .detail-row .value { flex: 1; color: var(--text); word-break: break-all; }

/* ===== 待审核页面 ===== */
.pending-banner { background: linear-gradient(135deg, #fef3c7, #fde68a); border: 1px solid #f59e0b; border-radius: 12px; padding: 18px 22px; margin-bottom: 16px; color: #92400e; }
.pending-banner .pending-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.pending-banner .pending-desc { font-size: 13px; line-height: 1.7; }
