:root {
  --bg: #f0f3f7;
  --surface: #ffffff;
  --ink: #1a2332;
  --muted: #5c6b7a;
  --accent: #005eb8;
  --accent-hover: #004a94;
  --border: #d0d8e0;
  --danger: #b42318;
  --ok: #067647;
  --emag-price: #7c3aed;
  --row-alt: #f7f9fc;
  --font: "Segoe UI", "Helvetica Neue", sans-serif;

  --on-accent: #ffffff;
  --surface-alt: #eef2f7;
  --glow-1: #c5daf0;
  --glow-2: #dde8f4;
  --shadow-1: rgba(26, 35, 50, 0.04);
  --shadow-2: rgba(26, 35, 50, 0.12);
  --shadow-3: rgba(0, 0, 0, 0.25);
  --overlay: rgba(15, 25, 40, 0.5);
  --warn: #b26a00;

  --banner-ink: #0c4a6e;
  --banner-bg: #e0f2fe;
  --banner-border: #7dd3fc;
  --banner-accent: #0284c7;

  --sync-btn: #e84a8a;
  --sync-btn-hover: #d63678;

  --th-bg: #e8eef5;
  --filter-bg: #eef3f8;
  --row-hover: #eef4fb;
  --detail-bg: #f3f6fa;

  --tint-blue: #dbeafe;
  --tint-blue-hover: #bfdbfe;
  --tint-blue-softest: #eff6ff;
  --rule-blue: #3b82f6;

  --tint-amber: #fef3c7;
  --tint-amber-hover: #fde68a;
  --rule-amber: #d97706;
  --tint-beige: #f5ecd7;
  --rule-beige: #c9ad7a;

  --tint-green: #dcfce7;
  --tint-green-hover: #bbf7d0;
  --tint-green-hover2: #86efac;
  --tint-green-soft: #f0fdf4;
  --rule-green: #16a34a;

  --tint-purple: #f3e8ff;
  --tint-purple-hover: #e9d5ff;
  --rule-purple: #9333ea;

  --tint-yellow: #fef08a;
  --tint-yellow-soft: #fef9c3;
  --rule-yellow: #ca8a04;

  --tint-indigo: #c7d2fe;
  --tint-indigo-hover: #a5b4fc;
  --tint-violet: #f5f3ff;

  --tint-red: #fee2e2;
  --tint-red-soft: #fef3f2;
  --tint-orange: #fff7ed;
  --border-orange: #fdba74;

  --badge-ok-bg: #dcfae6;
  --badge-bad-bg: #fee4e2;

  --st-new-ink: #1e40af;
  --st-prog-ink: #92400e;
  --st-prep-bg: #e0e7ff;
  --st-prep-ink: #3730a3;
  --st-fin-bg: #d1fae5;
  --st-fin-ink: #065f46;
  --st-canc-ink: #991b1b;
  --st-ret-bg: #f3e8ff;
  --st-ret-ink: #6b21a8;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --ink: #e6edf3;
  --muted: #98a5b3;
  --accent: #4a9eff;
  --accent-hover: #6cb2ff;
  --border: #2b3542;
  --danger: #ff6b5e;
  --ok: #3fb950;
  --emag-price: #b18cff;
  --row-alt: #12171f;

  --on-accent: #0d1117;
  --surface-alt: #1d242e;
  --glow-1: #14283d;
  --glow-2: #101c2b;
  --shadow-1: rgba(0, 0, 0, 0.4);
  --shadow-2: rgba(0, 0, 0, 0.55);
  --shadow-3: rgba(0, 0, 0, 0.7);
  --overlay: rgba(0, 0, 0, 0.65);
  --warn: #e0a33a;

  --banner-ink: #b6e3ff;
  --banner-bg: #10293b;
  --banner-border: #1d4d69;
  --banner-accent: #2f9ede;

  --sync-btn: #c73b74;
  --sync-btn-hover: #e04d88;

  --th-bg: #1c2430;
  --filter-bg: #171e28;
  --row-hover: #1b2531;
  --detail-bg: #131a23;

  --tint-blue: #16304d;
  --tint-blue-hover: #1e4166;
  --tint-blue-softest: #131f2e;
  --rule-blue: #4a9eff;

  --tint-amber: #3a2d10;
  --tint-amber-hover: #4d3c16;
  --rule-amber: #d9950b;
  --tint-beige: #3a3222;
  --rule-beige: #a88d5c;

  --tint-green: #14331f;
  --tint-green-hover: #1b472b;
  --tint-green-hover2: #235c37;
  --tint-green-soft: #0f2418;
  --rule-green: #2ea043;

  --tint-purple: #33204a;
  --tint-purple-hover: #452b63;
  --rule-purple: #c084fc;

  --tint-yellow: #453811;
  --tint-yellow-soft: #2e260c;
  --rule-yellow: #c99a1e;

  --tint-indigo: #262a52;
  --tint-indigo-hover: #333868;
  --tint-violet: #201a33;

  --tint-red: #3a1a1a;
  --tint-red-soft: #2a1414;
  --tint-orange: #392715;
  --border-orange: #a35f24;

  --badge-ok-bg: #14331f;
  --badge-bad-bg: #3a1a1a;

  --st-new-ink: #8fc0ff;
  --st-prog-ink: #f0c674;
  --st-prep-bg: #262a52;
  --st-prep-ink: #b3b8ff;
  --st-fin-bg: #14331f;
  --st-fin-ink: #6ee7a0;
  --st-canc-ink: #ff8c82;
  --st-ret-bg: #2c1d3d;
  --st-ret-ink: #d5aaff;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100%;
  /* Blochează scroll-ul fantomă al documentului (tabel înalt + thead sticky) */
  position: fixed;
  inset: 0;
  width: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, var(--glow-1) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, var(--glow-2) 0%, transparent 50%),
    var(--bg);
}

.page {
  max-width: none;
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0.75rem 0.5rem 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
}

/* Pagini fără tabel (ex. setări): scroll pe .page, nu pe document */
.page:not(:has(.table-wrap)) {
  overflow: auto;
  padding-bottom: 0.75rem;
}

.header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.sync-info-banner {
  margin: 0.85rem 0 0;
  padding: 0.85rem 1.1rem;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--banner-ink);
  background: var(--banner-bg);
  border: 1px solid var(--banner-border);
  border-left: 5px solid var(--banner-accent);
  border-radius: 6px;
}

.sync-info-banner[hidden] {
  display: none;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0.75rem 0 0.5rem;
  flex-shrink: 0;
}

.header {
  flex-shrink: 0;
}

.toolbar-fields,
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  width: 8.5rem;
}

.field > span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field input {
  width: 8.5rem;
  font: inherit;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--ink);
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.field input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

.field input[readonly] {
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 85%, var(--border));
  cursor: default;
}

.field input[readonly]:focus {
  outline: none;
  border-color: var(--border);
}

.btn {
  appearance: none;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  cursor: pointer;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

#btn-save-all.is-dirty:not(:disabled) {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

#btn-save-all.is-dirty:not(:disabled):hover {
  background: var(--accent-hover);
}

.btn-save-count {
  min-width: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--on-accent);
  color: var(--accent);
  font-size: 0.75rem;
  line-height: 1.25rem;
  text-align: center;
}

.btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--row-alt);
}

.toolbar-actions #btn-sync {
  margin-left: auto;
  background: var(--sync-btn);
}

#btn-sync:hover:not(:disabled) {
  background: var(--sync-btn-hover);
}

.status {
  font-size: 0.875rem;
  color: var(--muted);
}

.status.is-loading {
  color: var(--accent);
}

.status.is-error {
  color: var(--danger);
}

.status.is-ok {
  color: var(--ok);
}

.table-wrap {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  /* Forțează scrollport local pentru thead sticky — evită alungirea documentului */
  transform: translateZ(0);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  box-shadow: 0 1px 2px var(--shadow-1);
}

.page.is-table-fullscreen {
  padding: 0.35rem 0.35rem 0;
  height: 100%;
  max-height: 100%;
  min-height: 0;
}

.page.is-table-fullscreen .header,
.page.is-table-fullscreen .toolbar-fields,
.page.is-table-fullscreen .sync-summary,
.page.is-table-fullscreen .filter-status,
.page.is-table-fullscreen .calc-params {
  display: none;
}

