:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --border: #e5e9f2;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-border: #fecaca;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;
  --green: #059669;
  --green-bg: #ecfdf5;
  --green-border: #a7f3d0;
  --blue-bg: #eff6ff;
  --blue-border: #bfdbfe;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.muted-sm { color: var(--muted); font-size: 12.5px; }

/* Topbar */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
}
.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; gap: 10px; }

/* Container & Cards */
.container {
  max-width: 1280px;
  margin: 22px auto 60px;
  padding: 0 20px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled) { border-color: #cbd5e1; background: #f8fafc; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: #f1f5f9; color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-lg { padding: 11px 28px; font-size: 15px; font-weight: 600; }
.btn-full { width: 100%; }

/* Dual Workspace Grid */
.dual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 16px;
}
@media (max-width: 920px) {
  .dual-grid { grid-template-columns: 1fr; }
}
.panel-card { display: flex; flex-direction: column; overflow: hidden; }
.panel-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-title-wrap { display: flex; align-items: flex-start; gap: 10px; }
.panel-title-wrap h3 { margin: 0; font-size: 15px; }
.panel-title-wrap p { margin: 2px 0 0; }
.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--blue-bg);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.panel-body { padding: 18px; flex: 1; display: flex; flex-direction: column; }

/* Segmented Tabs */
.seg-tabs {
  display: inline-flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}
.seg-tab {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 500;
}
.seg-tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Dropzone */
.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: #fafcff;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 210px;
}
.dropzone-compact { min-height: 140px; padding: 22px 16px; }
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--blue-bg);
}
.dropzone-icon { font-size: 32px; margin-bottom: 8px; }
.dropzone-title { font-weight: 600; font-size: 14.5px; margin-bottom: 6px; }
.dropzone-hint { font-size: 12.5px; color: var(--muted); max-width: 400px; }
kbd {
  background: #e2e8f0;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  font-family: monospace;
}

.selected-file-bar {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 9px;
  background: var(--blue-bg);
  border: 1px solid var(--blue-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.file-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-icon {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 6px;
}
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Rich Paste Box */
.rich-paste-box {
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  padding: 12px 14px;
  min-height: 210px;
  max-height: 300px;
  overflow-y: auto;
  background: #fff;
  outline: none;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
}
.rich-paste-box:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.rich-paste-box:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  white-space: pre-wrap;
}
.rich-paste-box img { max-width: 140px; max-height: 90px; border-radius: 6px; margin: 4px; }
.paste-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

/* Screenshot Thumbnails */
.shot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
  margin-top: 14px;
  max-height: 240px;
  overflow-y: auto;
  padding: 2px;
}
.shot-thumb {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}
.shot-thumb img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.shot-idx {
  position: absolute;
  top: 5px;
  left: 5px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.shot-tools {
  display: flex;
  justify-content: space-between;
  padding: 3px 4px;
  background: #fff;
  border-top: 1px solid var(--border);
}
.shot-tools button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--muted);
}
.shot-tools button:hover { background: #f1f5f9; color: var(--text); }
.shot-tools button.del:hover { color: var(--red); background: var(--red-bg); }

/* URL Input */
.field-label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 13.5px; }
.url-textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  padding: 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: vertical;
  outline: none;
}
.url-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.info-callout {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
}

