/* Quote Compare tool — extends site.css tokens */

.qc-page {
  min-height: 100vh;
}

.qc-header {
  padding: 3.5rem 1.5rem 1.5rem;
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(29, 78, 216, 0.08), transparent 55%),
    var(--paper);
  border-bottom: 1px solid var(--rule);
}

.qc-header-inner {
  max-width: 960px;
  margin: 0 auto;
}

.qc-title {
  margin: 0.75rem 0 0.5rem;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
}

.qc-lead {
  margin: 0;
  max-width: 40rem;
  font-size: 1.05rem;
  color: var(--dim);
}

.qc-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  list-style: none;
  margin: 1.75rem 0 0;
  padding: 0;
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(11, 26, 46, 0.35);
}

.qc-step.is-active {
  color: var(--blue);
  font-weight: 600;
}

.qc-step.is-done {
  color: var(--ink);
}

.qc-panel {
  padding: 2rem 1.5rem 4rem;
}

.qc-panel-inner {
  max-width: 960px;
  margin: 0 auto;
}

.qc-panel-inner--wide {
  max-width: 1200px;
}

.qc-panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.qc-panel-lead {
  margin: 0 0 1.5rem;
  color: var(--dim);
  max-width: 36rem;
}

.qc-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 220px;
  padding: 2rem;
  border: 1.5px dashed rgba(11, 26, 46, 0.28);
  background:
    linear-gradient(180deg, rgba(244, 239, 230, 0.5), transparent),
    #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.qc-dropzone:hover,
.qc-dropzone:focus-visible,
.qc-dropzone.is-dragover {
  border-color: var(--blue);
  background: rgba(29, 78, 216, 0.04);
  outline: none;
}

.qc-dropzone-icon {
  color: var(--blue);
  margin-bottom: 0.25rem;
}

.qc-dropzone-title {
  margin: 0;
  font-weight: 600;
  font-size: 1.05rem;
}

.qc-dropzone-hint {
  margin: 0;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dim);
}

.qc-file-list {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.qc-file-row {
  display: grid;
  grid-template-columns: 1fr minmax(140px, 220px) auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid var(--rule);
}

.qc-file-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qc-file-meta {
  font-size: 12px;
  color: var(--dim);
}

.qc-file-meta.is-error {
  color: #b45309;
}

.qc-file-meta.is-ok {
  color: #15803d;
}

.qc-file-label {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--rule);
  font: inherit;
  font-size: 0.9rem;
  background: var(--paper);
  color: var(--ink);
}

.qc-file-label:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.qc-file-remove {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.qc-file-remove:hover {
  color: var(--ink);
}

.qc-panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1.5rem;
}

.qc-status {
  margin: 0;
  font-size: 0.9rem;
  color: var(--dim);
  flex: 1 1 100%;
}

.qc-map-controls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.qc-map-field label {
  display: block;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 0.35rem;
}

.qc-map-field select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--rule);
  font: inherit;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
}

.qc-map-field select:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.qc-preview-wrap {
  border: 1px solid var(--rule);
  background: #fff;
}

.qc-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--rule);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--dim);
  background: var(--cream);
}

.qc-preview-scroll {
  overflow: auto;
  max-height: 360px;
}

.qc-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.qc-preview-table th,
.qc-preview-table td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qc-preview-table th {
  position: sticky;
  top: 0;
  background: var(--paper);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  font-weight: 600;
  z-index: 1;
}

.qc-preview-table th.is-mapped {
  color: var(--blue);
  box-shadow: inset 0 -2px 0 var(--blue);
}

.qc-preview-table tbody tr:hover td {
  background: rgba(29, 78, 216, 0.04);
}

.qc-compare-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.qc-compare-toolbar .qc-panel-lead {
  margin-bottom: 0;
}

.qc-compare-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.qc-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.qc-summary-card {
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid var(--rule);
}

.qc-summary-card--win {
  border-color: rgba(29, 78, 216, 0.45);
  background: linear-gradient(180deg, rgba(29, 78, 216, 0.06), #fff 70%);
}

.qc-summary-label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 0.35rem;
}

