* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 13px; color: #1a1a1a; background: #f0f2f5; }

/* ── Nav ── */
nav { background: #2F5496; color: #fff; padding: 10px 24px; display: flex; align-items: center; gap: 16px; }
nav h1 { font-size: 16px; font-weight: 700; }
nav a { color: rgba(255,255,255,.7); text-decoration: none; font-size: 12px; font-weight: 500; }
nav a:hover { color: #fff; }
nav .spacer { flex: 1; }

/* ── Buttons ── */
.btn { padding: 6px 16px; font-size: 12px; font-weight: 600; border: none; border-radius: 5px; cursor: pointer; transition: background .15s; }
.btn-primary { background: #2F5496; color: #fff; }
.btn-primary:hover { background: #1d3a6f; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: #fff; color: #2F5496; border: 1px solid #2F5496; }
.btn-outline:hover { background: #eef3fc; }

/* ── Dashboard ── */
.page { padding: 24px; max-width: 1400px; margin: 0 auto; }
.page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.page-header h2 { font-size: 18px; color: #2F5496; }
.page-header .spacer { flex: 1; }

.dash-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.dash-table th { background: #f7f8fa; text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 600; color: #555; text-transform: uppercase; letter-spacing: .3px; border-bottom: 2px solid #e5e7eb; }
.dash-table td { padding: 8px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.dash-table tr:hover td { background: #fafbff; }
.dash-table tr.clickable { cursor: pointer; }

.dash-table input[type="text"],
.dash-table select {
  border: 1px solid transparent; background: transparent; padding: 3px 6px; font-size: 12px;
  border-radius: 3px; width: 100%; font-family: inherit; color: #1a1a1a;
}
.dash-table input[type="text"]:hover,
.dash-table select:hover { border-color: #d0d5dd; }
.dash-table input[type="text"]:focus,
.dash-table select:focus { border-color: #2F5496; outline: none; background: #fff; }

/* Status badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; text-transform: uppercase; }
.badge-done { background: #dcfce7; color: #166534; }
.badge-processing { background: #dbeafe; color: #1e40af; }
.badge-queued { background: #f3f4f6; color: #6b7280; }
.badge-error { background: #fee2e2; color: #991b1b; }

/* Review status badges */
.rs-pending { color: #d97706; }
.rs-in-review { color: #2563eb; }
.rs-approved { color: #16a34a; }
.rs-rejected { color: #dc2626; }

/* ── New Ficha Form ── */
.form-card { background: #fff; border-radius: 8px; padding: 32px; max-width: 560px; margin: 40px auto; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.form-card h2 { font-size: 18px; color: #2F5496; margin-bottom: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 11px; font-weight: 600; color: #555; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 4px; }
.form-group input, .form-group select {
  width: 100%; padding: 8px 12px; border: 1px solid #d0d5dd; border-radius: 5px;
  font-size: 13px; font-family: inherit;
}
.form-group input:focus, .form-group select:focus { border-color: #2F5496; outline: none; }
.form-actions { display: flex; gap: 8px; margin-top: 24px; }

/* Upload zone */
.upload-zone {
  border: 2px dashed #d0d5dd; border-radius: 8px; padding: 32px 24px;
  text-align: center; cursor: pointer; transition: border-color .2s, background .2s;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: #2F5496; background: #f0f4fc;
}
.upload-zone .upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-zone p { font-size: 13px; color: #555; margin: 2px 0; }
.upload-zone .upload-hint { font-size: 11px; color: #999; }

.upload-selected {
  display: flex; align-items: center; gap: 10px;
  background: #f0f4fc; border: 1px solid #c4d4ee; border-radius: 6px;
  padding: 10px 14px; font-size: 13px; color: #2F5496; font-weight: 600;
}
.upload-selected #uploadCount { font-weight: 400; color: #666; }
.upload-selected .btn { margin-left: auto; }

/* ── Progress ── */
.progress-card { background: #fff; border-radius: 8px; padding: 32px; max-width: 640px; margin: 40px auto; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.progress-card h2 { font-size: 16px; color: #2F5496; margin-bottom: 16px; }
.progress-bar-outer { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin-bottom: 12px; }
.progress-bar-inner { height: 100%; background: #2F5496; border-radius: 4px; transition: width .3s ease; width: 0%; }
.progress-log { max-height: 320px; overflow-y: auto; font-family: 'SF Mono', 'Menlo', monospace; font-size: 11px; line-height: 1.6; color: #555; padding: 12px; background: #f9fafb; border-radius: 5px; border: 1px solid #e5e7eb; }
.progress-log .line { padding: 1px 0; }
.progress-phase { font-size: 11px; font-weight: 600; color: #2F5496; margin-bottom: 8px; }

/* ── Viewer (extracted from ficha_viewer_1.5.html) ── */
.viewer-layout { display: flex; height: calc(100vh - 42px); }

.viewer-left { flex: 1; overflow-y: auto; background: #fff; display: flex; flex-direction: column; }
.viewer-toolbar { padding: 8px 16px; background: #f7f8fa; border-bottom: 1px solid #ddd; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.viewer-toolbar h3 { font-size: 13px; color: #2F5496; }
.viewer-toolbar .spacer { flex: 1; }
.viewer-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.viewer-body::-webkit-scrollbar { width: 5px; }
.viewer-body::-webkit-scrollbar-thumb { background: #bbb; border-radius: 3px; }

/* Ficha table */
.viewer-body table { width: 100%; border-collapse: collapse; margin-bottom: 1px; }
.viewer-body th, .viewer-body td { border: 1px solid #c8cdd3; padding: 4px 6px; vertical-align: top; font-size: 11px; }
.viewer-body .sec td { background: #2F5496; color: #fff; font-weight: 700; font-size: 11px; padding: 5px 8px; }
.viewer-body .sub td { background: #D6E4F0; font-weight: 600; font-size: 10px; }
.viewer-body td.lbl { font-weight: 600; background: #f7f8fa; }
.viewer-body td.yn { text-align: center; width: 60px; font-weight: 700; font-size: 10px; }
.viewer-body td.yn.y { color: #16a34a; }
.viewer-body td.yn.n { color: #dc2626; }
.viewer-body td.yn.partial { color: #d97706; }
.viewer-body td.yn.na { color: #6b7280; }
.viewer-body td.yn.nf { color: #b45309; font-style: italic; }
.viewer-body .nf { color: #b45309; font-style: italic; }
.viewer-body td.cell-click { cursor: pointer; }
.viewer-body td.cell-click:hover { background: #eef3fc !important; }
.viewer-body td.active-cell { outline: 2px solid #2F5496; outline-offset: -1px; background: #e8eefb !important; }
.viewer-body td.checker-disagree { background: #fef9c3 !important; border-left: 3px solid #eab308; }
.viewer-body td.checker-disagree:hover { background: #fef08a !important; }

/* Right panel */
.viewer-right { width: 520px; min-width: 400px; display: flex; flex-direction: column; background: #fafbfc; border-left: 2px solid #2F5496; }
.viewer-right-tabs { display: flex; background: #2F5496; flex-shrink: 0; }
.viewer-right-tabs button { flex: 1; padding: 7px; background: transparent; border: none; color: rgba(255,255,255,.6); font-size: 11px; font-weight: 600; cursor: pointer; }
.viewer-right-tabs button.active { color: #fff; border-bottom: 2px solid #fff; }
.viewer-right-header { padding: 5px 12px; background: #eef3fc; font-size: 11px; font-weight: 600; color: #2F5496; border-bottom: 1px solid #d0d5dd; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-right-body { flex: 1; overflow-y: auto; position: relative; }
.viewer-right-body::-webkit-scrollbar { width: 5px; }
.viewer-right-body::-webkit-scrollbar-thumb { background: #bbb; border-radius: 3px; }

/* PDF viewer */
.pdf-container { position: relative; width: 100%; }
.pdf-canvas { display: block; width: 100%; }
.textLayer { position: absolute; top: 0; left: 0; right: 0; bottom: 0; overflow: hidden; }
.textLayer :is(span, br) { color: transparent !important; }
.textLayer :is(span, br)::selection { background: rgba(47, 84, 150, 0.35); }
.textLayer .search-hit { background: rgba(255, 213, 0, 0.45) !important; border-radius: 2px; padding: 1px 0; }

.ocr-match-panel { border-bottom: 2px solid #2F5496; }
.ocr-match-header { padding: 7px 12px; background: #fff8e1; font-size: 11px; font-weight: 600; color: #92400e; display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; border-bottom: 1px solid #ffe082; }
.ocr-match-body { max-height: 220px; overflow-y: auto; padding: 10px 12px; font-size: 11px; line-height: 1.7; color: #333; background: #fffef5; white-space: pre-wrap; }
.ocr-match-body.collapsed { display: none; }

.ocr-block { padding: 10px; font-size: 11px; white-space: pre-wrap; line-height: 1.5; color: #333; background: #fff; }
.empty-state { text-align: center; color: #aaa; padding: 60px 20px; }
.empty-state .icon { font-size: 28px; margin-bottom: 6px; }
.exp-block { padding: 16px; font-size: 12px; line-height: 1.7; color: #333; background: #fff; }
.exp-block .exp-label { font-size: 10px; font-weight: 600; color: #2F5496; text-transform: uppercase; margin-bottom: 4px; }
.exp-block .exp-source { font-size: 10px; color: #888; margin-top: 12px; padding-top: 8px; border-top: 1px solid #eee; }

.src-nav { display: flex; gap: 3px; padding: 5px 10px; background: #f0f2f5; border-bottom: 1px solid #ddd; flex-shrink: 0; flex-wrap: wrap; }
.src-nav button { font-size: 10px; padding: 2px 7px; border: 1px solid #c8cdd3; background: #fff; border-radius: 3px; cursor: pointer; }
.src-nav button.active { background: #2F5496; color: #fff; border-color: #2F5496; }

.pdf-loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: #888; gap: 8px; }
.pdf-loading .spinner { width: 16px; height: 16px; border: 2px solid #ddd; border-top-color: #2F5496; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.viewer-stats { display: flex; gap: 16px; padding: 4px 16px; background: #f0f2f5; border-top: 1px solid #ddd; font-size: 10px; color: #666; flex-shrink: 0; }
.viewer-stats .stat { display: flex; gap: 4px; align-items: center; }
.viewer-stats .dot { width: 6px; height: 6px; border-radius: 50%; }
.dot-yes { background: #16a34a; }
.dot-no { background: #dc2626; }
.dot-partial { background: #d97706; }
.dot-na { background: #6b7280; }
.dot-nf { background: #b45309; }
.dot-flag { background: #eab308; }

/* Resize handle */
.resize-handle { width: 4px; cursor: col-resize; background: transparent; flex-shrink: 0; position: relative; z-index: 10; }
.resize-handle:hover, .resize-handle.dragging { background: #2F5496; }

@media (max-width: 900px) {
  .viewer-layout { flex-direction: column; }
  .viewer-right { width: 100% !important; height: 45vh; border-left: none; border-top: 2px solid #2F5496; }
  .resize-handle { display: none; }
}
