/* =============================================================
   Extract — minimal Swiss UI
   Switzer + JetBrains Mono. Restraint, hairlines, no flourishes.
============================================================= */

html, body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* Custom scrollbar */
.custom-scrollbar::-webkit-scrollbar { width: 6px; height: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #D4D4D4; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #737373; }

/* ----- Status feed items ----- */
.status-item {
  animation: status-in 0.32s cubic-bezier(0.2, 0.65, 0.3, 1) both;
}
@keyframes status-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid #EAEAEA;
  border-top-color: #0A0A0A;
  animation: spin 0.85s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Status icons */
.s-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0A0A0A;
  flex-shrink: 0;
}
.s-dot.muted { background: #A3A3A3; }
.s-dot.error { background: #A03030; }

.s-check {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid #0F7A4D;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}
.s-check::after {
  content: '';
  position: absolute;
  left: 1.5px;
  top: -1px;
  width: 4px;
  height: 6px;
  border-right: 1.5px solid #0F7A4D;
  border-bottom: 1.5px solid #0F7A4D;
  transform: rotate(45deg);
}

/* ----- Header tabs ----- */
.tab {
  padding: 6px 12px;
  color: #737373;
  text-decoration: none;
  border-bottom: 1.5px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab:hover { color: #0A0A0A; }
.tab-active {
  color: #0A0A0A;
  border-bottom-color: #0A0A0A;
}

/* ----- Duplicate chip (existing primary id badge in bulk preview) ----- */
.dup-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  margin-right: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  color: #737373;
  border: 1px solid #EAEAEA;
  background: #FAFAF9;
}

/* ----- Bulk preview status chips ----- */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid;
}
.status-chip::before {
  content: '';
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
}
.status-chip.new       { color: #0F7A4D; border-color: rgba(15,122,77,0.3); background: rgba(15,122,77,0.04); }
.status-chip.duplicate { color: #9A6B12; border-color: rgba(154,107,18,0.3); background: rgba(154,107,18,0.04); }
.status-chip.error     { color: #A03030; border-color: rgba(160,48,48,0.3); background: rgba(160,48,48,0.04); }
.status-chip.overwritten { color: #707080; border-color: rgba(112,112,128,0.3); background: rgba(112,112,128,0.05); }
.status-chip.muted     { color: #909098; border-color: rgba(112,112,128,0.25); background: rgba(112,112,128,0.04); font-style: italic; }

/* ----- Partner pill (invoice ↔ delivery-note switcher on detail) ----- */
.link-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line, #DCDCE0);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ink-muted, #606070);
  text-transform: uppercase;
  text-decoration: none;
  transition: border-color .15s, color .15s, background .15s;
}
.link-pill:hover:not(.active):not(.missing) {
  border-color: var(--ink, #1a1a1f);
  color: var(--ink, #1a1a1f);
}
.link-pill.active {
  border-color: var(--ink, #1a1a1f);
  color: var(--ink, #1a1a1f);
  background: rgba(0,0,0,0.03);
  font-weight: 500;
}
.link-pill.missing {
  border-style: dashed;
  color: #A0A0A8;
  font-style: italic;
  cursor: default;
}

/* Grey-out a finished job row whose docs were replaced by a force-upload. */
tr.status-row.overwritten { opacity: 0.55; }
tr.status-row.overwritten .progress-fill { background: #B8B8C0; }

/* ----- Search field toggle (Name ↔ Code) ----- */
.search-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid #EAEAEA;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.search-toggle button {
  padding: 8px 14px;
  background: transparent;
  color: #737373;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.search-toggle button:not(:last-child) { border-right: 1px solid #EAEAEA; }
.search-toggle button.active { background: #0A0A0A; color: #FAFAF9; }
.search-toggle button:hover:not(.active) { color: #0A0A0A; }

/* ----- Search autocomplete dropdown ----- */
.suggest-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  margin-top: 2px;
  background: #FFFFFF;
  border: 1px solid #EAEAEA;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  max-height: 360px;
  overflow-y: auto;
  list-style: none;
  padding: 0;
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  cursor: pointer;
  border-bottom: 1px solid #F5F5F4;
  font-size: 13px;
  line-height: 1.3;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item.active,
.suggest-item:hover { background: #FAFAF9; }
.suggest-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #0A0A0A;
}
.suggest-code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: #737373;
  padding: 3px 8px;
  border: 1px solid #EAEAEA;
  background: #FFFFFF;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  white-space: nowrap;
}
.suggest-code:hover,
.suggest-item.active .suggest-code,
.suggest-item:hover .suggest-code {
  color: #0A0A0A;
  border-color: #0A0A0A;
  background: #FAFAF9;
}

/* ----- Master-verification pill (detail page + SSE feed) ----- */
.master-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid;
  line-height: 1.4;
}
.master-pill.verified   { color: #0F7A4D; border-color: rgba(15,122,77,0.4);  background: rgba(15,122,77,0.04); }
.master-pill.unverified { color: #9A6B12; border-color: rgba(154,107,18,0.4); background: rgba(154,107,18,0.06); }
.master-pill.compact {
  padding: 1px 5px;
  font-size: 8.5px;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

/* ----- ID correction diff (status feed) ----- */
.id-strike {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: #A03030;
  text-decoration: line-through;
  text-decoration-thickness: 1.2px;
}
.id-arrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: #A3A3A3;
  margin: 0 6px;
}
.id-corrected {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: #0A0A0A;
}

/* ----- Confidence pills ----- */
.confidence-pill {
  display: inline-block;
  padding: 2px 7px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid;
  white-space: nowrap;
  line-height: 1.5;
}
.confidence-very_high { color: #0F7A4D; border-color: rgba(15, 122, 77, 0.3); background: rgba(15, 122, 77, 0.04); }
.confidence-high      { color: #2D5A8C; border-color: rgba(45, 90, 140, 0.3); background: rgba(45, 90, 140, 0.04); }
.confidence-medium    { color: #9A6B12; border-color: rgba(154, 107, 18, 0.3); background: rgba(154, 107, 18, 0.04); }
.confidence-low,
.confidence-very_low  { color: #A03030; border-color: rgba(160, 48, 48, 0.3); background: rgba(160, 48, 48, 0.04); }
.confidence-null      { color: #A3A3A3; border-color: rgba(163, 163, 163, 0.4); background: transparent; }

/* ----- Type badges ----- */
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid;
  white-space: nowrap;
  line-height: 1.3;
}
.type-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.type-badge.tax_invoice    { color: #0A0A0A; border-color: #D4D4D4; background: #FAFAF9; }
.type-badge.delivery_note  { color: #0A0A0A; border-color: #0A0A0A; background: #0A0A0A; color: #FAFAF9; }
.type-badge.delivery_note::before { background: #FAFAF9; }
.type-badge.other          { color: #A3A3A3; border-color: #EAEAEA; background: transparent; }

/* ----- Result rows ----- */
.result-row {
  transition: background 0.15s ease;
  cursor: pointer;
}
.result-row:hover { background: #F5F5F4; }
.result-row:hover .row-arrow { transform: translateX(2px); color: #0A0A0A; }
.result-row.muted { cursor: default; }
.result-row.muted:hover { background: transparent; }
.result-row.muted .row-arrow { display: none; }
.row-arrow {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  color: #A3A3A3;
  transition: transform 0.15s ease, color 0.15s ease;
}

/* ----- Iframes (PDF preview) ----- */
iframe { border: 0; background: #FFFFFF; }

/* ----- Upload empty state ----- */
#upload-empty {
  transition: background 0.15s ease;
}
#upload-empty:hover { background: #F5F5F4; }
#upload-empty.dragover {
  background: #F5F5F4;
  outline: 1px dashed #0A0A0A;
  outline-offset: -1px;
}

/* Selection */
::selection { background: #0A0A0A; color: #FAFAF9; }

/* Focus */
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 1px solid #0A0A0A;
  outline-offset: 2px;
}

button#process-btn:disabled:hover { background-color: #0A0A0A !important; }

/* ----- Search filter row: animated widening when Range is active ----- */
@media (min-width: 768px) {
  #filter-row .filter-narrow,
  #filter-row .filter-wide {
    transition: flex-basis 0.28s cubic-bezier(0.2, 0.65, 0.3, 1);
  }
  #filter-row.range-mode .filter-narrow {
    flex-basis: 12.5%;   /* slimmer "All types" / "Any status" */
  }
  #filter-row.range-mode .filter-wide {
    flex-basis: 41.66%;  /* date filter grows to fit From + To */
  }
}

/* ----- Detail-page edit mode ----- */
.field-edit {
  display: none;
  width: 100%;
  padding: 4px 6px;
  border: 0;
  border-bottom: 1px solid #D4D4D4;
  background: transparent;
  color: #0A0A0A;
  outline: none;
}
.field-edit:focus { border-bottom-color: #0A0A0A; }
body.editing .field-view { display: none; }
body.editing .field-edit { display: inline-block; }

/* ----- Docs / Admin status progress bar ----- */
.progress-bar {
  position: relative;
  height: 14px;
  background: #F5F5F4;
  border: 1px solid #EAEAEA;
  overflow: hidden;
  min-width: 120px;
}
.progress-fill {
  height: 100%;
  transition: width 0.35s cubic-bezier(0.2, 0.65, 0.3, 1);
}
.progress-fill.bg-ink { background: #0A0A0A; }
.progress-fill.bg-err { background: #A03030; }
.progress-pct {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  color: #FAFAF9;
  mix-blend-mode: difference;
  letter-spacing: 0.02em;
}
.status-row.live    { background: #FAFAF9; }
.status-row.errored td { color: #A03030; }
.status-row.history td { color: #737373; }
