:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  color: #182924;
  background: #f4f6f3;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --ink: #182924;
  --muted: #66776f;
  --line: #e2e8e2;
  --primary: #246b57;
  --primary-dark: #1b5545;
  --primary-soft: #eaf4ef;
  --danger: #b23a30;
  --sidebar: #123b31;
  --shadow: 0 1px 2px rgba(18, 59, 49, .05), 0 10px 30px rgba(18, 59, 49, .04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 248px;
  width: 248px;
  height: 100vh;
  padding: 24px 16px;
  background: var(--sidebar);
  color: #e8f2ed;
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand-mark {
  display: block;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
}
.brand strong { display: block; font-size: 15px; letter-spacing: .02em; }
.brand small { display: block; margin-top: 3px; font-size: 11px; color: rgba(232, 242, 237, .62); }
.nav { flex: 1; overflow-y: auto; }
.nav-group + .nav-group { margin-top: 24px; }
.nav-group-title {
  margin: 0 0 8px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  color: rgba(232, 242, 237, .46);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  margin-bottom: 3px;
  border-radius: 10px;
  color: rgba(232, 242, 237, .78);
  text-decoration: none;
  font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-link.is-active { background: rgba(255, 255, 255, .15); color: #fff; font-weight: 600; }
.nav-icon { display: flex; color: rgba(232, 242, 237, .72); }
.nav-link.is-active .nav-icon { color: #a9e0c8; }
.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px 4px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  font-size: 12px;
  color: rgba(232, 242, 237, .6);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: #5fd39f; flex: none; }
.nav-overlay { display: none; }

.content { flex: 1; min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 32px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.breadcrumb { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
.breadcrumb strong { color: var(--ink); font-weight: 600; }
.breadcrumb-sep { color: #b9c5bd; }
.topbar-right { margin-left: auto; }
.connection {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 600;
}
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.main { max-width: 1200px; margin: 0 auto; padding: 28px 32px 60px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: 24px; line-height: 1.3; letter-spacing: -.01em; }
.page-head p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}
.btn:hover { background: #f8faf7; border-color: #cbd6ce; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #eccac6; background: #fff; }
.btn-danger:hover { background: #fff5f4; border-color: #e5b3ad; }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-dark); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.btn-link {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 3px 5px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
}
.btn-link:hover { background: var(--primary-soft); }
.btn-link.is-danger { color: var(--danger); }
.btn-link.is-danger:hover { background: #fff2f1; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.panel + .panel { margin-top: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-head p { margin: 5px 0 0; font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { margin-top: 8px; font-size: 27px; font-weight: 700; line-height: 1; }
.stat-trend { margin-top: 9px; font-size: 11px; color: var(--muted); }

.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.quick-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, transform .15s;
}
.quick-card:hover { border-color: #b9d2c5; transform: translateY(-2px); }
.quick-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary);
}
.quick-card strong { display: block; font-size: 14px; }
.quick-card span { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); line-height: 1.5; }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.toolbar-field { margin: 0; min-width: 160px; }
.toolbar-field.is-search { flex: 1; min-width: 220px; }
.field { display: block; margin-bottom: 18px; }
.field-title { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; }
.field-hint { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cfd9d1;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36, 107, 87, .12); }
.input::placeholder { color: #a7b3ac; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.field--full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 6px; border-top: 1px solid var(--line); margin-top: 4px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; min-width: 800px; border-collapse: collapse; }
.check-cell { width: 42px; }
.check-cell input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.selection-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 13px;
}
.selection-bar strong { margin-right: auto; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-link { text-decoration: none; cursor: pointer; border: 1px solid transparent; }
.tag-link:hover { border-color: #b9d2c5; background: #dfece4; }
.tag-count { margin-left: 6px; color: var(--muted); font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 13px 15px; border-bottom: 1px solid var(--line); }
th { background: #f8faf7; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfa; }
.id-cell { color: var(--muted); font-variant-numeric: tabular-nums; width: 72px; }
.prompt-cell { max-width: 460px; }
.prompt-cell p { margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; line-height: 1.5; }
.tags-cell { max-width: 230px; }
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell .btn-link + .btn-link { margin-left: 8px; }

.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge--qa { background: #eaf1ff; color: #345bb0; }
.badge--single { background: #f2ebff; color: #7250b5; }
.badge--multiple { background: #fff2dd; color: #a66a13; }
.badge--truth { background: #e4f5ef; color: #21775e; }
.tag { display: inline-block; margin: 2px 4px 2px 0; padding: 2px 8px; border-radius: 6px; background: #f0f4f1; color: #4a6056; font-size: 12px; }

.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 12px; color: var(--muted); }
.pagination-buttons { display: flex; align-items: center; gap: 6px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; margin-bottom: 6px; color: var(--ink); font-size: 15px; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.detail-block { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fcfdfb; }
.detail-block.is-full { grid-column: 1 / -1; }
.detail-label { margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.detail-value { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.option-list { margin: 0; padding-left: 22px; line-height: 1.8; }
.option-list li.is-correct { color: var(--primary); font-weight: 600; }
.answer-line { display: inline-flex; align-items: center; gap: 8px; }

.upload-zone {
  display: block;
  padding: 22px;
  border: 1.5px dashed #b9cec1;
  border-radius: 13px;
  background: #f9fcfa;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-soft); }
.upload-zone input { margin-top: 12px; max-width: 340px; margin-left: auto; margin-right: auto; }
.upload-icon { display: grid; place-items: center; width: 42px; height: 42px; margin: 0 auto 12px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.upload-icon svg { width: 22px; height: 22px; }
.template-links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; font-size: 13px; }
.result-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.result-item { padding: 14px; border: 1px solid var(--line); border-radius: 11px; text-align: center; }
.result-item strong { display: block; font-size: 20px; }
.result-item span { font-size: 12px; color: var(--muted); }
.result-rows { max-height: 320px; overflow-y: auto; margin: 0; padding-left: 22px; font-size: 13px; line-height: 1.7; }
.result-rows li { padding: 2px 0; overflow-wrap: anywhere; }
.result-rows li.is-invalid, .result-rows li.is-duplicate { color: var(--muted); }
.result-rows li.is-ready { color: var(--primary-dark); }

.steps { display: grid; gap: 14px; }
.step { display: flex; gap: 14px; align-items: flex-start; }
.step-num { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px; }
.step p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.callout { padding: 14px 16px; border-left: 3px solid var(--primary); border-radius: 8px; background: var(--primary-soft); color: var(--primary-dark); font-size: 13px; line-height: 1.7; }

.toast-stack { position: fixed; right: 22px; bottom: 22px; z-index: 120; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 11px;
  background: #173d32;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(12, 38, 29, .25);
  animation: toast-in .2s ease-out;
}
.toast--error { background: #8c3029; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.modal { position: fixed; inset: 0; z-index: 110; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(12, 32, 25, .45); }
.modal-box { position: relative; width: min(420px, calc(100% - 32px)); padding: 24px; border-radius: 16px; background: #fff; box-shadow: 0 24px 60px rgba(12, 38, 29, .25); }
.modal-box h3 { margin: 0 0 10px; font-size: 17px; }
.modal-box p { margin: 0 0 22px; color: var(--muted); line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.batch-tag { display: inline-block; padding: 2px 9px; border-radius: 999px; background: #edf3f0; color: #2f6b57; font-size: 12px; font-weight: 600; white-space: nowrap; }
.import-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.batch-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.batch-row:last-child { border-bottom: 0; }
.batch-no { min-width: 74px; font-weight: 600; }
.batch-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.batch-time { color: var(--muted); font-size: 12px; }
.batch-note { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-actions { display: flex; gap: 8px; flex-shrink: 0; }
.batch-row.is-empty .batch-time { color: var(--danger); }
.toolbar-action { align-self: end; margin-bottom: 1px; }

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 12px 0 40px rgba(12, 38, 29, .2); }
  .sidebar.is-open { transform: none; }
  .nav-overlay.is-visible { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(12, 32, 25, .35); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 18px; }
  .main { padding: 22px 18px 48px; }
}
@media (max-width: 620px) {
  .stats, .form-grid, .detail-grid, .result-grid, .import-fields { grid-template-columns: 1fr; }
  .detail-block.is-full, .field--full { grid-column: auto; }
  .topbar-right { display: none; }
  .page-head { flex-direction: column; }
  .panel { padding: 18px; }
}
