* { box-sizing: border-box; }
:root {
  --ink: #1a1d21;
  --muted: #6b7280;
  --line: #e3e6ea;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --accent: #2563eb;
  --accent-soft: #eef3ff;
  --danger: #d92d20;
  --ok: #12805c;
}
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}
button, input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }

/* 登录 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 32px 30px;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 24px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  padding: 9px 11px;
  outline: none;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: #c9ced5; background: #fafbfc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--danger); border-color: #f3c9c6; }
.btn.danger:hover { background: #fff5f4; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: #f1f3f5; color: var(--ink); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px;
  flex: 0 0 210px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .logo {
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  letter-spacing: .3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav { padding: 10px 0; flex: 1; }
.nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 20px;
  color: #4b5563;
  font-size: 13.5px;
  border-left: 2px solid transparent;
}
.nav a:hover { background: #fafbfc; color: var(--ink); }
.nav a.active { color: var(--accent); background: var(--accent-soft); border-left-color: var(--accent); font-weight: 500; }
.nav .ico { width: 16px; height: 16px; display: inline-block; opacity: .8; }
.sidebar .bottom { border-top: 1px solid var(--line); padding: 12px 14px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h2 { font-size: 15px; margin: 0; font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.content { padding: 24px 24px 48px 0; margin-left: 24px; }

/* 卡片与表格 */
.panel { background: var(--panel); border: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-body { padding: 16px 18px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=text] { width: 220px; }
.toolbar select { width: auto; min-width: 110px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 500; color: var(--muted); font-size: 12px; background: #fafbfc; white-space: nowrap; }
tbody tr:hover { background: #fafbfc; }
td.col-title { min-width: 320px; max-width: 520px; }
td .qline { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag { display: inline-block; padding: 1px 7px; font-size: 11px; border: 1px solid var(--line); color: var(--muted); background: #fafbfc; }
.tag.ok { color: var(--ok); border-color: #bfe3d6; background: #f0f9f5; }
.tag.off { color: var(--danger); border-color: #f3c9c6; background: #fff5f4; }
.answer-cell { color: var(--ok); font-weight: 500; max-width: 220px; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 0; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pager .pages { display: flex; gap: 6px; align-items: center; }
.pager button { padding: 5px 10px; }

/* 概览 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); padding: 16px 18px; }
.stat .k { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat .v { font-size: 26px; font-weight: 600; letter-spacing: -.5px; line-height: 1.2; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
.chart { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding: 10px 4px 0; }
.chart .bar-wrap { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; }
.chart .bar { width: 100%; max-width: 46px; background: var(--accent); min-height: 2px; transition: height .3s; }
.chart .lbl { font-size: 11px; color: var(--muted); }
.list-simple { list-style: none; margin: 0; padding: 0; }
.list-simple li { padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; display: flex; justify-content: space-between; gap: 12px; }
.list-simple li:last-child { border-bottom: 0; }
.list-simple .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, "Courier New", monospace; }

/* 弹窗 */
.mask { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); display: flex; align-items: flex-start; justify-content: center; padding: 60px 20px; z-index: 100; overflow: auto; }
.modal { background: #fff; border: 1px solid var(--line); width: 640px; max-width: 100%; }
.modal.wide { width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 14px; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-tip { font-size: 12px; color: var(--muted); margin-top: 4px; }
.code-block { background: #16181d; color: #e6e9ef; padding: 14px 16px; font: 12.5px/1.7 Consolas, "Courier New", monospace; overflow: auto; max-height: 340px; white-space: pre; }
.inline-code { background: #f1f3f5; padding: 1px 5px; font-family: Consolas, monospace; font-size: 12px; }

/* toast */
.toast-root { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #111827; color: #fff; padding: 9px 16px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.toast.err { background: #b42318; }

@media (max-width: 960px) {
  .sidebar { width: 64px; flex: 0 0 64px; }
  .sidebar .logo { padding: 0; justify-content: center; font-size: 12px; }
  .nav a { justify-content: center; padding: 12px 0; font-size: 0; }
  .nav a .ico { font-size: 16px; }
  .sidebar .bottom { display: none; }
  .content { padding: 16px 16px 40px; margin-left: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .toolbar input[type=text] { width: 100%; }
}
