:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e8f0;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --danger: #dc2626;
  --ok: #059669;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font: 14px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink); background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; background: #f1f3f9; padding: 1px 5px; border-radius: 4px; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 224px; flex: 0 0 224px; background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; padding: 20px 0;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: #fff; padding: 0 20px 18px; letter-spacing: .2px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: #818cf8; box-shadow: 0 0 0 4px rgba(129,140,248,.18); }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.nav-item {
  display: block; padding: 9px 12px; border-radius: 8px; color: #cbd5e1; font-size: 13.5px;
}
.nav-item:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav-item.active { background: rgba(129,140,248,.18); color: #fff; font-weight: 600; }
.nav-item.disabled { color: #64748b; cursor: not-allowed; }
.nav-item.disabled:hover { background: transparent; }
.nav-sep { margin: 16px 12px 6px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #64748b; }
.side-foot { margin-top: auto; padding: 16px 20px 0; border-top: 1px solid rgba(255,255,255,.08); display: flex; justify-content: space-between; align-items: center; }
.side-foot .who { font-weight: 600; color: #fff; }
.side-foot a { color: #94a3b8; font-size: 13px; }

.main { flex: 1; padding: 26px 32px 60px; max-width: 1180px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; }
.topbar h1 { font-size: 20px; letter-spacing: -.01em; }
.page-switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.page-switch select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; }

/* cards & grid */
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 16px; }
.card h2 { font-size: 15px; margin-bottom: 12px; letter-spacing: -.01em; }
.card h2.mt { margin-top: 24px; }
.kpi span { color: var(--muted); font-size: 12.5px; letter-spacing: .03em; }
.kpi b { display: block; margin-top: 8px; font-size: 28px; letter-spacing: -.02em; }

/* table */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid #f1f3f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.hl td { background: var(--accent-soft); }
.table.compact td, .table.compact th { padding: 6px 8px; }
.trunc { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ops { display: flex; gap: 10px; align-items: center; }

/* forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid label, .form-row label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.form-grid .span2 { grid-column: span 2; }
.form-grid input, .form-grid select, .form-grid textarea,
.form-row input, .form-row select, .form-row textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; width: 100%;
}
.form-grid textarea, .form-row textarea { resize: vertical; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { outline: 2px solid #c7cdfb; border-color: var(--accent); }
.form-grid label.inline { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.form-grid label.inline input { width: auto; }
.form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-row .grow { flex: 1; min-width: 180px; }
.form-row input, .form-row select { width: auto; }
.actions { display: flex; gap: 10px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 14px 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: #cbd5e1; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4338ca; }
.link { background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); }
.inline-form { display: inline; margin: 0; }

/* misc */
.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13.5px; }
.flash.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash.err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag.on { background: #ecfdf5; color: #047857; }
.tag.off { background: #f1f5f9; color: #64748b; }
textarea.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; line-height: 1.55; background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 14px; width: 100%; border: 1px solid #1e293b; }

/* 扩展：产品/案例/表单/规则/系统 */
.hidden-form { display: none; }
.mt { margin-top: 18px; }
.link.danger, .btn.danger { color: var(--danger); }
.btn.danger { border-color: #fecaca; background: #fff; }
.btn.danger:hover { background: #fef2f2; }
.table img, .table video { max-height: 56px; max-width: 96px; border-radius: 6px; object-fit: cover; display: block; }
.chip { display: inline-block; margin: 2px 4px 2px 0; padding: 1px 8px; border-radius: 999px; background: #eef2ff; color: #3730a3; font-size: 11.5px; }
.field-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.field-row { display: grid; grid-template-columns: 1.2fr 1fr 0.9fr auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.field-row input, .field-row select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.filter-bar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.filter-bar label { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.filter-bar input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.inline-details summary { cursor: pointer; color: var(--accent); font-size: 12.5px; }
.code-block { background: #0f172a; color: #cbd5e1; padding: 8px 10px; border-radius: 6px; font-size: 11.5px; white-space: pre-wrap; word-break: break-all; max-height: 220px; overflow: auto; margin: 6px 0; }
.role { display: inline-block; margin-left: 6px; font-size: 10.5px; color: #94a3b8; text-transform: uppercase; letter-spacing: .06em; }
select, input[type=date] { font: inherit; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% 10%, #e0e7ff, transparent), radial-gradient(900px 500px at 90% 90%, #fae8ff, transparent), #f6f7fb; }
.login-card { width: min(400px, 92vw); background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border: 1px solid #fff; border-radius: 18px; padding: 30px; box-shadow: 0 24px 60px rgba(15,23,42,.12); display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { color: var(--ink); padding: 0; font-size: 16px; }
.login-card .brand .dot { background: var(--accent); box-shadow: 0 0 0 4px rgba(79,70,229,.12); }
.login-sub { color: var(--muted); font-size: 13px; margin-top: -8px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.login-card input { font: inherit; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; }
.login-card input:focus { outline: 2px solid #c7cdfb; border-color: var(--accent); }
.login-card .btn.primary { justify-content: center; padding: 12px; font-size: 15px; }
.login-card .hint { text-align: center; }

@media (max-width: 900px) {
  body { overflow-x: hidden; }
  .shell { flex-direction: column; min-height: 100vh; }
  .side { width: 100%; flex: none; flex-direction: column; align-items: stretch; padding: 10px 10px 6px; }
  .brand { padding: 2px 6px 10px; }
  .nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding: 0 2px 6px; scrollbar-width: thin; }
  .nav-item { white-space: nowrap; padding: 7px 11px; font-size: 13px; }
  .nav-sep, .side-foot { display: none; }
  .main { padding: 14px 14px 48px; max-width: none; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .login-card { padding: 22px; }
}

/* 图表 / 分页 / 复制反馈 */
.spark { width: 100%; height: 96px; display: block; background: linear-gradient(#f8fafc, #fff); border: 1px solid var(--line); border-radius: 10px; }
.spark polyline { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark-pv { stroke: #4f46e5; }
.spark-clk { stroke: #06b6d4; stroke-dasharray: 3 2; }
.legend { display: flex; gap: 16px; margin-top: 8px; font-size: 12.5px; color: var(--muted); align-items: center; }
.legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.legend .dot.pv { background: #4f46e5; }
.legend .dot.clk { background: #06b6d4; }
.pager { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pager-item { padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-size: 13px; }
.pager-item:hover { background: #f1f5f9; text-decoration: none; }
.pager-item.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.grow2 { flex: 1; min-width: 160px; }
.copied { outline: 2px solid #a7f3d0; background: #ecfdf5; border-radius: 6px; }
[data-copy] { cursor: pointer; }

/* 多选像素 */
.field-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 8px 0; }
.checks label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); }
.checks input[type=checkbox] { width: auto; }
