/* Additional CSS: product-prio-row, stepper, progress, switch, source-card, spinner */

.product-prio-row {
  display: grid;
  grid-template-columns: 110px 1fr 220px 14px;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 120ms var(--ease-out), background 120ms;
}
.product-prio-row:hover { border-color: var(--accent); background: var(--surface); }
.product-prio-row .sif { font-family: var(--font-mono); font-weight: 700; font-size: 12.5px; color: var(--text-muted); }
.product-prio-row .naziv { min-width: 0; }
.prio-bar-wrap {
  position: relative; height: 22px;
  background: var(--chip-bg); border-radius: 4px; overflow: hidden;
  display: flex; align-items: center;
}
.prio-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #8e5bff 100%);
  transition: width 400ms var(--ease-out);
}
.prio-val {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-weight: 700; font-size: 11.5px;
  color: var(--text);
  text-shadow: 0 0 4px var(--surface);
}

/* Stepper */
.stepper { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.step { display: flex; align-items: center; gap: 10px; color: var(--text-subtle); }
.step.active { color: var(--text); }
.step.done { color: var(--success); }
.step-num {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--chip-bg); color: var(--text-muted);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; font-family: var(--font-mono);
  border: 1.5px solid transparent;
}
.step.active .step-num { background: var(--accent); color: white; border-color: var(--accent); }
.step.done .step-num { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.step-label { font-size: 13px; font-weight: 600; }
.step-line { flex: 1; height: 2px; background: var(--border); border-radius: 2px; }
.step-line.done { background: var(--success); }

/* Progress */
.progress-bar {
  width: 100%; height: 6px;
  background: var(--chip-bg);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #8e5bff);
  transition: width 180ms var(--ease-out);
}

/* Source card */
.source-card {
  padding: 16px; border-radius: var(--r-md);
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  transition: border-color 120ms, background 120ms;
  position: relative;
}
.source-card:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.source-card.active { border-color: var(--accent); background: var(--accent-soft); }
.source-card.active::after {
  content: '✓'; position: absolute; top: 10px; right: 10px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: white; display: grid; place-items: center;
  font-size: 10px;
}

/* Card footer */
.card-footer { padding: 14px 18px; border-top: 1px solid var(--divider); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }

/* Switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 22px;
  transition: background 140ms var(--ease-out);
}
.switch .slider::before {
  content: ''; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background: white; border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform 140ms var(--ease-out);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* Spinner */
.spinner-sm {
  width: 14px; height: 14px;
  border: 1.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Store tag */
.store-tag {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 4px;
  background: var(--chip-bg);
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  color: var(--text-muted);
}

/* ==================== PIVOT: Bilans po dimenzijama ==================== */
.pivot-card { overflow: visible; }
.pivot-dims {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 14px 18px; border-bottom: 1px solid var(--divider);
  background: var(--surface-2);
}
.pivot-dims-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-subtle);
  margin-right: 4px;
}
.pivot-dim-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  cursor: pointer;
  transition: all 120ms var(--ease-out);
  font-family: inherit;
}
.pivot-dim-pill:hover { border-color: var(--accent); color: var(--text); }
.pivot-dim-pill.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.pivot-dim-ord {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255,255,255,0.25);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
}
.pivot-hierarchy-preview {
  margin-left: auto;
  font-size: 12px; font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 5px 10px; background: var(--chip-bg); border-radius: 4px;
}

