/* ── DS Design Tokens ──────────────────────────────────────── */
:root {
  --ds-bg:       #fafafa;
  --ds-surface:  #ffffff;
  --ds-ink:      #0a0a0a;
  --ds-ink2:     #171717;
  --ds-muted:    #737373;
  --ds-muted2:   #a3a3a3;
  --ds-line:     #e5e5e5;
  --ds-line2:    #f0f0f0;
  --ds-accent:   #0a0a0a;
  --ds-ok:       #16a34a;
  --ds-bad:      #dc2626;
  --ds-warn:     #ca8a04;
  --ds-ok-bg:    #f0fdf4;
  --ds-bad-bg:   #fef2f2;
  --ds-warn-bg:  #fefce8;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
}

body {
  height: 100%;
  background: var(--ds-bg);
  font-family: 'Geist', 'Inter', -apple-system, sans-serif;
  font-size: 13px;
  color: var(--ds-ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Top nav ───────────────────────────────────────────────── */
.ds-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  border-bottom: 1px solid var(--ds-line);
  background: var(--ds-surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.ds-topbar-left { display: flex; align-items: center; gap: 28px; }
.ds-brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.ds-brand-icon {
  width: 22px; height: 22px; border-radius: 5px;
  background: var(--ds-ink); color: #fff;
  display: grid; place-items: center;
  font-family: 'Geist Mono', monospace; font-weight: 700; font-size: 13px;
}
.ds-brand-name { font-weight: 600; font-size: 14px; color: var(--ds-ink); letter-spacing: -0.2px; }
.ds-brand-sub  { font-family: 'Geist Mono', monospace; font-size: 11px; color: var(--ds-muted); }

.ds-nav { display: flex; gap: 2px; }
.ds-nav-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; font-size: 13px; color: var(--ds-muted);
  text-decoration: none; border-radius: 6px; background: transparent;
}
.ds-nav-item:hover { background: var(--ds-line2); color: var(--ds-ink); }
.ds-nav-item.active { background: var(--ds-line2); color: var(--ds-ink); font-weight: 500; }
.ds-nav-item.disabled { pointer-events: none; opacity: 0.5; }

.ds-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ds-ink2); color: #fff;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
}

/* ── Page layout ───────────────────────────────────────────── */
/* main fills the viewport below the 53px topbar */
main {
  height: calc(100% - 53px);
  display: flex;
  flex-direction: column;
}

/* ds-page fills main; no overflow:hidden here — that would break position:sticky on ds-subheader */
.ds-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.ds-subheader {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--ds-line);
  background: var(--ds-surface);
  position: sticky; top: 53px; z-index: 10;
  flex-shrink: 0;
}
.ds-subheader-title { font-size: 14px; font-weight: 600; }
.ds-subheader-meta  { font-size: 11.5px; color: var(--ds-muted); font-family: 'Geist Mono', monospace; margin-top: 2px; }
.ds-spacer { flex: 1; }

.ds-search {
  display: flex; align-items: center; gap: 8px;
  flex: 1; max-width: 380px; margin: 0 16px;
  border: 1px solid var(--ds-line); border-radius: 6px;
  padding: 5px 10px; background: var(--ds-bg);
}
.ds-search input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 12.5px; color: var(--ds-ink); font-family: inherit;
}
.ds-search kbd {
  font-size: 10px; color: var(--ds-muted); font-family: 'Geist Mono', monospace;
  background: var(--ds-surface); padding: 1px 5px;
  border: 1px solid var(--ds-line); border-radius: 3px;
}

.ds-stats { display: flex; align-items: center; gap: 10px; }
.ds-progress { width: 72px; height: 4px; background: var(--ds-line2); border-radius: 2px; overflow: hidden; }
.ds-progress-fill { height: 100%; background: var(--ds-accent); border-radius: 2px; transition: width 400ms ease; }
.ds-stat-ok  { color: var(--ds-ok);  font-weight: 600; font-family: 'Geist Mono', monospace; }
.ds-stat-bad { color: var(--ds-bad); font-weight: 600; font-family: 'Geist Mono', monospace; }
.ds-divider  { width: 1px; height: 16px; background: var(--ds-line); }

