:root { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif; color:#171717; background:#f4f4f6; }
* { box-sizing:border-box; }
body { margin:0; }
main { max-width:900px; margin:auto; padding:24px 16px 80px; }
h1 { margin:0 0 6px; font-size:30px; }
header p { margin:0 0 22px; color:#666; line-height:1.4; }
.card { background:white; border:1px solid #dedee3; border-radius:18px; padding:16px; box-shadow:0 4px 18px rgba(0,0,0,.035); }
.uploader { text-align:center; padding:22px 16px; }
.uploader-actions { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }
button { border:0; border-radius:12px; padding:13px 18px; font-size:16px; font-weight:650; cursor:pointer; }
.primary { background:#111; color:white; }
.secondary { background:#ececf0; color:#222; }
.hint { margin-top:12px; color:#737373; font-size:14px; line-height:1.45; }
.subhint { margin-top:8px; color:#777; font-size:13px; line-height:1.4; }
.status { margin:16px 0; padding:13px 15px; border-radius:12px; background:#fff7d6; }
.hidden { display:none; }
.grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:14px; margin:16px 0; }
.doc { padding:0; overflow:hidden; }
.doc img { width:100%; aspect-ratio:4/3; object-fit:contain; background:#ececef; display:block; }
.doc-body { padding:14px; }
.filename { font-size:13px; color:#777; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; margin-bottom:11px; }
label { display:block; font-size:13px; color:#555; font-weight:600; text-align:left; }
select,input { width:100%; margin-top:7px; border:1px solid #d5d5db; border-radius:10px; padding:12px; font-size:16px; background:white; color:#111; }
.confidence { margin-top:9px; font-size:13px; color:#666; }
#actions { margin-top:16px; }
.row { display:flex; gap:10px; margin-top:16px; }
.row button { flex:1; }
.paste-label { margin-top:18px; margin-bottom:6px; }
.paste-area {
  width:100%;
  min-height:86px;
  border:1px solid #c7c7cf;
  border-radius:14px;
  background:#fff;
  padding:14px;
  text-align:left;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  font-size:16px;
  line-height:1.35;
  color:#222;
  outline:none;
  resize:none;
  -webkit-appearance:none;
  appearance:none;
}
.paste-area:focus {
  border-color:#111;
  box-shadow:0 0 0 3px rgba(0,0,0,.06);
}
.queue {
  margin-top:16px;
  border:1px solid #e1e1e8;
  border-radius:14px;
  padding:14px;
  text-align:left;
  background:#fafafa;
}
.queue-title { font-weight:700; margin-bottom:10px; }
.queue-list { display:flex; flex-wrap:wrap; gap:8px; }
.queue-item {
  border:1px solid #d6d6de;
  background:white;
  border-radius:999px;
  padding:8px 12px;
  font-size:13px;
  color:#444;
  max-width:100%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.uploader.drag { outline:3px solid #111; outline-offset:2px; background:#fafafa; }
@media(max-width:520px) {
  main { padding-top:18px; }
  h1 { font-size:26px; }
  .grid { grid-template-columns:1fr; }
  .uploader-actions, .row { flex-direction:column; }
}


.pdf-status {
  margin-top:14px;
  padding:13px 14px;
  border-radius:12px;
  background:#fff7d6;
  color:#222;
  font-size:15px;
  line-height:1.4;
  text-align:left;
}
.pdf-status.success { background:#eaf7ed; }
.pdf-status.error { background:#fdecec; }

.pdf-open {
  display:block;
  width:100%;
  margin-top:10px;
  border-radius:12px;
  padding:13px 16px;
  background:#111;
  color:#fff;
  text-decoration:none;
  text-align:center;
  font-size:16px;
  font-weight:700;
}

#phone {
  font-variant-numeric: tabular-nums;
  letter-spacing:.01em;
}


.app-version {
  margin-top:24px;
  text-align:center;
  font-size:12px;
  color:#aaa;
  user-select:none;
}


.archive-open {
  display:block;
  width:100%;
  margin-top:10px;
  border-radius:12px;
  padding:13px 16px;
  background:#ececf0;
  color:#111;
  text-decoration:none;
  text-align:center;
  font-size:16px;
  font-weight:700;
}

.ocr-details {
  margin-top:12px;
  border-top:1px solid #eee;
  padding-top:10px;
}

.ocr-details summary {
  cursor:pointer;
  font-weight:700;
}

.structured-data {
  margin:10px 0;
  font-size:14px;
}

.structured-row {
  display:grid;
  grid-template-columns:minmax(120px, 36%) 1fr;
  gap:8px;
  padding:6px 0;
  border-bottom:1px solid #eee;
}

.structured-key { color:#666; }
.structured-value { word-break:break-word; }

.ocr-text {
  white-space:pre-wrap;
  word-break:break-word;
  background:#f7f7f8;
  border-radius:10px;
  padding:10px;
  max-height:340px;
  overflow:auto;
  font-size:12px;
  text-align:left;
}

.copy-ocr {
  width:100%;
  margin:8px 0;
}


.delete-doc {
  width:100%;
  margin-top:12px;
}

.danger {
  background:#fff0f0;
  color:#b00020;
  border:1px solid #f2c6c6;
}

.danger:active {
  background:#ffe4e4;
}

.doc.deleting {
  opacity:.55;
  pointer-events:none;
}


#newSet {
  width: 100%;
  margin-top: 12px;
}

#newSet.hidden {
  display: none;
}


#pdfMode {
  margin-bottom: 14px;
}

.phone-label {
  margin-top: 10px;
}

.optional {
  font-weight: 400;
  color: #888;
}


.edit-actions {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin-top:12px;
}
.edit-actions button { width:100%; }
.reset-doc { font-size:14px; }
.doc.manual-edited .reset-doc { background:#e8f3ff; }

.crop-modal {
  position:fixed;
  inset:0;
  z-index:1000;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  background:rgba(0,0,0,.72);
}
.crop-modal.hidden { display:none; }
.crop-dialog {
  width:min(980px, 100%);
  max-height:96vh;
  overflow:auto;
  background:#fff;
  border-radius:18px;
  padding:16px;
  box-shadow:0 18px 80px rgba(0,0,0,.35);
}
.crop-head {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}
.crop-head h2 { margin:0 0 5px; font-size:22px; }
.crop-head p { margin:0; color:#666; font-size:14px; line-height:1.4; }
.icon-btn { min-width:44px; padding:8px 12px; font-size:26px; line-height:1; }
.crop-stage {
  margin-top:14px;
  width:100%;
  min-height:180px;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  border-radius:12px;
  background:#1c1c1e;
  touch-action:none;
  user-select:none;
}
#cropCanvas {
  display:block;
  max-width:100%;
  touch-action:none;
  cursor:crosshair;
}
.crop-toolbar,
.crop-footer {
  display:flex;
  gap:8px;
  margin-top:12px;
}
.crop-toolbar button { flex:1; }
.crop-footer button { flex:1; }
.crop-info {
  margin-top:10px;
  min-height:20px;
  color:#666;
  font-size:13px;
  text-align:center;
}
@media(max-width:520px) {
  .edit-actions { grid-template-columns:1fr; }
  .crop-modal { padding:0; align-items:stretch; }
  .crop-dialog { width:100%; max-height:100vh; border-radius:0; padding:12px; }
  .crop-head h2 { font-size:20px; }
  .crop-toolbar button { padding:11px 8px; font-size:14px; }
  .crop-footer { flex-direction:column; }
}


.color-controls {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 14px;
  background: #fafafa;
}

.color-controls-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.color-controls-head strong {
  font-size: 16px;
}

button.compact {
  width: auto;
  padding: 8px 12px;
  min-height: 38px;
  font-size: 14px;
}

.range-row {
  display: block;
  margin: 10px 0;
}

.range-row > span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
  font-size: 14px;
  color: #333;
}

.range-row output {
  font-variant-numeric: tabular-nums;
  color: #666;
}

.range-row input[type="range"] {
  display: block;
  width: 100%;
  height: 32px;
  margin: 0;
  accent-color: #111;
  touch-action: pan-y;
}

.color-hint {
  margin-top: 7px;
  color: #777;
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 640px) {
  .color-controls {
    padding: 10px;
  }

  .range-row {
    margin: 8px 0;
  }

  .range-row input[type="range"] {
    height: 38px;
  }
}


button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.diagnostic-card{margin:16px 0;padding:14px 16px}.diagnostic-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.diagnostic-head .compact{padding:8px 11px;font-size:13px}.diagnostic-text{margin-top:9px;color:#555;font-size:13px;line-height:1.5}.diagnostic-text b{color:#222}.diagnostic-warn{color:#8a5b00}.diagnostic-good{color:#246438}