.page.is-table-fullscreen .toolbar {
  margin: 0 0 0.35rem;
}

.page.is-table-fullscreen .toolbar-actions .sync-summary {
  display: flex;
  align-self: center;
  margin: 0;
}

.page.is-table-fullscreen .table-wrap {
  border-radius: 6px 6px 0 0;
}

.page.is-table-fullscreen #btn-table-fullscreen {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: max(100%, 1100px);
}

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

th {
  background: var(--th-bg);
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 3;
}

thead tr:not(.filter-row) th[data-col] {
  vertical-align: bottom;
}

thead tr:not(.filter-row) th[data-col] .th-label {
  display: block;
  max-width: 12rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

thead tr:not(.filter-row) th[data-col="index"] .th-label {
  max-width: 2.5rem;
}

thead tr:not(.filter-row) th[data-col] {
  cursor: pointer;
  user-select: none;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
  user-select: none;
  touch-action: none;
}

.col-resize-handle::after {
  content: "";
  position: absolute;
  top: 18%;
  bottom: 18%;
  left: 4px;
  width: 2px;
  border-radius: 1px;
  background: color-mix(in srgb, var(--border) 80%, transparent);
  transition: background 0.12s ease, opacity 0.12s ease;
}

th:hover > .col-resize-handle::after,
th.is-col-resizing > .col-resize-handle::after,
.col-resize-handle:hover::after {
  background: var(--accent);
  opacity: 1;
}

body.is-col-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.is-col-resizing * {
  cursor: col-resize !important;
}

th.is-col-dragging {
  opacity: 0.45;
}

thead tr:not(.filter-row) th.is-col-drop-before {
  box-shadow: inset 3px 0 0 var(--accent);
}

thead tr:not(.filter-row) th.is-col-drop-after {
  box-shadow: inset -3px 0 0 var(--accent);
}

body.is-col-dragging {
  user-select: none !important;
}

body.is-col-dragging * {
  cursor: grabbing !important;
}

th.is-col-resized .th-label {
  max-width: 100%;
}

thead tr.filter-row th.is-col-resized .col-filter {
  width: 100%;
  min-width: 0;
  max-width: none;
}

thead tr:not(.filter-row) th[data-src="channel"] {
  background: var(--tint-blue);
  box-shadow: inset 0 -2px 0 var(--rule-blue);
}

thead tr:not(.filter-row) th[data-src="db"] {
  background: var(--tint-amber);
  box-shadow: inset 0 -2px 0 var(--rule-amber);
}

thead tr:not(.filter-row) th[data-src="calc"] {
  background: var(--tint-green);
  box-shadow: inset 0 -2px 0 var(--rule-green);
}

thead tr:not(.filter-row) th[data-src="listing"] {
  background: var(--tint-purple);
  box-shadow: inset 0 -2px 0 var(--rule-purple);
}

thead tr:not(.filter-row) th[data-src="channel"]:hover {
  background: var(--tint-blue-hover);
}

thead tr:not(.filter-row) th[data-src="db"]:hover {
  background: var(--tint-amber-hover);
}

thead tr:not(.filter-row) th[data-src="calc"]:hover {
  background: var(--tint-green-hover);
}

thead tr:not(.filter-row) th[data-src="listing"]:hover {
  background: var(--tint-purple-hover);
}

.filter-row th {
  top: 2.45rem;
  z-index: 2;
  padding: 0.35rem 0.5rem;
  font-weight: 400;
  white-space: normal;
  vertical-align: middle;
  background: var(--filter-bg);
  border-bottom: 1px solid var(--border);
  cursor: default;
}

.filter-row th:hover {
  background: var(--filter-bg);
}

.col-filter {
  width: 7rem;
  min-width: 7rem;
  max-width: 7rem;
  box-sizing: border-box;
  padding: 0.28rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font: inherit;
  font-size: 0.75rem;
  color: var(--text);
}

.col-filter:focus {
  outline: none;
  border-color: var(--accent, #3b6ea5);
  box-shadow: 0 0 0 2px rgba(59, 110, 165, 0.15);
}

.col-filter.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.filter-row th.is-filter-active {
  background: color-mix(in srgb, var(--accent) 18%, var(--filter-bg));
}

.filter-row.is-filtering {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.filter-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin: 0 0 0.65rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
}

.filter-status[hidden] {
  display: none;
}

.filter-status .btn {
  margin-left: auto;
}

.table-wrap.is-filtering {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: -1px;
}

.is-row-filtered {
  display: none;
}

th.is-sorted-asc::after,
th.is-sorted-desc::after {
  margin-left: 0.35rem;
  font-size: 0.7em;
  color: var(--muted, #64748b);
}

th.is-sorted-asc::after {
  content: "▲";
}

th.is-sorted-desc::after {
  content: "▼";
}

tbody tr:nth-child(even) {
  background: var(--row-alt);
}

tbody tr:hover {
  background: var(--row-hover);
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active {
  background: var(--badge-ok-bg);
  color: var(--ok);
}

.badge-inactive {
  background: var(--badge-bad-bg);
  color: var(--danger);
}

thead tr:not(.filter-row) th.col-pret-emag {
  color: var(--emag-price);
  background: var(--tint-indigo);
  font-weight: 700;
}

thead tr:not(.filter-row) th.col-pret-emag:hover {
  background: var(--tint-indigo-hover);
}

td.col-pret-emag {
  color: var(--emag-price);
  font-weight: 700;
  background: var(--tint-violet);
}

td[data-col="pret_minim_profit"].is-below-emag {
  color: var(--danger);
  font-weight: 700;
}

td[data-col="prp"].is-prp-low {
  color: var(--danger);
  font-weight: 700;
}

td.col-pret-emag .input-sale-price {
  width: 6.5rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--emag-price);
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

td.col-pret-emag .input-sale-price:focus {
  outline: 2px solid color-mix(in srgb, var(--emag-price) 35%, transparent);
  border-color: var(--emag-price);
}

/* Produse fără nicio comandă: preț de vânzare bej (dirty/synced au prioritate, definite mai jos) */
tr.is-no-orders td.col-pret-emag {
  background: var(--tint-beige);
  box-shadow: inset 3px 0 0 var(--rule-beige);
}

tr.is-no-orders td.col-pret-emag .input-sale-price {
  background: var(--tint-beige);
  border-color: var(--rule-beige);
}

tbody tr.is-evening-no-orders td.col-pret-cumparare {
  color: var(--warn);
  background: var(--tint-amber);
  box-shadow: inset 3px 0 0 var(--rule-amber);
}

tbody tr.is-evening-no-orders td.col-pret-cumparare .input-pret-cumparare {
  color: var(--warn);
  font-weight: 700;
  border-color: var(--rule-amber);
}

td.col-stoc .input-stock {
  width: 4.5rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.875rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

td.col-stoc .input-stock:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

td.col-dim .input-dim {
  width: 4.5rem;
  font: inherit;
  font-size: 0.875rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

td.col-dim .input-dim:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

td.col-dim.is-dim-blue .input-dim,
td[data-col="greutate_volumetrica"].is-dim-blue {
  color: var(--accent);
  font-weight: 700;
}

td.col-dim.is-dim-gray .input-dim,
td[data-col="greutate_volumetrica"].is-dim-gray {
  color: var(--muted);
  font-weight: 500;
}

td.col-name .input-name,
td[data-col="name"] .input-name {
  display: block;
  width: 100%;
  min-width: 16rem;
  min-height: 4rem;
  max-height: 10rem;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.35;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  box-sizing: border-box;
  resize: vertical;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

td.col-name .input-name:focus,
td[data-col="name"] .input-name:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

td.col-images,
td[data-col="images"] {
  min-width: 9rem;
  vertical-align: middle;
}

.product-images-cell {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-start;
}

.product-images-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.product-image-thumb {
  position: relative;
  display: inline-block;
  width: 2.75rem;
  height: 2.75rem;
}

.product-image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  cursor: pointer;
}

.product-image-thumb.is-primary img {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.product-image-thumb .btn-set-primary {
  position: absolute;
  bottom: -0.3rem;
  left: -0.3rem;
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  line-height: 1;
  font-size: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted, var(--text));
  cursor: pointer;
  opacity: 0;
}

.product-image-thumb:hover .btn-set-primary,
.product-image-thumb .btn-set-primary.is-active {
  opacity: 1;
}

.product-image-thumb .btn-set-primary.is-active {
  color: var(--accent);
  border-color: var(--accent);
  cursor: default;
}

.product-image-thumb .btn-set-primary:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-lightbox[hidden] {
  display: none;
}

.image-lightbox-overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay);
}

.image-lightbox-stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  padding: 2.5rem 3.5rem 2rem;
}

.image-lightbox-img {
  display: block;
  max-width: min(90vw, 1100px);
  max-height: 85vh;
  object-fit: contain;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.image-lightbox-close {
  position: absolute;
  top: 0;
  right: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  padding: 0;
  line-height: 1;
  font-size: 1.35rem;
  cursor: pointer;
  color: var(--ink);
  background: var(--surface);
}

.image-lightbox-close:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.image-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
  background: var(--surface);
}

.image-lightbox-nav:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.image-lightbox-prev {
  left: 0.15rem;
}

.image-lightbox-next {
  right: 0.15rem;
}

.image-lightbox-counter {
  position: absolute;
  bottom: 0.15rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.2rem 0.55rem;
  font-size: 0.8125rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.product-image-thumb .btn-delete-image {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  line-height: 1;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.product-image-thumb .btn-delete-image:hover {
  background: color-mix(in srgb, var(--accent) 20%, var(--surface));
}

.product-images-add {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted, var(--text));
  cursor: pointer;
  user-select: none;
}

.product-images-add input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.product-images-add span {
  border: 1px dashed var(--border);
  border-radius: 3px;
  padding: 0.15rem 0.4rem;
}

.product-images-add:hover span {
  border-color: var(--accent);
  color: var(--accent);
}

/* Taburi seturi poze: EN (implicit) | RO | BG | HU */
.product-images-tabs {
  display: flex;
  gap: 0.15rem;
}

.btn-images-tab {
  font: inherit;
  font-size: 0.6875rem;
  line-height: 1;
  padding: 0.15rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted, var(--text));
  cursor: pointer;
}

.btn-images-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-images-tab.is-active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.btn-images-tab.is-empty {
  border-style: dashed;
}

.product-images-note {
  margin: 0;
  font-size: 0.6875rem;
  color: var(--muted, var(--text));
}

/* Pozele preluate din setul EN: vizibile, dar nu se editeaza din tabul altei platforme. */
.product-image-thumb.is-inherited img {
  opacity: 0.55;
  border-style: dashed;
}

.product-images-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.btn-push-images {
  font: inherit;
  font-size: 0.6875rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted, var(--text));
  cursor: pointer;
}

.btn-push-images:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-push-images:disabled {
  opacity: 0.6;
  cursor: default;
}

td.col-description .input-description,
td[data-col="description"] .input-description {
  display: block;
  width: 100%;
  min-width: 18rem;
  min-height: 4rem;
  max-height: 10rem;
  font: inherit;
  font-size: 0.8125rem;
  line-height: 1.35;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  box-sizing: border-box;
  resize: vertical;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

td.col-description .input-description:focus,
td[data-col="description"] .input-description:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

td.col-alte-costuri .alte-costuri-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

td.col-alte-costuri .input-alte-costuri {
  width: 5.5rem;
  font: inherit;
  font-size: 0.875rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

td.col-alte-costuri .input-alte-costuri:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

td.col-alte-costuri .btn-reset-alte {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

td.col-alte-costuri .btn-reset-alte:hover {
  background: var(--tint-red);
  border-color: var(--danger);
  color: var(--danger);
}

td.col-alte-costuri.is-alte-override {
  background: var(--tint-orange);
}

td.col-alte-costuri.is-alte-override .input-alte-costuri {
  border-color: var(--border-orange);
}

td.col-pret-minim .pret-minim-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

td.col-pret-minim .input-pret-minim {
  width: 5.5rem;
  font: inherit;
  font-size: 0.875rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

td.col-pret-minim .input-pret-minim:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

td.col-pret-minim .btn-reset-min {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

td.col-pret-minim .btn-reset-min:hover {
  background: var(--tint-red);
  border-color: var(--danger);
  color: var(--danger);
}

td.col-pret-minim.is-min-override {
  background: var(--tint-orange);
}

td.col-pret-minim.is-min-override .input-pret-minim {
  border-color: var(--border-orange);
}

thead tr:not(.filter-row) th.col-procentaj-emag {
  color: var(--ok);
  background: var(--tint-green-hover);
  font-weight: 700;
}

thead tr:not(.filter-row) th.col-procentaj-emag:hover {
  background: var(--tint-green-hover2);
}

td.col-procentaj-emag {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.col-procentaj-emag.has-emag-commission {
  background: var(--tint-green-soft);
  color: var(--ok);
  font-weight: 600;
}

td.col-procentaj-emag .procentaj-emag-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

td.col-procentaj-emag .input-procentaj-emag {
  width: 4rem;
  font: inherit;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

td.col-procentaj-emag .input-procentaj-emag:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

td.col-procentaj-emag .procentaj-emag-suffix {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

td.col-procentaj-emag .btn-reset-emag-pct {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

td.col-procentaj-emag .btn-reset-emag-pct:hover {
  background: var(--tint-red);
  border-color: var(--danger);
  color: var(--danger);
}

td.col-procentaj-emag .btn-fetch-commission-row {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

td.col-procentaj-emag .btn-fetch-commission-row:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--row-alt);
}

td.col-procentaj-emag .btn-fetch-commission-row:disabled {
  opacity: 0.35;
  cursor: default;
}

td.col-procentaj-emag.is-emag-pct-override {
  background: var(--tint-orange);
}

td.col-procentaj-emag.is-emag-pct-override .input-procentaj-emag {
  border-color: var(--border-orange);
}

tr.is-price-dirty td.col-pret-emag,
td.col-pret-emag.is-price-dirty {
  background: var(--tint-yellow);
  box-shadow: inset 3px 0 0 var(--rule-yellow);
}

td[data-col="prp"].is-price-dirty,
td[data-col="pret_minim"].is-price-dirty,
td[data-col="pret_maxim"].is-price-dirty {
  background: var(--tint-yellow-soft);
}

td.col-stoc.is-price-dirty,
td[data-col="stoc"].is-price-dirty {
  background: var(--tint-yellow);
  box-shadow: inset 3px 0 0 var(--rule-yellow);
}

td.col-name.is-price-dirty,
td[data-col="name"].is-price-dirty,
td.col-description.is-price-dirty,
td[data-col="description"].is-price-dirty {
  background: var(--tint-yellow);
  box-shadow: inset 3px 0 0 var(--rule-yellow);
}

/* Rămâne după sync OK, până la refresh — verificare vizuală subtilă */
tr.is-just-synced td.col-pret-emag,
td.col-pret-emag.is-just-synced {
  background: var(--tint-green);
  box-shadow: inset 3px 0 0 var(--rule-green);
}

td[data-col="prp"].is-just-synced,
td[data-col="pret_minim"].is-just-synced,
td[data-col="pret_maxim"].is-just-synced {
  background: var(--tint-green-soft);
}

td.col-stoc.is-just-synced,
td[data-col="stoc"].is-just-synced {
  background: var(--tint-green);
  box-shadow: inset 3px 0 0 var(--rule-green);
}

td.col-name.is-just-synced,
td[data-col="name"].is-just-synced,
td.col-description.is-just-synced,
td[data-col="description"].is-just-synced {
  background: var(--tint-green);
  box-shadow: inset 3px 0 0 var(--rule-green);
}

thead tr:not(.filter-row) th.col-profit {
  color: var(--ok);
  background: var(--tint-green-hover);
  font-weight: 700;
}

thead tr:not(.filter-row) th.col-profit:hover {
  background: var(--tint-green-hover2);
}

td.col-profit {
  color: var(--ok);
  font-weight: 700;
  background: var(--tint-green-soft);
}

thead tr:not(.filter-row) th.col-procentaj-profit {
  color: var(--ink);
  background: var(--tint-green-hover);
  font-weight: 700;
}

thead tr:not(.filter-row) th.col-procentaj-profit:hover {
  background: var(--tint-green-hover2);
}

td.col-procentaj-profit {
  font-weight: 700;
}

td.col-procentaj-profit .input-procentaj-profit {
  width: 5.5rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.875rem;
  color: inherit;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
}

td.col-procentaj-profit .input-procentaj-profit:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
  background: var(--surface);
}

td.col-procentaj-profit.pct-1 {
  color: var(--danger);
  background: var(--tint-red-soft);
}

td.col-procentaj-profit.pct-2 {
  color: var(--accent);
  background: var(--tint-blue-softest);
}

.col-menu-wrap {
  position: relative;
}

.col-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 20;
  min-width: 13rem;
  max-height: min(70vh, 28rem);
  overflow-y: auto;
  padding: 0.45rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px var(--shadow-2);
}

.col-ctx-menu {
  position: fixed;
  z-index: 1000;
  min-width: 12rem;
  padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px var(--shadow-2);
}

.col-ctx-menu[hidden] {
  display: none;
}

.col-ctx-menu button {
  display: block;
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}

.col-ctx-menu button:hover,
.col-ctx-menu button:focus-visible {
  background: var(--surface-alt);
}

.col-menu-item {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  border-radius: 4px;
  border-top: 2px solid transparent;
  border-bottom: 2px solid transparent;
}

.col-menu-item[data-src="channel"] {
  background: var(--tint-blue);
  box-shadow: inset 3px 0 0 var(--rule-blue);
}

.col-menu-item[data-src="db"] {
  background: var(--tint-amber);
  box-shadow: inset 3px 0 0 var(--rule-amber);
}

.col-menu-item[data-src="calc"] {
  background: var(--tint-green);
  box-shadow: inset 3px 0 0 var(--rule-green);
}

.col-menu-item[data-src="listing"] {
  background: var(--tint-purple);
  box-shadow: inset 3px 0 0 var(--rule-purple);
}

.col-menu-item.is-dragging {
  opacity: 0.45;
}

.col-menu-item.is-drop-before {
  border-top-color: var(--accent);
}

.col-menu-item.is-drop-after {
  border-bottom-color: var(--accent);
}

.col-drag-handle {
  flex-shrink: 0;
  width: 1.1rem;
  text-align: center;
  font-size: 0.7rem;
  line-height: 1;
  letter-spacing: -0.05em;
  color: var(--muted, #8a94a6);
  cursor: grab;
  user-select: none;
}

.col-menu-item:active .col-drag-handle {
  cursor: grabbing;
}

.col-menu label {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.4rem 0.35rem 0.15rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}

.col-menu-item:hover {
  filter: brightness(0.96);
}

.col-menu-item[data-src="channel"]:hover {
  background: var(--tint-blue-hover);
}

.col-menu-item[data-src="db"]:hover {
  background: var(--tint-amber-hover);
}

.col-menu-item[data-src="calc"]:hover {
  background: var(--tint-green-hover);
}

.col-menu-item[data-src="listing"]:hover {
  background: var(--tint-purple-hover);
}

.col-menu input {
  margin: 0;
  accent-color: var(--accent);
}

#products-table th.is-col-hidden,
#products-table td.is-col-hidden,
#pricing-table th.is-col-hidden,
#pricing-table td.is-col-hidden {
  display: none;
}

/* Descrierea in tabelul de preturi e doar text — o limitez la 3 randuri.
   :not(.is-col-hidden) ca display:-webkit-box sa nu bata display:none la ascundere. */
#pricing-table td.col-description-ro:not(.is-col-hidden) {
  max-width: 22rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  padding-bottom: 0.1rem;
}

.site-nav a:hover {
  color: var(--accent);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.field select {
  width: 8.5rem;
  font: inherit;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--ink);
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.field input[type="datetime-local"] {
  width: 14rem;
}

.field-hint {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--muted);
}

.field-readonly-info .field-value-line {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.15rem;
  padding: 0.35rem 0;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}

.field-edit-link {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.field-edit-link:hover {
  text-decoration: underline;
}

.btn-order-history {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.35rem 0.55rem;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  white-space: nowrap;
}

.btn-order-history:hover {
  border-color: var(--accent);
  background: var(--row-alt);
}

.order-history-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgb(15 23 42 / 45%);
}

.order-history-modal[hidden] {
  display: none;
}

.order-history-dialog {
  width: min(1100px, 96vw);
  max-height: min(800px, 92vh);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 1rem 3rem rgb(15 23 42 / 25%);
}

.order-history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.order-history-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.order-history-product {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.order-history-body {
  max-height: calc(min(800px, 92vh) - 5rem);
  overflow: auto;
  padding: 1rem 1.25rem 1.25rem;
}

.order-history-count {
  margin-bottom: 0.6rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.order-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.order-history-table th,
.order-history-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.order-history-table th {
  position: sticky;
  top: 0;
  background: var(--row-alt);
  color: var(--muted);
  font-size: 0.75rem;
}

.order-row {
  cursor: pointer;
}

.btn-expand {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
  padding: 0;
}

.btn-expand:hover {
  background: var(--row-alt);
  border-color: var(--accent);
  color: var(--accent);
}

.orders-table .col-expand {
  width: 2.5rem;
  text-align: center;
}

.order-row.is-expanded {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.order-detail-row > td {
  background: var(--detail-bg);
  padding: 0.5rem 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.order-products-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.order-products-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.order-products-table th,
.order-products-table td {
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.order-products-table th {
  background: var(--row-alt);
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 700;
}

.order-products-table tr:last-child td {
  border-bottom: none;
}

.order-products-table .is-missing,
.order-products-table .muted,
.product-cancelled {
  color: var(--muted);
}

.product-cancelled td {
  text-decoration: line-through;
  opacity: 0.75;
}

.product-cancelled .muted {
  text-decoration: none;
}

.status-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--row-alt);
  color: var(--ink);
}

.status-new {
  background: var(--tint-blue);
  color: var(--st-new-ink);
}

.status-progress {
  background: var(--tint-amber);
  color: var(--st-prog-ink);
}

.status-prepared {
  background: var(--st-prep-bg);
  color: var(--st-prep-ink);
}

.status-finalized {
  background: var(--st-fin-bg);
  color: var(--st-fin-ink);
}

.status-cancelled {
  background: var(--tint-red);
  color: var(--st-canc-ink);
}

.status-returned {
  background: var(--st-ret-bg);
  color: var(--st-ret-ink);
}

@media (max-width: 640px) {
  .page {
    padding: 0.75rem 0.35rem 0;
  }

  .header h1 {
    font-size: 1.4rem;
  }

  .field input[type="datetime-local"] {
    width: 100%;
    max-width: 14rem;
  }
}

/* ---------- Istoric preț: coloană vechime + buton + modal ---------- */
.col-pret-schimbat {
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--muted);
}
.col-pret-schimbat.is-stale-fresh {
  color: var(--ok);
}
.col-pret-schimbat.is-stale-warn {
  color: var(--warn);
}
.col-pret-schimbat.is-stale-old {
  color: var(--danger);
  font-weight: 600;
}

.col-istoric {
  text-align: center;
}
.btn-history {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.2;
}
.btn-history:hover {
  border-color: var(--accent);
  background: var(--row-alt);
}

.btn-push-row,
.btn-pull-row {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  padding: 0.1rem 0.4rem;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.2;
}
.btn-push-row:hover:not(:disabled),
.btn-pull-row:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--row-alt);
}
.btn-push-row:disabled,
.btn-pull-row:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Stari din coada de publicare pe rand */
.btn-push-row {
  min-width: 2rem;
  font-variant-numeric: tabular-nums;
}
.btn-push-row.is-queued {
  border-color: var(--rule-amber);
  background: var(--tint-amber);
  color: var(--warn);
  font-size: 0.8rem;
  font-weight: 600;
}
.btn-push-row.is-sending,
.btn-push-row.is-sending:disabled {
  opacity: 1;
  border-color: var(--accent);
  cursor: progress;
  position: relative;
  min-height: 1.45rem;
}
.btn-push-row.is-sending::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: push-spin 0.7s linear infinite;
}
.btn-push-row.is-done,
.btn-push-row.is-done:disabled {
  opacity: 1;
  border-color: var(--rule-green);
  background: var(--tint-green);
  color: var(--ok);
  font-weight: 700;
}
.btn-push-row.is-error {
  border-color: var(--danger);
  background: var(--tint-red);
  color: var(--danger);
  font-weight: 700;
}
#pricing-table tr.is-push-sending td {
  background-image: linear-gradient(var(--tint-blue-softest), var(--tint-blue-softest));
}
#pricing-table tr.is-push-error td[data-col="push"] {
  background: var(--tint-red-soft);
}
@keyframes push-spin {
  to {
    transform: rotate(360deg);
  }
}

.push-queue {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 900;
  width: min(360px, calc(100vw - 32px));
  max-height: min(60vh, 440px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 28px var(--shadow-2);
  font-size: 0.85rem;
  animation: push-queue-in 0.18s ease-out;
}
.push-queue[hidden] {
  display: none;
}
@keyframes push-queue-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.push-queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem 0.45rem;
}
.push-queue-head-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.push-queue-close {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}
.push-queue-close:hover {
  color: var(--ink);
}
.push-queue-progress {
  height: 3px;
  margin: 0 0.75rem 0.4rem;
  background: var(--surface-alt);
  border-radius: 2px;
  overflow: hidden;
}
.push-queue-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease;
}
.push-queue-progress.has-error span {
  background: var(--warn);
}
.push-queue-list {
  list-style: none;
  margin: 0;
  padding: 0 0.4rem 0.4rem;
  overflow-y: auto;
}
.push-queue-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem;
  border-radius: 6px;
}
.push-queue-item + .push-queue-item {
  border-top: 1px solid var(--surface-alt);
}
.push-queue-icon {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--surface-alt);
  color: var(--muted);
}
.push-queue-item.is-sending .push-queue-icon {
  background: none;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  animation: push-spin 0.7s linear infinite;
}
.push-queue-item.is-done .push-queue-icon {
  background: var(--tint-green);
  color: var(--ok);
}
.push-queue-item.is-error .push-queue-icon {
  background: var(--tint-red);
  color: var(--danger);
}
.push-queue-item.is-error {
  background: var(--tint-red-soft);
}
.push-queue-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.push-queue-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.push-queue-detail {
  color: var(--muted);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}
.push-queue-item.is-error .push-queue-detail {
  color: var(--danger);
}
.push-queue-action {
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
  cursor: pointer;
}
.push-queue-action:hover {
  border-color: var(--accent);
  background: var(--row-alt);
}
.push-queue-hint {
  margin: 0;
  padding: 0.4rem 0.75rem 0.6rem;
  color: var(--muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--surface-alt);
}
@media (max-width: 600px) {
  .push-queue {
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
  }
}

body.modal-open {
  overflow: hidden;
}
.history-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.history-modal[hidden] {
  display: none;
}
.history-modal-overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay);
}
.history-modal-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px var(--shadow-3);
  width: min(820px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.1rem 1.25rem 1.25rem;
}
.history-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.history-modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}
.history-modal-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.history-modal-close:hover {
  color: var(--ink);
}
.history-modal-sub {
  margin: 0.25rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.history-chart-wrap {
  position: relative;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--row-alt);
  padding: 0.25rem;
}
#history-chart {
  width: 100%;
  height: auto;
  display: block;
}
.chart-axis {
  stroke: var(--border);
  stroke-width: 1;
}
.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.6;
}
.chart-tick {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--font);
}
.chart-line {
  stroke: var(--emag-price);
  stroke-width: 2;
}
.chart-dot {
  fill: var(--emag-price);
  stroke: var(--surface);
  stroke-width: 1.5;
  cursor: pointer;
}
.chart-dot:hover {
  r: 6;
}
.chart-empty-text {
  fill: var(--muted);
  font-size: 13px;
  font-family: var(--font);
}
.history-chart-tooltip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: var(--ink);
  color: var(--bg);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}
