:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f3f4f7;
  --panel-3: #e9ebf0;
  --text: #1a1d23;
  --text-soft: #3c4250;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-soft: #eff4ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --err: #dc2626;
  --err-soft: #fef2f2;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
}

/* Pink theme — accents become #EB27C2 with subtle pink tint in surfaces.
   Status colors (ok/warn/err) stay semantic. */
[data-theme="pink"] {
  --bg: #FDF7FB;
  --panel: #ffffff;
  --panel-2: #FAF1F7;
  --panel-3: #F3E1ED;
  --accent: #EB27C2;
  --accent-2: #C71FA1;
  --accent-soft: #FDEBF8;
  --border: #EFE0EA;
  --border-strong: #DFC9D6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.app-sidebar {
  width: 270px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 4px 8px 12px;
  border-bottom: 1px solid var(--border);
}
.brand-logo {
  display: block;
  width: 100%;
  aspect-ratio: 1178 / 589;
  background-color: var(--logo-color, #1a1d23);
  -webkit-mask: url(/logo.png) center / contain no-repeat;
          mask: url(/logo.png) center / contain no-repeat;
}
[data-theme="pink"] .brand-logo {
  background-color: var(--accent);
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: 0 0 32px;
}

.app-header {
  padding: 22px 36px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.app-header h1 { margin: 0 0 2px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.app-header p { margin: 0; }
.app-header-actions { display: flex; gap: 8px; align-items: center; }
.header-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.header-icon-btn:hover {
  background: var(--panel-2);
  border-color: var(--accent, #4f46e5);
}
.header-icon-btn.active {
  background: var(--accent, #4f46e5);
  border-color: var(--accent, #4f46e5);
  color: #ffffff;
}
.header-icon { font-size: 14px; }
.header-icon-label { font-size: 12.5px; }
/* Daniel 2026-05-25: button "Co tu jest?" + rozwijany panel z pełną narracją zakładki. */
.page-heading-help-btn {
  display: inline-block;
  margin-left: 10px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 500;
  color: #6366f1;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.page-heading-help-btn:hover {
  background: #c7d2fe;
  color: #4338ca;
}
.page-heading-help-btn.expanded {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}
.page-heading-help-panel {
  margin: 10px 0 16px;
  padding: 14px 18px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-left: 4px solid #6366f1;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.55;
  color: #1f2937;
  max-width: 900px;
}
.page-heading-help-panel p { margin: 4px 0 8px; }
.page-heading-help-panel p:last-child { margin-bottom: 0; }
.page-heading-help-panel strong { color: #4338ca; }
.page-heading-help-panel code {
  background: #ede9fe;
  color: #5b21b6;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.page-heading-help-panel em { color: #6b21a8; }
/* Daniel 2026-05-25: badge nieprzeczytanych odpowiedzi na buttonie "Wysłane maile". */
.header-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #dc2626;
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 2px;
}
.header-icon-btn.active .header-icon-badge {
  background: #fff;
  color: var(--accent, #4f46e5);
}
/* Dynamiczny nagłówek "GRUPA > opis" — grupa wyróżniona kolorem akcentu. */
#page-heading-group {
  color: var(--accent, #4f46e5);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 16px;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
#page-heading-label {
  color: var(--text);
  font-weight: 500;
  font-size: 18px;
  vertical-align: middle;
}
#page-heading .muted {
  font-size: 16px;
  margin: 0 4px;
  vertical-align: middle;
}

.muted { color: var(--muted); font-size: 13px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 12px 36px;
  padding: 22px 26px;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: -0.005em;
}

.card-compact { padding: 14px 22px; }
.card-compact h2 { margin: 0; }

.upload-row {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.upload-row form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.upload-row input[type=file] { margin-right: 0; flex: 1; min-width: 0; }

.row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.filters input[type=search],
.filters input[type=date],
.filters select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  font: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.filters input[type=search] { min-width: 180px; flex: 1 1 180px; max-width: 280px; }
.filters input[type=date] { color-scheme: light; }
.filters select {
  max-width: 170px;
  text-overflow: ellipsis;
  padding-right: 22px;  /* miejsce na strzałkę */
}
.filters input[type=search]:focus,
.filters input[type=date]:focus,
.filters select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.filters select { cursor: pointer; }
.filters #count { margin-left: auto; color: var(--muted); font-size: 12px; }

.filter-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 10px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.filter-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.filter-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.filter-group input[type=date] {
  background: transparent;
  border: 0;
  padding: 3px 0;
  font-size: 12px;
  color: var(--text);
  outline: none;
  color-scheme: light;
  min-width: 100px;
  box-shadow: none;
}
.filter-group input[type=date]:focus { box-shadow: none; }
.filter-dash { color: var(--muted-2); font-size: 12px; }

button {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 8px 14px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, transform 0.06s;
  box-shadow: var(--shadow-sm);
}
button:hover { background: var(--accent-2); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

button.ghost {
  background: var(--panel);
  color: var(--text-soft);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
button.ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--panel-2);
}

mark.hl {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

input[type=file] {
  background: var(--panel-2);
  color: var(--text);
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-right: 8px;
  font: inherit;
  font-size: 13px;
}

.output {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  color: var(--text-soft);
  max-height: 220px;
  overflow: auto;
}
.output:empty { display: none; }

.shoper-status {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-soft);
}
.shoper-status.progress {
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background: var(--accent-soft);
  color: var(--accent);
}
.shoper-status.ok {
  border-color: rgba(5, 150, 105, 0.3);
  background: var(--ok-soft);
  color: var(--ok);
}
.shoper-status.warn {
  border-color: rgba(180, 83, 9, 0.3);
  background: var(--warn-soft);
  color: var(--warn);
}
.shoper-status.error {
  border-color: rgba(220, 38, 38, 0.3);
  background: var(--err-soft);
  color: var(--err);
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

/* Per-column compaction — keeps most text readable, truncates long values
   with ellipsis (tooltip via title shows the full value). */
#returns-table { table-layout: auto; }
#returns-table td.cell-truncate,
#returns-table th.col-truncate {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#returns-table td.cell-date,
#returns-table th.col-narrow { white-space: nowrap; }

@media (max-width: 1500px) {
  th, td { padding: 7px 8px; font-size: 12px; }
  thead th { font-size: 11px; }
  .badge { font-size: 10px; padding: 2px 7px; }
  .btn-save { font-size: 10px; padding: 4px 8px; }
  .nrb-input { font-size: 11px; min-width: 160px; }
}

@media (max-width: 1300px) {
  th, td { padding: 6px 7px; }
  .card { margin: 10px 16px; padding: 16px 18px; }
  .app-header { padding: 18px 16px 6px; }
  .app-sidebar { width: 230px; padding: 18px 12px; }
}

thead th {
  color: var(--muted);
  font-weight: 600;
  background: var(--panel-2);
  position: sticky;
  top: 0;
  z-index: 5;
  font-size: 12px;
  letter-spacing: 0;
  border-bottom: 1px solid var(--border-strong);
  box-shadow: 0 1px 0 var(--border);
  line-height: 1.25;
  vertical-align: bottom;
  max-width: 110px;
}

tbody tr { transition: background 0.08s; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
  text-align: center;
}
.badge.pending { background: var(--warn-soft); color: var(--warn); border-color: rgba(180, 83, 9, 0.18); }
.badge.done { background: var(--ok-soft); color: var(--ok); border-color: rgba(5, 150, 105, 0.18); }
.badge.error { background: var(--err-soft); color: var(--err); border-color: rgba(220, 38, 38, 0.18); }
.badge.skip { background: var(--panel-2); color: var(--muted); border-color: var(--border); }
.badge.todo { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 18%, transparent); }
.badge.action-required {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: rgba(180, 83, 9, 0.3);
  font-weight: 700;
}

tr.dim td { color: var(--muted); }

td.amount {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: center;
}
th.col-amount { text-align: center; }
td.amount .ccy { color: var(--muted); font-weight: 400; margin-left: 4px; font-size: 11px; }
td.amount .pln { display: block; color: var(--muted); font-weight: 400; font-size: 11px; margin-top: 1px; }
td.error-msg { color: var(--err); font-size: 11px; max-width: 240px; }

.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

tbody tr { cursor: pointer; }
tr.row-active td {
  background: var(--accent-soft);
  border-bottom-color: transparent;
}

/* Inline-expanded detail row */
tr.row-expand { cursor: default; }
tr.row-expand td {
  padding: 0;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border-strong);
}
tr.row-expand .expand-content {
  padding: 18px 22px 22px;
  /* Let the page scroll naturally — no inner scrollbar inside the drawer.
     Otherwise BOK has to scroll twice (page + drawer), which is annoying. */
}
tr.row-expand .drawer-section { margin-bottom: 16px; }

/* Sąsiadujące zwroty z tym samym order_id — wizualne pogrupowanie ramką w kolorze
   akcentu + lekkim tłem. Tworzy "kartę" obejmującą wszystkie rzędy danego zamówienia. */
tr.order-group td {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
tr.order-group:hover td {
  background: color-mix(in srgb, var(--accent) 11%, transparent);
}
tr.order-group td:first-child {
  border-left: 3px solid var(--accent);
}
tr.order-group td:last-child {
  border-right: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
}
tr.order-group-first td {
  border-top: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
}
tr.order-group-first td:first-child {
  border-top-left-radius: 6px;
}
tr.order-group-first td:last-child {
  border-top-right-radius: 6px;
}
tr.order-group-last td {
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
}
tr.order-group-last td:first-child {
  border-bottom-left-radius: 6px;
}
tr.order-group-last td:last-child {
  border-bottom-right-radius: 6px;
}
/* Inside the group, drop the default cell border-bottom between members
   so the frame reads as one continuous box. */
tr.order-group:not(.order-group-last) td {
  border-bottom-color: transparent;
}

.expand-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.expand-header h3 { margin: 0 0 2px; font-size: 14px; font-weight: 700; }
.expand-header .muted { font-size: 12px; }

.expand-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 22px;
  align-items: start;
}
.expand-grid .drawer-section { margin-bottom: 14px; }
.expand-grid .drawer-section:last-child { margin-bottom: 0; }
@media (max-width: 1100px) {
  .expand-grid { grid-template-columns: 1fr; gap: 14px; }
}

.expand-col-left { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.expand-col-right { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; min-width: 0; }
.expand-col-left .kv {
  row-gap: 5px;
  font-size: 12px;
  grid-template-columns: max-content minmax(0, 1fr);
}
.expand-col-left .kv dd { min-width: 0; }
.expand-col-left h4 { margin-top: 12px; }
.expand-col-left h4:first-child { margin-top: 0; }

.csv-raw-details {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
}
.csv-raw-details summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 0;
}
.csv-raw-details[open] summary { margin-bottom: 8px; }
.csv-kv {
  font-size: 12px;
  grid-template-columns: 200px 1fr;
  row-gap: 4px;
  column-gap: 12px;
}

.email-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.email-section h4 {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.email-history-item {
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
}
.email-history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.email-history-row a {
  color: var(--accent);
  text-decoration: none;
  font-size: 11px;
  margin-left: auto;
}
.email-history-row a:hover { text-decoration: underline; }
.email-compose-btn { background: var(--accent); }

/* Product thumbnails in detail view */
.product-thumb {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel);
  display: block;
}
.product-thumb-empty {
  display: inline-block;
  width: 38px;
  height: 38px;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: 4px;
}
.products-table td:first-child { width: 46px; padding: 4px 6px; }
tr.row-pulse td { animation: pulse 0.7s ease; }
@keyframes pulse {
  0% { background: color-mix(in srgb, var(--accent) 0%, transparent); }
  40% { background: color-mix(in srgb, var(--accent) 12%, transparent); }
  100% { background: transparent; }
}

[hidden] { display: none !important; }

.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.32);
  z-index: 50;
  animation: fade-in 0.15s ease;
  backdrop-filter: blur(2px);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(720px, 92vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 51;
  display: flex;
  flex-direction: column;
  animation: slide-in 0.2s ease;
}
@keyframes slide-in { from { transform: translateX(100%); } to { transform: none; } }

.drawer-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.drawer-header h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.drawer-header p { margin: 0; }
.drawer-body { padding: 20px 24px 36px; overflow-y: auto; flex: 1; }

.drawer-section { margin-bottom: 24px; }
.drawer-section h4 {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.kv {
  display: grid; grid-template-columns: max-content 1fr;
  column-gap: 16px; row-gap: 8px; font-size: 13px;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.kv dd code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.products-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.products-table th, .products-table td {
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border);
}
.products-table th { color: var(--muted); font-weight: 600; }
.products-table tr.unmatched td { color: var(--err); }
.products-table .num { text-align: right; font-variant-numeric: tabular-nums; }
/* Daniel 2026-05-17: stłumione produkty "pozostałe z zamówienia" w widoku magazyn
   (zwroty source='magazyn'). Pokazujemy je pod divider-row, jako kompaktowy ogon. */
.products-table tr.row-secondary td {
  color: var(--muted);
  background: #fafbfc;
  padding-top: 4px; padding-bottom: 4px;
}
.products-table tr.row-secondary .product-thumb { opacity: 0.6; }
.products-table tr.row-secondary .ean-badge { opacity: 0.7; }
.products-table tr.divider-row td { border-bottom: none; }

/* Daniel 2026-05-17: client-hint-badge — sugestia że klient zaznaczył ten produkt
   w formularzu klient.html. Wyświetlana tylko dla zwrotów "w drodze" (nie tknięte
   przez magazyn). To HINT — checkbox NIE jest auto-zaznaczony. */
.client-hint-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
  vertical-align: middle;
  cursor: help;
  white-space: nowrap;
}
.products-table tr.row-client-hinted {
  box-shadow: inset 3px 0 0 #93c5fd;
}

/* Sibling badge — produkt w innym zwrocie tego samego zamówienia. */
.sibling-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  vertical-align: middle;
}
.sibling-badge a { color: inherit; }
.products-table tr.row-in-sibling.row-secondary td { background: #f0fdf4; }
/* Produkty zablokowane bo są w innym zwrocie — kursor not-allowed, checkbox/qty mają
   wbudowane disabled, ale dodajemy wizualną klarowność (mniejsza opacity całego wiersza). */
.products-table tr.row-locked-sibling td { opacity: 0.75; }
.products-table tr.row-locked-sibling input[type="checkbox"][disabled],
.products-table tr.row-locked-sibling input[type="number"][disabled] {
  cursor: not-allowed;
}

.callout {
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.callout.error { border-color: rgba(220, 38, 38, 0.3); background: var(--err-soft); color: var(--err); }
.callout.warn { border-color: rgba(180, 83, 9, 0.3); background: var(--warn-soft); color: var(--warn); }
.callout pre { margin: 6px 0 0; white-space: pre-wrap; font-size: 11px; }

.progress-bar {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
  margin: 4px 0 0; min-width: 220px;
}
.progress-bar > span { display: block; height: 100%; background: var(--accent); transition: width 0.15s linear; }
.progress-text { font-size: 11px; color: var(--muted); margin-top: 4px; }

.confirm-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.confirm-header { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.confirm-header h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.confirm-header p { margin: 0; font-size: 12px; }
.confirm-body { padding: 18px 24px; max-height: 60vh; overflow-y: auto; }
.confirm-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 0 0 12px 12px;
}
.confirm-modal .summary-line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.confirm-modal .summary-line .muted { font-weight: 400; }
.confirm-modal .summary-line strong { font-variant-numeric: tabular-nums; }

/* ---- Zwrot łączny — okno wyboru zwrotów ---- */
.combine-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.combine-item {
  display: grid;
  grid-template-columns: 18px auto 1fr 1.3fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  background: var(--panel);
}
.combine-item:hover { border-color: var(--border-strong); }
.combine-item input.combine-check { margin: 0; cursor: pointer; }
.combine-item .combine-id {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.combine-primary-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 4px;
}
.combine-item .combine-type {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.combine-item .combine-products {
  color: var(--text);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.combine-item .combine-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}
.combine-item .combine-open-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  justify-self: end;
}
.combine-item .combine-open-link:hover { text-decoration: underline; }
.combine-item .combine-reason {
  grid-column: 2 / -1;
  color: var(--err);
  font-size: 11px;
}
.combine-item-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--bg);
}
.combine-item-disabled:hover { border-color: var(--border); }
.combine-item-disabled .combine-open-link { cursor: pointer; }
/* Zwrot, z którego otwarto okno — wyróżniony kolorem + strzałką */
.combine-item-primary {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.combine-item-primary:hover { border-color: var(--accent); }
.combine-primary-arrow {
  color: var(--accent);
  font-weight: 700;
}
.combine-sum-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.btn-save {
  background: var(--accent);
  border: 0;
  color: white;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.btn-save:hover { background: var(--accent-2); }
.btn-save:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.saved-indicator {
  font-size: 11px;
  color: var(--ok);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
a.saved-indicator { text-decoration: none; }
.saved-indicator:hover {
  background: color-mix(in srgb, var(--ok) 22%, transparent);
  border-color: color-mix(in srgb, var(--ok) 50%, transparent);
}

.nrb-input {
  width: 100%;
  min-width: 200px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.nrb-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.nrb-input:disabled { opacity: 0.6; }
.drawer-nrb-input { min-width: 0 !important; }

.histogram { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.histogram h4 { margin: 0 0 6px; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.histogram ul { list-style: none; padding: 0; margin: 0; font-size: 12px; }
.histogram li { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed var(--border); }
.histogram li code { background: transparent; color: var(--text); border: 0; padding: 0; }
.histogram .n { color: var(--muted); font-variant-numeric: tabular-nums; }

.tabs-vertical {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
}
/* Daniel 2026-05-25: HTML5 hidden attribute musi nadpisywać display:flex z .tabs-vertical.
   Bez tego quickFiltersEl.hidden = true nie schowało elementu (flex nadpisywał none). */
.tabs-vertical[hidden] { display: none; }
.tabs-vertical::before {
  content: 'Workflow';
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
  padding: 0 12px 8px;
}
.tabs-vertical.quick-filters {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.tabs-vertical.quick-filters::before {
  content: 'Szybkie filtry';
}
.tabs-vertical.other-views {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.tabs-vertical.other-views::before {
  content: 'Inne';
}
/* Group header — System / WayTo nagłówki w sidebar Workflow.
   Daniel 2026-05-25: graficzne rozdzielenie System vs Wayto żeby Marta nie myliła grup.
   System = cyan/turquoise (świeży nowy), Wayto = bursztynowy (legacy). Niezależne od
   różowej skórki — różowy zostaje jako --accent dla aktywnego taba. */
.tabs-vertical .tab-group-header {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-left-width: 4px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  margin-top: 14px;
  border-radius: 6px;
  transition: background 0.15s, border-color 0.15s;
}
.tabs-vertical .tab-group-header:first-of-type {
  margin-top: 0;
}
.tabs-vertical .tab-group-header:hover {
  background: #f3f4f6;
}

/* SYSTEM — cyan/teal akcent (świeży nowy workflow z klient.html + magazyn). */
.tabs-vertical .tab-group-header[data-group-key="system"] {
  border-left-color: #0891b2;
}
.tabs-vertical .tab-group-header[data-group-key="system"] .tab-group-label {
  color: #0e7490;
}
.tabs-vertical .tab-group-header[data-group-key="system"].active-source {
  background: linear-gradient(90deg, #cffafe 0%, #f0fdfa 100%);
  border-left-color: #0891b2;
  border-color: #67e8f9;
}
.tabs-vertical .tab-group-header[data-group-key="system"].active-source .tab-group-label {
  color: #155e75;
}

/* WAYTO — bursztynowy akcent (legacy CSV import ze starego Completio). */
.tabs-vertical .tab-group-header[data-group-key="wayto"] {
  border-left-color: #d97706;
}
.tabs-vertical .tab-group-header[data-group-key="wayto"] .tab-group-label {
  color: #b45309;
}
.tabs-vertical .tab-group-header[data-group-key="wayto"].active-source {
  background: linear-gradient(90deg, #fef3c7 0%, #fefce8 100%);
  border-left-color: #d97706;
  border-color: #fcd34d;
}
.tabs-vertical .tab-group-header[data-group-key="wayto"].active-source .tab-group-label {
  color: #92400e;
}

.tabs-vertical .tab-group-toggle {
  font-size: 9px;
  width: 10px;
  display: inline-block;
  opacity: 0.6;
}
.tabs-vertical .tab-group-label {
  flex: 0 0 auto;
  text-transform: uppercase;
}
.tabs-vertical .tab-group-hint {
  flex: 1 1 auto;
  font-size: 10px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  text-align: right;
  opacity: 0.7;
}
/* Daniel 2026-05-25: separator sekcji w sidebarze System (Do zrobienia / Rozliczone / Pomocnicze).
   Mały muted-text bez clickable affordance — czysto wizualne grupowanie zakładek. */
.tabs-vertical .tab-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  padding: 12px 18px 4px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  user-select: none;
}
.tabs-vertical .tab-section-label:first-of-type {
  border-top: none;
  margin-top: 0;
}
/* Tabs w grupach — identyczne style jak WayTo (bez wcięcia, te same padding/font). */

.tabs-vertical .tab {
  background: transparent;
  border: 0;
  color: var(--text-soft);
  padding: 8px 12px 8px 12px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  width: 100%;
  position: relative;
  transition: color 0.12s, background 0.12s;
  box-shadow: none;
}
.tabs-vertical .tab:hover {
  color: var(--text);
  background: var(--panel-2);
}
.tabs-vertical .tab.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.tabs-vertical .tab .tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--muted);
}
.tabs-vertical .tab.active .tab-icon { color: var(--accent); }
.tabs-vertical .tab .tab-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tabs-vertical .tab .tab-count {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  flex-shrink: 0;
}
/* Sub-zakładki pod "Zapisane w Shoperze" */
.tabs-vertical .tab-subbar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 4px 0 6px 24px;
  padding-left: 8px;
  border-left: 2px solid var(--accent-soft, #eef2ff);
}
.tabs-vertical .tab-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: 0;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  text-align: left;
}
.tabs-vertical .tab-sub:hover {
  background: var(--panel-2, #f9fafb);
  color: var(--text);
}
.tabs-vertical .tab-sub.active {
  background: var(--accent-soft, #eef2ff);
  color: var(--accent, #4f46e5);
  font-weight: 600;
}
.tabs-vertical .tab-sub .tab-sub-count {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tabs-vertical .tab-sub.active .tab-sub-count { color: var(--accent, #4f46e5); }

.tabs-vertical .tab.active .tab-count {
  color: var(--accent);
}
.tabs-vertical .tab.has-errors:not(.active) .tab-icon,
.tabs-vertical .tab.has-errors:not(.active) .tab-count {
  color: var(--err);
}
.tabs-vertical .tab.has-errors.active {
  color: var(--err);
  background: var(--err-soft);
}
.tabs-vertical .tab.has-errors.active .tab-icon,
.tabs-vertical .tab.has-errors.active .tab-count { color: var(--err); }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .app-sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
  }
  .brand-logo { max-width: 240px; }
  .tabs-vertical {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .tabs-vertical::before { display: none; }
  .tabs-vertical .tab { width: auto; padding-left: 18px; }
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 0 6px;
  flex-wrap: wrap;
  font-size: 13px;
}
/* Daniel 2026-05-25: kompaktowy pasek paginacji pod tabelą magazyn (System).
   Prev / info / Next + pageSize select, na jednej linii, niewielki padding. */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 8px;
  flex-wrap: wrap;
  font-size: 13px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}
.pagination-bar button {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
}
.pagination-bar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.pagination-bar select {
  padding: 5px 8px;
  font-size: 13px;
  margin-left: auto;
}
@media (max-width: 600px) {
  .pagination-bar { gap: 6px; }
  .pagination-bar select { margin-left: 0; width: 100%; }
}
.pagination button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  min-width: 36px;
  box-shadow: none;
}
.pagination button:hover:not(:disabled) {
  background: var(--panel-2);
  border-color: var(--border-strong);
}
.pagination button.active {
  background: var(--text);
  border-color: var(--text);
  color: white;
  font-weight: 600;
}
.pagination .ellipsis {
  color: var(--muted);
  padding: 0 6px;
}
.pagination .info {
  color: var(--muted);
  margin-right: 12px;
  font-size: 12px;
}
.pagination .goto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  color: var(--muted);
  font-size: 12px;
}
.pagination .goto input {
  width: 60px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font: inherit;
  text-align: center;
}

.cell-date {
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.days-pill {
  display: inline-block;
  margin-top: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
  align-self: flex-start;
}
.cell-date .date-main { display: block; }
.days-pill.days-ok {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 18%, transparent);
}
.days-pill.days-overdue {
  background: var(--err-soft);
  color: var(--err);
  border-color: rgba(220, 38, 38, 0.25);
}
.cell-date .date-main { color: var(--text); font-weight: 500; }
.cell-date .date-rel { color: var(--muted); font-size: 11px; display: block; }
.cell-action-label {
  font-size: 11px;
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* --- Login page --- */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px 28px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-logo {
  display: block;
  margin: 0 auto 18px;
  height: 32px;
  width: 192px;
  background-color: var(--text);
  -webkit-mask: url(/logo.png) center / contain no-repeat;
          mask: url(/logo.png) center / contain no-repeat;
}
[data-theme="pink"] .login-logo { background-color: var(--accent); }
.login-card h1 { margin: 0 0 4px; font-size: 18px; font-weight: 700; }
.login-sub { margin: 0 0 22px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}
.login-card label span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.login-card input {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.login-card button {
  margin-top: 6px;
  width: 100%;
  padding: 10px;
  font-size: 14px;
}
.login-error {
  background: var(--err-soft);
  color: var(--err);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  text-align: left;
}

/* --- Sidebar user / admin nav --- */
.sidebar-user {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.sidebar-user .user-name { font-weight: 600; color: var(--text); }
.sidebar-user .user-email { color: var(--muted); margin-top: 2px; word-break: break-all; }

/* Theme switcher dots — two colored circles for picking app theme. */
.theme-switch {
  display: flex;
  gap: 8px;
  margin: 10px 0 4px;
  align-items: center;
  justify-content: flex-start;
}
.theme-dot {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  position: relative;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.theme-dot:hover { transform: scale(1.08); }
.theme-dot.active {
  border-color: var(--text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 12%, transparent);
}
.theme-dot-default { background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); }
.theme-dot-pink { background: linear-gradient(135deg, #EB27C2 0%, #C71FA1 100%); }
.theme-dot.active::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid #fff;
}

.admin-nav .tab[href] {
  text-decoration: none;
}

/* --- Form fields in modals --- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field span { font-size: 12px; color: var(--muted); font-weight: 500; }
.field input, .field select {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  outline: none;
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.field-inline { display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* ===== Email reply tracking — dot column, unread highlight, thread modal ===== */

/* Reply-status dot in the first column of "Wysłane maile" */
.col-replies { width: 44px; text-align: center; }
.cell-replies { text-align: center; }
.reply-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  position: relative;
}
.reply-dot-none {
  width: 8px;
  height: 8px;
  background: var(--border-strong);
  opacity: 0.4;
}
.reply-dot-read {
  background: color-mix(in srgb, var(--muted) 22%, transparent);
  color: var(--text-soft);
  border: 1px solid color-mix(in srgb, var(--muted) 30%, transparent);
}
.reply-dot-unread {
  background: var(--err);
  color: #fff;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--err) 60%, transparent);
  animation: replyPulse 2s ease-out infinite;
}
.reply-dot .reply-count {
  line-height: 1;
}

@keyframes replyPulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--err) 50%, transparent); }
  70% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--err) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--err) 0%, transparent); }
}

/* Unread row highlight in emails table */
tr.email-row { transition: background 0.12s; }
tr.email-row:hover { background: var(--panel-2); }
tr.email-row-unread {
  background: color-mix(in srgb, var(--err) 4%, transparent);
}
tr.email-row-unread:hover {
  background: color-mix(in srgb, var(--err) 8%, transparent);
}
tr.email-row-unread td:nth-child(6) { /* Subject column — bold for unread */
  font-weight: 600;
}

/* Unread badge in nav */
.tabs-vertical .tab .tab-count-unread {
  background: var(--err);
  color: #fff !important;
  padding: 1px 7px;
  font-size: 11px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}
.tabs-vertical .tab.active .tab-count-unread {
  background: var(--err);
  color: #fff !important;
}

/* Thread modal — chat-style conversation */
.thread-msg {
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: 10px;
  max-width: 78%;
  word-wrap: break-word;
  border: 1px solid var(--border);
}
.thread-msg-outgoing {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
  margin-left: auto;
  margin-right: 0;
}
.thread-msg-incoming {
  background: var(--panel-2);
  border-color: var(--border);
  margin-left: 0;
  margin-right: auto;
}
.thread-msg-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}
.thread-msg-header strong {
  color: var(--text);
}
.thread-msg-body {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--text);
}

/* Załączniki Zendesk w wiadomości */
.thread-msg-attachments {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.thread-msg-attachments-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  font-weight: 600;
}
.thread-attach {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin: 3px 6px 3px 0;
  background: var(--panel-2, #f9fafb);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  font-size: 12px;
  transition: background 0.15s;
}
.thread-attach:hover {
  background: var(--accent-soft, #eef2ff);
  border-color: var(--accent, #4f46e5);
}
.thread-attach-img {
  flex-direction: column;
  align-items: flex-start;
  max-width: 200px;
  padding: 6px;
}
.thread-attach-img img {
  max-width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}
.thread-attach-name {
  display: block;
  font-weight: 500;
  word-break: break-word;
}
.thread-attach-meta {
  display: block;
  font-size: 10px;
  color: var(--muted);
}
.thread-attach-icon {
  font-size: 18px;
}

/* Thread as a full page (Gmail-style) */
.thread-page-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.thread-page-header .thread-page-meta {
  flex: 1;
  min-width: 200px;
}
.thread-page-body {
  padding: 0 4px 16px;
  max-height: 60vh;
  overflow-y: auto;
}
.thread-page-reply {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 8px;
}
.thread-reply-header {
  margin-bottom: 8px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.thread-page-reply textarea {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 100px;
  box-sizing: border-box;
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.thread-page-reply textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.thread-reply-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

/* Wayto attachments row + notes block in drawer */
.wayto-attachments-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.wayto-attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  text-decoration: none;
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s;
}
.wayto-attachment-link:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.wayto-notes-block {
  white-space: pre-line;
  font-size: 12px;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--panel-2);
  border-radius: 6px;
  border-left: 3px solid var(--warn);
  line-height: 1.5;
  color: var(--text);
}

/* Standalone yellow "soap" callout for Wayto text notes — placed between products
   and emails in the drawer. Bright but not screaming, so BOK eye lands on it fast. */
.wayto-notes-soap {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-left: 4px solid var(--warn);
  border-radius: 8px;
}
.wayto-notes-soap-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--warn);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.wayto-notes-soap-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-line;
  word-wrap: break-word;
}

/* Drawer email thread — one line per message (Gmail-style flat list).
   Each .msg-row is: [icon | content | when] in a flex layout. */
.msg-thread-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}
.msg-row:hover {
  background: var(--panel-2);
}
.msg-row-icon {
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  user-select: none;
}
.msg-row-content {
  flex: 1;
  min-width: 0;
}
.msg-row-line1 {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 1px;
}
.msg-row-line1 strong {
  font-size: 12px;
  color: var(--text);
}
.msg-row-line2 {
  font-size: 12px;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}
.msg-row-when {
  flex-shrink: 0;
  font-size: 11px;
  align-self: center;
  white-space: nowrap;
}
.msg-row-incoming .msg-row-icon { color: var(--accent); font-weight: 700; }
.msg-row-outgoing .msg-row-icon { color: var(--muted-2); }
.msg-row-unread .msg-row-line2 { font-weight: 600; color: var(--text); }
.msg-row-unread { background: color-mix(in srgb, var(--err) 4%, transparent); }
.msg-row-unread:hover { background: color-mix(in srgb, var(--err) 8%, transparent); }
.msg-row-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--err);
  flex-shrink: 0;
}
.msg-row-meta {
  cursor: default;
  background: var(--panel-2);
  border-left: 2px solid var(--border-strong);
}
.msg-row-meta:hover { background: var(--panel-2); }
.msg-row-divider {
  height: 0;
  border-bottom: 0;
}
.msg-row-divider:not(:last-child) {
  height: 1px;
  background: var(--border-strong);
  margin: 4px 0;
}
.msg-row:last-child {
  border-bottom: 0;
}

/* Clickable order link in thread page subtitle */
.thread-page-sub-link {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.thread-page-sub-link:hover {
  text-decoration: underline;
}

/* === Siblings — multi-return orders === */

/* Inline badge next to order_id in the main table */
.siblings-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.2;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.siblings-badge:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: var(--accent);
}

/* Drawer section listing related returns as a table — visually mirrors the main
   returns table so BOK can match drawer-row to main-row at a glance. */
.siblings-section {
  margin: 12px 0 16px;
  padding: 10px 14px 12px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 13px;
}
.siblings-section strong {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
}
.siblings-order-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.siblings-order-link:hover {
  text-decoration: none;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 3px;
  padding: 0 3px;
  margin: 0 -3px;
}
.siblings-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 6px;
  overflow: hidden;
  font-size: 12px;
}
.siblings-table thead th {
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.siblings-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.siblings-table tbody tr:last-child td {
  border-bottom: 0;
}
.siblings-row {
  cursor: pointer;
  transition: background 0.12s;
}
/* Daniel 2026-05-24: highlight nowych split-childów po decyzji BOK.
   Flash 3× w pierwszych 4.5s gdy rekord właśnie powstał z splitu. */
.siblings-row-new-split {
  animation: siblingsNewSplitFlash 1.5s ease-in-out 0s 3;
  background: color-mix(in srgb, var(--ok) 22%, transparent) !important;
}
@keyframes siblingsNewSplitFlash {
  0%, 100% { background: transparent; box-shadow: none; }
  50%      { background: color-mix(in srgb, var(--ok) 35%, transparent); box-shadow: inset 0 0 0 2px var(--ok); }
}
.siblings-row:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.siblings-row-current {
  cursor: default !important;
  background: color-mix(in srgb, var(--accent) 14%, transparent) !important;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  position: relative;
}
.siblings-row-current:hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent) !important;
}
.siblings-marker {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.siblings-col-marker { width: 70px; text-align: center; }
.siblings-col-date {
  width: 130px;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
  white-space: nowrap;
}
.siblings-col-status { width: 200px; }
.siblings-col-purpose {
  font-weight: 500;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.siblings-col-meta { width: 200px; font-size: 11px; }

/* Status CSV pill — neutral by default, green for "80: Zakończony", grey for "90: Anulowany". */
.sibling-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sibling-status.sibling-status-completed {
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  color: var(--ok);
}
.sibling-status.sibling-status-cancelled {
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  border-color: var(--border-strong);
  color: var(--muted);
  text-decoration: line-through;
}

/* Side-panel modal for read-only preview of a sibling return.
   Slides in from the right, stays on top of the table without disturbing it. */
#sibling-preview-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(900px, 92vw);
  background: var(--bg);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 90;
  animation: slideInFromRight 0.18s ease-out;
}
@keyframes slideInFromRight {
  from { transform: translateX(100%); opacity: 0.5; }
  to { transform: translateX(0); opacity: 1; }
}
.sibling-preview-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}
.sibling-preview-header h3 {
  font-size: 16px;
  font-weight: 600;
}
.sibling-preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
/* Read-only mode — hide all interactive action buttons inside the preview.
   Save / Refund / Send-email / NRB-edit etc. should not be triggerable here. */
.read-only button:not(#thread-back-btn):not(#thread-page-refresh):not(#sibling-preview-close):not(.expand-toggle),
.read-only .btn-save,
.read-only .email-compose-btn,
.read-only .wayto-fetch-btn,
.read-only .nrb-edit-btn,
.read-only .nrb-save-btn,
.read-only .nrb-cancel-btn {
  display: none !important;
}
.read-only .nrb-input { pointer-events: none; opacity: 0.7; }

/* ===== PayU drawer & refund modal ===== */
.payu-drawer {
  margin-top: 16px;
  border: 2px solid var(--accent, #4f46e5);
  border-radius: 10px;
  background: var(--panel);
  padding: 16px 20px;
}
.payu-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.payu-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 24px;
  font-size: 13px;
}
.payu-meta dt {
  color: var(--muted, #6b7280);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.payu-meta dd { margin: 0 0 6px; font-weight: 500; }

.payu-row-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: #fafafa;
}
.payu-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.payu-row-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px 14px;
  font-size: 12px;
}
.payu-row-grid .muted {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Modal — refund dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  background: var(--panel, white);
  border-radius: 10px;
  padding: 20px 24px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}
.modal-card .field { margin-bottom: 12px; }
.modal-card .field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-sizing: border-box;
}
.modal-card .field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.modal-card .field small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Refund "mydełko" — wizualne oznaczenie zwróconej transakcji */
.payu-row-refunded {
  background: #fef2f2 !important;
  opacity: 0.85;
}
.payu-row-refunded:hover {
  background: #fee2e2 !important;
  opacity: 1;
}
.payu-refund-badge {
  display: inline-block;
  background: #fecaca;
  color: #991b1b;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  margin-top: 2px;
}

/* Alarm flag — zwroty oznaczone przez import alarmów (już ogarnięte w Wayto) */
tr.row-alarm {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.18), rgba(245, 158, 11, 0.06)) !important;
  border-left: 4px solid #f59e0b !important;
}
tr.row-alarm:hover {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.28), rgba(245, 158, 11, 0.12)) !important;
}
.alarm-badge {
  display: inline-block;
  background: #fbbf24;
  color: #78350f;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  animation: alarm-pulse 2s ease-in-out infinite;
}
@keyframes alarm-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Workflow zwrotów — statyczne drzewka prezentacyjne w menu BOK (Completio 2026-05-15).
   Dwa drzewka obok siebie na desktopie, jedno pod drugim na mobile. */