/* ── Main grid ─────────────────────────────────────────────── */
.ds-main {
  display: grid;
  grid-template-columns: 1fr 0px;
  grid-template-rows: 1fr;
  transition: grid-template-columns 220ms ease;
  flex: 1;
  min-height: 0;
  overflow: hidden;  /* clips to ds-content scroll container */
}
.ds-main--open { grid-template-columns: 1fr 440px; }
.ds-content { padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0; overflow: auto; min-height: 0; }

/* ── Loading ───────────────────────────────────────────────── */
.ds-progress-card {
  padding: 18px 20px; background: var(--ds-surface);
  border: 1px solid var(--ds-line); border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.ds-spinner {
  width: 16px; height: 16px; border: 2px solid var(--ds-line2);
  border-top-color: var(--ds-ink); border-radius: 50%;
  animation: spin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Input panel ───────────────────────────────────────────── */
.ds-input-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px 8px 16px;
  background: var(--ds-surface); border: 1px solid var(--ds-line); border-radius: 8px;
  font-size: 12.5px;
}
.ds-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.ds-dot-ok { background: var(--ds-ok); }
.ds-mono  { font-family: 'Geist Mono', monospace; }

.ds-input-panel {
  background: var(--ds-surface); border: 1px solid var(--ds-line); border-radius: 8px; padding: 18px;
}
.ds-input-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.ds-input-label { font-size: 13px; font-weight: 600; }
.ds-input-hint  { font-size: 12px; color: var(--ds-muted); margin-top: 2px; }
.ds-textarea {
  width: 100%; resize: vertical; padding: 12px;
  font-family: 'Geist Mono', monospace; font-size: 12.5px; line-height: 1.6;
  color: var(--ds-ink); background: var(--ds-bg);
  border: 1px solid var(--ds-line); border-radius: 6px; outline: none;
}
.ds-textarea:focus { border-color: var(--ds-ink); }

/* ── Tabs ──────────────────────────────────────────────────── */
.ds-tabs {
  display: flex; gap: 2px; margin-bottom: 14px;
  border-bottom: 1px solid var(--ds-line); padding-bottom: 0;
}
.ds-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; font-size: 12.5px; font-weight: 500;
  color: var(--ds-muted); background: transparent; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  cursor: pointer; font-family: inherit; transition: color 100ms;
}
.ds-tab:hover { color: var(--ds-ink2); }
.ds-tab--active { color: var(--ds-ink); border-bottom-color: var(--ds-ink); }
.ds-tab-body { padding: 2px 0 4px; }

/* ── Buttons ───────────────────────────────────────────────── */
.ds-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; font-size: 12px; font-weight: 500;
  color: var(--ds-ink2); background: var(--ds-surface);
  border: 1px solid var(--ds-line); border-radius: 6px;
  cursor: pointer; font-family: inherit;
  transition: background 100ms, border-color 100ms;
  white-space: nowrap;
}
.ds-btn:hover { background: var(--ds-line2); }
.ds-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ds-btn-primary {
  color: #fff; background: var(--ds-ink); border-color: var(--ds-ink);
}
.ds-btn-primary:hover { background: #262626; border-color: #262626; }

/* ── Category chips ────────────────────────────────────────── */
.ds-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ds-chips-label {
  font-size: 11px; color: var(--ds-muted);
  text-transform: uppercase; letter-spacing: 0.6px; margin-right: 4px;
}
.ds-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; font-size: 12px; font-weight: 500;
  color: var(--ds-muted); background: transparent;
  border: 1px solid var(--ds-line); border-radius: 999px;
  cursor: pointer; font-family: inherit;
  transition: all 100ms;
}
.ds-chip--on { color: var(--ds-ink); background: var(--ds-surface); border-color: var(--ds-ink); }
.ds-chip-count { font-family: 'Geist Mono', monospace; font-size: 10.5px; color: var(--ds-muted); }