.history-chart-tooltip[hidden] {
  display: none;
}
.history-section-title {
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
}
.history-orders-wrap {
  max-height: 40vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.history-orders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.history-orders-table th,
.history-orders-table td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.history-orders-table thead th {
  position: sticky;
  top: 0;
  background: var(--row-alt);
  z-index: 1;
}
.history-orders-empty {
  color: var(--muted);
  text-align: center;
}

.export-wrap {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
}

.export-wrap #btn-export {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.btn-caret {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: -1px;
}

.export-menu {
  left: auto;
  right: 0;
  min-width: 15rem;
}

.export-menu-item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.export-menu-item:hover {
  background: var(--surface-alt);
}

/* ---------- Comutator temă (light / dark) ---------- */
/* Containerul fix din dreapta sus: iconita de logs + comutatorul de tema. */
.top-actions {
  position: fixed;
  top: 0.6rem;
  right: 0.75rem;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.top-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px var(--shadow-2);
  text-decoration: none;
}

.top-action-btn svg {
  width: 1.05rem;
  height: 1.05rem;
}

.top-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.top-action-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow-2);
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.theme-toggle .icon-moon {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

/* ---------- Selector canal + pagina de sincronizare ---------- */

.field-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.field-inline > span {
  white-space: nowrap;
}

.field-checkbox input {
  width: auto;
  margin: 0;
}

.sync-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 1.6rem 0 0.5rem;
}