.qc-summary-value {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.qc-summary-sub {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: var(--dim);
}

.qc-matrix-scroll {
  overflow: auto;
  border: 1px solid var(--rule);
  background: #fff;
  max-height: min(70vh, 720px);
}

.qc-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 640px;
}

.qc-matrix th,
.qc-matrix td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  vertical-align: top;
}

.qc-matrix th:last-child,
.qc-matrix td:last-child {
  border-right: none;
}

.qc-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--ink);
  color: var(--cream);
  font-weight: 600;
  text-align: left;
}

.qc-matrix thead th.qc-col-desc {
  left: 0;
  z-index: 3;
  min-width: 200px;
}

.qc-matrix thead .qc-col-supplier {
  text-align: right;
  min-width: 120px;
}

.qc-matrix thead .qc-supplier-total {
  display: block;
  margin-top: 0.2rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--cream-70);
}

.qc-matrix tbody td.qc-col-desc {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 1;
  font-weight: 500;
  max-width: 280px;
}

.qc-matrix tbody tr:hover td.qc-col-desc {
  background: #f8f6f1;
}

.qc-matrix tbody tr:hover td {
  background: rgba(11, 26, 46, 0.02);
}

.qc-matrix .qc-cell-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.82rem;
  white-space: nowrap;
}

.qc-matrix .qc-cell-best {
  background: rgba(29, 78, 216, 0.1);
  color: var(--blue);
  font-weight: 600;
}

.qc-matrix .qc-cell-high {
  background: rgba(217, 119, 6, 0.12);
  color: #92400e;
}

.qc-matrix .qc-cell-missing {
  color: rgba(11, 26, 46, 0.3);
  text-align: right;
}

.qc-matrix .qc-cell-rate {
  display: block;
  font-size: 0.75rem;
  color: var(--dim);
  font-weight: 400;
}

.qc-matrix .qc-cell-best .qc-cell-rate {
  color: rgba(29, 78, 216, 0.7);
}

.qc-matrix tfoot td {
  position: sticky;
  bottom: 0;
  background: var(--cream);
  font-weight: 700;
  border-top: 2px solid var(--ink);
}

.qc-matrix tfoot .qc-col-desc {
  left: 0;
  z-index: 1;
}

.qc-row-merge {
  margin-top: 0.35rem;
}

.qc-row-merge select {
  max-width: 100%;
  font-size: 0.75rem;
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--dim);
}

.qc-footnote {
  margin: 1rem 0 0;
  font-size: 11px;
  letter-spacing: 0.4px;
  color: var(--dim);
}

/* Loading overlay */
.qc-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(11, 26, 46, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: qc-overlay-in 0.18s ease-out;
}

.qc-overlay[hidden] {
  display: none;
}

.qc-overlay-card {
  width: min(360px, 100%);
  padding: 2rem 1.75rem 1.75rem;
  background: #fff;
  border: 1px solid rgba(11, 26, 46, 0.12);
  box-shadow: 0 18px 48px rgba(11, 26, 46, 0.18);
  text-align: center;
}

.qc-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 1.1rem;
  border: 2.5px solid rgba(11, 26, 46, 0.12);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: qc-spin 0.75s linear infinite;
}

.qc-overlay-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.qc-overlay-sub {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--dim);
}

@keyframes qc-spin {
  to { transform: rotate(360deg); }
}

@keyframes qc-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

body.qc-loading {
  overflow: hidden;
}

@media (max-width: 720px) {
  .qc-file-row {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
  }

  .qc-file-name {
    grid-column: 1;
  }

  .qc-file-remove {
    grid-column: 2;
    grid-row: 1;
  }

  .qc-file-label {
    grid-column: 1 / -1;
  }

  .qc-file-meta {
    grid-column: 1 / -1;
  }

  .qc-compare-toolbar {
    flex-direction: column;
  }

  .qc-matrix tbody td.qc-col-desc,
  .qc-matrix thead th.qc-col-desc,
  .qc-matrix tfoot .qc-col-desc {
    position: static;
  }
}