/* ── Table ─────────────────────────────────────────────────── */
.ds-table-wrap {
  background: var(--ds-surface); border: 1px solid var(--ds-line);
  border-radius: 8px; overflow: hidden;
}
.ds-table-info {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--ds-line);
  font-size: 12.5px; color: var(--ds-muted);
}
.ds-table-info strong { color: var(--ds-ink); }
.ds-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
  table-layout: fixed;
}
.ds-table th {
  text-align: left; padding: 10px 14px;
  font-size: 10.5px; font-weight: 500; color: var(--ds-muted);
  text-transform: uppercase; letter-spacing: 0.6px;
  background: var(--ds-bg); border-bottom: 1px solid var(--ds-line);
  white-space: nowrap;
}
.ds-table td { padding: 8px 14px; border-bottom: 1px solid var(--ds-line2); vertical-align: middle; }
.ds-row { cursor: pointer; transition: background 80ms; }
.ds-row:hover td { background: #f7f7f7; }
.ds-row--open td { background: var(--ds-bg); }
.ds-row--open td:first-child { box-shadow: inset 3px 0 0 var(--ds-accent); }
.ds-cell-img { width: 72px; padding: 4px 8px !important; }
.ds-product-img {
  width: 60px; height: 40px; object-fit: contain; border-radius: 4px;
  border: 1px solid var(--ds-line); background: #fff; display: block;
}
.ds-product-img-ph {
  width: 60px; height: 40px; border-radius: 4px;
  border: 1px solid var(--ds-line); background: var(--ds-line2);
  display: flex; align-items: center; justify-content: center;
  color: var(--ds-muted2);
}
.ds-cell-erp { width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ds-muted); font-size: 12px; }
.ds-cell-ean { width: 135px; white-space: nowrap; }
.ds-cell-name { min-width: 200px; overflow: hidden; }
.ds-cell-conf { width: 110px; white-space: nowrap; }
.ds-cell-cat  { width: 193px; white-space: nowrap; }
.ds-cell-status { width: 120px; white-space: nowrap; }
.ds-cell-chev { width: 28px; text-align: center; color: var(--ds-muted2); }

