/* PDF → Excel com OCR */
.excel-ocr-badge {
  display: inline-block;
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  vertical-align: middle;
}
.excel-pro-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 20px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  vertical-align: middle;
}

.excel-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px 16px;
  align-items: stretch;
  margin: 14px 0 12px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.excel-options .opt-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
}
.excel-options .opt-group .opt-label { margin: 0; white-space: nowrap; font-size: 12px; }
.excel-options .opt-group .text-input { flex: 1; min-width: 0; width: 100%; }
.excel-options .chk { margin: 0; font-size: 12.5px; align-self: center; }

.excel-progress {
  display: block;
  margin-top: 12px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.excel-progress[hidden],
#workspace[hidden],
#preview[hidden],
#result[hidden],
#batchTools[hidden],
#batchLock[hidden],
#batchResult[hidden],
#previewPage[hidden] { display: none !important; }

.excel-preview {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}
.excel-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.excel-preview-stats { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.excel-preview-stats strong { font-size: 13px; }
.excel-preview-stats .text-input { width: auto; max-width: 220px; padding: 5px 8px; font-size: 12px; }
.excel-preview-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.excel-preview-actions .btn { padding: 6px 10px; font-size: 12px; }
.excel-preview-actions .chk { margin: 0; font-size: 11.5px; }

.excel-table-wrap {
  max-height: 480px;
  overflow: auto;
  background: #fff;
}
#excelPreview {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 420px;
  font-size: 12.5px;
  color: #0f172a;
}
#excelPreview th,
#excelPreview td {
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 8px;
  min-width: 70px;
  max-width: 320px;
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #fff;
}
#excelPreview th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eff6ff;
  color: #1e3a8a;
  font-weight: 700;
  border-bottom: 1px solid #bfdbfe;
}
#excelPreview td:focus,
#excelPreview th:focus {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
  background: #eff6ff;
}
#excelPreview td.low-confidence {
  background: #fffbeb;
  box-shadow: inset 0 0 0 1px #fcd34d;
}
#excelPreview td.low-confidence:focus { background: #fef3c7; }
#excelPreview td.selected-cell,
#excelPreview th.selected-cell {
  outline: 2px solid #0f766e;
  outline-offset: -2px;
}
#excelPreview .row-remove,
#excelPreview .col-remove { display: none; }

.excel-batch,
.excel-advanced {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.excel-batch > summary,
.excel-advanced > summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 14px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.excel-batch > summary::-webkit-details-marker,
.excel-advanced > summary::-webkit-details-marker { display: none; }
.excel-batch > summary::before,
.excel-advanced > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 7px;
  color: var(--muted);
  transition: transform .15s ease;
}
.excel-batch[open] > summary::before,
.excel-advanced[open] > summary::before { transform: rotate(90deg); }
.excel-batch-body,
.excel-advanced-body { padding: 12px 14px 14px; }

.excel-batch-list { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.excel-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  font-size: 12.5px;
}
.excel-file-row .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.excel-file-row .meta { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.excel-file-row .remove { padding: 4px 8px; }

.excel-dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  max-width: 420px;
  width: calc(100% - 32px);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .35);
}
.excel-dialog::backdrop { background: rgba(15, 23, 42, .55); }
.excel-dialog form { padding: 20px; }
.excel-dialog h2 { margin: 0 0 8px; font-size: 18px; }
.excel-dialog .text-input { width: 100%; }
.excel-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

[data-theme="dark"] .excel-table-wrap { background: #0f172a; }
[data-theme="dark"] #excelPreview { color: #e2e8f0; }
[data-theme="dark"] #excelPreview th,
[data-theme="dark"] #excelPreview td { background: #1e293b; border-color: #334155; }
[data-theme="dark"] #excelPreview th { background: #172554; color: #bfdbfe; border-bottom-color: #1d4ed8; }
[data-theme="dark"] #excelPreview td:focus,
[data-theme="dark"] #excelPreview th:focus { background: #1e3a8a; }
[data-theme="dark"] #excelPreview td.low-confidence { background: rgba(161, 98, 7, .22); box-shadow: inset 0 0 0 1px #a16207; }
[data-theme="dark"] #excelPreview td.low-confidence:focus { background: rgba(161, 98, 7, .36); }
[data-theme="dark"] .excel-file-row { background: #0f172a; }
[data-theme="dark"] .excel-progress { background: #0f172a; }

@media (max-width: 700px) {
  .excel-options { grid-template-columns: 1fr; align-items: stretch; }
  .excel-options .chk { margin: 2px 0; }
  .excel-preview-actions .btn { flex: 1 1 calc(50% - 7px); }
  .excel-table-wrap { max-height: 60vh; }
  .excel-file-row { align-items: flex-start; flex-direction: column; }
  .excel-file-row .meta { white-space: normal; }
  .excel-dialog-actions .btn { flex: 1; }
  .result { flex-direction: column; align-items: stretch; }
  .result p { flex: none; }
  .result .actions { margin-top: 12px; }
  .result .actions .btn { flex: 1 1 calc(50% - 6px); }
}