.pivot-table { font-size: 12.5px; }
.pivot-table thead th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-subtle); font-weight: 700;
  padding: 10px 12px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.pivot-table tbody td {
  padding: 9px 12px; border-bottom: 1px solid var(--divider);
}
.pivot-table .dim-cell { min-width: 220px; }
.pivot-table .pivot-dim-value { font-weight: 600; color: var(--text); }
.pivot-chev {
  display: inline-grid; place-items: center;
  width: 16px; height: 16px; margin-right: 8px;
  font-size: 10px; color: var(--text-subtle);
  transition: transform 140ms var(--ease-out);
}
.pivot-chev.empty { opacity: 0; }
.pivot-data-row.expandable { cursor: pointer; }
.pivot-data-row.expandable:hover { background: var(--surface-hover); }
.pivot-data-row.open > .dim-cell .pivot-chev { transform: rotate(90deg); color: var(--accent); }
.pivot-data-row.depth-0 > .dim-cell .pivot-dim-value { font-weight: 700; }
.pivot-data-row.depth-1 > .dim-cell { color: var(--text-muted); }
.pivot-data-row.depth-2 > .dim-cell { color: var(--text-subtle); }
.pivot-data-row.depth-1 { background: color-mix(in srgb, var(--surface-2) 40%, transparent); }
.pivot-data-row.depth-2 { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.pivot-data-row.depth-3 { background: var(--surface-2); }

.pivot-table .pct-cell { white-space: nowrap; }
.pivot-table .pct-val { display: inline-block; min-width: 46px; font-family: var(--font-mono); }
.pivot-table .pct-val.strong { font-weight: 700; color: var(--text); }
.pivot-table .pct-bar {
  display: inline-block; height: 6px; border-radius: 2px;
  margin-left: 8px; vertical-align: middle;
  opacity: 0.75;
}
.pivot-totals-row {
  font-weight: 700; background: var(--surface-2);
  border-top: 2px solid var(--border);
}
.pivot-totals-row td {
  padding: 9px 12px; font-size: 12.5px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.pivot-totals-row td.num { font-family: var(--font-mono); letter-spacing: 0; text-transform: none; }

/* Product-page classic tables */
.prod-table-wrap { display: grid; gap: 16px; }
.prod-table-wrap .card-header .card-title {
  display: flex; align-items: center; gap: 10px;
}
.prod-table-wrap .table-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 4px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  font-family: var(--font-mono);
}
.prod-table-wrap .table-badge.pre { background: var(--chip-bg); color: var(--text-muted); }
.prod-table-wrap .table-badge.sales { background: var(--accent-soft); color: var(--accent); }
.prod-table-wrap .table-badge.post { background: rgba(18,185,129,0.14); color: var(--success); }
.prod-table-wrap .table-badge.xfer { background: rgba(245,158,11,0.14); color: var(--warning); }

.size-cell { font-family: var(--font-mono); font-weight: 600; }
.size-cell.zero { color: var(--text-subtle); opacity: 0.4; }
.size-cell.hole { color: var(--danger); background: rgba(239,68,68,0.10); }
.size-cell.improved { color: var(--success); font-weight: 700; }
.size-cell.worsened { color: var(--warning); }
.prod-sum-cell { font-family: var(--font-mono); font-weight: 700; background: var(--surface-2); }
.prod-table tbody tr:hover { background: var(--surface-hover); }
.prod-table th, .prod-table td {
  padding: 8px 10px; text-align: center;
  border-bottom: 1px solid var(--divider);
  font-size: 12.5px;
}
/* Fixed column widths so all 3 tables line up vertically */
.prod-table { table-layout: fixed; min-width: 720px; }
.prod-table col.col-obj { width: 90px; }
.prod-table col.col-size { width: 60px; }
.prod-table col.col-summary { width: 90px; }
.prod-table col.col-summary-wide { width: 90px; }
.prod-table th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-subtle); font-weight: 700;
  background: var(--surface-2);
  border-bottom: 1.5px solid var(--border);
}
.prod-table th:first-child, .prod-table td:first-child { text-align: left; }
.prod-table .obj-cell { font-family: var(--font-mono); font-weight: 700; white-space: nowrap; }
.prod-table .totals-row { background: var(--surface-2); font-weight: 700; }
.prod-table .totals-row td { border-top: 2px solid var(--border); }

/* Post-cell: value (delta) inline */
.size-cell .post-val { font-family: var(--font-mono); font-weight: 700; }
.size-cell .post-delta {
  margin-left: 4px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  opacity: 0.85;
}
.size-cell .post-delta.pos { color: var(--success); }
.size-cell .post-delta.neg { color: var(--warning); }
.size-cell.hole .post-delta.neg { color: var(--danger); }

/* Summary columns (Ukupno / SR / %) */
.prod-table th.summary-col { color: var(--accent); background: var(--accent-soft); }
.prod-table .sr-cell {
  font-family: var(--font-mono); font-weight: 600;
}
.prod-table .sr-cell.sr-good { background: rgba(18,185,129,0.18); color: var(--success); font-weight: 700; }
.prod-table .sr-cell.sr-mid { background: rgba(245,158,11,0.14); color: var(--warning); }
.prod-table .sr-cell.sr-bad { background: rgba(239,68,68,0.14); color: var(--danger); }
/* legacy */
.prod-table .sr-cell.sr-full { background: rgba(18,185,129,0.18); color: var(--success); font-weight: 700; }
.prod-table .sr-cell.sr-partial { background: rgba(245,158,11,0.12); color: var(--warning); }
.prod-table .sr-cell.sr-empty { background: var(--chip-bg); color: var(--text-subtle); }