.ds-ean { font-family: 'Geist Mono', monospace; font-size: 12px; color: var(--ds-ink2); letter-spacing: 0.2px; }
.ds-name-primary { font-weight: 500; color: var(--ds-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-name-desc { font-size: 11px; color: var(--ds-muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-alt-badge {
  margin-left: 8px; font-size: 10.5px; color: var(--ds-muted);
  font-family: 'Geist Mono', monospace; font-weight: 500;
  padding: 1px 6px; border: 1px solid var(--ds-line); border-radius: 3px;
  white-space: nowrap;
}

/* Confidence bar */
.ds-conf { display: inline-flex; align-items: center; gap: 8px; }
.ds-conf-pct { font-family: 'Geist Mono', monospace; font-size: 12px; font-weight: 500; min-width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.ds-conf-track { position: relative; width: 48px; height: 4px; background: var(--ds-line2); border-radius: 2px; }
.ds-conf-fill  { position: absolute; inset: 0; border-radius: 2px; }

/* Tag */
.ds-tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; font-size: 11px; font-weight: 500;
  color: var(--ds-ink2); background: var(--ds-line2);
  border: 1px solid var(--ds-line); border-radius: 999px;
  white-space: nowrap;
}

/* Status segmented */
.ds-status-seg { display: inline-flex; border: 1px solid var(--ds-line); border-radius: 6px; overflow: hidden; background: var(--ds-surface); }
.ds-status-btn {
  width: 32px; height: 26px; border: none; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; background: var(--ds-surface); color: var(--ds-muted2);
  transition: background 100ms, color 100ms;
}
.ds-status-btn + .ds-status-btn { border-left: 1px solid var(--ds-line); }
.ds-status-btn--ok  { background: var(--ds-ok-bg);  color: var(--ds-ok); }
.ds-status-btn--bad { background: var(--ds-bad-bg); color: var(--ds-bad); }
.ds-status-btn--def { background: var(--ds-line2);  color: var(--ds-muted); }

/* ── Drawer ────────────────────────────────────────────────── */
.ds-drawer {
  background: var(--ds-surface); border-left: 1px solid var(--ds-line);
  display: flex; flex-direction: column; overflow: hidden;
  min-height: 0;
}
.ds-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--ds-line);
  background: var(--ds-surface); position: sticky; top: 0; z-index: 1;
  flex-shrink: 0;
}
.ds-drawer-label { font-size: 10.5px; color: var(--ds-muted); text-transform: uppercase; letter-spacing: 0.6px; }
.ds-drawer-title { font-size: 14px; font-weight: 600; color: var(--ds-ink); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-drawer-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.ds-cand-header-label { font-size: 11px; color: var(--ds-muted); text-transform: uppercase; letter-spacing: 0.6px; }

.ds-candidate {
  padding: 14px; background: var(--ds-surface);
  border: 1.5px solid var(--ds-line); border-radius: 8px; cursor: pointer;
  transition: border-color 120ms;
}
.ds-candidate:hover { border-color: var(--ds-muted2); }
.ds-candidate--chosen { background: var(--ds-bg); border-color: var(--ds-accent); }
.ds-cand-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.ds-cand-rank {
  font-size: 10px; font-weight: 600; color: var(--ds-muted);
  font-family: 'Geist Mono', monospace;
  padding: 1px 5px; border: 1px solid var(--ds-line); border-radius: 3px;
}
.ds-cand-name { font-size: 13.5px; font-weight: 600; color: var(--ds-ink); margin-bottom: 2px; }
.ds-cand-desc { font-size: 11.5px; color: var(--ds-muted); margin-bottom: 8px; }
.ds-cand-ean  { font-size: 11px; margin-bottom: 8px; }
.ds-cand-attrs {
  display: flex; flex-wrap: wrap; gap: 3px 12px;
  padding-top: 8px; border-top: 1px solid var(--ds-line2); font-size: 11px;
}
.ds-attr-name { color: var(--ds-muted); }
.ds-attr-val  { color: var(--ds-ink2); font-weight: 500; }
.ds-chosen-mark { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--ds-line2); font-size: 11px; font-weight: 500; color: var(--ds-ok); }

.ds-comment-section { display: flex; flex-direction: column; gap: 6px; }
.ds-drawer-hint {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px; border: 1px dashed var(--ds-line); border-radius: 6px;
  font-size: 11.5px; color: var(--ds-muted);
}

/* ── Allegro publishing animation ─────────────────────────── */
@keyframes al-cw     { to { transform: rotate(360deg);  } }
@keyframes al-ccw    { to { transform: rotate(-360deg); } }
@keyframes al-wrench {
  0%,100% { transform: rotate(-20deg); }
  50%     { transform: rotate(20deg);  }
}
@keyframes al-spark {
  0%   { opacity:1; transform:scale(.4) translate(0,0); }
  100% { opacity:0; transform:scale(1)  translate(var(--sx,12px),var(--sy,-16px)); }
}
@keyframes al-shimmer {
  0%   { background-position:-200% center; }
  100% { background-position: 200% center; }
}
@keyframes al-fadein { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }
@keyframes al-bar    { from { width:0%; } }

/* Gears — applied directly via style attr for reliable transform-origin */
.al-gear { display:block; flex-shrink:0; }

/* Sparks container */
.al-sparks { position:relative; width:12px; height:12px; margin:0 2px; }
.al-spark  {
  position:absolute; top:50%; left:50%;
  width:5px; height:5px; border-radius:50%; background:#ffcc00;
  animation:al-spark .8s ease-out infinite;
}
.al-spark:nth-child(2) { animation-delay:.27s; --sx:-10px; --sy:-12px; }
.al-spark:nth-child(3) { animation-delay:.54s; --sx:14px;  --sy:-8px;  }

/* Labels */
.al-title {
  font-size:13px; font-weight:700;
  background:linear-gradient(90deg,#ff5a00,#ff9040,#ff5a00);
  background-size:200%;
  -webkit-background-clip:text; -webkit-text-fill-color:transparent;
  animation:al-shimmer 2.2s linear infinite;
}
.al-product { font-size:12px; font-weight:500; color:var(--ds-ink2);
              animation:al-fadein .3s ease; white-space:nowrap;
              overflow:hidden; text-overflow:ellipsis; max-width:340px; margin:4px 0 2px; }
.al-step    { font-size:11.5px; color:#ff5a00; display:flex; align-items:center;
              justify-content:center; gap:5px; animation:al-fadein .3s ease; }
.al-counter { font-size:11px; color:var(--ds-muted); font-family:'Geist Mono',monospace; margin:6px 0 3px; }
.al-progress-bar  { height:4px; background:var(--ds-line2); border-radius:2px; overflow:hidden; }
.al-progress-fill { height:100%; background:linear-gradient(90deg,#ff5a00,#ffaa55);
                    border-radius:2px; transition:width .5s ease; animation:al-bar .5s ease; }

/* ── Modal ─────────────────────────────────────────────────── */
.ds-modal-backdrop {
  position: fixed !important;
  top: 0 !important; left: 0 !important;
  width: 100% !important; height: 100% !important;
  background: rgba(0, 0, 0, 0.6);
  display: flex !important; align-items: center !important; justify-content: center !important;
  z-index: 9999 !important;
  overflow: hidden;
}
.ds-modal {
  background: var(--ds-surface); border: 1px solid var(--ds-line);
  border-radius: 10px; width: 480px; max-width: calc(100% - 32px);
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
  display: flex; flex-direction: column;
  max-height: 90vh; overflow-y: auto;
  transition: width .25s ease;
}
/* Publishing: +25% */
.ds-modal--publishing { width: 600px; }
.ds-modal--wide      { width: 620px; }
/* Done / results: +50% szerokości względem bazowej */
.ds-modal--done { width: 1080px; }
.ds-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--ds-line);
}
.ds-modal-body  { padding: 18px 20px; display: flex; flex-direction: column; gap: 0; }
.ds-modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--ds-line);
}