/* Action Bar */
.action-bar {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.config-controls {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.ctrl-item { display: flex; align-items: center; gap: 8px; }
.ctrl-item label { font-size: 13px; color: var(--muted); font-weight: 500; }
.select-input, .text-input {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.select-input:focus, .text-input:focus { border-color: var(--primary); }
.checkbox-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

/* Loading & Alerts */
.loading-card {
  margin-top: 16px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-left: 4px solid var(--primary);
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text-wrap { flex: 1; }
.loading-title { font-weight: 600; font-size: 14.5px; }
.loading-timer { font-family: monospace; font-weight: 700; color: var(--primary); font-size: 15px; }

.alert-box {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
}
.alert-error { background: var(--red-bg); border: 1px solid var(--red-border); color: #991b1b; }
.alert-warn { background: var(--amber-bg); border: 1px solid var(--amber-border); color: #92400e; flex-direction: column; align-items: flex-start; }

/* Report Section */
.verdict-banner {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-left: 5px solid var(--primary);
}
.verdict-banner.v-pass { border-left-color: var(--green); }
.verdict-banner.v-need_confirm { border-left-color: var(--amber); }
.verdict-banner.v-need_fix { border-left-color: var(--red); }
.verdict-left { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 260px; }
.verdict-pill {
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}
.v-pass .verdict-pill { background: var(--green-bg); color: var(--green); }
.v-need_confirm .verdict-pill { background: var(--amber-bg); color: var(--amber); }
.v-need_fix .verdict-pill { background: var(--red-bg); color: var(--red); }
.report-title { margin: 0 0 3px; font-size: 17px; }
.verdict-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 16px 0;
}
@media (max-width: 780px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
.stat-card { padding: 15px 18px; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 800; margin: 4px 0; }
.stat-sub { font-size: 12px; color: var(--muted); }
.stat-red .stat-value { color: var(--red); }
.stat-amber .stat-value { color: var(--amber); }
.stat-blue .stat-value { color: var(--primary); }
.stat-green .stat-value { color: var(--green); }

/* Report Tabs */
.report-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.rtab {
  border: none;
  background: transparent;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.rtab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-badge {
  background: #e2e8f0;
  color: #475569;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

.section-card { padding: 18px 20px; margin-bottom: 16px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.section-head h3 { margin: 0; font-size: 15px; }

/* Filter pills */
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--border);
  background: #fff;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--muted);
}
.pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Audit Item Cards */
.audit-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 15px;
  margin-bottom: 10px;
  background: #fff;
}
.audit-item.st-modified { border-left: 4px solid var(--red); background: #fffafa; }
.audit-item.st-omitted { border-left: 4px solid var(--amber); background: #fffdf5; }
.audit-item.st-omitted.is-acked { border-left-color: #94a3b8; background: #f8fafc; opacity: 0.78; }
.audit-item.st-matched { border-left: 4px solid var(--green); }

.item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.item-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 5px;
  font-weight: 600;
}
.tag-type { background: #f1f5f9; color: #475569; }
.tag-red { background: var(--red-bg); color: var(--red); }
.tag-amber { background: var(--amber-bg); color: var(--amber); }
.tag-green { background: var(--green-bg); color: var(--green); }
.tag-blue { background: var(--blue-bg); color: var(--primary); }

.diff-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.75;
  word-break: break-word;
}
.diff-del {
  background: #fee2e2;
  color: #b91c1c;
  text-decoration: line-through;
  padding: 1px 3px;
  border-radius: 3px;
}
.diff-ins {
  background: #dcfce7;
  color: #166534;
  font-weight: 600;
  padding: 1px 3px;
  border-radius: 3px;
}
.diff-rep-wrap { display: inline; }
.diff-legend { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.entity-warn-list {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.entity-warn {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 5px;
}

.empty-ok {
  padding: 22px;
  text-align: center;
  color: var(--green);
  background: var(--green-bg);
  border-radius: 8px;
  font-weight: 500;
}

/* Image Compare Grid */
.img-audit-row {
  display: grid;
  grid-template-columns: 180px 1fr 180px;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
@media (max-width: 720px) {
  .img-audit-row { grid-template-columns: 1fr; }
}
.img-audit-row.st-omitted { border-left: 4px solid var(--amber); background: #fffdf5; }
.img-audit-row.st-order_mismatch, .img-audit-row.st-extra_target { border-left: 4px solid var(--red); background: #fffafa; }
.img-audit-row.st-matched { border-left: 4px solid var(--green); }
.img-thumb-box {
  text-align: center;
}
.img-thumb-box img {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f8fafc;
  cursor: zoom-in;
}
.img-placeholder {
  height: 90px;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  background: #f8fafc;
}

/* Extracted View */
.extracted-shots {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 12px;
}
.extracted-shots img {
  height: 120px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: zoom-in;
}
.extracted-pre {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 13.5px;
  max-height: 520px;
  overflow-y: auto;
  margin: 0;
}

/* Drawer & Modals */
.drawer-backdrop, .modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 60;
  display: flex;
  justify-content: flex-end;
}
.modal-backdrop { justify-content: center; align-items: center; }
.drawer-panel {
  width: 420px;
  max-width: 92vw;
  background: #fff;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.14);
}
.drawer-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-head h3 { margin: 0; }
.drawer-body { padding: 14px; overflow-y: auto; flex: 1; }
.history-item {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.history-item:hover { border-color: var(--primary); background: #fafcff; }
.history-title { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.history-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

.auth-card { width: 360px; max-width: 92vw; padding: 26px; display: flex; flex-direction: column; gap: 12px; background: #fff; border-radius: 12px; }
.auth-card h2 { margin: 0; }
.error-inline { color: var(--red); font-size: 12.5px; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 6px; box-shadow: 0 8px 36px rgba(0, 0, 0, 0.45); }

/* Toast */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 90;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
