/* ── Stats bar ──────────────────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all .15s;
  box-shadow: var(--shadow-sm);
}
.stat-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.stat-card.active { border-color: var(--primary); background: var(--primary-light); }

.stat-card__num {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.stat-card.active .stat-card__num { color: var(--primary); }

.stat-card__label {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.3;
  max-width: 80px;
}

/* ── Kanban board ───────────────────────────────────────────────────────── */
.kanban-wrap {
  position: relative;
}

.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
  align-items: flex-start;
  min-height: 400px;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  scrollbar-width: none;             /* Firefox: прячем нижнюю полосу */
}
.kanban-board::-webkit-scrollbar {
  display: none;                     /* Webkit: прячем нижнюю полосу */
}

/* ── Верхняя (основная) полоса прокрутки канбана ────────────────────── */
.kanban-scroll-top {
  overflow-x: auto;
  overflow-y: hidden;
  height: 20px;
  margin-bottom: 10px;
  scrollbar-color: var(--text-muted) transparent;  /* Firefox */
}
.kanban-scroll-top__spacer {
  height: 1px;
  width: 100%;
}
.kanban-scroll-top::-webkit-scrollbar {
  height: 20px;
}
.kanban-scroll-top::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 10px;
  border: 3px solid var(--surface);
  min-width: 60px;
}
.kanban-scroll-top::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}
.kanban-scroll-top::-webkit-scrollbar-track {
  background: var(--surface2);
  border-radius: 10px;
}
.kanban-scroll-top[hidden] {
  display: none;
}

.kanban-col {
  flex: 0 0 270px;
  /* Подавляем дефолтный min-width: auto у flex-item — иначе длинный
     nowrap-текст внутри карточек (имя заказчика, № счёта) растягивает
     колонку шире flex-basis 270 px. */
  min-width: 0;
  max-width: 270px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
  scroll-snap-align: start;
}

.kanban-scroll-btn {
  position: absolute;
  top: 45%;
  transform: translateY(-50%);
  z-index: 5;
  width: 36px;
  height: 60px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: opacity .15s, background .15s;
}
.kanban-scroll-btn:hover {
  opacity: 1;
  background: var(--surface2);
}
.kanban-scroll-btn--left  { left:  -4px; }
.kanban-scroll-btn--right { right: -4px; }
.kanban-scroll-btn[hidden] { display: none; }

.kanban-col__head {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.kanban-col__step {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kanban-col__title {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  color: var(--text);
}

.kanban-col__count {
  background: var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.kanban-col__body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

/* ── Kanban card ────────────────────────────────────────────────────────── */
.kcard {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  cursor: pointer;
  transition: all .15s;
  box-shadow: var(--shadow-sm);
  /* Подавляем дефолтный min-width: auto у flex-item'а внутри .kanban-col__body,
     иначе длинный nowrap-текст (имя заказчика, № счёта) продавливает колонку
     шире 270 px. */
  min-width: 0;
  max-width: 100%;
}
.kcard:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

/* Индикатор исполнителя: 4 px полоса слева (v0.3.14) */
.kcard--executing::before,
.kcard--idle::before,
.kcard--awaiting-supply::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-top-left-radius: var(--r);
  border-bottom-left-radius: var(--r);
  pointer-events: none;
}
.kcard--executing::before       { background: var(--success); }
.kcard--idle::before            { background: var(--warning); }
.kcard--awaiting-supply::before { background: var(--danger); }

/* Индикатор близости срока отгрузки: 4 px полоса справа (v0.12.0) */
.kcard--due-warn::after,
.kcard--due-alert::after,
.kcard--due-overdue::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 4px;
  border-top-right-radius: var(--r);
  border-bottom-right-radius: var(--r);
  pointer-events: none;
}
.kcard--due-warn::after    { background: var(--warning); }  /* ≤7 раб. дн. */
.kcard--due-alert::after   { background: var(--danger); }   /* ≤3 раб. дн. */
.kcard--due-overdue::after { background: #7f1d1d; }          /* просрочка */

.kcard__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.kcard__num {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

.kcard__invoice {
  text-align: right;
  line-height: 1.1;
  max-width: 55%;
}

.kcard__invoice-num {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kcard__invoice-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.kcard__summary {
  margin: 6px 0 8px;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kcard__item {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.kcard__item-qty {
  color: var(--text-muted);
  font-weight: 600;
}

.kcard__summary--simple {
  font-size: 11px;
  color: var(--text-muted);
}

.kcard__simple-row {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kcard__client {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kcard__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.kcard__date {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── Order detail panel ─────────────────────────────────────────────────── */
.order-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  max-width: 680px;
  width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.order-detail__head {
  padding: 18px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.order-detail__num {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.order-detail__client {
  font-size: 15px;
  color: var(--text);
}

.order-detail__badges {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.order-detail__body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.order-detail__foot {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.order-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.order-info-item__label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.order-info-item__value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

/* ── Step mark form ─────────────────────────────────────────────────────── */
.step-mark-form {
  background: var(--primary-light);
  border: 1px solid rgba(59,91,219,.2);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.step-mark-form__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

/* ── Items list ─────────────────────────────────────────────────────────── */
.items-list { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: var(--r);
  border: 1px solid var(--border);
}
.item-row__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.item-row__body { flex: 1; min-width: 0; }
.item-row__name { font-size: 13px; font-weight: 600; }
.item-row__meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Виртуальная колонка «Отгружено» (v0.16.0) ──────────────────────────── */
.kanban-col--shipped .kanban-col__step {
  background: #47556922;
  color: #475569;
}
.kanban-col__title-sub {
  display: block;
  font-size: 11px;
  font-weight: normal;
  color: var(--text-muted);
}
.kcard__shipped-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── РЧ-индикатор (v0.17.0) ─────────────────────────────────────────────── */
.kcard-rch-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  border: none;
  cursor: pointer;
  font-weight: 600;
  line-height: 1.4;
}
.kcard-rch-btn--red {
  background: #fee2e2;
  color: #991b1b;
}
.kcard-rch-btn--red:hover:not(:disabled) {
  background: #fca5a5;
}
.kcard-rch-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}
.badge-rch-green {
  background: #dcfce7;
  color: #166534;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-weight: 600;
  line-height: 1.4;
}
