/* Indkøb tab — upload an ERP ItemPlanning export, show a per-IPN price overview.
   Every value comes from the shared design tokens in style.css (:root and its
   [data-theme="dark"] override), so this file needs no dark-mode rules of its own. */

.indkob-wrap { display: flex; flex-direction: column; gap: var(--gap-stack); }

.indkob-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}
.indkob-card h2 { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.indkob-sub { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; max-width: 720px; }

.indkob-dropzone {
  position: relative;
  margin-top: 12px;
  border: 2px dashed var(--border-strong, #c2c7cf);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .12s, background .12s;
  color: var(--text-muted);
}
.indkob-api-error-badge {
  position: absolute; top: 8px; right: 10px;
  background: var(--red-tint); color: var(--red);
  font-size: 0.68rem; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  cursor: help;
}
.indkob-dropzone:hover,
.indkob-dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-ink);
}
.indkob-dz-title { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.indkob-dz-sub { font-size: 0.74rem; color: var(--text-muted); margin-top: 4px; }

.indkob-filename {
  margin-top: 10px; font-size: 0.76rem; color: var(--text-2); font-family: var(--mono);
}
.indkob-error {
  margin-top: 10px; padding: 9px 13px; border-radius: var(--radius-sm); font-size: 0.78rem;
  background: var(--red-tint); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 30%, transparent);
}

.indkob-history { margin-top: 14px; }
.indkob-history-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin-bottom: 6px; }
.indkob-history-list { display: flex; flex-wrap: wrap; gap: 6px; }
.indkob-history-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text-2);
  padding: 6px 10px; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit;
  text-align: left; max-width: 240px;
}
.indkob-history-item:hover { border-color: var(--accent); }
.indkob-history-item.active { border-color: var(--accent); background: var(--accent-tint); }
.indkob-history-name {
  font-size: 0.76rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.indkob-history-meta { font-size: 0.66rem; color: var(--text-muted); }

.indkob-progress { margin-top: 14px; }
.indkob-progress-bar {
  height: 6px; border-radius: 3px; background: var(--surface3); overflow: hidden;
}
.indkob-progress-fill { height: 100%; background: var(--accent); transition: width .15s; }
.indkob-progress-label { margin-top: 6px; font-size: 0.74rem; color: var(--text-muted); }

/* ── Results ─────────────────────────────────────────────────────────────── */
.indkob-summary { display: flex; flex-wrap: wrap; gap: 16px; font-size: 0.8rem; color: var(--text-2); }
.indkob-summary b { color: var(--text); }
.indkob-sum-ok   { color: var(--green); }
.indkob-sum-flag { color: var(--yellow); }
.indkob-sum-miss { color: var(--text-muted); }
.indkob-sum-yellow { color: var(--yellow); }
.indkob-sum-lightred { color: color-mix(in srgb, var(--yellow) 40%, var(--red) 60%); }
.indkob-sum-severe { color: var(--red); }
.indkob-sum-lightgreen { color: color-mix(in srgb, var(--green) 70%, var(--text-muted) 30%); }
.indkob-sum-cheap { color: var(--green); }

.indkob-filters { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.indkob-filter-btn {
  border: 1px solid var(--border); background: var(--surface2); color: var(--text-2);
  font-size: 0.74rem; font-weight: 600; padding: 5px 10px; border-radius: 20px;
  cursor: pointer; font-family: inherit;
}
.indkob-filter-btn:hover { border-color: var(--accent); }
.indkob-filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.indkob-filter-count { opacity: 0.75; }

.indkob-table-wrap { margin-top: 12px; overflow-x: auto; }
.indkob-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; white-space: nowrap; }
.indkob-table thead th {
  text-align: left; padding: 8px 10px; font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted);
  border-bottom: 2px solid var(--border); cursor: pointer; user-select: none;
}
.indkob-table thead th:hover { color: var(--text); }
.indkob-table thead th.is-sorted { color: var(--accent-ink); }
.indkob-table tbody td { padding: 7px 10px; border-bottom: 1px solid var(--divider); }
.indkob-table tbody tr:hover td { background: var(--surface2); }
.indkob-table tbody tr.indkob-row-missing td { color: var(--text-faint); }

.indkob-td-ipn { font-family: var(--mono); }
.indkob-td-desc { white-space: normal; max-width: 320px; }
.indkob-td-num, .indkob-td-money { text-align: right; font-family: var(--mono); }
.indkob-td-status { color: var(--text-muted); font-size: 0.74rem; }

/* Tiered price-vs-kostpris flag: yellow -> light-red -> red as the found price climbs above
   SE Kostpris, light-green -> green as it drops below (see indkobPriceFlag in indkob.js for the
   10/30/50% boundaries). The "light" tiers use color-mix rather than a third pair of tokens. */
.indkob-flag-yellow { background: var(--yellow-tint); color: var(--yellow); font-weight: 700; }
.indkob-flag-light-red {
  background: color-mix(in srgb, var(--yellow-tint) 50%, var(--red-tint) 50%);
  color: color-mix(in srgb, var(--yellow) 40%, var(--red) 60%);
  font-weight: 700;
}
.indkob-flag-red { background: var(--red-tint); color: var(--red); font-weight: 700; }
.indkob-flag-light-green {
  background: color-mix(in srgb, var(--green-tint) 55%, transparent 45%);
  color: var(--green);
  font-weight: 700;
}
.indkob-flag-green { background: var(--green-tint); color: var(--green); font-weight: 700; }

.indkob-supplier-changed { background: var(--yellow-tint); color: var(--yellow); cursor: help; }

.indkob-td-num span[title] { cursor: help; border-bottom: 1px dotted var(--text-faint); }

.indkob-td-supplier a { color: var(--accent-ink); text-decoration: none; }
.indkob-td-supplier a:hover { text-decoration: underline; }

/* Whole row — Würth/Microchip parts must be hand-priced, never trusted from the automated search. */
.indkob-table tbody tr.indkob-row-manual td {
  background: var(--yellow-tint); color: var(--text);
}
.indkob-row-manual .indkob-td-status { color: var(--yellow); font-weight: 700; }

.indkob-merge-badge {
  display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 20px;
  background: var(--green-tint); color: var(--green);
  font-size: 0.64rem; font-weight: 700; vertical-align: middle; cursor: help;
}

.indkob-split-badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  background: var(--accent-tint); color: var(--accent-ink);
  font-size: 0.7rem; font-weight: 700; cursor: help;
}

.indkob-merges { margin-top: 14px; }
.indkob-merges-title { font-size: 0.78rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.indkob-merges-table { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.indkob-merges-table thead th {
  background: var(--surface2); border-bottom: 1px solid var(--border);
}
.indkob-savings { color: var(--green); font-weight: 700; }