.sync-section-head .sync-section-title {
  margin: 0;
}

.sync-section-title {
  margin: 1.6rem 0 0.5rem;
  font-size: 1rem;
  color: var(--text);
}

.btn-compact {
  font-size: 0.8rem;
  padding: 0.25rem 0.55rem;
}

.toolbar-actions #btn-compact-products,
.toolbar-actions #btn-compact-pricing,
.sync-section-head .btn-compact {
  margin-left: auto;
}

.sync-hint {
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--muted);
}

.sync-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.sync-chip {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--muted);
}

button.sync-chip {
  cursor: pointer;
  font: inherit;
  line-height: inherit;
  appearance: none;
  -webkit-appearance: none;
}

button.sync-chip:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  color: var(--text);
}

button.sync-chip.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

button.sync-chip.is-active strong {
  color: var(--accent);
}

.sync-chip strong {
  color: var(--text);
}

.sync-chip.is-diff {
  border-color: var(--warn);
  color: var(--warn);
}

.sync-chip.is-diff strong {
  color: var(--warn);
}

button.sync-chip.is-diff:hover,
button.sync-chip.is-diff.is-active {
  border-color: var(--warn);
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
}

button.sync-chip.is-diff.is-active strong {
  color: var(--warn);
}

.sync-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.sync-table th,
.sync-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.sync-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-alt);
  z-index: 1;
}

