:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }
code {
  background: #eef1f5;
  color: #374151;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12.5px;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  height: 60px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  color: #fff; border-radius: 9px;
  font-size: 15px; font-weight: 700;
}
.logo.big { width: 46px; height: 46px; border-radius: 14px; font-size: 22px; margin: 0 auto 14px; }
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: .2px; }
.status { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #d1d5db; transition: background .2s; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }

/* 分段控件 */
.segmented { display: inline-flex; background: #f1f3f6; border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 13.5px; transition: background .15s, color .15s;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 500; }
.segmented.small { margin-bottom: 12px; }
.segmented.small button { padding: 5px 11px; font-size: 13px; }

/* 主体 */
.wrap {
  flex: 1; min-height: 0;
  width: 100%; max-width: 1080px;
  margin: 0 auto;
  padding: 24px 28px 28px;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.panel { display: flex; flex-direction: column; gap: 16px; flex: 1; min-height: 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  flex-shrink: 0;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.log-card { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 320px; }
.pill {
  background: #f1f3f6; color: var(--muted);
  border-radius: 999px; padding: 2px 10px; font-size: 12.5px;
}

/* 表单 */
textarea, input[type=text], input[type=tel], input[type=password], select {
  font: inherit; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { width: 100%; min-height: 112px; resize: vertical; font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px; line-height: 1.7; }
textarea:focus, input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
  background: #fff;
}
input[type=file] { color: var(--muted); font-size: 13px; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.field { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; cursor: pointer; }
input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

button, .button {
  font: inherit; cursor: pointer; text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  transition: background .15s, border-color .15s, box-shadow .15s;
  display: inline-flex; align-items: center; justify-content: center;
}
button:hover:not(:disabled), .button:hover { background: #f9fafb; border-color: #d1d5db; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, .button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500;
}
button.primary:hover:not(:disabled), .button.primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 10px; }
button.ghost:hover { background: #f3f4f6; color: var(--text); }
button.block { width: 100%; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; line-height: 1.7; }
.msg { color: var(--err); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* 日志 */
pre#jb-log {
  flex: 1; margin: 0; min-height: 240px; overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-all;
  color: #374151;
}

/* 千兰 */
.steps {
  display: flex; align-items: center; gap: 10px;
  list-style: none; margin: 0; padding: 0;
}
.steps li {
  display: flex; align-items: center; gap: 8px;
  color: #9ca3af; font-size: 13px;
}
.steps li b {
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #eceef2; color: #9ca3af; font-size: 12px; font-weight: 600;
}
.steps li.active { color: var(--text); }
.steps li.active b { background: var(--accent-soft); color: var(--accent); }
.steps li.done b { background: var(--accent); color: #fff; }
.steps li + li::before { content: ""; width: 28px; height: 1px; background: var(--border); margin-right: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  background: var(--surface-2); border-radius: 999px; padding: 7px 14px; font-size: 13px;
}
.chips button:hover { border-color: #c7d2fe; background: #f8faff; }
.chips button.active { background: var(--accent-soft); border-color: #bfdbfe; color: var(--accent); font-weight: 500; }

.table-wrap { max-height: 46vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; border-bottom: 1px solid #f0f2f5; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 500; z-index: 1; }
th.c, td:first-child { width: 44px; text-align: center; }
tbody tr:nth-child(even) { background: #fcfcfd; }
tbody tr:hover { background: #f8faff; }
tr.dim td { color: #9ca3af; }
td.status { white-space: normal; max-width: 380px; }
td.status[data-status*="已一致"] { color: var(--ok); }
td.status[data-status*="失败"], td.status[data-status*="错误"] { color: var(--err); }
td.status[data-status*="待生成"], td.status[data-status*="请"] { color: var(--warn); }

.notes { color: var(--muted); font-size: 13px; line-height: 1.9; margin: 16px 0 0; padding-left: 18px; }

/* 登录 */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(17, 24, 39, .45);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 360px; background: var(--surface);
  border-radius: 18px; box-shadow: 0 20px 50px rgba(16, 24, 40, .18);
  padding: 32px 30px 26px; text-align: center;
}
.login-card h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.login-card p { margin: 0 0 18px; }
.login-card input { width: 100%; margin-bottom: 12px; }

/* 主界面：记录 */
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat { flex: 1 1 160px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow); }
.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 22px; font-weight: 600; margin-top: 2px; }
.rec-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rec-form input[type=text], .rec-form input[type=datetime-local] { min-width: 170px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
td .thumbs { margin: 0; gap: 4px; }
td .thumbs img { width: 38px; height: 38px; }
td.problem { white-space: normal; max-width: 420px; word-break: break-word; }
td.time { white-space: nowrap; color: var(--muted); }

/* 归档 / 编辑 / 分页 */
.table-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; min-height: 28px; }
tr.archived td { color: #9ca3af; }
.tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: #f1f3f6; color: #6b7280; font-size: 11.5px; vertical-align: 1px; }
.edit-card { width: 540px; max-width: 92vw; max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 16px; padding: 22px; box-shadow: 0 20px 50px rgba(16,24,40,.18); text-align: left; }
#edit-problem { min-height: 92px; margin-top: 12px; }
.thumb-wrap { position: relative; display: inline-block; }
.thumb-wrap button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; padding: 0; border-radius: 50%; background: #111827; color: #fff; border: 0; font-size: 11px; line-height: 18px; }

/* 备注 / 图片 / 分页 / 日期选择器 */
.field.grow { flex: 1 1 240px; }
.field.grow input { flex: 1; min-width: 160px; }
.field.block-field { display: flex; margin-top: 12px; }
.field.block-field input { flex: 1; }
.edit-imgs-head { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.file-btn { display: inline-flex; align-items: center; padding: 6px 10px; border: 1px dashed var(--border); border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 12.5px; }
.file-btn:hover { border-color: var(--accent); color: var(--accent); }
td.note { white-space: normal; max-width: 260px; word-break: break-word; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 4px; }
.pager .page { min-width: 30px; padding: 5px 8px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); }
.pager .page:hover:not(:disabled) { background: #f3f4f6; }
.pager .page.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; border-color: #bfdbfe; }
.page-ellipsis { color: var(--muted); padding: 0 2px; }
:root { color-scheme: light; }
input[type=datetime-local] { font-variant-numeric: tabular-nums; }
input[type=datetime-local]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .55; padding: 3px; border-radius: 5px; }
input[type=datetime-local]::-webkit-calendar-picker-indicator:hover { opacity: 1; background: #eef2f7; }

/* flatpickr 主题 */
.flatpickr-calendar {
  font-family: inherit;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, .16);
  border: 1px solid var(--border);
}
.flatpickr-calendar.arrowTop:before, .flatpickr-calendar.arrowTop:after { display: none; }
.flatpickr-months .flatpickr-month { color: var(--text); }
.flatpickr-current-month .flatpickr-monthDropdown-months { font-weight: 600; }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.selected:focus {
  background: var(--accent); border-color: var(--accent);
}
.flatpickr-day.today { border-color: #bfdbfe; }
.flatpickr-day:hover { background: #f3f4f6; }
.flatpickr-time input { font-family: inherit; }
input.flatpickr-input {
  padding-right: 36px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M3 11h18'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
