:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #6b7686;
  --line: #e6e9ef;
  --brand: #2563eb;
  --brand-weak: #eaf1ff;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }

/* 顶部条 */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 700; font-size: 16px; }
.topbar .nav { display: flex; gap: 14px; font-size: 14px; }
.topbar .nav a { color: var(--muted); }
.topbar .nav a.active { color: var(--brand); font-weight: 600; }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px; }
.wrap.wide { max-width: 1200px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field label .req { color: var(--err); margin-left: 2px; }
.field input, .field select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; background: #fff; color: var(--ink); outline: none; transition: border .15s, box-shadow .15s;
}
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field .err-msg { font-size: 12px; color: var(--err); margin-top: 5px; display: none; }
.field.invalid input, .field.invalid select { border-color: var(--err); }
.field.invalid .err-msg { display: block; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; gap: 0; } }

/* 自动补齐预览 */
.derived {
  background: var(--brand-weak); border: 1px dashed #bcd0ff; border-radius: 10px;
  padding: 12px; margin: 4px 0 14px; font-size: 13px; display: none;
}
.derived.show { display: block; }
.derived .row { display: flex; justify-content: space-between; padding: 3px 0; }
.derived .k { color: var(--muted); }
.derived .v { font-weight: 600; color: var(--brand); font-family: ui-monospace, Menlo, Consolas, monospace; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 15px; cursor: pointer; transition: background .15s, border .15s;
}
.btn:hover { background: #f7f9fc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #1d4fd7; }
.btn.danger { color: var(--err); border-color: #f3c2c2; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #1f2733; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.grid th { background: #fafbfc; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
table.grid tr:hover td { background: #f9fbff; }
table.grid td input, table.grid td select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; }

/* 敏感值遮挡 */
.masked { cursor: pointer; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }
.masked .dot { letter-spacing: 1px; }
.reveal { color: var(--ink); font-family: ui-monospace, Menlo, monospace; }

/* 筛选条 */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.filters .f input, .filters .f select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; min-width: 120px; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.brand .num { color: var(--brand); }
.stat.ok .num { color: var(--ok); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs .tab { padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-size: 15px; }
.tabs .tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

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

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 14px; max-width: 560px; width: 100%; max-height: 88vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal .head { padding: 16px 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 18px; }
.modal .foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.modal .close { cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; }

/* 日志明细 */
.log-detail { font-size: 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 4px; max-height: 120px; overflow: auto; }
.log-detail .ch { margin: 2px 0; }
.log-detail .old { color: var(--err); text-decoration: line-through; }
.log-detail .new { color: var(--ok); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #eef2f7; color: var(--muted); }
.tag.ok { background: #e7f6ec; color: var(--ok); }
.tag.warn { background: #fdf3e3; color: var(--warn); }
.tag.brand { background: var(--brand-weak); color: var(--brand); }

/* 上传区 */
.upload { border: 2px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: border .15s, background .15s; }
.upload:hover { border-color: var(--brand); background: var(--brand-weak); }
.upload .big { font-size: 15px; color: var(--ink); font-weight: 600; margin-bottom: 4px; }

/* 空状态 */
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }

/* 批量操作条 */
.batch-bar { display: none; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--brand-weak); border: 1px solid #bcd0ff; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.batch-bar.show { display: flex; }
.batch-bar .cnt { font-weight: 700; color: var(--brand); }

/* 我的记录列表 */
.my-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.my-item .ttl { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.my-item .ttl .name { font-weight: 700; }
.my-item .kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 14px; font-size: 13px; }
.my-item .kv .k { color: var(--muted); }
@media (max-width: 520px) { .my-item .kv { grid-template-columns: 1fr; } }