.sync-table .sync-sub {
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--muted);
}

.sync-table td.sync-theirs {
  border-right: 1px solid var(--border);
}

/* Coloanele din catalogul local (data-src="db"): tint discret pe celule, ca
   diferentele (is-diff) sa ramana totusi cele mai vizibile. */
#pricing-table tbody td.is-src-db:not(.is-diff) {
  background: color-mix(in srgb, var(--tint-amber) 55%, transparent);
}

/* Override-uri locale pe oferta (marketplace_listings) — alta culoare decat
   catalogul local, ca sa se distinga cele doua surse din DB. */
#pricing-table tbody td.is-src-listing:not(.is-diff) {
  background: color-mix(in srgb, var(--tint-purple) 55%, transparent);
}

.sync-table td.is-diff,
#pricing-table td.is-diff {
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  font-weight: 600;
}

.sync-table tr.has-diff td:first-child,
#pricing-table tr.has-diff td:first-child {
  border-left: 3px solid var(--warn);
}

/* Ofertă prezentă pe canal, dar fără produs în catalogul local. */
#pricing-table tr.is-remote-only td:first-child {
  border-left: 3px solid var(--muted);
}
#pricing-table tr.is-remote-only {
  opacity: 0.85;
}

/* Prețuri și marjă: fără tinturi decorative — doar is-diff / has-diff */
#pricing-table thead tr:not(.filter-row) th[data-src],
#pricing-table thead tr:not(.filter-row) th[data-src]:hover,
#pricing-table thead tr:not(.filter-row) th.col-pret-emag,
#pricing-table thead tr:not(.filter-row) th.col-pret-emag:hover,
#pricing-table thead tr:not(.filter-row) th.col-procentaj-emag,
#pricing-table thead tr:not(.filter-row) th.col-procentaj-emag:hover,
#pricing-table thead tr:not(.filter-row) th.col-profit,
#pricing-table thead tr:not(.filter-row) th.col-profit:hover,
#pricing-table thead tr:not(.filter-row) th.col-procentaj-profit,
#pricing-table thead tr:not(.filter-row) th.col-procentaj-profit:hover {
  color: inherit;
  background: var(--surface-alt);
  box-shadow: none;
  font-weight: 600;
}

