/* Календарь продаж — карточка на странице + выдвижная панель */

.upload-cal-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--bg2) 0%, var(--bg3) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r, 14px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.upload-cal-card-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

.upload-cal-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(124, 92, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.upload-cal-card-title {
  font-size: 16px;
  font-weight: 700;
}

.upload-cal-card-sub {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
  line-height: 1.45;
}

.upload-cal-summary-stat {
  color: var(--text);
  font-weight: 600;
}

.upload-cal-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.upload-cal-quick-label {
  cursor: pointer;
}

/* Backdrop + drawer */
.upload-cal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9810;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.upload-cal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.upload-cal-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  z-index: 9825;
  background: var(--bg2);
  border-left: 1px solid var(--border2);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.upload-cal-drawer.open {
  transform: translateX(0);
}

body.upload-cal-open {
  overflow: hidden;
}

.upload-cal-drawer-hdr {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  flex-shrink: 0;
}

.upload-cal-drawer-title {
  font-size: 17px;
  font-weight: 800;
}

.upload-cal-drawer-sub {
  font-size: 11px;
  color: var(--text2);
  margin-top: 4px;
  line-height: 1.35;
}

.upload-cal-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}

.upload-cal-close:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.upload-cal-drawer-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  flex-shrink: 0;
}

.upload-cal-tab {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.upload-cal-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.upload-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px 10px;
  flex-shrink: 0;
}

.upload-cal-nav-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}

.upload-cal-nav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.upload-cal-summary-hint {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--accent3, #a78bfa);
  line-height: 1.4;
}

.upload-cal-legend {
  padding: 0 14px 8px;
  font-size: 11px;
  color: var(--text2);
  line-height: 1.4;
}

.upload-cal-month-pick {
  flex: 1;
  min-width: 0;
  max-width: 220px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.upload-cal-jump {
  display: flex;
  gap: 6px;
  padding: 0 14px 8px;
}

.upload-cal-jump-btn {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.upload-cal-jump-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.upload-cal-to-products {
  padding: 0 14px 10px;
}

.upload-cal-month-title {
  font-size: 15px;
  font-weight: 700;
  text-transform: capitalize;
}

.upload-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  padding: 0 14px 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
}

.upload-cal-dow {
  font-size: 10px;
  text-align: center;
  color: var(--text3);
  font-weight: 700;
  padding: 4px 0;
}

.upload-cal-day {
  aspect-ratio: 1;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg3);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px;
  font-family: inherit;
  color: var(--text);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.1s ease;
}

.upload-cal-day:hover {
  border-color: var(--accent);
  transform: scale(1.04);
}

.upload-cal-day.out-range {
  opacity: 0.2;
  pointer-events: none;
  border: none;
  background: transparent;
}

.upload-cal-day.loaded {
  background: rgba(52, 211, 153, 0.2);
  border-color: rgba(52, 211, 153, 0.55);
}