.workflow-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 960px) {
  .workflow-grid { grid-template-columns: 1fr; }
}
.workflow-tree {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px 18px;
}
.workflow-tree-head {
  margin: 0 0 4px;
  font-size: 16px;
  color: #1f2937;
}
.workflow-tree-sub {
  margin: 0 0 14px;
  font-size: 12px;
}
.workflow-tree code {
  background: #e5e7eb;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
  color: #1f2937;
}
.workflow-steps {
  margin: 0;
  padding: 0 0 0 22px;
  font-size: 13px;
  line-height: 1.55;
  color: #374151;
}
.workflow-steps > li {
  margin-bottom: 12px;
  padding-left: 4px;
}
.workflow-steps > li > strong {
  display: inline-block;
  color: #4f46e5;
  font-size: 14px;
  margin-bottom: 4px;
}
.workflow-steps ul {
  margin: 4px 0 0;
  padding-left: 20px;
  list-style: none;
}
.workflow-steps ul li {
  position: relative;
  padding: 2px 0 2px 14px;
}
.workflow-steps ul li::before {
  content: '├─';
  position: absolute;
  left: -2px;
  top: 2px;
  color: #9ca3af;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
}
.workflow-steps ul li:last-child::before { content: '└─'; }
.workflow-steps ul ul li::before { color: #cbd5e1; }
.workflow-steps i {
  background: #eef2ff;
  color: #4338ca;
  padding: 0 5px;
  border-radius: 3px;
  font-style: normal;
  font-size: 12px;
}

/* Daniel 2026-05-24: Custom tooltip (data-tt="...") — szybki, bez delay browsera.
   Działa na każdym elemencie z atrybutem data-tt. Pojawia się od razu na hover. */
[data-tt] { position: relative; }
[data-tt]:hover::after {
  content: attr(data-tt);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: #1f2937;
  color: #ffffff;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  max-width: 320px;
  text-overflow: ellipsis;
  overflow: hidden;
}
[data-tt]:hover::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #1f2937;
  pointer-events: none;
  z-index: 9999;
}
/* Wariant bottom — tooltip pod elementem (gdy element jest u góry strony) */
[data-tt-pos="bottom"]:hover::after {
  bottom: auto;
  top: 100%;
  transform: translateX(-50%) translateY(4px);
}
[data-tt-pos="bottom"]:hover::before {
  bottom: auto;
  top: 100%;
  border-top-color: transparent;
  border-bottom-color: #1f2937;
}
/* Wariant multiline — gdy tekst ma być w wielu liniach, użyj data-tt z \A separator
   plus klasa .tt-multiline */