#pricing-table td.col-pret-emag,
#pricing-table td.col-profit,
#pricing-table td.col-procentaj-emag,
#pricing-table td.col-procentaj-emag.has-emag-commission,
#pricing-table td.col-procentaj-emag.is-emag-pct-override,
#pricing-table td.col-procentaj-profit,
#pricing-table td.col-procentaj-profit.pct-1,
#pricing-table td.col-procentaj-profit.pct-2,
#pricing-table td[data-col="pret_minim_profit"].is-below-emag,
#pricing-table td.col-pret-schimbat.is-stale-fresh,
#pricing-table td.col-pret-schimbat.is-stale-warn,
#pricing-table td.col-pret-schimbat.is-stale-old {
  color: inherit;
  background: transparent;
  font-weight: inherit;
}

/* Pretul de pe canal ramane evidentiat (violet), ca sa iasa in ochi in tabel. */
#pricing-table thead tr:not(.filter-row) th.col-pret-emag,
#pricing-table thead tr:not(.filter-row) th.col-pret-emag:hover {
  color: var(--emag-price);
  font-weight: 700;
}

#pricing-table td.col-pret-emag {
  background: var(--tint-violet);
}

#pricing-table td.col-pret-emag .diff-mine,
#pricing-table td.col-pret-emag:not(.is-diff) {
  color: var(--emag-price);
  font-weight: 700;
}

#pricing-table td.is-diff {
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  font-weight: 600;
}

#pricing-table td.is-diff .diff-mine {
  display: block;
  font-weight: 600;
}

#pricing-table td.is-diff .diff-vs {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

/* Nume/descriere: badge-ul local se incadreaza in coloana, nu forteaza latimea. */
#pricing-table td.is-diff .diff-vs-text {
  white-space: normal;
  overflow-wrap: anywhere;
}

.table-wrap.is-compact #pricing-table td.is-diff .diff-vs {
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-wrap.is-compact #pricing-table td.is-diff .diff-vs-text {
  white-space: nowrap;
}

.table-wrap.is-compact #pricing-table td.is-diff {
  white-space: normal;
  max-width: 11rem;
  vertical-align: top;
}

/* Compact: un rând, truncate, hover via title */
.table-wrap.is-compact td {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 10rem;
}

.table-wrap.is-compact #pricing-table td.col-name:not(.is-col-hidden),
.table-wrap.is-compact #pricing-table td.col-description-ro:not(.is-col-hidden) {
  max-width: 12rem;
  display: table-cell;
  -webkit-line-clamp: unset;
  -webkit-box-orient: unset;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
}

.table-wrap.is-compact #pricing-table td[data-col="id"],
.table-wrap.is-compact #pricing-table td[data-col="part_number"],
.table-wrap.is-compact #pricing-table td[data-col="ean"],
.table-wrap.is-compact #pricing-table td[data-col="pnk"],
.table-wrap.is-compact #products-table td[data-col="id"],
.table-wrap.is-compact #products-table td[data-col="part_number"],
.table-wrap.is-compact #products-table td[data-col="ean"],
.table-wrap.is-compact #products-table td[data-col="pnk"] {
  max-width: 7rem;
}

.table-wrap.is-compact #products-table td.col-name:not(.is-col-hidden),
.table-wrap.is-compact #products-table td[data-col="name"]:not(.is-col-hidden) {
  max-width: 16rem;
}

.table-wrap.is-compact #products-table td.col-description:not(.is-col-hidden),
.table-wrap.is-compact #products-table td[data-col="description"]:not(.is-col-hidden) {
  max-width: 14rem;
}

.table-wrap.is-compact #products-table td.col-name .input-name,
.table-wrap.is-compact #products-table td[data-col="name"] .input-name,
.table-wrap.is-compact #products-table td.col-description .input-description,
.table-wrap.is-compact #products-table td[data-col="description"] .input-description {
  min-width: 0;
  min-height: 1.75rem;
  max-height: 1.75rem;
  height: 1.75rem;
  padding: 0.2rem 0.35rem;
  resize: none;
  overflow: hidden;
  white-space: nowrap;
  word-break: normal;
  field-sizing: fixed;
  text-overflow: ellipsis;
}

.table-wrap.is-compact #products-table td.col-name .input-name:focus,
.table-wrap.is-compact #products-table td[data-col="name"] .input-name:focus,
.table-wrap.is-compact #products-table td.col-description .input-description:focus,
.table-wrap.is-compact #products-table td[data-col="description"] .input-description:focus {
  position: relative;
  z-index: 2;
  min-height: 4rem;
  max-height: 10rem;
  height: auto;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  text-overflow: unset;
  field-sizing: content;
  resize: vertical;
}

.table-wrap.is-compact .sync-table td {
  max-width: 6.5rem;
}

.sync-table .empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 1rem;
}

.sync-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.sync-summary,
.filter-status {
  flex-shrink: 0;
}

