* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 40%, #0f172a 100%);
  height: 100vh; overflow: hidden; color: #1e293b; line-height: 1.6; }
/* .container removed — replaced by .app-layout grid */

/* Subtle ambient glow */
.app-layout::before {
  content: '';
  position: fixed;
  top: -30%;
  left: -20%;
  width: 60%;
  height: 60%;
  background: radial-gradient(ellipse, rgba(196,181,138,0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.app-layout::after {
  content: '';
  position: fixed;
  bottom: -20%;
  right: -15%;
  width: 50%;
  height: 50%;
  background: radial-gradient(ellipse, rgba(99,133,199,0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Header bar */
.header-bar { display: flex; align-items: center; gap: 16px; flex-shrink: 0; margin-bottom: 14px; position: relative; z-index: 1; }
.header-bar h1 { text-align: left; margin-bottom: 0; color: #f1f5f9; font-size: 20px; text-shadow: 0 2px 12px rgba(0,0,0,0.3); letter-spacing: 1px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.header-logo { width: 32px; height: 32px; object-fit: contain; }

/* Document name banner — floating overlay above step panels */
.doc-name-banner {
  display: inline-flex; align-items: center; gap: 6px;
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  padding: 4px 16px; border-radius: 20px;
  background: rgba(201,168,76,0.14); border: 1px solid rgba(201,168,76,0.25);
  color: #e0c97f; font-size: 13px; font-weight: 600;
  max-width: 520px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  z-index: 10; backdrop-filter: blur(6px);
  pointer-events: none;
}

/* Stepper */
.stepper { flex: 1; display: flex; justify-content: center; align-items: center; gap: 0; position: relative; z-index: 1; }
.step-item { display: flex; align-items: center; cursor: default; }
.step-circle { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; transition: all 0.3s; flex-shrink: 0;
  background: rgba(241,245,249,0.08); color: rgba(241,245,249,0.4); border: 2px solid rgba(241,245,249,0.12); }
.step-label { font-size: 11px; margin-left: 5px; color: rgba(241,245,249,0.4); font-weight: 600; white-space: nowrap; transition: all 0.3s; }
.step-connector { width: 24px; height: 2px; background: rgba(241,245,249,0.1); margin: 0 4px; flex-shrink: 0; transition: background 0.3s; }
.step-item.active .step-circle {
  background: linear-gradient(135deg, #c9a84c, #e0c97f);
  color: #1e293b; border-color: #c9a84c;
  box-shadow: 0 2px 12px rgba(201,168,76,0.4); transform: scale(1.08);
}
.step-item.active .step-label { color: #f1f5f9; }
.step-item.done .step-circle { background: rgba(201,168,76,0.25); color: #c9a84c; border-color: rgba(201,168,76,0.4); }
.step-item.done .step-label { color: rgba(241,245,249,0.7); }
.step-item.done + .step-connector, .step-connector.done { background: rgba(201,168,76,0.3); }
.step-item.clickable { cursor: pointer; }

/* Panels */
.step-panel {
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(241,245,249,0.15);
  border-radius: 16px; padding: 32px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.5);
  display: none; animation: fadeSlideIn 0.35s ease; position: relative; z-index: 1;
  flex: 1; overflow: hidden; min-height: 0; margin-bottom: 24px;
}
.step-panel.active { display: flex; flex-direction: column; }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

h2 { font-size: 20px; margin-bottom: 24px; padding-bottom: 12px; border-bottom: 2px solid #e2e8f0; color: #1e293b; font-weight: 700; letter-spacing: 0.5px; }

/* Panel content (scrollable area) */
.panel-content { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; }

/* Nav buttons */
.nav-bar { display: flex; justify-content: space-between; align-items: center; padding-top: 18px; border-top: 1px solid #e2e8f0; flex-shrink: 0; }
.nav-bar .btn-nav { min-width: 140px; }

.hidden { display: none !important; }
.disabled { opacity: 0.5; pointer-events: none; }

/* Upload zone */
.upload-zone {
  border: 2px dashed #cbd5e1; border-radius: 16px; padding: 56px 40px;
  text-align: center; cursor: pointer; transition: all 0.3s;
  background: linear-gradient(160deg, #f8fafc 0%, #f1f5f9 100%);
  max-width: 560px; margin: 0 auto;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: #c9a84c; background: linear-gradient(160deg, #fffbeb 0%, #fef3c7 100%);
  box-shadow: 0 4px 24px rgba(201,168,76,0.15);
}
.upload-zone .icon { font-size: 56px; margin-bottom: 12px; filter: grayscale(0.2); }
.upload-zone p { color: #64748b; font-size: 15px; }
.upload-zone .filename { margin-top: 12px; color: #1e293b; font-weight: 600; font-size: 15px; }

/* Form elements */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.form-grid .full-width { grid-column: 1 / -1; }
label { display: block; font-size: 13px; font-weight: 600; color: #475569; margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; padding: 9px 14px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 14px;
  background: #ffffff; color: #1e293b; transition: all 0.2s;
}
textarea { min-height: 120px; font-family: monospace; resize: vertical; }
.config-modal-body textarea { flex: 1; min-height: 60px; resize: none; }
input:focus, textarea:focus { outline: none; border-color: #c9a84c; box-shadow: 0 0 0 3px rgba(201,168,76,0.12); }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: #c9a84c; }

/* Config tabs */
.config-tabs {
  display: flex; gap: 2px; border-bottom: 2px solid #e2e8f0;
  margin-bottom: 16px; flex-shrink: 0; flex-wrap: wrap;
}
.config-tab {
  padding: 8px 12px; border: none; background: transparent;
  font-size: 13px; font-weight: 600; color: #94a3b8; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.2s; white-space: nowrap; border-radius: 6px 6px 0 0;
}
.config-tab:hover { color: #475569; background: rgba(0,0,0,0.03); }
.config-tab.active {
  color: #b8960f; border-bottom-color: #c9a84c;
  background: rgba(201,168,76,0.06);
}
.config-tab-panels { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.config-tab-panel { display: none; animation: fadeTabIn 0.2s ease; }
.config-tab-panel.active { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }
@keyframes fadeTabIn { from { opacity: 0; } to { opacity: 1; } }

/* Keep legacy classes for other potential uses */
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checkbox-grid .checkbox-row { min-width: auto; }

/* Buttons */
.btn { -webkit-appearance: none; appearance: none; padding: 10px 24px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; letter-spacing: 0.3px; }
.btn-sm { padding: 5px 14px; font-size: 12px; border-radius: 6px; }
.btn-primary {
  background: linear-gradient(135deg, #b8960f, #d4af37, #c9a84c);
  color: #1e293b; box-shadow: 0 2px 10px rgba(201,168,76,0.35);
}
.btn-primary:hover { box-shadow: 0 4px 20px rgba(201,168,76,0.5); transform: translateY(-1px); background: linear-gradient(135deg, #c9a84c, #e0c97f); }
.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff; box-shadow: 0 2px 10px rgba(16,185,129,0.3);
}
.btn-success:hover { box-shadow: 0 4px 20px rgba(16,185,129,0.4); transform: translateY(-1px); }
.btn-danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff; box-shadow: 0 2px 10px rgba(239,68,68,0.3);
}
.btn-danger:hover { box-shadow: 0 4px 20px rgba(239,68,68,0.4); transform: translateY(-1px); }
.btn-secondary { background: #64748b; color: #f1f5f9; }
.btn-secondary:hover { background: #475569; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
#exceptions-badge.badge {
  background: #ef4444; color: #fff; margin-left: 4px;
  min-width: 18px; text-align: center; padding: 1px 6px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* Progress */
.progress-container { margin-top: 16px; }
.progress-bar-outer { background: #e2e8f0; border-radius: 10px; height: 24px; overflow: hidden; position: relative; }
.progress-bar-inner { background: linear-gradient(90deg, #c9a84c, #10b981); height: 100%; transition: width 0.3s; border-radius: 10px; min-width: 0; }
.progress-text { text-align: center; font-size: 13px; color: #64748b; margin-top: 6px; }

/* Table editor */
.table-container { flex: 1; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 8px; min-height: 0; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; background: #f8fafc; padding: 10px 12px; text-align: left; font-size: 13px; border-bottom: 2px solid #e2e8f0; z-index: 1; color: #475569; }
td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; font-size: 14px; vertical-align: top; }
td textarea { width: 100%; min-height: 40px; border: 1px solid transparent; border-radius: 6px; padding: 4px 8px; font-size: 14px; resize: none; overflow: hidden; background: #ffffff; transition: border-color 0.2s; }
td textarea:focus { border-color: #c9a84c; background: #fffefb; }
.original-input { color: #64748b; background: #f8fafc !important; }
.original-input:focus { background: #ffffff !important; color: #334155; }
tr.changed { background: #fffbeb; }
.diff-del { background: #fef2f2; color: #991b1b; text-decoration: line-through; }
.diff-ins { background: #ecfdf5; color: #065f46; text-decoration: underline; }
.raw-json { width: 100%; flex: 1; min-height: 200px; font-family: monospace; font-size: 13px; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; }
#view-table, #view-table-parsed { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Status badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge-uploaded { background: #f1f5f9; color: #475569; }
.badge-proofreading { background: #fef3c7; color: #92400e; }
.badge-proofread_done { background: #d1fae5; color: #065f46; }
.badge-rendering { background: #fef3c7; color: #92400e; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-error { background: #fef2f2; color: #991b1b; }
.badge-cancelled { background: #f1f5f9; color: #64748b; }

/* Error display */
.error-box { background: #fef2f2; border: 1px solid #fca5a5; border-radius: 8px; padding: 12px; color: #991b1b; margin-top: 10px; }

/* Edit cell */
.edit-cell { display: flex; flex-direction: column; gap: 4px; }
.highlight-wrap { position: relative; }
.highlight-backdrop { position: absolute; top: 0; left: 0; width: 100%; padding: 4px 8px; font-family: monospace; font-size: 14px; line-height: 1.3; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; letter-spacing: normal; font-variant-ligatures: none; font-kerning: none; pointer-events: none; color: transparent; z-index: 0; border: 1px solid transparent; border-radius: 6px; min-height: 40px; box-sizing: border-box; }
.highlight-wrap textarea {
  position: relative; z-index: 1;
  /* Every text-layout property must match .highlight-backdrop exactly */
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  font-family: monospace;
  font-size: 14px;
  font-weight: normal;
  font-style: normal;
  line-height: 1.3;
  letter-spacing: normal;
  word-spacing: normal;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  font-variant-ligatures: none;
  text-indent: 0;
  text-transform: none;
  tab-size: 8;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: hidden;
}
.highlight-backdrop:not(:empty) ~ textarea { background: transparent !important; }
.highlight-backdrop:not(:empty) ~ textarea.original-input { background: transparent !important; }
.highlight-backdrop:not(:empty) ~ textarea:focus { background: transparent !important; }
mark.search-highlight { background: rgba(254, 240, 138, 0.5); color: transparent; border-radius: 2px; padding: 0; }
.edit-toolbar { display: flex; justify-content: flex-end; gap: 4px; }
.btn-nochange { font-size: 11px; padding: 2px 8px; background: #fff7ed; border: 1px solid #fdba74; border-radius: 4px; cursor: pointer; color: #ea580c; transition: all 0.15s; }
.btn-nochange:hover { background: #ffedd5; color: #c2410c; border-color: #fb923c; }
.btn-check { font-size: 11px; padding: 2px 8px; background: #faf5ff; border: 1px solid #c4b5fd; border-radius: 4px; cursor: pointer; color: #7c3aed; transition: all 0.15s; }
.btn-check:hover { background: #ede9fe; color: #5b21b6; border-color: #a78bfa; }
.btn-reset { font-size: 11px; padding: 2px 8px; background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 4px; cursor: pointer; color: #64748b; transition: all 0.15s; }
.btn-reset:hover { background: #e2e8f0; color: #334155; border-color: #94a3b8; }
.btn-orig-reset { font-size: 11px; padding: 2px 8px; background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 4px; cursor: pointer; color: #64748b; transition: all 0.15s; align-self: flex-start; }
.btn-orig-reset:hover { background: #e2e8f0; color: #334155; border-color: #94a3b8; }
.btn-log { font-size: 11px; padding: 2px 8px; background: #eff6ff; border: 1px solid #93c5fd; border-radius: 4px; cursor: pointer; color: #3b82f6; transition: all 0.15s; }
.btn-log:hover { background: #dbeafe; color: #1d4ed8; border-color: #60a5fa; }
.btn-reproofread { font-size: 11px; padding: 2px 8px; background: #f0fdf4; border: 1px solid #86efac; border-radius: 4px; cursor: pointer; color: #16a34a; transition: all 0.15s; }
.btn-reproofread:hover { background: #dcfce7; color: #15803d; border-color: #4ade80; }
.btn-reproofread:disabled { opacity: 0.5; cursor: not-allowed; }
.diff-preview { padding: 6px 8px; background: #ffffff; border: 1px dashed #e2e8f0; border-radius: 6px; font-size: 14px; line-height: 1.8; white-space: pre-wrap; word-break: break-all; min-height: 20px; }
.diff-preview .del { background: #fef2f2; color: #991b1b; text-decoration: line-through; }
.diff-preview .ins { background: #ecfdf5; color: #065f46; text-decoration: underline; }

/* Edit layout */
.edit-layout { display: flex; gap: 16px; flex: 1; min-height: 0; }
.edit-single-layout { display: flex; gap: 16px; flex: 1; min-height: 0; }
.edit-left { flex: 3; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.preview-panel { flex: 2; min-width: 0; display: flex; flex-direction: column; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; }
.preview-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: #f1f5f9; font-size: 13px; font-weight: 600; color: #475569; }
.preview-viewport { position: relative; background: #ffffff; overflow: auto; flex: 1; min-height: 200px; display: flex; justify-content: center; align-items: flex-start; }
.preview-img-wrap { position: relative; display: inline-block; line-height: 0; }
.preview-img-wrap img { display: block; max-width: 100%; height: auto; }
.highlight-box { position: absolute; border: 2.5px solid #dc2626; background: rgba(220,38,38,0.15); pointer-events: none; display: none; transition: all 0.15s; border-radius: 2px; }
.preview-nav { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 8px; background: #f1f5f9; }
.preview-nav button { border: 1px solid #cbd5e1; background: #ffffff; padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; color: #475569; transition: all 0.15s; }
.preview-nav button:hover { background: #f8fafc; border-color: #94a3b8; }
.preview-nav button:disabled { opacity: 0.4; cursor: not-allowed; }
.preview-page-input { width: 40px !important; min-width: 0 !important; max-width: 40px !important; text-align: center; border: 1px solid #cbd5e1; border-radius: 6px; padding: 3px 4px; font-size: 13px; color: #475569; outline: none; box-sizing: content-box; }
.preview-page-input:focus { border-color: #6366f1; box-shadow: 0 0 0 2px rgba(99,102,241,0.15); }
.preview-page-input::-webkit-inner-spin-button, .preview-page-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.preview-page-input { -moz-appearance: textfield; }
#preview-page-label { font-size: 13px; color: #475569; white-space: nowrap; }
.preview-empty { display: flex; justify-content: center; align-items: center; min-height: 300px; color: #94a3b8; font-size: 14px; }
.page-badge { display: inline-block; padding: 1px 6px; border-radius: 8px; font-size: 11px; background: #f1f5f9; color: #475569; margin-right: 6px; }

/* Page separator rows in edit tables */
tr.page-separator td { padding: 0; border-bottom: none; background: transparent; }
tr.page-separator:hover td { background: transparent; }
.page-separator-inner { display: flex; align-items: center; gap: 12px; padding: 8px 12px; margin: 2px 0; }
.page-separator-line { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, #e2e8f0, transparent); }
.page-separator-label { font-size: 11px; font-weight: 600; color: #94a3b8; white-space: nowrap; letter-spacing: 0.3px; }

tr.selected { outline: 2px solid #c9a84c; outline-offset: -2px; background: #fffbeb !important; }
tr.deleted { opacity: 0.45; background: #fef2f2 !important; }
tr.deleted td { text-decoration: line-through; color: #b91c1c; }
.deleted-text { color: #94a3b8; font-size: 13px; font-style: italic; }
.highlight-wrap { position: relative; }
.btn-del-entry { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border: 1px solid #fca5a5; background: #fef2f2; color: #dc2626; border-radius: 4px; cursor: pointer; font-size: 16px; line-height: 1; padding: 0; display: flex; align-items: center; justify-content: center; transition: all 0.15s; z-index: 2; }
.btn-del-entry:hover { background: #fee2e2; border-color: #ef4444; }
.btn-del-restore { padding: 2px 8px; border: 1px solid #86efac; background: #f0fdf4; color: #166534; border-radius: 4px; cursor: pointer; font-size: 12px; transition: all 0.15s; }
.btn-del-restore:hover { background: #dcfce7; border-color: #22c55e; }
.btn-cleanup-restore { padding: 2px 8px; border: 1px solid #fcd34d; background: #fffbeb; color: #92400e; border-radius: 4px; cursor: pointer; font-size: 11px; margin-right: 8px; flex-shrink: 0; transition: all 0.15s; }
.btn-cleanup-restore:hover { background: #fef3c7; border-color: #f59e0b; }
.edit-cell { position: relative; }

/* Cleanup (LLM text cleanup) */
.cleanup-action-bar { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.cleanup-status { font-size: 13px; color: #64748b; white-space: nowrap; }
.cleanup-progress { width: 120px; height: 6px; border-radius: 3px; overflow: hidden; }
.cleanup-progress::-webkit-progress-bar { background: #e2e8f0; border-radius: 3px; }
.cleanup-progress::-webkit-progress-value { background: #3b82f6; border-radius: 3px; transition: width 0.2s; }
.cleanup-progress::-moz-progress-bar { background: #3b82f6; border-radius: 3px; }

/* Batch operations */
.batch-row { display: flex; gap: 12px; margin-bottom: 12px; }
.batch-panel { flex: 1; min-width: 0; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.batch-panel-header { padding: 10px 14px; background: #f8fafc; cursor: pointer; font-weight: 600; font-size: 13px; user-select: none; display: flex; justify-content: space-between; align-items: center; color: #475569; transition: background 0.15s; }
.batch-panel-header:hover { background: #f1f5f9; }
.batch-panel-body { padding: 14px; border-top: 1px solid #e2e8f0; }
.batch-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.batch-form span { font-size: 13px; color: #475569; white-space: nowrap; }
.batch-form input { width: 80px; padding: 4px 8px; font-size: 14px; text-align: center; border: 1px solid #e2e8f0; border-radius: 6px; background: #ffffff; }
.batch-form input:focus { border-color: #c9a84c; outline: none; box-shadow: 0 0 0 2px rgba(201,168,76,0.12); }
.batch-result { margin-top: 8px; font-size: 13px; color: #475569; padding: 6px 10px; background: #f8fafc; border-radius: 6px; }
.batch-result.err { background: #fef2f2; color: #991b1b; }

/* Search bar */
.toolbar-panel { margin-bottom: 12px; }
.search-bar { display: flex; align-items: center; gap: 8px; overflow: hidden; margin-bottom: 12px; padding: 8px 12px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; }
.search-bar input[type="text"] { flex: 1; min-width: 200px; padding: 4px 8px; font-size: 14px; border: 1px solid #e2e8f0; border-radius: 6px; background: #ffffff; }
.search-bar input[type="text"]:focus { border-color: #c9a84c; outline: none; box-shadow: 0 0 0 2px rgba(201,168,76,0.12); }
.search-bar select { flex: none; width: 90px; padding: 4px 8px; font-size: 13px; border: 1px solid #e2e8f0; border-radius: 6px; background: #ffffff; color: #475569; }
.search-count { font-size: 13px; color: #64748b; white-space: nowrap; min-width: 50px; text-align: center; }

/* Batch history */
.batch-history { margin-top: 12px; }
.batch-history-header { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; color: #64748b; margin-bottom: 6px; }
.batch-history-actions { display: flex; gap: 6px; }
.batch-history-list { max-height: 200px; overflow-y: auto; }
.batch-history-empty { font-size: 12px; color: #94a3b8; text-align: center; padding: 8px; }
.batch-history-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; transition: background 0.15s; font-size: 13px; }
.batch-history-item:hover { background: #f8fafc; }
.batch-history-check input { width: 16px; height: 16px; cursor: pointer; accent-color: #c9a84c; }
.batch-history-from, .batch-history-to { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: #ffffff; padding: 2px 6px; border: 1px solid #e2e8f0; border-radius: 4px; font-family: monospace; }

/* Loading overlay */
.loading-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.65); z-index: 2000;
  display: none; align-items: center; justify-content: center; }
.loading-overlay.visible { display: flex; }
.loading-box { background: rgba(255,255,255,0.97); border-radius: 16px; padding: 36px 48px; text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2); min-width: 320px; }
.loading-box h3 { margin: 0 0 20px 0; font-size: 16px; color: #1e293b; }
.loading-steps { text-align: left; }
.loading-step { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 14px; color: #94a3b8; transition: color 0.2s; }
.loading-step.active { color: #1e293b; font-weight: 600; }
.loading-step.done { color: #10b981; }
.loading-step-icon { width: 20px; text-align: center; flex-shrink: 0; }
.loading-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #e2e8f0; border-top-color: #c9a84c;
  border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* History panel overlay */
.history-backdrop { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15,23,42,0.5); z-index: 999; opacity: 0; transition: opacity 0.25s ease; }
.history-backdrop.visible { opacity: 1; }
.history-panel { position: fixed; top: 0; right: 0; width: 520px; max-width: 90vw; height: 100vh;
  background: #fff;
  box-shadow: -4px 0 32px rgba(0,0,0,0.4); z-index: 1000; overflow-y: auto; padding: 24px;
  transform: translate3d(100%, 0, 0); will-change: transform;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
.history-panel.visible { transform: translate3d(0, 0, 0); }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
  padding-bottom: 12px; border-bottom: 2px solid #e2e8f0; }
.history-header h2 { border: none; margin: 0; padding: 0; font-size: 18px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-empty { text-align: center; padding: 40px 0; color: #94a3b8; font-size: 14px; }
.history-item { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px;
  border: 1px solid #e2e8f0; border-radius: 10px; transition: all 0.2s; cursor: pointer; }
.history-item:hover { background: #f8fafc; border-color: #c9a84c; box-shadow: 0 2px 12px rgba(201,168,76,0.1); }
.history-item-name { font-size: 14px; font-weight: 600; color: #1e293b; line-height: 1.5; word-break: break-word; }
.history-item-row { display: flex; align-items: center; gap: 12px; }
.history-item-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.history-item-meta { font-size: 12px; color: #64748b; white-space: nowrap; }
.history-item-time { font-size: 11px; color: #94a3b8; white-space: nowrap; }
.history-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.batch-history-arrow { color: #64748b; font-weight: bold; flex-shrink: 0; }
.batch-history-btns { display: flex; gap: 4px; margin-left: auto; flex-shrink: 0; }
.batch-history-edit-form { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: #f8fafc; border-radius: 6px; margin-top: 4px; }
.batch-history-edit-form input { width: 80px; padding: 3px 6px; font-size: 13px; border: 1px solid #e2e8f0; border-radius: 4px; background: #ffffff; font-family: monospace; }
.batch-history-edit-form span { color: #64748b; font-weight: bold; }
.batch-select-all { font-size: 13px; font-weight: 600; color: #64748b; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.history-header-actions { display: flex; gap: 8px; align-items: center; }
.history-check { width: 16px; height: 16px; cursor: pointer; accent-color: #c9a84c; flex-shrink: 0; }

/* History date groups */
.history-date-group { margin-bottom: 12px; }
.history-date-header { display: flex; align-items: center; gap: 6px; padding: 6px 0; cursor: pointer; user-select: none; font-size: 13px; color: #475569; }
.history-date-header:hover { color: #1e293b; }
.history-date-arrow { display: inline-block; width: 16px; color: #64748b; font-size: 11px; }
.history-date-label { font-weight: 600; }
.history-date-count { color: #94a3b8; font-size: 12px; }
.history-date-body { display: flex; flex-direction: column; gap: 8px; }
.history-date-body.hidden { display: none; }

/* History config detail (expandable) */
.history-config-toggle { display: inline-block; width: 18px; color: #64748b; cursor: pointer; font-size: 14px; user-select: none; transition: color 0.15s; }
.history-config-toggle:hover { color: #c9a84c; }
.history-config-body { margin-top: 8px; padding: 12px; background: #f8fafc; border-radius: 8px; border: 1px solid #e8ecf1; }
.history-config-body.hidden { display: none; }
.history-config-section { margin-bottom: 8px; }
.history-config-section:last-child { margin-bottom: 0; }
.history-config-section-title { font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 4px; padding-bottom: 4px; border-bottom: 1px solid #e2e8f0; }
.hist-config-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.hist-config-table td { padding: 2px 8px 2px 0; vertical-align: top; }
.hist-config-key { color: #64748b; white-space: nowrap; width: 1%; font-weight: 500; }
.hist-config-bool { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.hist-config-bool.bool-true { background: #d1fae5; color: #065f46; }
.hist-config-bool.bool-false { background: #f1f5f9; color: #64748b; }
.hist-config-empty { color: #94a3b8; }
.hist-config-prompt { margin-top: 6px; }
.hist-config-prompt pre { margin: 4px 0 0 0; padding: 6px 8px; background: #fff; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 11px; white-space: pre-wrap; word-break: break-word; max-height: 120px; overflow-y: auto; color: #334155; }
.batch-select-all input { width: 16px; height: 16px; cursor: pointer; accent-color: #c9a84c; }
.batch-progress-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.55); z-index: 2000;
  display: flex; align-items: center; justify-content: center; }
.batch-progress-overlay.hidden { display: none; }
.batch-progress-box { background: rgba(255,255,255,0.97); border-radius: 16px; padding: 32px 40px; text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2); min-width: 360px; }
.batch-progress-box h3 { margin: 0 0 16px 0; font-size: 16px; color: #1e293b; }
.batch-progress-box .progress-text { margin-top: 8px; font-size: 13px; color: #64748b; }

/* ---- Batch Preview Modal ---- */
.batch-preview-modal { position: fixed; inset: 0; z-index: 2100; display: flex; align-items: center; justify-content: center; }
.batch-preview-modal.hidden { display: none; }
.batch-preview-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.batch-preview-content {
  position: relative; z-index: 1;
  width: min(92vw, 900px); max-height: 85vh;
  background: #1e293b; border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; overflow: hidden;
}
.batch-preview-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.batch-preview-header h3 { color: #f1f5f9; font-size: 16px; margin: 0; }
.batch-preview-close {
  background: none; border: none; color: #94a3b8; font-size: 24px; cursor: pointer;
  padding: 4px 8px; line-height: 1; border-radius: 4px;
}
.batch-preview-close:hover { color: #f1f5f9; background: rgba(255,255,255,0.08); }
.batch-preview-summary {
  padding: 10px 20px; color: #cbd5e1; font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.batch-preview-controls {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 20px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.batch-preview-count { color: #94a3b8; font-size: 13px; margin-left: auto; }
.batch-preview-list { flex: 1; overflow-y: auto; padding: 8px 20px; min-height: 120px; }
.batch-preview-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.batch-preview-item:last-child { border-bottom: none; }
.batch-preview-check { flex-shrink: 0; padding-top: 2px; }
.batch-preview-check input { width: 16px; height: 16px; cursor: pointer; accent-color: #c9a84c; }
.batch-preview-label {
  color: #94a3b8; font-size: 12px; font-family: monospace;
  flex-shrink: 0; min-width: 52px; padding-top: 2px;
}
.batch-preview-text { flex: 1; min-width: 0; }
.batch-preview-before, .batch-preview-after {
  font-size: 13px; line-height: 1.5; word-break: break-all;
  font-family: monospace; color: #e2e8f0;
}
.batch-preview-arrow { color: #475569; font-size: 11px; margin: 1px 0; }
.batch-preview-del {
  background: rgba(239,68,68,0.15); color: #fca5a5;
  text-decoration: line-through; border-radius: 2px; padding: 0 1px;
}
.batch-preview-ins {
  background: rgba(16,185,129,0.15); color: #6ee7b7;
  text-decoration: underline; border-radius: 2px; padding: 0 1px;
}
.batch-preview-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px; border-top: 1px solid rgba(255,255,255,0.08);
}

/* ---- Content-sparse page decorations ---- */

/* Centered content wrapper for sparse panels */
.panel-center {
  display: flex; flex-direction: column; align-items: center;
  max-width: 640px; margin: 0 auto; text-align: center;
}
.panel-center h2 { text-align: center; width: 100%; }

/* Decorative icon above headings */
.panel-icon {
  font-size: 48px; margin-bottom: 8px;
  filter: drop-shadow(0 2px 8px rgba(201,168,76,0.25));
}

/* Subtle decorative line below sparse content */
.panel-divider {
  width: 60px; height: 3px; border-radius: 2px; margin: 20px auto;
  background: linear-gradient(90deg, #c9a84c, #e0c97f);
}

/* Download buttons area */
.download-area {
  text-align: center; padding: 32px 0 16px;
}
.download-area p { font-size: 16px; color: #475569; margin-bottom: 24px; }
.download-area .btn-row { justify-content: center; }

/* Progress page enhancements */
.progress-page-content {
  max-width: 520px; margin: 0 auto; text-align: center;
}
.progress-page-content h2 { text-align: center; }
.progress-page-content .btn-row { justify-content: center; }
.progress-page-content .progress-container { margin-top: 20px; }
.progress-page-content .progress-bar-outer { height: 28px; }

/* Completed animation */
@keyframes checkPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.completed-icon {
  font-size: 64px; display: inline-block; animation: checkPulse 2s ease-in-out infinite;
}

/* ---- Config Modal ---- */
.config-modal { position: fixed; inset: 0; z-index: 200; display: flex !important; align-items: center; justify-content: center; visibility: hidden; opacity: 0; pointer-events: none; }
.config-modal:not(.hidden) { visibility: visible; opacity: 1; pointer-events: auto; }
.config-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.config-modal-content {
  position: relative; z-index: 1;
  width: min(92vw, 1080px); height: 82vh;
  background: #ffffff; border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; overflow: hidden;
}
.config-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #e2e8f0;
}
.config-modal-header h3 { color: #1e293b; font-size: 16px; margin: 0; }
.config-modal-close {
  background: none; border: none; color: #94a3b8; font-size: 24px; cursor: pointer;
  padding: 4px 8px; line-height: 1; border-radius: 4px;
}
.config-modal-close:hover { color: #1e293b; background: rgba(0,0,0,0.06); }
.config-modal-body {
  padding: 16px 20px; flex: 1; display: flex; flex-direction: column; min-height: 0;
}

/* ---- Log Modal ---- */
.log-modal { position: fixed; inset: 0; z-index: 200; display: flex !important; align-items: center; justify-content: center; visibility: hidden; opacity: 0; pointer-events: none; }
.log-modal:not(.hidden) { visibility: visible; opacity: 1; pointer-events: auto; }
.log-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.log-modal-content {
  position: relative; z-index: 1;
  width: min(90vw, 800px); max-height: 85vh;
  background: #1e293b; border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; overflow: hidden;
}
.log-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.log-modal-header h3 { color: #f1f5f9; font-size: 16px; margin: 0; }
.log-modal-close {
  background: none; border: none; color: #94a3b8; font-size: 24px; cursor: pointer;
  padding: 4px 8px; line-height: 1; border-radius: 4px;
}
.log-modal-close:hover { color: #f1f5f9; background: rgba(255,255,255,0.08); }
.log-modal-body {
  padding: 16px 20px; overflow-y: auto; flex: 1;
  color: #cbd5e1; font-size: 13px; line-height: 1.6;
}
.log-section { margin-bottom: 16px; }
.log-section-title {
  font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
  color: #94a3b8; margin-bottom: 6px;
  padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.log-pre {
  background: #0f172a; border: 1px solid rgba(255,255,255,0.06); border-radius: 8px;
  padding: 12px 14px; white-space: pre-wrap; word-break: break-all;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace; font-size: 12px;
  color: #e2e8f0; max-height: 300px; overflow-y: auto; line-height: 1.5;
}
.log-pre-small { max-height: 120px; font-size: 11px; padding: 8px 10px; }
.log-section-toggle {
  cursor: pointer; padding: 8px 0; color: #94a3b8; font-weight: 600; font-size: 13px;
  user-select: none; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.log-section-toggle:hover { color: #f1f5f9; }
.log-toggle-arrow { font-size: 10px; margin-right: 4px; }
.log-section-collapsible { margin-top: 4px; margin-bottom: 12px; }
.log-meta-table { width: 100%; border-collapse: collapse; }
.log-meta-table td { padding: 4px 8px; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 12px; }
.log-meta-key { color: #94a3b8; width: 100px; white-space: nowrap; }
.log-context-label { font-size: 11px; color: #64748b; margin-bottom: 4px; font-weight: 600; }

/* Log revision selector */
.log-revision-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.log-revision-label { color: #94a3b8; font-size: 12px; font-weight: 600; white-space: nowrap; }
.log-revision-select {
  flex: 1; background: #0f172a; color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
  padding: 6px 10px; font-size: 12px; font-family: inherit;
  cursor: pointer; outline: none;
}
.log-revision-select:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,0.2); }
.log-revision-select option { background: #1e293b; color: #e2e8f0; }

/* Log tabs (首次校对 / 二次校对) */
.log-tab-bar {
  display: flex; gap: 0; border-bottom: 1px solid #334155; margin-bottom: 16px;
}
.log-tab {
  flex: 1; padding: 10px 16px; border: none; background: transparent;
  color: #94a3b8; font-size: 13px; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; transition: all 0.15s;
}
.log-tab:hover { color: #e2e8f0; background: rgba(255,255,255,0.03); }
.log-tab.active { color: #c9a84c; border-bottom-color: #c9a84c; }

.log-tab-panel { }
.log-tab-panel.hidden { display: none; }

.log-pre-highlight {
  border-left: 3px solid #c9a84c; padding-left: 12px;
  background: rgba(201,168,76,0.06); color: #e2e8f0;
}

/* Per-pass stats bar */
.log-pass-stats {
  display: flex; flex-wrap: wrap; gap: 12px; padding: 8px 12px;
  background: rgba(201,168,76,0.08); border-radius: 6px; margin-bottom: 12px;
  font-size: 12px; color: #cbd5e1;
}
.log-pass-stats strong { color: #c9a84c; }

/* Version picker dropdown */
.version-picker-dropdown {
  position: fixed; z-index: 10000;
  background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
  min-width: 200px; max-width: 320px; max-height: 300px; overflow-y: auto;
  font-size: 13px; padding: 4px 0;
}
.version-picker-header {
  padding: 8px 12px; font-weight: 600; color: #475569;
  border-bottom: 1px solid #e2e8f0; font-size: 12px;
}
.version-picker-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 12px; cursor: pointer; color: #334155;
  transition: background 0.1s;
}
.version-picker-item:hover { background: #f1f5f9; }
.version-picker-label { font-weight: 500; }
.version-picker-time { font-size: 11px; color: #94a3b8; white-space: nowrap; margin-left: 12px; }

/* Log cost summary bar */
.log-summary-table {
  width: 100%; margin-bottom: 16px; border-collapse: collapse;
  font-size: 12px; color: #cbd5e1;
  border: 1px solid rgba(255,255,255,0.06); border-radius: 8px; overflow: hidden;
}
.log-summary-table thead th {
  padding: 6px 10px; text-align: right; font-weight: 600;
  color: #94a3b8; background: rgba(30,41,59,0.8); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.log-summary-table thead th:first-child { text-align: left; }
.log-summary-table tbody td {
  padding: 6px 10px; text-align: right;
  background: rgba(30,41,59,0.4); font-variant-numeric: tabular-nums;
}
.log-summary-table tbody td:first-child {
  text-align: left; font-weight: 600; color: #94a3b8;
}
.log-summary-table tbody tr + tr td { border-top: 1px solid rgba(255,255,255,0.04); }
.log-summary-total td {
  background: rgba(201,168,76,0.08) !important;
  color: #c9a84c; font-weight: 700;
}
.log-summary-total td:first-child { color: #c9a84c; }

/* Highlight row for total cost */
.log-meta-total {
  font-weight: 700;
  color: #38bdf8;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 6px;
  margin-top: 4px;
}

/* ---- Term Editing Panel ---- */
.step4-tabs { display: flex; gap: 0; margin-bottom: 12px; border-bottom: 2px solid #e2e8f0; }
.step4-tab { padding: 8px 20px; border: none; background: none; cursor: pointer; font-size: 14px; font-weight: 600; color: #94a3b8; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color 0.15s, border-color 0.15s; }
.step4-tab:hover { color: #64748b; }
.step4-tab.active { color: #1e293b; border-bottom-color: #c9a84c; }
.step4-tab-content { display: none; }
.step4-tab-content.active { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.terms-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.terms-count { font-size: 12px; color: #94a3b8; }
.terms-table-wrap { max-height: 70vh; overflow-y: auto; }
.terms-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.terms-table th { text-align: left; padding: 6px 8px; border-bottom: 1px solid #e2e8f0; color: #64748b; font-weight: 600; font-size: 12px; }
.terms-table td { padding: 4px 6px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.terms-table tr:hover td { background: #f8fafc; }
.terms-table input { width: 100%; padding: 4px 8px; font-size: 13px; border: 1px solid #e2e8f0; border-radius: 4px; background: #fff; }
.terms-table input:focus { border-color: #c9a84c; outline: none; box-shadow: 0 0 0 2px rgba(201,168,76,0.12); }
.btn-term-del { background: none; border: none; color: #ef4444; cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 4px; }
.btn-term-del:hover { background: #fef2f2; }
.terms-empty { font-size: 12px; color: #94a3b8; text-align: center; padding: 16px 0; }
.term-logs-section { margin-top: 20px; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.term-logs-header { padding: 10px 14px; background: #f8fafc; cursor: pointer; font-weight: 600; font-size: 13px; user-select: none; display: flex; justify-content: space-between; align-items: center; color: #475569; transition: background 0.15s; }
.term-logs-header:hover { background: #f1f5f9; }
.term-logs-body { padding: 14px; border-top: 1px solid #e2e8f0; max-height: 60vh; overflow-y: auto; }
.term-log-item { border: 1px solid #e2e8f0; border-radius: 6px; margin-bottom: 10px; overflow: hidden; }
.term-log-item:last-child { margin-bottom: 0; }
.term-log-item-header { padding: 8px 12px; background: #f8fafc; cursor: pointer; font-size: 12px; color: #64748b; display: flex; justify-content: space-between; align-items: center; user-select: none; }
.term-log-item-header:hover { background: #f1f5f9; }
.term-log-item-body { padding: 12px; display: none; }
.term-log-item-body.open { display: block; }
.term-log-label { font-size: 11px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; margin-top: 10px; }
.term-log-label:first-child { margin-top: 0; }
.term-log-pre { background: #1e293b; color: #e2e8f0; padding: 10px 12px; border-radius: 6px; font-size: 12px; font-family: 'Menlo', 'Consolas', monospace; white-space: pre-wrap; word-break: break-word; max-height: 300px; overflow-y: auto; margin: 0; line-height: 1.5; }
.term-logs-empty { font-size: 12px; color: #94a3b8; text-align: center; padding: 16px 0; }

/* ── Consistency registry editing ──────────────────────────────────── */

#step4-tab-consistency.active {
  display: flex; flex-direction: column; flex: 1; min-height: 0;
}
.consistency-type-tabs { display: flex; gap: 0; margin-bottom: 8px; border-bottom: 1px solid #e2e8f0; flex-shrink: 0; }
.consistency-type-tab { padding: 6px 16px; border: none; background: none; cursor: pointer; font-size: 13px; font-weight: 600; color: #94a3b8; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.15s, border-color 0.15s; }
.consistency-type-tab:hover { color: #64748b; }
.consistency-type-tab.active { color: #1e293b; border-bottom-color: #c9a84c; }
.consistency-type-content { display: none; }
.consistency-type-content.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.consistency-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-shrink: 0; }
.consistency-count { font-size: 12px; color: #94a3b8; margin-left: 4px; }
.consistency-table-wrap { flex: 1; min-height: 0; overflow-y: auto; }
.consistency-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.consistency-table th { text-align: left; padding: 6px 8px; border-bottom: 1px solid #e2e8f0; color: #64748b; font-weight: 600; font-size: 12px; position: sticky; top: 0; background: #fff; z-index: 1; }
.consistency-table th:first-child { width: 30px; text-align: center; }
.consistency-table td { padding: 4px 6px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.consistency-table td:first-child { text-align: center; }
.consistency-table tr:hover td { background: #f8fafc; }
.consistency-table input { width: 100%; padding: 4px 8px; font-size: 13px; border: 1px solid #e2e8f0; border-radius: 4px; background: #fff; }
.consistency-table input:focus { border-color: #c9a84c; outline: none; box-shadow: 0 0 0 2px rgba(201,168,76,0.12); }

.cons-input { font-size: 13px; }

.cons-status-badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.cons-status-badge.confirmed { background: #dcfce7; color: #16a34a; }
.cons-status-badge.pending { background: #fef3c7; color: #d97706; }
.cons-status-badge.rejected { background: #f1f5f9; color: #94a3b8; }

.cons-source-badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 3px; background: #f1f5f9; color: #64748b; }

.consistency-empty { font-size: 12px; color: #94a3b8; text-align: center; padding: 16px 0; }

.consistency-toolbar-spacer { flex: 1; }

.cons-input { font-size: 13px; }

.cons-status-select { font-size: 12px; padding: 2px 4px; border: 1px solid #e2e8f0; border-radius: 4px; background: #fff; cursor: pointer; }
.cons-status-select:focus { border-color: #c9a84c; outline: none; }

.cons-source-badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 3px; background: #f1f5f9; color: #64748b; }

.consistency-empty { font-size: 12px; color: #94a3b8; text-align: center; padding: 16px 0; }

/* ── App Layout (sidebar + main) ─────────────────────────────────────── */

:root {
  --sidebar-width: 260px;
}

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
  overflow: hidden;
}

.app-layout.sidebar-collapsed {
  --sidebar-width: 0px;
}

/* ── Document Sidebar ────────────────────────────────────────────────── */

.doc-sidebar {
  background: #1e293b;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2;
  min-width: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 10px;
  flex-shrink: 0;
}

/* ── Sidebar action buttons ────────────────────────────────────────── */

.btn-sidebar-action {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(241,245,249,0.4);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 7px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.15s;
}

.btn-sidebar-action:hover {
  background: rgba(255,255,255,0.12);
  color: rgba(241,245,249,0.7);
}

/* ── Sidebar right-edge controls ────────────────────────────────────── */

.sidebar-edge {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Toggle button — click to collapse/expand */
.sidebar-toggle-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 44px;
  border: 1px solid rgba(255,255,255,0.08);
  border-right: none;
  border-radius: 4px 0 0 4px;
  background: rgba(30,41,59,0.9);
  color: rgba(241,245,249,0.4);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  z-index: 2;
}

.sidebar-toggle-btn:hover {
  background: rgba(201,168,76,0.2);
  color: #e0c97f;
  border-color: rgba(201,168,76,0.3);
}

/* Resize grip — drag to change width */
.sidebar-resize-grip {
  flex: 1;
  width: 6px;
  cursor: col-resize;
  margin: 4px 0;
  border-radius: 3px;
  background: transparent;
  transition: background 0.15s;
}

.sidebar-resize-grip:hover,
.sidebar-resize-grip.dragging {
  background: rgba(255,255,255,0.08);
}

/* Collapsed state */
.sidebar-collapsed .sidebar-edge {
  position: fixed;
  left: 0;
  right: auto;
  width: auto;
}

.sidebar-collapsed .sidebar-toggle-btn {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 0 5px 5px 0;
  border: 1px solid rgba(255,255,255,0.1);
  border-left: none;
  width: 24px;
  height: 48px;
  background: rgba(30,41,59,0.9);
}

.sidebar-collapsed .sidebar-toggle-btn:hover {
  background: rgba(59,130,246,0.2);
  border-color: rgba(59,130,246,0.3);
  color: #60a5fa;
}

.sidebar-collapsed .sidebar-resize-grip {
  display: none;
}

.sidebar-header h2 {
  color: #f1f5f9;
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  padding: 0;
  border: none;
}

.sidebar-filters {
  display: flex;
  gap: 0;
  padding: 0 14px 10px;
  flex-shrink: 0;
}

.sidebar-filter {
  flex: 1;
  padding: 6px 0;
  border: none;
  background: rgba(241,245,249,0.06);
  color: rgba(241,245,249,0.5);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s;
}

.sidebar-filter:first-child {
  border-radius: 6px 0 0 6px;
}

.sidebar-filter:last-child {
  border-radius: 0 6px 6px 0;
}

.sidebar-filter:hover {
  color: rgba(241,245,249,0.8);
  background: rgba(241,245,249,0.1);
}

.sidebar-filter.active {
  background: rgba(201,168,76,0.2);
  color: #e0c97f;
}

/* ── Sidebar search ─────────────────────────────────────────────────── */

.sidebar-search {
  position: relative;
  padding: 0 14px 8px;
  flex-shrink: 0;
}

.sidebar-search input {
  width: 100%;
  padding: 7px 28px 7px 10px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  font-size: 12px;
  background: rgba(255,255,255,0.06);
  color: #e2e8f0;
  transition: all 0.2s;
  outline: none;
}

.sidebar-search input::placeholder {
  color: rgba(241,245,249,0.3);
}

.sidebar-search input:focus {
  border-color: rgba(201,168,76,0.3);
  background: rgba(255,255,255,0.1);
  box-shadow: 0 0 0 2px rgba(201,168,76,0.1);
}

.sidebar-search-clear {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(241,245,249,0.35);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.sidebar-search-clear:hover {
  color: rgba(241,245,249,0.7);
}

.sidebar-search-clear.hidden {
  display: none;
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 12px;
}

.sidebar-date-group {
  margin-bottom: 2px;
}

.sidebar-date-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 6px;
  cursor: pointer;
  user-select: none;
  border-radius: 4px;
  transition: background 0.15s;
}

.sidebar-date-header:hover {
  background: rgba(255,255,255,0.04);
}

.sidebar-date-arrow {
  font-size: 10px;
  color: rgba(241,245,249,0.3);
  width: 12px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-date-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(241,245,249,0.5);
}

.sidebar-date-count {
  font-size: 10px;
  color: rgba(241,245,249,0.25);
  margin-left: auto;
}

.sidebar-date-body {
  padding: 0;
}

.sidebar-date-body.hidden {
  display: none;
}

.sidebar-empty {
  color: rgba(241,245,249,0.3);
  font-size: 13px;
  text-align: center;
  padding: 32px 14px;
}

/* ── Document Card ────────────────────────────────────────────────────── */

.doc-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  transition: all 0.2s;
}

.doc-card:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
}

.doc-card.active {
  background: rgba(201,168,76,0.1);
  border-color: rgba(201,168,76,0.3);
}

.doc-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.doc-type-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.6;
}

.doc-type-badge.pdf {
  background: rgba(239,68,68,0.15);
  color: #f87171;
}

.doc-type-badge.docx {
  background: rgba(59,130,246,0.15);
  color: #60a5fa;
}

.doc-card-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}

.doc-config-toggle {
  font-size: 9px;
  color: rgba(241,245,249,0.25);
  cursor: pointer;
  flex-shrink: 0;
  width: 10px;
  text-align: center;
  user-select: none;
  transition: color 0.15s;
}

.doc-config-toggle:hover {
  color: rgba(241,245,249,0.6);
}

.doc-card-name {
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-card-meta {
  font-size: 11px;
  color: rgba(241,245,249,0.4);
  display: flex;
  gap: 8px;
  margin-bottom: 2px;
}

.doc-card-time {
  font-size: 10px;
  color: rgba(241,245,249,0.25);
}

/* ── Config details inside doc card ─────────────────────────────────── */

.doc-config-body {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.doc-config-body.hidden {
  display: none;
}

.doc-config-section {
  margin-bottom: 6px;
}

.doc-config-section:last-child {
  margin-bottom: 0;
}

.doc-config-section-title {
  font-size: 10px;
  font-weight: 600;
  color: rgba(241,245,249,0.35);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.doc-config-table {
  width: 100%;
  font-size: 10px;
  border-collapse: collapse;
  margin-bottom: 4px;
}

.doc-config-table td {
  padding: 1px 4px 1px 0;
  vertical-align: top;
  color: rgba(241,245,249,0.45);
  word-break: break-all;
}

.doc-config-key {
  width: 70px;
  color: rgba(241,245,249,0.3) !important;
  white-space: nowrap;
  padding-right: 6px;
}

.doc-config-empty {
  color: rgba(241,245,249,0.15);
}

.doc-config-bool {
  padding: 0 4px;
  border-radius: 2px;
  font-weight: 600;
}

.doc-config-bool.bool-true {
  color: #4ade80;
}

.doc-config-bool.bool-false {
  color: rgba(241,245,249,0.3);
}

.doc-config-prompt {
  background: rgba(255,255,255,0.03);
  color: rgba(241,245,249,0.4);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-family: 'Menlo', 'Consolas', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
  margin: 0;
  line-height: 1.4;
}

.doc-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.doc-card-actions .btn {
  font-size: 10px;
  padding: 2px 8px;
}

.doc-status-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.6;
}

.badge-uploaded,
.badge-parsing,
.badge-parsed {
  background: rgba(251,191,36,0.15);
  color: #fbbf24;
}

.badge-proofreading {
  background: rgba(59,130,246,0.15);
  color: #60a5fa;
}

.badge-rendering {
  background: rgba(168,85,247,0.15);
  color: #c084fc;
}

.badge-proofread_done {
  background: rgba(34,197,94,0.15);
  color: #4ade80;
}

.badge-completed {
  background: rgba(34,197,94,0.2);
  color: #4ade80;
}

.badge-error {
  background: rgba(239,68,68,0.15);
  color: #f87171;
}

.badge-cancelled {
  background: rgba(148,163,184,0.15);
  color: #94a3b8;
}

/* ── Main Content ────────────────────────────────────────────────────── */

.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
  padding: 18px 28px 0;
}

/* ── Welcome State ───────────────────────────────────────────────────── */

.welcome-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  color: #f1f5f9;
}

.welcome-state.hidden {
  display: none;
}

.welcome-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.welcome-state h2 {
  font-size: 24px;
  margin-bottom: 8px;
  padding: 0;
  border: none;
  color: #f1f5f9;
}

.welcome-state p {
  color: rgba(241,245,249,0.5);
  font-size: 15px;
  margin-bottom: 24px;
}

/* ── Workspace Container ─────────────────────────────────────────────── */

.workspace-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 10px 0 0;
  position: relative;
}

.workspace-container.hidden {
  display: none;
}

/* ── Rule Matches Panel (Step 5) ───────────────────────────────────── */

.rule-matches-panel {
  flex: 0 0 280px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  transition: flex 0.2s ease, min-width 0.2s ease;
}
.rule-matches-panel.collapsed {
  flex: 0 0 22px;
  min-width: 22px;
  border-radius: 10px;
  cursor: pointer;
}
.rule-matches-panel.collapsed:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.rule-matches-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #f1f5f9;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.rule-matches-panel.collapsed .rule-matches-header {
  writing-mode: vertical-rl;
  padding: 6px 3px;
  font-size: 11px;
  justify-content: center;
  background: transparent;
  height: 100%;
  letter-spacing: 2px;
}

.rule-matches-toggle {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: #64748b;
  padding: 0 4px;
  transition: transform 0.2s;
}
.rule-matches-panel.collapsed .rule-matches-toggle,
.rule-matches-panel.collapsed #rule-matches-count {
  display: none;
}

.rule-matches-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.rule-matches-panel.collapsed .rule-matches-body {
  display: none;
}
.rule-matches-panel.collapsed .rule-matches-nav {
  display: none;
}

/* Rule-match highlights in the backdrop */
mark.rule-match-highlight {
  border-radius: 2px;
  padding: 0 1px;
  color: transparent;
}
mark.rule-match-highlight.preferred_word {
  background: rgba(59, 130, 246, 0.35);
}
mark.rule-match-highlight.user_rule {
  background: rgba(20, 184, 166, 0.40);
}

/* Edit-memory fragment highlight in the edit table */
mark.em-highlight {
  background: rgba(250, 204, 21, 0.55);
  border-radius: 2px;
  padding: 0 1px;
}

.rule-matches-empty {
  text-align: center;
  padding: 20px 0;
  color: #94a3b8;
  font-size: 13px;
}

.rule-matches-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rule-match-group {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #ffffff;
  overflow: hidden;
}

.rule-match-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  background: #ffffff;
  user-select: none;
}
.rule-match-group-header:hover {
  background: #f8fafc;
}
.rule-match-group.highlighted {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px #3b82f6;
}

.rule-match-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}
.rule-match-badge.preferred_word {
  background: #dbeafe;
  color: #1d4ed8;
}
.rule-match-badge.user_rule {
  background: #ccfbf1;
  color: #0f766e;
}

.rule-match-source {
  color: #475569;
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rule-match-arrow {
  color: #94a3b8;
  flex-shrink: 0;
}
.rule-match-target {
  color: #059669;
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rule-match-count {
  color: #94a3b8;
  font-size: 11px;
  flex-shrink: 0;
}

.rule-match-entries {
  display: none;
  flex-wrap: wrap;
  gap: 3px;
  padding: 4px 10px 6px 10px;
  border-top: 1px solid #f1f5f9;
}
.rule-match-group.expanded .rule-match-entries {
  display: flex;
}

.rule-match-entry-btn {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-size: 11px;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}
.rule-match-entry-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
}
.rule-match-entry-btn.active {
  background: #c9a84c;
  color: #fff;
  border-color: #b8960f;
}

.rule-matches-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  color: #64748b;
  flex-shrink: 0;
}
.rule-matches-nav.hidden {
  display: none;
}

/* ── Rule Tooltip ──────────────────────────────────────────────────── */

.rule-tooltip {
  position: fixed;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  background: #1e293b;
  color: #f1f5f9;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  pointer-events: none;
}
.rule-tooltip.hidden {
  display: none;
}
.rule-tooltip-badges {
  display: flex;
  gap: 4px;
}
.rule-tooltip-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rule-tooltip-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}
.rule-tooltip-badge.preferred_word {
  background: #3b82f6;
  color: #fff;
}
.rule-tooltip-badge.user_rule {
  background: #14b8a6;
  color: #fff;
}
.rule-tooltip-source {
  color: #fca5a5;
  font-weight: 500;
}
.rule-tooltip-arrow {
  color: #94a3b8;
  flex-shrink: 0;
}
.rule-tooltip-target {
  color: #6ee7b7;
  font-weight: 500;
}
.rule-tooltip-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Edit Memory Panel ─────────────────────────────────── */
/* Reuses .rule-matches-panel base layout */

/* Edit-memory section headers (grouped by type) */
.em-section {
  border-bottom: 1px solid #e2e8f0;
}
.em-section:last-child {
  border-bottom: none;
}
.em-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: #f1f5f9;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  position: sticky;
  top: 0;
  z-index: 1;
}
.em-section-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
}
.em-section-label {
  flex: 1;
}
.em-section-count {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 400;
}

.em-group {
  border-bottom: 1px solid #e2e8f0;
}
.em-group:last-child {
  border-bottom: none;
}
.em-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  cursor: pointer;
  flex-wrap: wrap;
}
.em-group-header:hover {
  background: #f1f5f9;
}
.em-group-header .em-toggle {
  margin-left: auto;
  font-size: 10px;
  color: #94a3b8;
  transition: transform 0.15s;
}
.em-group.expanded .em-group-header .em-toggle {
  transform: rotate(180deg);
}
.em-type-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.em-type-proper_noun_intro { background: #dbeafe; color: #1e40af; }
.em-type-proper_noun_abbr { background: #e0e7ff; color: #3730a3; }
.em-type-term, .em-type-term_sub { background: #dcfce7; color: #166534; }
.em-type-knowledge { background: #fef3c7; color: #92400e; }

.em-text {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.em-orig {
  color: #dc2626;
  text-decoration: line-through;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.em-arrow {
  color: #94a3b8;
  flex-shrink: 0;
}
.em-proof {
  color: #16a34a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.em-meta {
  font-size: 10px;
  color: #64748b;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 3px;
}
.em-meta-badge {
  font-size: 10px;
  color: #475569;
  background: #e2e8f0;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: monospace;
  letter-spacing: 0.5px;
}

.em-group-body {
  display: none;
  padding: 4px 8px 8px 8px;
  font-size: 11px;
}
.em-group.expanded .em-group-body {
  display: block;
}
.em-label {
  color: #94a3b8;
}
.em-source, .em-triggers {
  margin-top: 4px;
  line-height: 1.8;
}
.em-nav-btn {
  font-size: 11px;
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
  border-radius: 3px;
  padding: 1px 6px;
  cursor: pointer;
  margin: 1px;
}
.em-nav-btn:hover {
  background: #e0f2fe;
  color: #0284c7;
}
.em-none {
  color: #94a3b8;
  font-style: italic;
}

/* ── JSON Editor ──────────────────────────────────────────────────── */

.json-editor-wrap { position: relative; }
.json-editor-backdrop {
  position: absolute; top: 0; left: 0; width: 100%;
  padding: 4px 8px; font-family: monospace; font-size: 12px; line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal;
  letter-spacing: normal; font-variant-ligatures: none; font-kerning: none;
  pointer-events: none; color: transparent; z-index: 0;
  border: 1px solid transparent; border-radius: 6px;
  min-height: 28px; box-sizing: border-box;
}
.json-editor-wrap textarea.json-editor-input {
  position: relative; z-index: 1;
  -webkit-appearance: none; appearance: none;
  margin: 0; font-family: monospace; font-size: 12px; font-weight: normal;
  font-style: normal; line-height: 1.4; letter-spacing: normal;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal;
  font-variant-ligatures: none; text-indent: 0; text-transform: none;
  tab-size: 8; padding: 4px 8px; border: 1px solid #e2e8f0; border-radius: 6px;
  box-sizing: border-box; overflow-x: hidden; overflow-y: auto; max-height: 400px;
  background: #ffffff; resize: vertical; min-height: 28px;
}
.json-editor-backdrop:not(:empty) ~ textarea.json-editor-input {
  background: transparent !important;
}
.json-editor-backdrop:not(:empty) ~ textarea.json-editor-input:focus {
  background: transparent !important;
}

/* JSON syntax colors */
.json-key { color: #06b6d4; }
.json-string { color: #22c55e; }
.json-number { color: #3b82f6; }
.json-bool { color: #8b5cf6; font-weight: 500; }
.json-null { color: #8b5cf6; font-style: italic; }

/* Validation states */
.json-editor-wrap textarea.json-editor-input.valid { border-color: #86efac; }
.json-editor-wrap textarea.json-editor-input.invalid { border-color: #fca5a5; }
.json-editor-wrap textarea.json-editor-input.format-error {
  border-color: #ef4444;
  animation: json-shake 0.3s ease;
}

/* Controls — top-right corner overlay */
.json-editor-controls {
  position: absolute; top: 3px; right: 3px; z-index: 2;
  display: flex; align-items: center; gap: 4px;
  opacity: 0.5; transition: opacity 0.15s;
}
.json-editor-wrap:focus-within .json-editor-controls,
.json-editor-controls:hover { opacity: 1; }
.json-format-btn {
  font-size: 10px; padding: 1px 7px;
  border: 1px solid #cbd5e1; border-radius: 3px;
  background: rgba(255,255,255,0.85); color: #475569; cursor: pointer;
  transition: all 0.15s; white-space: nowrap; line-height: 1.4;
  backdrop-filter: blur(4px);
}
.json-format-btn:hover {
  background: #f1f5f9; color: #1e293b; border-color: #94a3b8;
}
.json-valid-indicator { font-size: 11px; white-space: nowrap; }
.json-valid-indicator.valid { color: #22c55e; }
.json-valid-indicator.invalid { color: #ef4444; }
.json-valid-indicator.json-valid-dot {
  display: inline-block; font-weight: 600; vertical-align: middle;
}

@keyframes json-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

#pg-config.pg-hidden { display: none; }

/* ── Auth / User Area ───────────────────────────────────────────────────── */

.auth-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.auth-balance {
  color: #c9a84c;
  font-weight: 600;
  font-size: 0.9rem;
}

.auth-username {
  color: #94a3b8;
  font-size: 0.85rem;
}

/* ── Auth Modal ─────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.auth-modal-box h2 {
  margin: 0 0 20px;
  color: #e2e8f0;
  font-size: 1.3rem;
  text-align: center;
}

.auth-modal-box .form-group {
  margin-bottom: 16px;
}

.auth-modal-box label {
  display: block;
  margin-bottom: 4px;
  color: #94a3b8;
  font-size: 0.85rem;
}

.auth-modal-box .form-input {
  width: 100%;
  padding: 8px 12px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.auth-modal-box .form-input:focus {
  outline: none;
  border-color: #c9a84c;
}

.auth-error {
  color: #f87171;
  font-size: 0.85rem;
  margin-bottom: 12px;
  text-align: center;
}

.auth-error.hidden {
  display: none;
}

.auth-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.auth-switch {
  text-align: center;
  margin-top: 16px;
}

.auth-switch a {
  color: #c9a84c;
  text-decoration: none;
  font-size: 0.85rem;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* ── Admin Panel ────────────────────────────────────────────────────────── */

.admin-panel {
  position: fixed;
  top: 60px;
  right: 0;
  width: 480px;
  max-height: calc(100vh - 60px);
  background: #1e293b;
  border-left: 1px solid #334155;
  border-bottom: 1px solid #334155;
  border-radius: 0 0 0 12px;
  z-index: 5000;
  overflow-y: auto;
  box-shadow: -4px 8px 24px rgba(0, 0, 0, 0.4);
}

.admin-panel.hidden {
  display: none;
}

.admin-tabs {
  display: flex;
  border-bottom: 1px solid #334155;
  position: sticky;
  top: 0;
  background: #1e293b;
}

.admin-tab {
  flex: 1;
  padding: 12px 16px;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
}

.admin-tab:hover {
  color: #e2e8f0;
  background: #263348;
}

.admin-tab.active {
  color: #c9a84c;
  border-bottom: 2px solid #c9a84c;
}

.admin-content {
  padding: 16px;
  min-height: 200px;
}

.admin-content.hidden {
  display: none;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.user-table th {
  text-align: left;
  color: #94a3b8;
  padding: 8px 6px;
  border-bottom: 1px solid #334155;
  font-weight: 500;
}

.user-table td {
  padding: 8px 6px;
  color: #e2e8f0;
  border-bottom: 1px solid #1a2538;
}

.user-table .text-green { color: #4ade80; }
.user-table .text-red { color: #f87171; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.stat-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #c9a84c;
}

.stat-label {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 4px;
}

.btn-xs {
  padding: 2px 8px;
  font-size: 0.75rem;
  border-radius: 4px;
}

/* ── Login Page ────────────────────────────────────────────────────────── */

.login-page {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 40%, #0f172a 100%);
  z-index: 99999;
  color-scheme: dark;
}

.login-page.hidden {
  display: none;
}

.login-card {
  display: block;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 40px 36px 32px;
  width: 100%;
  max-width: 400px;
  flex-shrink: 0;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo img {
  display: block;
  width: 56px;
  height: 56px;
  max-width: 56px;
  max-height: 56px;
  object-fit: contain;
  margin: 0 auto 12px;
}

.login-logo h1 {
  color: #f1f5f9;
  font-size: 1.6rem;
  margin: 0;
  letter-spacing: 1px;
  font-weight: 700;
}

.login-logo p {
  color: #64748b;
  font-size: 0.85rem;
  margin-top: 4px;
}

.login-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #334155;
}

.login-tab {
  flex: 1;
  padding: 10px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.login-tab.active {
  background: rgba(201, 168, 76, 0.12);
  color: #c9a84c;
  font-weight: 600;
}

.login-tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.04);
}

.login-form .form-group {
  margin-bottom: 16px;
}

.login-form label {
  display: block;
  margin-bottom: 4px;
  color: #94a3b8;
  font-size: 0.85rem;
}

.login-form .form-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  padding: 10px 14px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.login-form .form-input:focus {
  outline: none;
  border-color: #c9a84c;
}

.login-submit-btn {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
  margin-top: 4px;
}

/* ---- Debug workbench (校对调试) ---- */
.debug-tabs {
  display: flex; gap: 2px; border-bottom: 2px solid #e2e8f0;
  margin-bottom: 12px; flex-wrap: wrap;
}
.debug-tab {
  padding: 8px 12px; border: none; background: transparent;
  font-size: 13px; font-weight: 600; color: #94a3b8; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  white-space: nowrap; border-radius: 6px 6px 0 0; transition: all 0.2s;
}
.debug-tab:hover { color: #475569; background: rgba(0,0,0,0.03); }
.debug-tab.active { color: #b8960f; border-bottom-color: #c9a84c; background: rgba(201,168,76,0.06); }
.debug-tab-panel { display: none; }
.debug-tab-panel.active { display: block; }

.debug-status-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.debug-status-running { background: #dbeafe; color: #1d4ed8; animation: debugStatusPulse 1.2s ease-in-out infinite; }
.debug-status-completed { background: #d1fae5; color: #065f46; }
.debug-status-failed { background: #fef2f2; color: #991b1b; }
@keyframes debugStatusPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.debug-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.debug-table th {
  text-align: left; padding: 6px 8px; color: #64748b; font-weight: 600;
  border-bottom: 2px solid #e2e8f0; white-space: nowrap;
}
.debug-table td {
  padding: 6px 8px; border-bottom: 1px solid #f1f5f9;
  vertical-align: top; word-break: break-all;
}
.debug-cell-changed { background: #fef9c3; }

.debug-call-card { border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.debug-call-header {
  width: 100%; text-align: left; padding: 8px 12px; border: none; cursor: pointer;
  background: #f8fafc; font-size: 12px; color: #334155; display: flex; flex-wrap: wrap; gap: 4px 14px;
}
.debug-call-header:hover { background: #f1f5f9; }
.debug-call-body { padding: 10px 12px; border-top: 1px solid #e2e8f0; }
.debug-pre {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 10px 12px; white-space: pre-wrap; word-break: break-all;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace; font-size: 12px;
  color: #1e293b; max-height: 300px; overflow-y: auto; line-height: 1.5; margin: 4px 0 10px 0;
}
.debug-block-label {
  display: block; font-size: 11px; font-weight: 600; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.5px; margin: 8px 0 2px 0; cursor: pointer;
}
.debug-tool-block { border: 1px solid #c9a84c; border-radius: 6px; padding: 8px 10px; margin: 8px 0; background: #fffdf5; }
.debug-tool-block.debug-tool-error { border-color: #ef4444; background: #fff5f5; }

.debug-toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #f1f5f9; padding: 10px 20px; border-radius: 8px;
  font-size: 13px; z-index: 400; box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
