/* PixToPDF — bố cục riêng cho tool Lấy kích thước bản vẽ kỹ thuật.
 * Dùng lại token màu, nút và lưới của site.css/tool-flow.css; chỉ bổ sung
 * phần xem trước / panel xác minh để không lặp lại toàn bộ design system.
 */
.dim-file-grid {
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}

.dim-file-card {
  cursor: pointer;
  user-select: none;
}

.dim-file-card:active {
  cursor: pointer;
}

.dim-file-card.is-active {
  border-color: var(--accent, #0d8f7c);
  box-shadow: 0 0 0 2px var(--accent-soft, #e8f5f2);
}

.dim-file-card.is-error {
  border-color: #d14343;
  box-shadow: 0 0 0 2px #fdecec;
}

.dim-file-card .page-thumb {
  height: 132px;
}

.dim-file-card .page-thumb img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.dim-file-card .page-meta {
  display: grid;
  gap: 3px;
  align-items: start;
}

.dim-file-card .page-meta strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dim-file-card .dim-card-values {
  color: var(--muted, #61716c);
  font-size: 10.5px;
  line-height: 1.35;
}

.dim-file-card .page-actions {
  align-items: center;
}

.dim-file-card .page-actions .dim-open {
  flex: 1 1 auto;
}

.dim-file-card .page-actions .dim-remove {
  flex: 0 0 auto;
  color: #8d2f2f;
}

.dim-file-card.is-active .dim-open {
  border-color: var(--accent, #0d8f7c);
  color: var(--accent, #0d8f7c);
  font-weight: 600;
}

.dim-file-card .dim-card-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  color: var(--muted, #61716c);
  font-size: 10.5px;
}

.dim-batch-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  align-items: center;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line, #dce5e2);
  border-radius: 10px;
  background: #fbfdfc;
}

.dim-batch-options .field {
  margin: 0;
}

.dim-batch-options .hint {
  margin-top: 3px;
}

.dim-batch-options .dim-option-note {
  flex: 1 1 260px;
  min-width: 220px;
  color: var(--muted, #61716c);
  font-size: 12px;
  line-height: 1.45;
}

.dim-verify {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
  gap: 16px;
  align-items: start;
  margin-top: 22px;
  padding: 16px;
  border: 1px solid var(--line, #dce5e2);
  border-radius: 12px;
  background: #fff;
}

.dim-preview-pane {
  min-width: 0;
}

.dim-preview-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dim-preview-head .dim-preview-name {
  display: grid;
  gap: 2px;
  min-width: 180px;
}

.dim-preview-head strong {
  color: var(--ink, #17211f);
  font-size: 14px;
}

.dim-preview-head span {
  color: var(--muted, #61716c);
  font-size: 11.5px;
}

.dim-zoom {
  display: flex;
  gap: 4px;
  align-items: center;
}

.dim-zoom button {
  min-width: 32px;
  padding: 5px 8px;
  border: 1px solid var(--line, #dce5e2);
  border-radius: 7px;
  background: #fff;
  color: var(--ink, #17211f);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.dim-zoom button:hover:not(:disabled) {
  border-color: var(--accent, #0d8f7c);
  color: var(--accent, #0d8f7c);
}

.dim-zoom button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.dim-zoom-label {
  min-width: 47px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.dim-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 460px;
  overflow: hidden;
  border: 1px solid var(--line, #dce5e2);
  border-radius: 9px;
  background:
    linear-gradient(45deg, #f0f4f2 25%, transparent 25%, transparent 75%, #f0f4f2 75%, #f0f4f2),
    linear-gradient(45deg, #f0f4f2 25%, #f7faf8 25%, #f7faf8 75%, #f0f4f2 75%, #f0f4f2);
  background-position: 0 0, 10px 10px;
  background-size: 20px 20px;
  touch-action: none;
  cursor: grab;
}

.dim-stage:active {
  cursor: grabbing;
}

.dim-transform {
  position: relative;
  flex: 0 0 auto;
  transform-origin: center center;
  will-change: transform;
}

.dim-stage canvas {
  display: block;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(23, 33, 31, .12);
  pointer-events: none;
}

.dim-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.dim-box {
  position: absolute;
  border: 1.5px solid #d94848;
  border-radius: 3px;
  background: rgba(217, 72, 72, .12);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .55) inset;
}

.dim-box-title {
  border-color: #0d8f7c;
  background: rgba(13, 143, 124, .12);
}

.dim-box-label {
  position: absolute;
  left: -1.5px;
  bottom: calc(100% + 3px);
  max-width: 190px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(23, 33, 31, .92);
  color: #fff;
  font-size: 9px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dim-box-title .dim-box-label {
  background: rgba(13, 143, 124, .95);
}

.dim-stage-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--muted, #61716c);
  font-size: 11px;
}

.dim-fields {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line, #dce5e2);
  border-radius: 10px;
  background: #fbfdfc;
}

.dim-fields-head {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  justify-content: space-between;
  align-items: baseline;
}

.dim-fields-head strong {
  font-size: 14px;
}

.dim-fields-head span {
  color: var(--muted, #61716c);
  font-size: 11px;
}

.dim-fields .field {
  margin: 0;
}

.dim-fields label {
  font-size: 12px;
  font-weight: 600;
}

.dim-fields input,
.dim-fields select,
.dim-fields textarea {
  width: 100%;
  min-width: 0;
}

.dim-fields textarea {
  min-height: 52px;
  resize: vertical;
}

.dim-triplet {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.dim-triplet .field {
  min-width: 0;
}

.dim-unit-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dim-field-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.dim-field-actions .btn {
  flex: 1 1 auto;
}

.dim-field-note {
  margin: 0;
  color: var(--muted, #61716c);
  font-size: 11px;
  line-height: 1.4;
}

.dim-confidence {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  min-height: 18px;
}

.dim-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e8f5f2;
  color: #0b6f61;
  font-size: 10.5px;
}

.dim-pill.dim-pill-warn {
  background: #fff4dc;
  color: #8a5a0b;
}

.dim-pill.dim-pill-muted {
  background: #eef2f1;
  color: #51615c;
}

.dim-empty {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line, #dce5e2);
  border-radius: 10px;
  color: var(--muted, #61716c);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.dim-result-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.dim-result-table th,
.dim-result-table td {
  padding: 6px 7px;
  border-bottom: 1px solid var(--line, #dce5e2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.dim-result-table th {
  color: var(--muted, #61716c);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.dim-result-table col:nth-child(1) { width: 22%; }
.dim-result-table col:nth-child(2) { width: 22%; }
.dim-result-table col:nth-child(3) { width: 10%; }
.dim-result-table col:nth-child(4) { width: 10%; }
.dim-result-table col:nth-child(5) { width: 10%; }
.dim-result-table col:nth-child(6) { width: 12%; }
.dim-result-table col:nth-child(7) { width: 14%; }

.dim-result-table td.dim-num {
  font-variant-numeric: tabular-nums;
}

.dim-result-wrap {
  max-width: 100%;
  overflow: auto;
}

@media (max-width: 900px) {
  .dim-verify {
    grid-template-columns: minmax(0, 1fr);
  }

  .dim-stage {
    height: 390px;
  }

  .dim-fields {
    order: 2;
  }
}

@media (max-width: 620px) {
  .dim-file-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dim-file-card .page-thumb {
    height: 112px;
  }

  .dim-stage {
    height: 330px;
}
  .dim-preview-head {
    align-items: flex-start;
  }

  .dim-triplet {
    grid-template-columns: minmax(0, 1fr);
  }

  .dim-unit-row {
    grid-template-columns: minmax(0, 1fr);
  }
}