td.col-pret-cumparare .input-pret-cumparare {
  width: 5.5rem;
  font: inherit;
  font-size: 0.875rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

td.col-pret-cumparare .input-pret-cumparare:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

td.col-pret-cumparare-usd .input-pret-cumparare-usd {
  width: 5.5rem;
  font: inherit;
  font-size: 0.875rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

td.col-pret-cumparare-usd .input-pret-cumparare-usd:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

td.col-link-cumparare .link-cumparare-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 12rem;
}

td.col-link-cumparare .input-link-cumparare,
td.col-link-cumparare .input-link-extra {
  flex: 1 1 auto;
  min-width: 9rem;
  font: inherit;
  font-size: 0.8125rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

td.col-link-cumparare .input-link-cumparare:focus,
td.col-link-cumparare .input-link-extra:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

td.col-link-cumparare .btn-open-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  text-decoration: none;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font-size: 0.9rem;
  line-height: 1;
}

td.col-link-cumparare .btn-open-link[hidden] {
  display: none;
}

td.col-link-cumparare .btn-open-link:hover {
  background: var(--surface-alt);
}

/* ---------- Pagina de loguri ---------- */
.logs-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.logs-filters .field {
  min-width: 8rem;
}

.logs-filters .field-search {
  min-width: 16rem;
  flex: 1 1 16rem;
}

.logs-meta {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.logs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.logs-table th,
.logs-table td {
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.logs-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.logs-table tbody tr.log-row {
  cursor: pointer;
}

.logs-table tbody tr.log-row:hover {
  background: var(--surface-alt);
}

.log-time {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.log-message {
  word-break: break-word;
}

.log-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.log-level-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.log-level-badge--debug {
  color: var(--muted);
}

.log-level-badge--info {
  color: var(--accent);
}

.log-level-badge--warn {
  color: #b45309;
}

.log-level-badge--error {
  color: #dc2626;
}

[data-theme="dark"] .log-level-badge--warn {
  color: #fbbf24;
}

[data-theme="dark"] .log-level-badge--error {
  color: #f87171;
}

.log-detail td {
  background: var(--surface-alt);
}

.log-detail pre {
  margin: 0;
  max-height: 22rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.78rem;
  line-height: 1.45;
}

.log-changes {
  border-collapse: collapse;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
  background: var(--surface);
}

.log-changes th,
.log-changes td {
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.log-changes td {
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 32rem;
}

.log-changes-field {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}

.log-changes-from {
  background: var(--tint-red-soft);
}

.log-changes-to {
  background: var(--tint-green-soft);
}

.log-changes-empty {
  color: var(--muted);
  font-style: italic;
}

.logs-pager {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.logs-auto {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding-bottom: 0.55rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.logs-filters select {
  font: inherit;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--ink);
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.logs-filters .field-search input {
  width: 100%;
}

/* ---------- Setări credentiale ---------- */
.cred-section {
  margin: 1.25rem 0 1.75rem;
  padding: 1rem 1.1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  max-width: 32rem;
  scroll-margin-top: 3.5rem;
}

.cred-section.is-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

.cred-section-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.cred-section-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.cred-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-alt, var(--surface));
}

.cred-badge.is-ok {
  color: var(--ok, #1a7f37);
  border-color: color-mix(in srgb, var(--ok, #1a7f37) 40%, var(--border));
}

.cred-badge.is-missing {
  color: var(--danger, #b42318);
  border-color: color-mix(in srgb, var(--danger, #b42318) 40%, var(--border));
}

.cred-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field.field-wide {
  width: 100%;
  max-width: 28rem;
}

.cred-form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.notif-hint {
  margin: 0 0 0.85rem;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--muted);
}

.notif-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  cursor: pointer;
  max-width: 28rem;
}

.notif-toggle span {
  line-height: 1.35;
}

.notif-actions {
  margin-top: 0.75rem;
}

.notif-status {
  margin: 0.65rem 0 0;
  min-height: 1.25em;
  font-size: 0.85rem;
  color: var(--muted);
}

.order-notif-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: min(22rem, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 28px color-mix(in srgb, #000 18%, transparent);
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.order-notif-toast .order-notif-close {
  position: absolute;
  top: 0.25rem;
  right: 0.35rem;
  min-width: 4.5rem;
  height: 2rem;
  padding: 0 0.45rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.order-notif-toast .order-notif-close:hover,
.order-notif-toast .order-notif-close:focus-visible {
  background: color-mix(in srgb, var(--border) 55%, transparent);
  color: var(--text);
}

.order-notif-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.order-notif-toast strong {
  font-size: 0.95rem;
}

.order-notif-toast span {
  font-size: 0.85rem;
  color: var(--muted);
}

.order-notif-toast a {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  margin-top: 0.15rem;
}

.order-notif-toast a:hover {
  text-decoration: underline;
}

.status a.status-settings-link {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.status a.status-settings-link:hover {
  color: var(--accent);
}

/* ---------- Auth gate + login ---------- */
html.auth-pending body {
  visibility: hidden;
}

.login-body {
  min-height: 100%;
  height: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, var(--glow-1), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 80%, var(--glow-2), transparent 50%),
    var(--bg);
}

.login-shell {
  width: 100%;
  max-width: 22rem;
  padding: 1.25rem;
  box-sizing: border-box;
}

/* Formularul de pe pagina de apeluri acoperă ecranul și stă la mijloc. */
#review-login.login-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1.25rem;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, var(--glow-1), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 80%, var(--glow-2), transparent 50%),
    var(--bg);
}

#review-login .login-card {
  width: 100%;
  max-width: 22rem;
}

.login-shell[hidden],
.page[hidden] {
  display: none !important;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.5rem 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px var(--shadow-2);
}

.login-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.login-sub {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.4;
}

.login-field {
  width: 100%;
}

.login-field input {
  width: 100%;
  box-sizing: border-box;
}

.login-error {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--danger);
}

.login-submit {
  margin-top: 0.25rem;
  width: 100%;
  justify-content: center;
}

/* Tooltip text complet pentru celule trunchiate (click / hover) */
.cell-text-tip {
  position: fixed;
  z-index: 1200;
  max-width: min(28rem, calc(100vw - 1rem));
  max-height: min(50vh, 18rem);
  overflow: auto;
  padding: 0.55rem 0.75rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 28px var(--shadow-2);
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  pointer-events: none;
}

.cell-text-tip.is-pinned {
  pointer-events: auto;
}

.cell-text-tip[hidden] {
  display: none;
}

/* Tooltip de diferenta: sursa valorii se citeste din culoare, la fel ca in tabel. */
.cell-text-tip.is-diff-tip {
  white-space: normal;
  display: grid;
  gap: 0.5rem;
}

.cell-text-tip .tip-row {
  display: grid;
  gap: 0.1rem;
  padding-left: 0.5rem;
  border-left: 3px solid currentColor;
}

.cell-text-tip .tip-row-channel {
  color: var(--emag-price);
}

.cell-text-tip .tip-row-local {
  color: var(--accent);
}

.cell-text-tip .tip-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cell-text-tip .tip-value {
  color: var(--ink);
  word-break: break-word;
}

.cell-text-tip .tip-delta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

#pricing-table td.is-cell-overflow {
  cursor: zoom-in;
}



/* ---------- Calculator (parametri + coloane din Excel) ---------- */

.calc-params {
  flex-shrink: 0;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.calc-params > summary {
  cursor: pointer;
  padding: 0.55rem 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.calc-params-summary {
  margin-left: 0.5rem;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted);
}

.calc-params-body {
  padding: 0 0.85rem 0.85rem;
}

.calc-params-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.calc-params-grid .field.field-wide select {
  width: 100%;
}

.calc-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.calc-params-grid .calc-input-wrap input {
  width: 100%;
  min-width: 0;
}

.calc-params-grid input[readonly] {
  background: var(--surface-alt);
  color: var(--muted);
}

.calc-unit {
  flex: 0 0 auto;
  font-weight: 500;
  color: var(--muted);
}

.calc-params-notes {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

td.col-calc {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

td.col-calc.is-calc-negative {
  color: var(--danger);
  font-weight: 600;
  background: var(--tint-red);
}

td.col-calc.is-calc-positive {
  color: var(--ok);
  font-weight: 600;
}

td.col-calc.is-cost-legacy {
  color: var(--muted);
  font-style: italic;
}

td[data-col="moneda_fabrica"] .input-moneda,
td[data-col="nr_bucati"] .input-nr-bucati,
td .input-text-field {
  font: inherit;
  font-size: 0.875rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}

td[data-col="nr_bucati"] .input-nr-bucati {
  width: 4rem;
  text-align: right;
}

td .input-text-field {
  width: 9rem;
}

/* Tabelul de produse: antetele se rup pe 2-3 randuri in loc sa fie taiate cu "…". */
#products-table thead tr:not(.filter-row) th[data-col] {
  white-space: normal;
  min-width: 8.5rem;
  vertical-align: bottom;
}

#products-table thead tr:not(.filter-row) th[data-col] .th-label {
  display: block;
  max-width: none;
  overflow: visible;
  white-space: normal;
  line-height: 1.25;
}

#products-table thead tr:not(.filter-row) th[data-col="index"] {
  min-width: 3rem;
}

#products-table thead tr:not(.filter-row) th[data-col="name"],
#products-table thead tr:not(.filter-row) th[data-col="description"] {
  min-width: 14rem;
}

/* Etichetele din bara de sus si din panoul calculatorului: pe 2 randuri, nu taiate. */
.toolbar-fields .field > span,
.calc-params-grid .field > span:first-child {
  white-space: normal;
  overflow: visible;
  line-height: 1.2;
}

/* Preseturi de coloane (pagina Produse) */
.col-preset-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.col-preset-select {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  max-width: 17rem;
}

.btn-col-preset-delete {
  padding-inline: 0.6rem;
}

/* Panoul de apeluri review */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.review-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  gap: 0.55rem;
  margin-top: 0.65rem;
  padding: 0.35rem 0 0.55rem;
  background: var(--bg);
}

.review-search {
  display: block;
  width: 100%;
}

.review-search input {
  width: 100%;
  min-height: 2.75rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.review-search input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

.review-filters-size {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 2.85rem;
  padding: 0.45rem 0.75rem;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 35%, transparent);
}

.review-filters-size:hover {
  background: color-mix(in srgb, var(--accent) 24%, var(--surface));
}

.review-filters-size:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.review-filters-size-kicker {
  flex: 0 0 auto;
  padding: 0.16rem 0.48rem;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
}

.review-filters-size-label {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  line-height: 1.2;
}

.review-filters-size-chevron {
  flex: 0 0 auto;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.15rem;
  border-right: 2.5px solid var(--accent);
  border-bottom: 2.5px solid var(--accent);
  transform: rotate(45deg) translateY(-0.12rem);
}

.review-toolbar:not(.is-filters-compact) .review-filters-size {
  background: var(--accent);
  color: var(--on-accent);
}

.review-toolbar:not(.is-filters-compact) .review-filters-size:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.review-toolbar:not(.is-filters-compact) .review-filters-size-kicker {
  background: color-mix(in srgb, var(--on-accent) 22%, transparent);
  color: var(--on-accent);
}

.review-toolbar:not(.is-filters-compact) .review-filters-size-chevron {
  border-color: var(--on-accent);
  transform: rotate(225deg) translateY(-0.12rem);
}

.review-toolbar.is-filters-compact .review-filters {
  display: none;
}

.review-filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.4rem;
}

.review-chip {
  appearance: none;
  min-height: 2.75rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.review-chip[data-filter="all"] {
  grid-column: 1 / -1;
}

.review-chip[data-filter="uncalled"],
.review-chip[data-filter="reviewed"] {
  grid-column: 1 / -1;
}

.review-chip[data-filter="called"],
.review-chip[data-filter="romania"] {
  grid-column: span 3;
}

.review-chip[data-filter="returned"],
.review-chip[data-filter="everything"] {
  grid-column: span 3;
}

.review-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.review-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.review-toolbar-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.review-toolbar-bar .btn {
  min-height: 2.75rem;
  flex: 0 0 auto;
}

.review-toolbar-bar .status {
  min-width: 0;
}

.review-list {
  display: grid;
  gap: 0.8rem;
}

.review-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  box-shadow: 0 2px 5px var(--shadow-1);
}

.review-card.is-called {
  border-left-color: var(--ok);
  opacity: 0.72;
}

.review-card.has-review {
  border-left-color: var(--ok);
}

.review-left-badge {
  background: color-mix(in srgb, var(--ok) 16%, var(--surface));
  color: var(--ok);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
}

.review-given {
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--ok) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--border));
}

.review-given-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.review-given-head time {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8rem;
}

.review-stars {
  color: #eab308;
  letter-spacing: 0.04em;
}

.review-given-title {
  margin-top: 0.25rem;
  font-weight: 700;
}

.review-given p {
  margin: 0.3rem 0 0;
  white-space: pre-wrap;
}

.review-card-head,
.review-customer,
.review-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.review-card-head {
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.review-card-head time {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

.review-called {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  font-weight: 700;
  color: var(--ok);
}

.review-order-id {
  color: var(--muted);
  font-size: 0.9rem;
}

.review-customer {
  padding: 0.75rem 0;
}

.review-phone {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.review-phones {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.review-phone-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.review-country {
  margin-left: auto;
  font-weight: 600;
}

.review-products {
  display: grid;
  gap: 0.65rem;
}

.review-product {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  padding: 0.65rem;
  background: var(--surface-alt);
  border-radius: 6px;
}

.review-product-image {
  width: 72px;
  height: 72px;
  object-fit: contain;
  flex: 0 0 72px;
  border-radius: 5px;
  background: var(--surface);
}

.review-product-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.review-product-info {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.review-price {
  font-weight: 700;
  color: var(--emag-price);
}

.btn-small {
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
}

@media (max-width: 700px) {
  .review-card-head time,
  .review-country {
    margin-left: 0;
  }

  .review-product {
    align-items: flex-start;
  }
}

/* ---------- Promotie activa pe canal (pretul nu se trimite) ---------- */
.promo-badge {
  display: block;
  margin-top: 0.25rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--warn);
  background: var(--tint-amber);
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ---------------- Statistici ---------------- */

:root {
  --viz-pos: #2a78d6;
  --viz-neg: #e34948;
  --viz-grid: #e6eaf0;
  --viz-zero: #b8c2ce;
  --viz-track: #eef2f7;
}

[data-theme="dark"] {
  --viz-pos: #3987e5;
  --viz-neg: #e66767;
  --viz-grid: #232b36;
  --viz-zero: #4a5666;
  --viz-track: #1d242e;
}

.stats-page {
  overflow: auto;
  padding: 0.75rem clamp(0.5rem, 2vw, 1.5rem) 2rem;
}

.stats-page > * {
  flex-shrink: 0;
}

.stats-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin: 0.9rem 0 0.75rem;
}

.stats-toolbar .field {
  width: auto;
}

.stats-toolbar .field input[type="date"] {
  width: 9.5rem;
}

.stats-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.stats-chip {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.stats-chip:hover {
  border-color: var(--accent);
}

.stats-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.stats-chip-count {
  font-weight: 400;
  opacity: 0.75;
}

.stats-alerts {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.stats-alerts:empty {
  display: none;
}

.stats-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  background: var(--surface);
  font-size: 0.92rem;
  line-height: 1.4;
}

.stats-alert.is-warn {
  border-left-color: var(--rule-amber);
  background: var(--tint-amber);
}

.stats-alert.is-bad {
  border-left-color: var(--danger);
  background: var(--tint-red-soft);
}

.stats-alert.is-info {
  border-left-color: var(--banner-accent);
  background: var(--banner-bg);
}

.stats-alert-icon {
  flex: 0 0 auto;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--surface);
  background: var(--muted);
}

.stats-alert.is-warn .stats-alert-icon { background: var(--rule-amber); }
.stats-alert.is-bad .stats-alert-icon { background: var(--danger); }
.stats-alert.is-info .stats-alert-icon { background: var(--banner-accent); }

.stats-section {
  margin: 0.5rem 0 1rem;
}

.stats-h2 {
  margin: 0.75rem 0 0.6rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.stats-h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 700;
}

.stats-h2-note {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.35rem;
}

.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px var(--shadow-1);
  min-width: 0;
}

.stats-card-note {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.stats-grid-2,
.stats-grid-3 {
  display: grid;
  gap: 0 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
}

.stats-grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.stats-kpis {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  margin-bottom: 1rem;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.kpi-hero {
  grid-column: span 2;
}

@media (max-width: 460px) {
  .kpi-hero {
    grid-column: span 1;
  }
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.kpi-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.kpi-hero .kpi-value {
  font-size: 2.6rem;
  line-height: 1.1;
}

.kpi-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.kpi-delta {
  font-weight: 700;
  color: var(--muted);
}

.kpi-delta.is-good { color: var(--ok); }
.kpi-delta.is-bad { color: var(--danger); }

.is-neg {
  color: var(--danger);
}

.stats-empty {
  margin: 0.5rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stats-chart {
  width: 100%;
  min-height: 220px;
}

.stats-chart-sm {
  min-height: 180px;
}

.viz {
  display: block;
  max-width: 100%;
  overflow: visible;
}

.viz-grid {
  stroke: var(--viz-grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.viz-grid.viz-zero {
  stroke: var(--viz-zero);
}

.viz-tick {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.viz-pos { fill: var(--viz-pos); }
.viz-neg { fill: var(--viz-neg); }

.viz-hit {
  fill: transparent;
  cursor: default;
}

.viz-hit:hover {
  fill: var(--viz-grid);
  fill-opacity: 0.45;
}

.viz-barlist {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.viz-barrow {
  display: grid;
  grid-template-columns: minmax(8rem, 40%) 1fr auto;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.86rem;
}

.viz-barrow.is-total {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  font-weight: 700;
}

.viz-barlabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viz-bartrack {
  height: 12px;
  border-radius: 0 4px 4px 0;
  background: var(--viz-track);
  overflow: hidden;
}

.viz-barfill {
  display: block;
  height: 100%;
  min-width: 2px;
  background: var(--viz-pos);
  border-radius: 0 4px 4px 0;
}

.viz-barfill.is-neg {
  background: var(--viz-neg);
}

.viz-barvalue {
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 5.5rem;
}

.stats-tooltip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  max-width: 280px;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.8rem;
  line-height: 1.4;
  box-shadow: 0 4px 14px var(--shadow-2);
}

.stats-table-scroll {
  overflow-x: auto;
  max-width: 100%;
}

.stats-table {
  min-width: 100%;
  font-size: 0.85rem;
}

.stats-table th,
.stats-table td {
  padding: 0.5rem 0.6rem;
  white-space: nowrap;
}

.stats-table th {
  position: static;
}

.stats-table th.is-sortable {
  cursor: pointer;
  user-select: none;
}

.stats-table th.is-sortable:hover {
  color: var(--accent);
}

.stats-table .is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stats-table tbody tr:hover {
  background: var(--row-hover);
}

.stats-prod {
  display: inline-block;
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.stats-code {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.stats-details {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.stats-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.stats-method-list {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--muted);
}

.stats-method-list b {
  color: var(--ink);
}

@media (max-width: 640px) {
  .stats-prod {
    max-width: 12rem;
  }

  .kpi-hero .kpi-value {
    font-size: 2.1rem;
  }
}