[data-tt].tt-multiline:hover::after {
  white-space: pre;
  max-width: none;
  text-align: left;
}

/* Initial pill — kolorowy badge z inicjałami użytkownika.
   Kolor generowany deterministycznie z user_id (zachowana spójność per user). */
.user-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  vertical-align: middle;
  cursor: default;
  line-height: 1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.user-pill.sm { min-width: 18px; height: 16px; font-size: 9px; padding: 0 4px; }
.user-pill.lg { min-width: 26px; height: 22px; font-size: 11px; padding: 0 7px; }
.user-pill-system {
  background: #94a3b8 !important;
  font-weight: 600;
}

/* Daniel 2026-05-24: globalny source badge — spójna konwencja w całej aplikacji.
   Dwie warstwy zwrotów:
     - "system" = nowy system (klient.html + magazyn ręczny) — niebieski
     - "Wayto" = legacy CSV (returns) — żółty
   Bez ikon: tekst lowercase, krótki, czytelny. */
.src-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  vertical-align: middle;
  line-height: 1.4;
}
.src-badge.src-wayto  { background: #fef3c7; color: #92400e; }
.src-badge.src-system { background: #dbeafe; color: #1e3a8a; }
.src-badge.src-system-klient { background: #dcfce7; color: #166534; }      /* sub-tag: klient.html */
.src-badge.src-system-manual { background: #e0e7ff; color: #3730a3; }      /* sub-tag: magazyn ręcznie */
.src-badge.src-unknown { background: #f3f4f6; color: #4b5563; }
.src-badge + .src-badge { margin-left: 4px; }

/* Daniel 2026-05-24: segmented pille dla decyzji BOK + przeznaczenia (1 klik = wybór).
   Zastępują dropdowny — szybciej i bardziej czytelne wizualnie. */
.opt-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.opt-pill {
  padding: 5px 11px;
  border-radius: 99px;
  border: 1.5px solid #e5e7eb;
  background: #fff;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
  white-space: nowrap;
  color: #4b5563;
  line-height: 1.3;
  font-family: inherit;
}
.opt-pill:hover:not(:disabled):not(.active) {
  border-color: #94a3b8;
  background: #f9fafb;
  color: #1f2937;
}
.opt-pill:disabled { opacity: 0.55; cursor: not-allowed; }
.opt-pill.active {
  box-shadow: 0 0 0 2px rgba(99,102,241,0.15);
}
/* Decyzja BOK — 3 kolory */
.opt-pill.active.opt-decision-green   { background: #16a34a; border-color: #15803d; color: #fff; }
.opt-pill.active.opt-decision-purple  { background: #9333ea; border-color: #7e22ce; color: #fff; }
.opt-pill.active.opt-decision-red     { background: #ec4899; border-color: #db2777; color: #fff; }
/* Przeznaczenie — neutralny indygo dla aktywnej */
.opt-pill.active.opt-dest             { background: #4338ca; border-color: #3730a3; color: #fff; }

/* Daniel 2026-05-24: toast container — non-blocking notifications + undo. */
#gg-toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.gg-toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  background: #1f2937;
  color: #ffffff;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.28);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  animation: gg-toast-in 0.18s ease-out;
}
.gg-toast.gg-toast-success { background: #047857; }
.gg-toast.gg-toast-error   { background: #b91c1c; }
.gg-toast.gg-toast-info    { background: #1d4ed8; }
.gg-toast .gg-toast-icon { font-size: 16px; }
.gg-toast .gg-toast-msg { flex: 1; line-height: 1.4; }
/* Daniel 2026-05-24: code/kbd w toast — globalny .code style daje biały bg
   na białym tle toast'a. Wymuszamy ciemne tło + jasny tekst dla kontrastu. */
.gg-toast .gg-toast-msg code,
.gg-toast .gg-toast-msg kbd {
  background: rgba(255,255,255,0.18);
  color: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 0.92em;
  border: 1px solid rgba(255,255,255,0.25);
}
.gg-toast .gg-toast-action {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.gg-toast .gg-toast-action:hover { background: rgba(255,255,255,0.28); }
.gg-toast .gg-toast-close {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.7);
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.gg-toast .gg-toast-close:hover { color: #fff; }
@keyframes gg-toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.gg-toast.gg-toast-leaving {
  animation: gg-toast-out 0.18s ease-in forwards;
}
@keyframes gg-toast-out {
  to { transform: translateY(8px); opacity: 0; }
}

/* Decision summary box — mini-podsumowanie pod tabelą decyzji */
.decision-summary {
  margin-top: 10px;
  padding: 10px 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 12px;
}
.decision-summary-title {
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10.5px;
  margin-bottom: 6px;
}
.decision-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  border-bottom: 1px dashed #e5e7eb;
}
.decision-summary-row:last-of-type { border-bottom: 0; }
.decision-summary-row.warn { color: #b45309; font-weight: 600; }

/* Activity feed table — kompaktowy widok 20 osobowej ekipy: numer zam + co się zmieniło + kto */
.activity-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
.activity-table thead th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 10px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 1;
}
.activity-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.activity-table tbody tr.activity-row { transition: background 0.1s; }
.activity-table tbody tr.activity-row:hover { background: #fafbfc; }
.activity-table tbody tr.activity-row[data-activity-target]:hover { background: #eff6ff; }
.activity-col-time { width: 110px; white-space: nowrap; }
.activity-col-order { width: 110px; white-space: nowrap; }
.activity-col-action { width: 220px; white-space: nowrap; }
.activity-col-change { min-width: 280px; }
.activity-col-who { width: 50px; text-align: center; }

/* Daniel 2026-05-26: pasek DEV ENV — pokazywany tylko gdy backend zwraca DEV_MODE=1
   (toggle przez fetch /api/env w app.js / magazyn.js). Czerwony gradient u góry strony,
   sticky, żeby Marta/BOK nie pomyliła dev z prod. */
.dev-banner {
  background: linear-gradient(90deg, #dc2626 0%, #ea580c 100%);
  color: #fff;
  padding: 8px 16px;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
  z-index: 10000;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

/* Daniel 2026-05-27: badge DHL flow — etykieta zwrotna z klient.html + BLIK 12,99 zł.
   Żółty (jak inne info-badges) żeby BOK od razu widziała "to inny flow niż klasyczny". */
.dhl-badge {
  background: #fef3c7;
  color: #92400e;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Daniel 2026-05-28: wyszarzenie zakończonych rekordów na liście System
   (tab=all głównie). isCompleted obliczane front-side wg backend case 'completed':
   refunded / Odrzucone / ZOR wystawiony / shoper no_refund / Niedoręczona COD / saved.
   Opacity 0.55 — tekst nadal czytelny ale wyraźnie inny ton. Hover daje full opacity
   żeby kliknięcie i odczyt były wygodne. */
.magazyn-bok-row--completed {
  opacity: 0.55;
}
.magazyn-bok-row--completed:hover {
  opacity: 1;
}

/* Daniel 2026-05-28: panel admin → "📊 Statystyki użytkowników".
   Karty per user z totalem dnia + poziomy pasek breakdown po kategoriach.
   Kolory kategorii spójne z legendą (ustats-legend-dot pod listą). */
:root {
  --ustats-decisions: #6366f1;   /* indigo — Decyzje BOK */
  --ustats-refund: #10b981;      /* emerald — Zwroty kasy */
  --ustats-zor: #f59e0b;         /* amber — ZOR */
  --ustats-register: #3b82f6;    /* blue — Rejestracja */
  --ustats-shoper: #8b5cf6;      /* violet — Shoper */
  --ustats-mail: #ec4899;        /* pink — Maile */
  --ustats-export: #14b8a6;      /* teal — Eksporty */
  --ustats-edit: #64748b;        /* slate — Edycje */
  --ustats-other: #94a3b8;       /* slate-light — Inne */
}

.ustats-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.ustats-total-card {
  background: var(--panel-2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 12px 16px;
}
.ustats-total-card .ustats-tval {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.ustats-total-card .ustats-tlabel {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ustats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}
.ustats-card {
  background: var(--panel, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 14px 16px;
  transition: box-shadow 0.15s;
}
.ustats-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.ustats-card--inactive { opacity: 0.6; }

.ustats-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.ustats-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent, #6366f1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.ustats-name {
  flex: 1;
  min-width: 0;
}
.ustats-name-text {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ustats-name-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.ustats-name-meta .ustats-role-pill {
  display: inline-block;
  padding: 1px 6px;
  background: var(--panel-2, #f1f5f9);
  border-radius: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.ustats-total {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.ustats-total-label {
  font-size: 10px;
  color: var(--muted);
  text-align: right;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ustats-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--panel-2, #f1f5f9);
  margin: 10px 0 8px;
}
.ustats-bar-seg {
  height: 100%;
  min-width: 2px;
  transition: filter 0.15s;
  cursor: default;
}
.ustats-bar-seg:hover { filter: brightness(1.15); }
.ustats-bar-seg[data-cat="decisions"] { background: var(--ustats-decisions); }
.ustats-bar-seg[data-cat="refund_money"] { background: var(--ustats-refund); }
.ustats-bar-seg[data-cat="zor"] { background: var(--ustats-zor); }
.ustats-bar-seg[data-cat="register"] { background: var(--ustats-register); }
.ustats-bar-seg[data-cat="shoper"] { background: var(--ustats-shoper); }
.ustats-bar-seg[data-cat="mail"] { background: var(--ustats-mail); }
.ustats-bar-seg[data-cat="export"] { background: var(--ustats-export); }
.ustats-bar-seg[data-cat="edit"] { background: var(--ustats-edit); }
.ustats-bar-seg[data-cat="other"] { background: var(--ustats-other); }

.ustats-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 11px;
  margin-bottom: 8px;
}
.ustats-breakdown-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}
.ustats-breakdown-item strong {
  color: var(--text);
  font-weight: 600;
}
.ustats-breakdown-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.ustats-times {
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border, #e2e8f0);
  padding-top: 6px;
  display: flex;
  justify-content: space-between;
}

.ustats-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin: 0 4px 0 10px;
  vertical-align: middle;
}
.ustats-legend-dot[data-cat="decisions"] { background: var(--ustats-decisions); }
.ustats-legend-dot[data-cat="refund_money"] { background: var(--ustats-refund); }
.ustats-legend-dot[data-cat="zor"] { background: var(--ustats-zor); }
.ustats-legend-dot[data-cat="register"] { background: var(--ustats-register); }
.ustats-legend-dot[data-cat="shoper"] { background: var(--ustats-shoper); }
.ustats-legend-dot[data-cat="mail"] { background: var(--ustats-mail); }
.ustats-legend-dot[data-cat="export"] { background: var(--ustats-export); }
.ustats-legend-dot[data-cat="edit"] { background: var(--ustats-edit); }
.ustats-legend-dot[data-cat="other"] { background: var(--ustats-other); }

/* Daniel 2026-05-29: statystyki ekipy magazynu — reuse ustats-* card/bar struktury,
   ale kategorie magazynowe (photos, close) potrzebują własnych kolorów. Pozostałe
   (register/edit/shoper/zor/export/other) dziedziczą z --ustats-*. */
:root {
  --ustats-photos: #ef4444;   /* red — Zdjęcia (weryfikacja jakościowa) */
  --ustats-close: #0ea5e9;    /* sky — Zamknięcia (do bufora eksportu) */
}
.ustats-bar-seg[data-cat="photos"] { background: var(--ustats-photos); }
.ustats-bar-seg[data-cat="close"] { background: var(--ustats-close); }

.ts-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin: 0 4px 0 10px;
  vertical-align: middle;
}
/* Daniel 2026-05-29: mydełka szybkiego wyboru zakresu (Dziś / tygodnie). */
.ts-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 0;
}
.ts-chip {
  border: 1px solid var(--border, #e2e8f0);
  background: var(--panel, #fff);
  color: var(--text, #1e293b);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.ts-chip:hover { background: var(--panel-2, #f1f5f9); }
.ts-chip.active {
  background: var(--accent, #6366f1);
  border-color: var(--accent, #6366f1);
  color: #fff;
  font-weight: 600;
}
.ts-chip-sub { opacity: 0.7; font-size: 11px; margin-left: 4px; }
.ts-chip.active .ts-chip-sub { opacity: 0.85; }

.ts-legend-dot[data-cat="register"] { background: var(--ustats-register); }
.ts-legend-dot[data-cat="edit"] { background: var(--ustats-edit); }
.ts-legend-dot[data-cat="photos"] { background: var(--ustats-photos); }
.ts-legend-dot[data-cat="shoper"] { background: var(--ustats-shoper); }
.ts-legend-dot[data-cat="close"] { background: var(--ustats-close); }
.ts-legend-dot[data-cat="zor"] { background: var(--ustats-zor); }
.ts-legend-dot[data-cat="export"] { background: var(--ustats-export); }
.ts-legend-dot[data-cat="other"] { background: var(--ustats-other); }