.upload-cal-day.closed {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.upload-cal-day.selected {
  background: rgba(124, 92, 255, 0.28);
  border-color: var(--accent);
  color: #fff;
}

.upload-cal-day .cal-rows {
  font-size: 8px;
  font-weight: 800;
  color: var(--green);
  line-height: 1;
}

.upload-cal-day.selected .cal-rows {
  color: rgba(255, 255, 255, 0.85);
}

.upload-cal-drawer-foot {
  flex-shrink: 0;
  padding: 12px 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg3);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upload-cal-selected-line {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.upload-cal-day-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.upload-cal-day-actions.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.upload-cal-day-actions label {
  cursor: pointer;
}

.upload-cal-day-actions .upload-btn.secondary,
.upload-cal-card-actions .upload-btn.secondary {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
}

@media (max-width: 520px) {
  .upload-cal-drawer {
    width: 100vw;
  }
  .upload-cal-day {
    min-height: 38px;
    font-size: 12px;
  }
}

/* История продаж в карточке товара */
.pdp-history-wrap {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.pdp-history-intro {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.45;
  margin-bottom: 8px;
}

.pdp-history-toggle {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: rgba(124, 92, 255, 0.12);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.pdp-history-toggle:hover {
  background: rgba(124, 92, 255, 0.22);
}

.pdp-listed-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
}

.pdp-listed-row input[type="date"] {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-family: inherit;
}

.pdp-chart {
  margin-top: 12px;
}

.pdp-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 8px;
}

.pdp-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.pdp-chart-col {
  flex: 0 0 12px;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: 1px;
  height: 100%;
  min-width: 12px;
}

.pdp-chart-bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.pdp-chart-bar.wb {
  background: var(--accent3, #a78bfa);
}

.pdp-chart-bar.oz {
  background: var(--blue, #60a0f2);
}

.pdp-chart-empty {
  font-size: 12px;
  color: var(--text3);
  padding: 16px 0;
  text-align: center;
}

/* ── Приоритет: компактная таблица ── */
.priority-panel {
  margin: 0 0 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg2);
  overflow: hidden;
}
.pri-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}
@media (max-width: 900px) {
  .pri-toolbar { grid-template-columns: 1fr; }
}
.pri-toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.pri-select {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: 12px;
}
.pri-abc-chips { display: flex; gap: 3px; }
.pri-chip {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.pri-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pri-chip-a.active { background: #16a34a; border-color: #16a34a; }
.pri-chip-b.active { background: #ca8a04; border-color: #ca8a04; }
.pri-chip-c.active { background: #64748b; border-color: #64748b; }
.pri-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 10px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border2, var(--border));
  background: var(--bg2);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.12);
}
.pri-search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99,102,241,.2);
}
.pri-search-ico { flex-shrink: 0; color: var(--text3); }
.pri-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.pri-search-input::placeholder { color: var(--text3); }
.pri-search-clear {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: rgba(255,255,255,.08);
  color: var(--text2);
  cursor: pointer;
  font-size: 11px;
}
.pri-toolbar-actions { display: flex; gap: 6px; }
.pri-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.pri-btn:hover { border-color: var(--accent); }
.pri-btn-green { background: #16a34a; border-color: #16a34a; color: #fff; }
.priority-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,.08);
}
.pri-meta { white-space: nowrap; }
.pri-meta-abc { display: inline-flex; gap: 5px; }
.pri-meta-abc i { font-style: normal; }
.pri-warn { color: #f59e0b; font-weight: 600; }
.pri-meta-muted { color: var(--text3); font-size: 11px; }
.priority-table-wrap {
  overflow: auto;
  max-height: min(74vh, 720px);
  -webkit-overflow-scrolling: touch;
  width: 100%;
}
.priority-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  font-size: 12.5px;
  line-height: 1.3;
  table-layout: fixed;
}
.priority-table th,
.priority-table td {
  padding: 4px 5px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid rgba(255,255,255,.04);
  vertical-align: middle;
}
.priority-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #1e1f35;
  color: #c8cde8;
  font-size: 11px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: .01em;
  white-space: normal;
  word-break: keep-all;
  line-height: 1.3;
  user-select: none;
  padding: 6px 7px;
}
.priority-table thead th.pri-th-highlight {
  background: #3b1f6e;
  color: #e4bbff;
  border-left: 2px solid #8b5cf6;
}
.pri-sort { cursor: pointer; }
.pri-sort:hover { color: var(--text); }
.pri-sorted::after { content: ' ▲'; font-size: 8px; opacity: .8; }
.pri-sorted-desc::after { content: ' ▼'; }
.pri-col-n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pri-col-entity { text-align: center; width: 34px; max-width: 34px; min-width: 34px; padding-left: 2px; padding-right: 2px; }
.pri-col-abc { text-align: center; width: 28px; max-width: 28px; min-width: 28px; padding-left: 2px; padding-right: 2px; }
.pri-col-product { width: 26%; min-width: 190px; max-width: 320px; white-space: normal; }
/* Ширины числовых столбцов (table-layout: fixed) */
.pri-col-rub  { width: 5.5%; }
.pri-col-qty  { width: 7%; }
.pri-col-pct  { width: 5%; }
.pri-col-coef { width: 4.5%; }
.pri-col-q    { width: 7.5%; }
.pri-col-q { font-weight: 700; color: #c4b5fd; min-width: 64px; }
.pri-q-hot { color: #e9d5ff !important; background: rgba(139,92,246,.12); }
/* Выделение колонок Заказы и Выкупы */
.pri-col-qty { font-size: 14px !important; font-weight: 700; color: #e2e8f0; }
/* Колонка ликвидации */
.pri-col-liq { width: 28px; max-width: 28px; text-align: center; padding: 2px; }
.pri-liq-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 3px;
  border-radius: 4px;
  opacity: .25;
  transition: opacity .15s, background .15s;
  display: block;
  width: 100%;
}
.pri-liq-btn:hover { opacity: 1; background: rgba(239,68,68,.18); }
.pri-row:hover .pri-liq-btn { opacity: .55; }
.pri-sticky-l { position: sticky; left: 0; z-index: 2; background: var(--bg2); width: 24px; text-align: right; }
.pri-sticky-l2 { position: sticky; left: 24px; z-index: 2; background: var(--bg2); }
.pri-sticky-l3 { position: sticky; left: 58px; z-index: 2; background: var(--bg2); }
.pri-sticky-l4 {
  position: sticky;
  left: 86px;
  z-index: 2;
  background: var(--bg2);
  box-shadow: 4px 0 8px -4px rgba(0,0,0,.35);
}
.pri-sticky-r {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--bg2);
  box-shadow: -4px 0 8px -4px rgba(0,0,0,.35);
}
.priority-table thead .pri-sticky-l,
.priority-table thead .pri-sticky-l2,
.priority-table thead .pri-sticky-l3,
.priority-table thead .pri-sticky-l4 { z-index: 5; background: #1e1f35; }
.priority-table thead .pri-sticky-r { z-index: 5; background: #3b1f6e; }
.pri-product { display: flex; gap: 8px; align-items: flex-start; min-width: 0; }
.pri-thumb {
  width: 30px;
  height: 30px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg3);
}
.pri-thumb-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.pri-product-body { min-width: 0; flex: 1; }
.pri-product-name {
  font-weight: 600;
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.pri-product-arts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.pri-art {
  font-size: 11px;
  font-family: ui-monospace, monospace;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(255,255,255,.05);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pri-abc {
  font-weight: 800;
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  display: inline-block;
}
.pri-abc-A { background: rgba(34,197,94,.2); color: #4ade80; }
.pri-abc-B { background: rgba(234,179,8,.2); color: #facc15; }
.pri-abc-C { background: rgba(148,163,184,.2); color: #94a3b8; }
/* Бейджи юр.лиц */
.pri-ent {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .05em;
  border-radius: 3px;
  padding: 2px 5px;
  white-space: nowrap;
  background: #475569;
  color: #fff;
}
.pri-ent-inn  { background: #4f46e5; color: #fff; }
.pri-ent-shb  { background: #db2777; color: #fff; }
.pri-ent-vega { background: #0d9488; color: #fff; }
.pri-row:nth-child(even) td { background: rgba(255,255,255,.02); }
.pri-row:nth-child(even) .pri-sticky-l,
.pri-row:nth-child(even) .pri-sticky-l2,
.pri-row:nth-child(even) .pri-sticky-l3,
.pri-row:nth-child(even) .pri-sticky-l4,
.pri-row:nth-child(even) .pri-sticky-r { background: #16172a; }
.pri-row-click { cursor: pointer; }
.pri-row-click:hover td { background: rgba(99,102,241,.1) !important; }
.pri-neg { color: #f87171; }
.pri-hi { background: rgba(250,204,21,.35); color: inherit; border-radius: 2px; padding: 0 1px; }
.pri-empty { text-align: center; padding: 24px !important; color: var(--text3); }
.priority-legend-details {
  padding: 6px 12px 10px;
  font-size: 11px;
  color: var(--text3);
  border-top: 1px solid var(--border);
}
.priority-legend-details summary { cursor: pointer; color: var(--text2); }
.pri-leg-text { margin: 6px 0 0; line-height: 1.45; }

/* Десктоп: только таблица */
.pri-mobile-list { display: none; }
.pri-sort-mobile { display: none; }

/* Планшет: таблица + горизонтальный скролл, панель в 2 ряда */
@media (min-width: 769px) and (max-width: 1100px) {
  .pri-toolbar {
    grid-template-columns: 1fr auto;
    gap: 8px;
  }
  .pri-toolbar-filters {
    grid-column: 1 / -1;
    flex-wrap: wrap;
  }
  .pri-search-wrap {
    grid-column: 1 / -1;
    min-width: 0;
  }
  .pri-sort-mobile { display: block; flex: 1; min-width: 140px; }
  .priority-table-wrap {
    max-height: min(58vh, 520px);
  }
  .pri-sticky-r {
    position: static;
    box-shadow: none;
  }
  .pri-col-product { min-width: 160px; max-width: 220px; }
}

@media (min-width: 769px) and (max-width: 900px) {
  .pri-sticky-l4 {
    position: static;
    box-shadow: none;
  }
  .pri-sticky-l3 { position: static; }
  .pri-sticky-l2 { position: static; }
  .pri-sticky-l { position: static; }
}