.prod-table .pct-cell-num {
  font-family: var(--font-mono); font-weight: 600;
}

.prod-table .sr-promena-cell {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; padding: 6px 6px;
  flex-wrap: wrap;
}
.sr-pill {
  display: inline-flex; align-items: center;
  padding: 2px 6px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
}
.sr-pill.sr-good { background: rgba(18,185,129,0.20); color: var(--success); }
.sr-pill.sr-mid { background: rgba(245,158,11,0.16); color: var(--warning); }
.sr-pill.sr-bad { background: rgba(239,68,68,0.16); color: var(--danger); }
.sr-pill.sr-full { background: rgba(18,185,129,0.18); color: var(--success); }
.sr-pill.sr-partial { background: rgba(245,158,11,0.14); color: var(--warning); }
.sr-pill.sr-empty { background: var(--chip-bg); color: var(--text-subtle); }

.qty-delta-pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 5px 2px 4px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--border);
}
.qty-delta-pill.pos { color: var(--success); }
.qty-delta-pill.neg { color: var(--accent); }
.qty-delta-pill .qty-delta-bar {
  width: 3px; height: 12px; border-radius: 2px; display: inline-block;
  background: currentColor;
}

/* Share tab pct-bar (duplicate visual of pivot) */
.prod-table .share-pct-cell { white-space: nowrap; }
.prod-table .share-pct-val { display: inline-block; min-width: 46px; font-family: var(--font-mono); }
.prod-table .share-pct-val.strong { font-weight: 700; color: var(--text); }
.prod-table .share-pct-bar {
  display: inline-block; height: 6px; border-radius: 2px;
  margin-left: 8px; vertical-align: middle; opacity: 0.8;
}

/* Product thumb hover preview */
.thumb-hover-wrap { position: relative; }
.thumb-hover-preview {
  position: absolute;
  top: 50%; left: calc(100% + 10px);
  transform: translateY(-50%) scale(0.92);
  transform-origin: left center;
  opacity: 0; pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-pop, 0 16px 48px rgba(0,0,0,0.25));
  z-index: 50;
  transition: opacity 140ms var(--ease-out), transform 140ms var(--ease-out);
  width: 200px;
  overflow: hidden;
}
.thumb-hover-preview > div:first-child {
  width: 100% !important; height: 200px !important;
  border-radius: 0 !important;
  display: flex; align-items: center; justify-content: center;
}
.thumb-hover-wrap:hover .thumb-hover-preview {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* Date range row (new-analysis) */
.date-range-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr 1fr;
  gap: 10px; align-items: stretch;
}
.date-box {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px; border-radius: var(--r-md);
  border: 1.5px solid var(--border); background: var(--surface-2);
}
.date-box.input { border-color: var(--accent); background: var(--accent-soft); }
.date-box.computed { background: var(--surface); border-style: dashed; }
.date-box.span { background: var(--surface); }
.date-box-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-subtle);
}
.date-box-value {
  font-size: 17px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.date-box-value.mono { font-family: var(--font-mono); font-weight: 700; }
.date-box-input {
  font-size: 17px; font-weight: 600; color: var(--text);
  background: transparent; border: none; outline: none; padding: 0;
  font-family: inherit; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.date-box-input::-webkit-calendar-picker-indicator {
  cursor: pointer; opacity: 0.6; filter: invert(var(--cal-invert, 0));
}
[data-theme="dark"] .date-box-input { --cal-invert: 1; }
.date-box-arrow {
  display: grid; place-items: center;
  font-size: 20px; color: var(--text-subtle); font-weight: 300;
  align-self: center;
}

/* ==========================================================================
   App footer — diskretan brand link na dnu svake stranice
   ========================================================================== */
.app-footer {
  margin-top: auto;
  padding: 8px 32px 10px;
  display: flex; justify-content: center; align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--text-subtle);
  letter-spacing: 0.02em;
  border-top: 1px solid var(--divider);
}
.app-footer-link {
  color: var(--text-muted);
  font-weight: 600;
  text-decoration: none;
  transition: color 120ms ease;
}
.app-footer-link:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
