:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #657087;
  --line: #e1e6ed;
  --soft: #f4f6f9;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #059669;
  --orange: #d97706;
  --red: #dc2626;
  --purple: #9333ea;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: #f5f7fb; color: var(--ink); font-size: 14px; line-height: 1.55; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, [role="button"]:focus-visible { outline: 3px solid rgba(37, 99, 235, .25); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.app-header { min-height: 86px; padding: 18px max(24px, calc((100vw - 1500px) / 2)); background: #111c34; color: white; display: flex; align-items: center; gap: 14px; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 50px; border-radius: 9px; background: linear-gradient(145deg, #3b82f6, #2563eb); font-size: 13px; font-weight: 800; letter-spacing: .04em; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.app-header h1 { margin: 0; font-size: 21px; line-height: 1.25; letter-spacing: -.02em; }
.app-header p { margin: 4px 0 0; color: #b7c3da; font-size: 13px; }
.local-badge { margin-left: auto; display: flex; align-items: center; gap: 7px; color: #d6deed; border: 1px solid #35425c; border-radius: 99px; padding: 5px 11px; font-size: 12px; }
.local-badge > span { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .12); }
.page-shell { width: min(1500px, calc(100% - 48px)); margin: 28px auto 40px; }
.import-card, .document-bar, .workspace, .results-section, .text-section { background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 4px 18px rgba(20, 34, 58, .035); }
.import-card { padding: 26px; }
.import-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 4px; color: var(--blue); font-weight: 700; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
h2 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.import-heading p:not(.eyebrow), .document-bar p:not(.eyebrow) { margin: 6px 0 0; color: var(--muted); }
.file-limit { flex: none; border-radius: 6px; background: var(--soft); color: var(--muted); padding: 5px 9px; font-size: 12px; }
.dropzone { display: flex; align-items: center; gap: 17px; min-height: 114px; padding: 22px; border: 1.5px dashed #b7c3d6; border-radius: 11px; background: #fafbfe; transition: border-color .18s, background .18s; cursor: pointer; }
.dropzone:hover, .dropzone.dragover { border-color: var(--blue); background: #f2f6ff; }
.upload-icon { width: 36px; height: 36px; flex: none; fill: none; stroke: var(--blue); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dropzone-copy { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.dropzone-copy strong { font-size: 15px; overflow-wrap: anywhere; }
.dropzone-copy span { color: var(--muted); font-size: 12px; }
.dropzone .secondary-button { margin-left: auto; flex: none; }
.primary-button, .secondary-button { border-radius: 7px; padding: 8px 15px; font-weight: 650; border: 1px solid transparent; transition: background .15s, border-color .15s; }
.primary-button { background: var(--blue); color: white; border-color: var(--blue); }
.primary-button:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); }
.secondary-button { background: white; color: #344054; border-color: #cbd3df; }
.secondary-button:hover:not(:disabled) { background: var(--soft); border-color: #9aa9bd; }
.import-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 17px; }
.import-actions p { margin: 0; color: var(--muted); font-size: 12px; }
.import-actions .primary-button { display: flex; gap: 20px; align-items: center; min-width: 150px; justify-content: space-between; }
.progress-panel { margin-top: 18px; display: flex; gap: 13px; align-items: center; border-radius: 9px; background: #eff6ff; color: #1e40af; padding: 13px 15px; }
.progress-panel p { margin: 2px 0 0; font-size: 12px; color: #5570a7; }
.spinner { width: 22px; height: 22px; flex: none; border: 2.5px solid #bfdbfe; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-banner, .warning-banner { border-radius: 8px; padding: 11px 14px; white-space: pre-wrap; }
.error-banner { margin-top: 16px; color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; }
.warning-banner { margin: 14px 0; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; }
#results { margin-top: 24px; }
.document-bar { padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.document-bar h2 { overflow-wrap: anywhere; }
.document-actions { display: flex; gap: 9px; flex: none; }
.stats-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 11px; margin: 14px 0; }
.stats-grid article { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 13px 16px; display: flex; flex-direction: column; }
.stats-grid span { color: var(--muted); font-size: 12px; }
.stats-grid strong { margin-top: 2px; font-size: 25px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stats-grid .review-stat strong { color: var(--orange); }
.workspace { display: grid; grid-template-columns: 190px minmax(0, 1fr); overflow: hidden; }
.pages-panel { border-right: 1px solid var(--line); background: #fafbfc; min-width: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px 11px; }
.panel-heading h3 { margin: 0; font-size: 14px; }
.panel-heading span { color: var(--muted); font-size: 11px; }
#pageList { max-height: 720px; overflow-y: auto; padding: 0 8px 10px; }
.page-button { width: 100%; text-align: left; border: 0; background: transparent; border-radius: 7px; padding: 9px 10px; color: #344054; margin: 2px 0; }
.page-button:hover { background: #edf1f7; }
.page-button.active { background: #e8f0ff; color: #1d4ed8; }
.page-button strong, .page-button span { display: block; }
.page-button strong { font-size: 13px; }
.page-button span { margin-top: 2px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-button.active span { color: #5874aa; }
.preview-panel { min-width: 0; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.layer-controls { display: flex; flex-wrap: wrap; gap: 8px 13px; }
.layer-controls label, .current-page-filter { display: flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 12px; color: #475467; }
input[type="checkbox"] { accent-color: var(--blue); }
.zoom-controls { display: flex; align-items: center; gap: 5px; flex: none; }
.zoom-controls button { border: 1px solid #d5dce6; background: white; border-radius: 5px; padding: 3px 8px; color: #475467; font-size: 12px; }
.zoom-controls button:hover { background: var(--soft); }
#zoomText { min-width: 40px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.preview-caption { color: var(--muted); font-size: 11px; padding: 7px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); }
.pdf-viewer { height: 67vh; min-height: 460px; overflow: auto; background: #e7ebf0; }
.canvas-wrap { position: relative; width: 100%; margin: 0 auto; background: white; transition: width .15s; box-shadow: 0 1px 5px rgba(0,0,0,.08); }
#pageImage { display: block; width: 100%; height: auto; min-height: 50px; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.black-box { fill: rgba(37,99,235,.08); stroke: var(--blue); stroke-width: .45; }
.black-label { fill: var(--blue); font-weight: 700; }
.black-arrow { fill: none; stroke: var(--green); stroke-width: .65; }
.black-target { fill: white; stroke: var(--green); stroke-width: .65; }
.red-box { fill: rgba(220,38,38,.05); stroke: var(--red); stroke-width: .45; }
.red-label { fill: var(--red); font-weight: 700; }
.red-link { fill: none; stroke: var(--orange); stroke-width: .6; }
.red-target { fill: white; stroke: var(--orange); stroke-width: .6; }
.result-label { font-size: 4px; paint-order: stroke; stroke: white; stroke-width: 1.1px; stroke-linejoin: round; }
.clickable { cursor: pointer; }
.selected-shape { stroke: var(--purple) !important; stroke-width: 1.2 !important; fill: rgba(147,51,234,.14) !important; }
.results-section { margin-top: 20px; overflow: hidden; }
.section-heading { display: flex; align-items: center; justify-content: space-between; padding: 19px 22px 13px; }
.section-heading > span { color: var(--muted); font-size: 12px; }
.table-filters { display: flex; align-items: center; gap: 10px; padding: 0 22px 14px; }
.search-field { flex: 1; max-width: 360px; }
input[type="search"], select { width: 100%; border: 1px solid #cfd7e3; background: white; border-radius: 7px; color: #344054; padding: 7px 10px; }
select { width: auto; min-width: 140px; }
.current-page-filter { margin-left: auto; }
.table-wrap { overflow: auto; max-height: 650px; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; border-bottom: 1px solid #e9edf2; padding: 10px 13px; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; background: #f8fafc; color: #526077; font-size: 12px; font-weight: 650; white-space: nowrap; }
td { font-size: 13px; }
.result-row { cursor: pointer; }
.result-row:hover { background: #f5f8fd; }
.result-row.selected-row { background: #f5efff; }
.page-number { color: var(--muted); white-space: nowrap; }
.badge { display: inline-block; border-radius: 4px; padding: 2px 7px; font-size: 11px; white-space: nowrap; }
.badge.black { color: #1d4ed8; background: #e8f0ff; }
.badge.red { color: #b91c1c; background: #feecec; }
.result-text { font-weight: 700; font-size: 14px; }
.result-id { display: block; color: var(--muted); font-size: 10px; font-weight: 400; margin-top: 2px; }
.coordinate { white-space: nowrap; color: #475467; }
.review { color: #b45309; font-weight: 650; }
.muted { color: var(--muted); }
.empty-state { padding: 38px; text-align: center; color: var(--muted); }
.text-section { margin-top: 20px; overflow: hidden; }
.text-section summary { display: flex; justify-content: space-between; cursor: pointer; padding: 16px 21px; font-weight: 650; }
.text-section summary span:last-child { color: var(--muted); font-size: 12px; font-weight: 400; }
.text-section pre { margin: 0; max-height: 450px; overflow: auto; padding: 18px 22px; border-top: 1px solid var(--line); background: #fafbfc; white-space: pre-wrap; overflow-wrap: anywhere; color: #344054; font: 12px/1.7 "Cascadia Code", Consolas, monospace; }
.footnote { color: var(--muted); font-size: 11px; margin: 13px 4px 0; }
footer { text-align: center; color: #98a2b3; font-size: 11px; padding: 0 20px 25px; }
@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .preview-toolbar { align-items: flex-start; flex-direction: column; }
  .zoom-controls { align-self: flex-end; }
}
@media (max-width: 760px) {
  .page-shell { width: min(100% - 24px, 1500px); margin-top: 14px; }
  .app-header { padding: 15px 18px; }
  .local-badge { display: none; }
  .import-card { padding: 18px; }
  .import-heading, .document-bar, .import-actions { align-items: stretch; flex-direction: column; }
  .file-limit { display: none; }
  .dropzone { flex-direction: column; text-align: center; }
  .dropzone .secondary-button { margin: 4px 0 0; }
  .import-actions .primary-button { align-self: flex-end; }
  .document-actions { flex-wrap: wrap; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .workspace { grid-template-columns: 1fr; }
  .pages-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  #pageList { display: flex; overflow-x: auto; max-height: none; padding: 5px 9px 10px; }
  .page-button { width: 120px; flex: none; }
  .panel-heading { padding-bottom: 3px; }
  .pdf-viewer { min-height: 340px; height: 55vh; }
  .table-filters { flex-wrap: wrap; }
  .search-field { max-width: none; flex-basis: 100%; }
  .current-page-filter { margin-left: 0; }
  th, td { padding: 9px; }
}