/* ── Blazor error UI (preserve) ────────────────────────────── */
#blazor-error-ui {
  background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2);
  display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.blazor-error-boundary {
  background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbmsiPjxwYXRoIGQ9Ik0yNjMuNTA2IDUxQzI2NC43MTcgNTEgMjY1LjgxMyA1MS40ODM3IDI2Ni42MDYgNTIuMjY1OEwyNjcuMDUyIDUyLjc5ODcgMjY3LjUzOSA1My42MjgzIDI5MC4xODUgOTIuMTgzMSAyOTAuNTQ1IDkyLjc5NSAyOTAuNjU2IDkyLjk5NkMyOTAuODc3IDkzLjUxMyAyOTEgOTQuMDgxNSAyOTEgOTQuNjc4MiAyOTEgOTcuMDY1MSAyODkuMDM4IDk5IDI4Ni42MTcgOTlMMjQwLjM4MyA5OUMyMzcuOTYzIDk5IDIzNiA5Ny4wNjUxIDIzNiA5NC42NzgyIDIzNiA5NC4zNzk5IDIzNi4wMzEgOTQuMDg4NiAyMzYuMDg5IDkzLjgwNzJMMjM2LjMzOCA5My4wMTYyIDIzNi44NTggOTIuMTMxNCAyNTkuNDczIDUzLjYyOTQgMjU5Ljk2MSA1Mi43OTg1IDI2MC40MDcgNTIuMjY1OEMyNjEuMiA1MS40ODM3IDI2Mi4yOTYgNTEgMjYzLjUwNiA1MVoiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==) no-repeat 1rem/1.8rem, #b32121;
  padding: 1rem 1rem 1rem 3.7rem; color: white;
}
.blazor-error-boundary::after { content: "An error has occurred."; }
