:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #e3e8f0;
  --line-strong: #cbd5e1;
  --text: #1e293b;
  --muted: #64748b;
  --sidebar: #0f172a;
  --sidebar-2: #16213a;
  --accent: #1d4ed8;
  --accent-soft: #eff4ff;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------------- 侧边栏 ---------------- */
.sidebar {
  width: 236px; flex: 0 0 236px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #cbd5e1;
  display: flex; flex-direction: column;
  border-right: 1px solid #0b1220;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-logo {
  width: 32px; height: 32px; border-radius: 8px; flex: 0 0 32px;
  object-fit: contain; background: #fff;
}

.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff; font-weight: 700; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(37,99,235,.45);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { color: #fff; font-size: 14px; letter-spacing: .5px; }
.brand-text span { font-size: 11px; color: #7c8db5; }

.nav { flex: 1; overflow-y: auto; padding: 10px 0 20px; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: #26324d; border-radius: 3px; }

.nav-group-title {
  padding: 12px 16px 6px;
  font-size: 11px; letter-spacing: 1px;
  color: #64748b; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 16px 7px 20px;
  cursor: pointer; font-size: 13px;
  color: #b6c2d9; border-left: 3px solid transparent;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active {
  background: rgba(37,99,235,.18);
  color: #fff; border-left-color: #3b82f6;
}
.nav-item .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #3f4d6b; flex: 0 0 6px;
}
.nav-item.active .dot { background: #60a5fa; }

.sidebar-foot { padding: 10px 14px 14px; border-top: 1px solid rgba(255,255,255,.07); }
.sys-badge { font-size: 11px; color: #7c8db5; line-height: 1.6; }
.sys-badge b { color: #93c5fd; font-weight: 600; }

/* ---------------- 主区 ---------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 56px; flex: 0 0 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
}
.title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.title-wrap h1 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: .3px; }


/* 长文本列允许换行（上报校验信息可能很长） */
table.grid td.wrap { white-space: normal; max-width: 460px; line-height: 1.45; }

.page-meta { font-size: 12px; color: var(--muted); }
.scope-tip { font-size: 11px; color: var(--muted); background: #f1f5f9; padding: 3px 8px; border-radius: 4px; }

/* 按钮行容器（客户端管理 / 数据概览的操作区） */
.tcy-switch { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* 辅助说明文字：按钮旁提示、状态行（app.js 里 class="hint" 用到 4 处） */
.hint { font-size: 12px; color: var(--muted); }
.hint b { color: #334155; font-weight: 600; }

/* 页面「读取中…」占位（app.js 里 class="loading" 用到 3 处） */
.loading { padding: 28px 18px; color: var(--muted); font-size: 13px; }

/* 顶栏右侧容器 */
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ---------------- 筛选区 ---------------- */
.filter-bar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 10px 18px;
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end;
}
.f-item { display: flex; flex-direction: column; gap: 4px; }
.f-item label { font-size: 11px; color: var(--muted); }
.f-item input, .f-item select {
  height: 30px; padding: 0 8px;
  border: 1px solid var(--line-strong); border-radius: 5px;
  font: inherit; font-size: 12.5px; color: var(--text);
  background: #fff; outline: none; min-width: 130px;
}
.f-item input:focus, .f-item select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(29,78,216,.12); }
.f-item.mode select { min-width: 160px; font-weight: 600; }
.f-actions { display: flex; gap: 8px; margin-left: auto; }

.btn {
  height: 30px; padding: 0 14px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--line-strong); background: #fff; color: var(--text);
  font: inherit; font-size: 12.5px;
}
.btn:hover { border-color: #94a3b8; background: #f8fafc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1e40af; }
.btn.ghost { color: var(--muted); }

/* ---------------- 内容 ---------------- */
.content { flex: 1; overflow: auto; padding: 14px 18px 6px; min-height: 0; }
.view { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }

.table-wrap { width: 100%; overflow-x: auto; }

/* 宽度取列宽合计：内容再长也不挤压其它列，容器负责横向滚动 */
table.grid { border-collapse: separate; border-spacing: 0; font-size: 12.5px;
  table-layout: fixed; width: auto; min-width: 100%; }
/* 列宽由 colgroup 决定，超长内容省略，hover 看全文 */
table.grid th, table.grid td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: center; max-width: 0; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2;
  background: #f8fafc;
  border-bottom: 1px solid var(--line-strong);
  padding: 8px 10px; text-align: center; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis;
  color: #334155; white-space: nowrap; cursor: pointer; user-select: none;
}
table.grid thead th:hover { background: #eef2f7; }
table.grid thead th .arrow { color: #94a3b8; font-size: 10px; margin-left: 3px; }
table.grid tbody td {
  padding: 6px 10px; border-bottom: 1px solid #f1f5f9;
  white-space: nowrap; color: #26324a;
}
table.grid tbody tr:hover td { background: #f8fbff; }
table.grid .num { text-align: center; font-variant-numeric: tabular-nums; }
table.grid .neg { color: var(--bad); }
table.grid .pos { color: var(--ok); }
table.grid .dash { color: #b6bfd0; }

table.grid tfoot td {
  padding: 8px 10px; font-weight: 700;
  background: #f1f5f9; border-top: 2px solid var(--line-strong);
  white-space: nowrap; text-align: center;
  overflow: hidden; text-overflow: ellipsis;
}
table.grid tfoot tr.total td { background: #e8eefb; }

/* 模式 pill */
.mode-pill {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 11.5px; font-weight: 600; line-height: 18px;
}
.mode-1 { background: #e0e7ff; color: #3730a3; }
.mode-2 { background: #dcfce7; color: #166534; }
.mode-3 { background: #fef3c7; color: #92400e; }
.mode-4 { background: #ffe4e6; color: #9f1239; }
.mode-5 { background: #e0f2fe; color: #075985; }
.mode-6 { background: #f3e8ff; color: #6b21a8; }
.mode-7 { background: #ccfbf1; color: #115e59; }
.mode-8 { background: #ffedd5; color: #9a3412; }
.mode-9 { background: #f1f5f9; color: #475569; }
.mode-0 { background: #f1f5f9; color: #64748b; }

.lvl { font-size: 11px; padding: 1px 6px; border-radius: 3px; font-weight: 600; }
.lvl-常规 { background: #e2e8f0; color: #475569; }
.lvl-警告 { background: #fef3c7; color: #b45309; }
.lvl-危险 { background: #fee2e2; color: #b91c1c; }
.lvl-高危 { background: #fecaca; color: #7f1d1d; }

.empty { padding: 60px 0; text-align: center; color: var(--muted); }

/* 汇总条 */
.summary-bar {
  display: flex; flex-wrap: wrap; gap: 22px;
  padding: 12px 16px; margin-top: 0;
  background: linear-gradient(90deg, #eef4ff, #f8fafc);
  border-top: 1px solid var(--line);
  font-size: 12.5px;
}
.summary-bar .k { color: var(--muted); margin-right: 4px; }
.summary-bar .v { font-weight: 700; color: #1e3a8a; font-variant-numeric: tabular-nums; }

/* 分页 */
.pager {
  flex: 0 0 46px; height: 46px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px; background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
}
.pager .pages { display: flex; gap: 4px; margin-left: 6px; }
.pager button {
  min-width: 28px; height: 26px; padding: 0 8px;
  border: 1px solid var(--line-strong); background: #fff;
  border-radius: 4px; cursor: pointer; font: inherit; font-size: 12px; color: var(--text);
}
.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager button:disabled { opacity: .45; cursor: default; }
.pager select { height: 26px; border: 1px solid var(--line-strong); border-radius: 4px; font: inherit; font-size: 12px; }
.pager .spacer { flex: 1; }

/* 对账 / 概览 */
.panel { padding: 18px; }
.panel h2 { margin: 0 0 4px; font-size: 15px; }
.panel p.sub { margin: 0 0 16px; color: var(--muted); font-size: 12.5px; }
.checks { display: flex; flex-direction: column; gap: 10px; }
.check {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff;
}
.check .state {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
}
.check.pass .state { background: var(--ok); }
.check.fail .state { background: var(--bad); }
/* 提示（不是错误）：例如封盘到开奖之间的在途注单 */
.check.warn { background: #fffdf5; border-color: #f3e2b8; }
.check.warn .state { background: var(--warn); }
.check .body { flex: 1; }
.check .name { font-weight: 600; margin-bottom: 2px; }
.check .expr { font-size: 12px; color: var(--muted); font-family: Consolas, monospace; }
.check .vals { font-size: 12px; color: #334155; font-variant-numeric: tabular-nums; }

.info-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.info-card {
  border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; background: #fff;
}
.info-card .k { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.info-card .v { font-size: 20px; font-weight: 700; color: #1e3a8a; font-variant-numeric: tabular-nums; }
.info-card .v small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }

.panel + .panel { border-top: 8px solid var(--bg); }
.panel table.grid { margin-top: 8px; }
.panel code {
  background: #f1f5f9; padding: 1px 5px; border-radius: 3px;
  font-family: Consolas, monospace; font-size: 12px; color: #334155;
}
.key-box {
  font-family: Consolas, monospace; font-size: 11.5px; line-height: 1.7;
  word-break: break-all; background: #f8fafc; border: 1px solid var(--line);
  border-radius: 6px; padding: 12px 14px; color: #334155;
}

/* ---------------------------------------------------------------- 登录页 */
body.login-mode .app { display: block; }
body.login-mode .sidebar,
body.login-mode .topbar,
body.login-mode .filter-bar,
body.login-mode .pager { display: none; }
body.login-mode .main { padding: 0; height: 100vh; overflow: auto; }
body.login-mode .content {
  padding: 0 24px; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 460px at 20% -12%, #e9efff 0%, transparent 62%),
    radial-gradient(800px 420px at 100% 112%, #eef2ff 0%, transparent 58%),
    #f6f8fc;
}
body.login-mode #view { width: 100%; max-width: 360px; }

.login-wrap { display: flex; justify-content: center; }
.login-card {
  width: 100%; box-sizing: border-box; padding: 34px 30px 30px;
  background: #fff; border-radius: 16px; text-align: center;
  box-shadow: 0 18px 48px rgba(15, 26, 58, .13), 0 2px 6px rgba(15, 26, 58, .05);
  border: 1px solid #e8ebf2;
}
.login-logo {
  width: 52px; height: 52px; border-radius: 14px; padding: 6px;
  background: linear-gradient(150deg, #1e2b52, #16213e);
  box-shadow: 0 8px 20px rgba(22, 33, 62, .28);
}
.login-card h1 { margin: 14px 0 22px; font-size: 17px; color: #16213e; letter-spacing: .6px; }

.login-card form { display: flex; flex-direction: column; gap: 11px; text-align: left; }

.lg-field { position: relative; display: flex; align-items: center; }
.lg-ic { position: absolute; left: 12px; display: flex; color: #a3adbd; pointer-events: none; }
.lg-field input {
  width: 100%; box-sizing: border-box; height: 42px;
  padding: 0 40px 0 37px; font-size: 13.5px; font-family: inherit; color: #16213e;
  border: 1px solid #e2e6ee; border-radius: 9px; background: #f8fafd;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.lg-field input::placeholder { color: #b3bbc9; }
.lg-field input:focus {
  outline: none; background: #fff; border-color: #3b5bdb;
  box-shadow: 0 0 0 3.5px rgba(59, 91, 219, .12);
}
.lg-eye {
  position: absolute; right: 7px; display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border: 0; border-radius: 6px; cursor: pointer;
  background: transparent; color: #a3adbd;
}
.lg-eye:hover { background: #eef1f7; color: #4b5563; }

.lg-msg { min-height: 0; font-size: 12px; color: #d64545; }
.lg-msg:empty { display: none; }

.lg-submit {
  height: 43px; margin-top: 3px; border: 0; border-radius: 9px; cursor: pointer;
  font-size: 14px; font-family: inherit; letter-spacing: 3px; color: #fff; font-weight: 600;
  background: linear-gradient(135deg, #2f5bea, #1d3fbf);
  box-shadow: 0 6px 18px rgba(47, 91, 234, .28);
  transition: transform .12s, box-shadow .15s, filter .15s;
}
.lg-submit:hover { filter: brightness(1.06); box-shadow: 0 8px 22px rgba(47, 91, 234, .36); }
.lg-submit:active { transform: translateY(1px); }
.lg-submit:disabled { filter: grayscale(.25) brightness(.96); cursor: default; box-shadow: none; }

/* ---------------------------------------------------------------- 系统设置表单 */
.pwd-form input,
.pwd-form select {
  border: 1px solid #d5d9e0; border-radius: 6px; padding: 8px 10px;
  font-size: 13px; font-family: inherit; width: 100%; box-sizing: border-box;
}
.pwd-form input:focus,
.pwd-form select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.login-msg { min-height: 18px; font-size: 12px; color: #b45309; }
.pwd-form { display: flex; flex-direction: column; gap: 6px; max-width: 380px; }
.pwd-form label { font-size: 12px; color: #6b7280; }
.pwd-form .btn { margin-top: 8px; align-self: flex-start; }
.warn-box {
  margin: 14px 0; padding: 12px 14px; border-radius: 8px; line-height: 1.7;
  background: #fff4f2; border: 1px solid #f6c9c0; color: #9a3412; font-size: 13px;
}
.user-box {
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap;
  padding: 6px 8px; margin-bottom: 8px; border-radius: 6px;
  background: rgba(255,255,255,.06);
}
.user-box .who {
  font-size: 12px; font-weight: 600; color: #e5e9f2;
  max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-box .role {
  font-size: 10px; padding: 1px 6px; border-radius: 9px;
  background: rgba(99,132,255,.22); color: #b9c6ff; white-space: nowrap;
}
.user-box .logout { margin-left: auto; font-size: 11px; color: #9aa8c4; text-decoration: none; white-space: nowrap; }
.user-box .logout:hover { color: #dbe4ff; }
td .ok { color: #15803d; }
td .bad { color: #b91c1c; }