* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }
/* Дизайн-токени (бренд, теми, status-кольори, тіні, радіуси) виокремлені у themes.css.
   Старі :root-змінні (--bg, --text, --blue, --green, --red, --surface ...) тепер
   є зворотними аліасами на нові токени — це дозволяє не переписувати 2000+ рядків
   нижче і одночасно дає light/dark тему. */
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); margin: 0; overflow-x: hidden; padding-bottom: 80px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
/* ─── Soft design — м'які тіні, плавні hover, єдиний tone. ───────────────── */
button { font-family: inherit; }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid rgba(34, 197, 94, 0.4); outline-offset: 2px; }
.btn, .btn-sm { transition: transform .12s ease, box-shadow .18s ease, background .15s ease; }
.btn:hover, .btn-sm:hover { transform: translateY(-1px); }
.btn:active, .btn-sm:active { transform: translateY(0); }
/* Soft card shadows — спільний стиль для всіх "карток" */
.card, .order-card, .printer-card, .stat-card, .pc-card, .live-card, .history-row, .skeleton-card {
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
  transition: box-shadow .2s ease, transform .15s ease;
}
.pc-card:hover, .live-card:hover, .printer-card:hover, .order-card:hover {
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.08), 0 12px 24px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}
.ms { font-family: 'Material Symbols Rounded'; font-weight: normal; font-style: normal; font-size: 22px; display: inline-block; line-height: 1; letter-spacing: normal; text-transform: none; white-space: nowrap; word-wrap: normal; direction: ltr; -webkit-font-smoothing: antialiased; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }

.flex { display: flex; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-1\.5 { gap: 6px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.min-w-0 { min-width: 0; }
.flex-shrink-0 { flex-shrink: 0; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.h-screen { height: 100vh; }

.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.pb-20 { padding-bottom: 80px; }
.pb-24 { padding-bottom: 96px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-top: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mr-1 { margin-right: 4px; }
.mx-auto { margin-left: auto; margin-right: auto; }
.max-w-xs { max-width: 320px; }
.space-y-3 > * + * { margin-top: 12px; }

.text-xs { font-size: 12px; }
.text-sm { font-size: 14px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.text-muted { color: var(--muted); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.logo-box { width: 80px; height: 80px; margin: 0 auto; border-radius: 20px; background: linear-gradient(135deg, var(--brand) 0%, var(--brand) 100%); display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(22,163,74,0.30); }
.logo-box span { color: #fff; font-size: 28px; font-weight: 800; }
.logo-box-amber { background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%); box-shadow: 0 8px 24px rgba(245,158,11,0.25); }
.logo-box-sm { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--brand) 0%, var(--brand) 100%); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 10px; font-weight: 800; box-shadow: 0 2px 6px rgba(22,163,74,0.25); }

.page { display: none; }
.page.active { display: block; }
/* Перемикач секцій. Проста плавна opacity-анімація — без blur/translate, щоб не виглядало як «завантаження». */
.section { display: none; }
.section.active { display: block; animation: sectionIn .18s ease-out; }
.section.leaving {
  display: block;
  position: absolute;
  inset: 0;
  pointer-events: none;
  animation: sectionOut .14s ease-in forwards;
  z-index: 1;
}
/* Cached секції не анімуються взагалі — щоб користувач бачив що вона була тут весь час. */
.section.active[data-from-cache="1"] { animation: none; }
.desktop-main, body.is-telegram .section { position: relative; }
@keyframes sectionIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes sectionOut { from { opacity: 1; } to { opacity: 0; } }
/* Стара fadeIn зберігаємо для зворотної сумісності — використовується деінде. */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.card { background: var(--surface); border-radius: 16px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); border: 1px solid rgba(0,0,0,0.04); transition: transform 0.15s ease; }
.card:active { transform: scale(0.98); }
.card-accent { background: linear-gradient(135deg, var(--brand) 0%, var(--brand) 100%); color: white; border: none; }
.card-green { background: linear-gradient(135deg, var(--brand) 0%, #14b8a6 100%); color: white; border: none; }

.btn { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-hover) 100%); color: #fff; border: none; border-radius: 12px; padding: 13px 20px; font-weight: 600; cursor: pointer; width: 100%; font-size: 14px; transition: all 0.15s ease; box-shadow: 0 2px 8px rgba(22,163,74,0.25); font-family: inherit; }
.btn:active { transform: scale(0.97); opacity: 0.9; }
.btn-danger { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); box-shadow: 0 2px 8px rgba(239,68,68,0.25); }
.btn-success { background: linear-gradient(135deg, var(--brand) 0%, var(--brand) 100%); box-shadow: 0 2px 8px rgba(34,197,94,0.25); }
.btn-amber { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); box-shadow: 0 2px 8px rgba(245,158,11,0.25); }
.btn-outline { background: transparent; border: 2px solid var(--brand); color: var(--brand); box-shadow: none; }
.btn-outline:active { background: rgba(22,163,74,0.05); }
.btn-ghost { background: transparent; color: var(--brand); box-shadow: none; font-weight: 500; }
.btn-sm { padding: 8px 14px; font-size: 12px; width: auto; border-radius: 10px; }
.btn-icon { width: 44px; height: 44px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: transparent; border: none; cursor: pointer; }
.btn-icon-header { width: 44px; height: 44px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: #fff; border: 1px solid rgba(0,0,0,0.06); box-shadow: 0 1px 4px rgba(0,0,0,0.06); cursor: pointer; }
.btn-lg { padding: 16px 24px; font-size: 16px; border-radius: 14px; }
/* Деструктивний outline-варіант — раніше повторювався інлайном у 6 файлах. */
.btn-outline-danger { color: #ef4444; border-color: #fecaca; }
/* Малі квадратні кнопки-іконки в рядках списків (редагувати/видалити). */
.btn-icon--edit   { width: 30px; height: 30px; border-radius: 8px; background: #eff6ff; }
.btn-icon--edit .ms   { font-size: 14px; color: #1d4ed8; }
.btn-icon--delete { width: 30px; height: 30px; border-radius: 8px; background: #fef2f2; }
.btn-icon--delete .ms { font-size: 14px; color: #ef4444; }

.input { width: 100%; padding: 12px 16px; border: 1.5px solid var(--border); border-radius: 12px; font-size: 14px; background: var(--bg-surface); color: var(--text); box-sizing: border-box; font-family: 'Inter', sans-serif; transition: all 0.2s ease; }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(22,163,74,0.08); }
.input::placeholder { color: var(--muted); }
select.input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
.input-label { display: block; font-size: 12px; font-weight: 600; color: #71717a; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
textarea.input { resize: vertical; min-height: 60px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 8px; font-size: 11px; font-weight: 600; }
.badge-green { background: var(--success-soft); color: #166534; }
.badge-red { background: #fef2f2; color: #991b1b; }
.badge-yellow { background: #fefce8; color: #854d0e; }
.badge-blue { background: var(--success-soft); color: var(--brand-hover); }
.badge-purple { background: #f3e8ff; color: #6b21a8; }
.badge-gray { background: #f3f4f6; color: #6b7280; }

.prod-img { width: 56px; height: 56px; border-radius: 12px; object-fit: contain; flex-shrink: 0; box-shadow: 0 1px 4px rgba(0,0,0,0.10); background: #f4f4f5; }
.prod-img-placeholder { width: 56px; height: 56px; border-radius: 12px; flex-shrink: 0; background: #f4f4f5; display: flex; align-items: center; justify-content: center; }
/* Велике фото товару в модалці — без обрізки, з обмеженням висоти, фон-плейсхолдер */
.prod-img-lg {
  width: 100%;
  max-height: 200px;
  min-height: 120px;
  object-fit: contain;
  border-radius: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  background: #f4f4f5;
  cursor: zoom-in;
  display: block;
}
.prod-img-lg.prod-img-placeholder { object-fit: contain; height: 120px; }

.color-dot { width: 28px; height: 28px; border-radius: 50%; display: inline-block; border: 3px solid rgba(255,255,255,0.5); flex-shrink: 0; box-shadow: 0 2px 6px rgba(0,0,0,0.15); }

.loader { text-align: center; padding: 40px; color: var(--muted); font-size: 14px; animation: fadeIn .25s ease-out; }
.loader::after { content: ''; display: block; width: 36px; height: 36px; margin: 14px auto; border: 3px solid #e4e4e7; border-top-color: var(--blue); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Skeleton card grid — нативний вигляд що зʼявляється поки реальні дані вантажаться.
   Використання: <div class="skeleton-grid"></div> або просто div.loader зі skeleton класом. */
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; padding: 4px; animation: fadeIn .25s ease-out; }
.skeleton-card { height: 180px; border-radius: 12px; background: linear-gradient(90deg, #f4f4f5 0%, #fafafa 50%, #f4f4f5 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.stat-card { text-align: center; padding: 12px 8px; background: #f8fafc; border-radius: 12px; }
.stat-card .value { font-size: 20px; font-weight: 800; line-height: 1.2; }
.stat-card .label { font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 500; }
.stat-card-blue .value { color: var(--blue); }
.stat-card-green .value { color: var(--green); }
.stat-card-red .value { color: var(--red); }

.search-wrap { position: relative; margin-bottom: 12px; }
.search-wrap > .ms { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 20px; pointer-events: none; }
.search-input { width: 100%; padding: 11px 38px 11px 40px; border: 1.5px solid var(--border); border-radius: 12px; font-size: 14px; background: var(--bg-surface); color: var(--text); font-family: inherit; box-sizing: border-box; transition: all 0.2s; }
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(22,163,74,0.08); }
.search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border-radius: 50%; background: #f4f4f5; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.search-clear .ms { font-size: 16px; color: #71717a; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { padding: 6px 12px; border-radius: 999px; background: #fff; border: 1.5px solid var(--border); color: #52525b; font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: all 0.15s ease; }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip-count { opacity: 0.6; margin-left: 4px; font-weight: 500; }

.info-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f4f4f5; font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-row .lbl { color: #71717a; }
.info-row .val { font-weight: 600; text-align: right; max-width: 60%; word-break: break-word; }

.divider { height: 1px; background: #f4f4f5; margin: 16px 0; }

/* Старий single-toast лишається для legacy ховаємо. */
.toast.hidden { display: none; }
/* Toast v2 — стек, color-coded, з undo-кнопкою. */
#toast-stack {
  position: fixed;
  bottom: 16px; right: 16px;
  z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
body:not(.layout-desktop) #toast-stack {
  bottom: auto; top: 16px; right: 50%;
  transform: translateX(50%);
}
#toast-stack .toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  background: #18181b; color: #fff;
  padding: 10px 14px; border-radius: 12px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2), 0 2px 6px rgba(0,0,0,0.1);
  max-width: 380px;
  animation: toastIn .25s cubic-bezier(.16, 1, .3, 1);
  position: static; top: auto; left: auto; transform: none; white-space: normal;
}
#toast-stack .toast-leaving { animation: toastOut .18s ease-in forwards; }
#toast-stack .toast-icon { font-size: 18px; flex-shrink: 0; }
#toast-stack .toast-msg { flex: 1; min-width: 0; }
#toast-stack .toast-undo {
  background: transparent; border: 1px solid rgba(255,255,255,0.25);
  color: #fff; padding: 4px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background .12s ease;
}
#toast-stack .toast-undo:hover { background: rgba(255,255,255,0.1); }
#toast-stack .toast-x {
  background: transparent; border: none; cursor: pointer;
  color: rgba(255,255,255,0.5); padding: 2px 4px; line-height: 0;
}
#toast-stack .toast-x:hover { color: #fff; }
#toast-stack .toast-success { background: var(--brand-hover); }
#toast-stack .toast-error   { background: #b91c1c; }
#toast-stack .toast-info    { background: #18181b; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(10px); } }

/* ─── Модалки — мобільний bottom-sheet ───────────────────────────────────── */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.42); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 100; display: flex; align-items: flex-end; justify-content: center; animation: modalOverlayIn 0.22s ease-out; }
.modal-content { background: #fff; border-radius: 20px 20px 0 0; padding: 0; width: 100%; max-width: 540px; max-height: 88vh; overflow: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; animation: slideUp 0.32s cubic-bezier(0.16, 1, 0.3, 1); box-shadow: 0 -20px 60px rgba(0,0,0,0.22); display: flex; flex-direction: column; }
@keyframes modalOverlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalOverlayOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideDown { from { transform: translateY(0); } to { transform: translateY(100%); } }
.modal-handle { width: 36px; height: 4px; background: #d4d4d8; border-radius: 2px; margin: 8px auto 0; }
.modal-overlay.modal-closing { animation: modalOverlayOut 0.18s ease-in forwards; pointer-events: none; }
.modal-overlay.modal-minimized { display: none !important; }
.modal-overlay.modal-closing .modal-content { animation: slideDown 0.22s cubic-bezier(0.4, 0, 1, 1) forwards; }
body.modal-open { overflow: hidden; touch-action: none; }

/* ─── Modal v3 — side-drawer (Linear/GitHub style) ────────────────────────── */
.modal-titlebar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid #f4f4f5;
  user-select: none;
  -webkit-user-select: none;
  flex-shrink: 0;
}
.modal-traffic { display: none; } /* Mac-light приховано в новому стилі. */
.modal-title-text {
  flex: 1; min-width: 0;
  font-size: 15px; font-weight: 600; color: #18181b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.modal-body {
  padding: 18px 22px 24px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
/* Кнопка-X справа замість Mac-кружечків. */
.modal-close-x {
  width: 32px; height: 32px; border-radius: 8px;
  background: transparent; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: #71717a; transition: background .15s ease, color .15s ease;
  flex-shrink: 0;
}
.modal-close-x:hover { background: #f4f4f5; color: #18181b; }
.modal-close-btn, .modal-min-btn { display: none !important; }

/* ─── Desktop — floating card в центрі, без закриття по backdrop ─────────── */
body.layout-desktop .modal-overlay {
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  animation: drawerOverlayIn .18s ease-out;
}
body.layout-desktop .modal-content {
  width: 560px;
  max-width: 92vw;
  max-height: 86vh;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15,23,42,0.32), 0 8px 16px rgba(15,23,42,0.12);
  animation: modalPopIn .22s cubic-bezier(.16, 1, .3, 1);
  transform: translateZ(0);
  will-change: transform;
  contain: layout style paint;
}
body.layout-desktop .modal-handle { display: none; }
@keyframes drawerOverlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPopIn { from { opacity: 0; transform: translateY(20px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-overlay.modal-closing { animation: drawerOverlayOut .16s ease-in forwards; pointer-events: none; }
body.layout-desktop .modal-overlay.modal-closing .modal-content { animation: modalPopOut .15s ease-in forwards; }
@keyframes drawerOverlayOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes modalPopOut { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(10px) scale(.98); } }

.modal-overlay.modal-dragged { pointer-events: auto; }
body.layout-desktop .modal-titlebar { cursor: default; }

.mobile-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(248,250,252,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.mobile-header-actions { display: flex; align-items: center; gap: 8px; }

.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  /* z-index 200 > modal-overlay (100) — мобільна навігація доступна поки відкрита модалка. */
  z-index: 200;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 4px 20px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0,0,0,0.04);
}
.nav-item { display: flex; flex-direction: column; align-items: center; padding: 6px 8px; border-radius: 14px; font-size: 10px; font-weight: 500; color: var(--muted); gap: 2px; transition: all 0.2s ease; min-width: 48px; border: none; background: transparent; cursor: pointer; }
.nav-item .ms { font-size: 22px; transition: transform 0.2s ease; }
.nav-item.active { color: var(--blue); }
.nav-item.active .ms { transform: scale(1.1); }
.nav-item-scan { background: linear-gradient(135deg, var(--brand), var(--brand)); color: #fff !important; border-radius: 16px; padding: 8px 12px; margin-top: -16px; box-shadow: 0 4px 12px rgba(22,163,74,0.35); }
.nav-item-scan .ms { color: #fff; }

.empty-state { text-align: center; padding: 40px 20px; }
.empty-state .ms { font-size: 48px; color: #d4d4d8; display: block; margin-bottom: 12px; }
.empty-state p { color: var(--muted); font-size: 14px; }

.hidden { display: none !important; }
.section-title { font-size: 22px; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* Ліва частина заголовка (іконка + назва) тягнеться, але дає простір кнопкам справа.
   Кнопки на вузькому екрані переносяться на новий рядок (через flex-wrap вище). */
.section-title > div:first-child { min-width: 0; }
.section-title > .flex { flex-shrink: 0; }
.section-title .ms { font-size: 26px; color: var(--blue); }
/* Заголовки секцій ПОКАЗУЄМО на всіх сторінках — раніше приховували перший
 * .section-title як "дубль sidebar", але разом з ним ховались action-кнопки
 * (наприклад "+ Нове замовлення" на сторінці Замовлення). */

.grid-cards { display: grid; gap: 10px; }

.stock-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.stock-actions .btn { font-size: 13px; padding: 12px 8px; }

.qr-container { display: flex; justify-content: center; padding: 16px; }
.qr-container canvas { border-radius: 12px; }

.photo-upload-area { display: flex; gap: 8px; margin-top: 8px; }
.photo-upload-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px; background: transparent; border: 2px dashed var(--border); border-radius: 12px; color: #71717a; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s; font-family: inherit; }
.photo-upload-btn:active { background: rgba(22,163,74,0.05); border-color: var(--blue); }
.photo-upload-btn input { display: none; }

.color-weight-tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 8px; background: #f3f4f6; font-size: 11px; font-weight: 600; margin: 2px; }
.color-weight-tag .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.plate-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #f8fafc; border: 1px solid #f1f5f9; border-radius: 12px; margin-bottom: 6px; }
.plate-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.15); flex-shrink: 0; }

/* Cost analytics — собівартість плити/товару у деталях. */
.prod-cost-grid { display: flex; flex-direction: column; gap: 4px; background: var(--bg-muted, #f4f4f5); padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.prod-cost-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; }
.prod-cost-row span:first-child { color: var(--text-muted); }
.prod-cost-row span:last-child { font-weight: 500; }
.prod-cost-row b { font-weight: 700; color: var(--text); }
.prod-cost-total { border-top: 1px solid var(--border-soft, #e4e4e7); padding-top: 6px; margin-top: 4px; font-weight: 700; }
.prod-cost-total span:first-child { color: var(--text); font-weight: 700; }
.prod-cost-margin { padding-top: 4px; font-weight: 700; font-size: 14px; }
.prod-cost-margin b { color: inherit; }

/* Мініатюра пластини в модалці товару — або зображення, або fallback dots. */
.plate-row-thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: contain; flex-shrink: 0; background: var(--bg-muted, #f4f4f5); border: 1px solid rgba(0,0,0,0.06); display: flex; align-items: center; justify-content: center; gap: 3px; padding: 3px; box-sizing: border-box; }
.plate-row-thumb--dots { flex-wrap: wrap; }
.plate-row-thumb--dots .plate-dot { width: 12px; height: 12px; margin: 0; }
.plate-editor-row { padding: 12px; background: #f8fafc; border: 1px solid #e4e4e7; border-radius: 14px; margin-bottom: 10px; }
.plate-color-grid { grid-template-columns: 1.4fr 0.8fr 1fr; }
.plate-color-input { padding: 4px; height: 42px; cursor: pointer; }
.plates-total { padding: 10px 14px; background: linear-gradient(135deg, rgba(22,163,74,0.08), rgba(99,102,241,0.06)); border-radius: 12px; font-size: 13px; text-align: center; }
.plate-ams-auto { display: flex; align-items: center; gap: 6px; padding: 6px 10px; margin-bottom: 8px; border-radius: 8px; font-size: 11px; font-weight: 700; color: #fff; background: linear-gradient(90deg, #ff3b30, #ff9500, #ffcc00, #34c759, #5856d6, #af52de); background-size: 200% 100%; animation: amsShine 3.5s linear infinite; }
.plate-ams-auto .ms { font-size: 14px; }

.plate-filaments-section { margin-top: 6px; }
.filament-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.filament-material { flex: 0 0 80px !important; width: 80px !important; padding: 8px 6px !important; font-size: 12px !important; }
.filament-color { flex: 1 !important; min-width: 0 !important; padding: 8px 8px !important; font-size: 12px !important; }
.filament-hex { flex: 0 0 36px !important; width: 36px !important; height: 36px !important; padding: 2px !important; cursor: pointer; border-radius: 8px !important; }
.filament-weight { flex: 0 0 56px !important; width: 56px !important; padding: 8px 4px !important; font-size: 12px !important; text-align: center !important; }
.filament-del { flex: 0 0 28px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; background: #fef2f2; border: none; border-radius: 6px; cursor: pointer; padding: 0; }

.model-file-card { display: flex; align-items: center; gap: 12px; padding: 12px; background: #f8fafc; border: 1px solid #e4e4e7; border-radius: 14px; margin-bottom: 8px; }

.spool-card { display: flex; align-items: center; gap: 12px; padding: 14px; }
.spool-card .color-dot { width: 40px; height: 40px; border-width: 3px; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.pc-card { background: var(--surface); border-radius: 14px; padding: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); border: 1px solid rgba(0,0,0,0.04); cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; overflow: hidden; display: flex; flex-direction: column; }
.pc-card:active { transform: scale(0.97); }
.pc-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.pc-img-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; background: #f4f4f5; margin-bottom: 8px; }
.pc-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.pc-img-placeholder { width: 100%; height: 100%; }
.ams-badge { position: absolute; top: 6px; right: 6px; display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px 3px 6px; border-radius: 999px; font-size: 11px; font-weight: 800; color: #fff; letter-spacing: 0.4px; background: linear-gradient(90deg, #ff3b30 0%, #ff9500 16%, #ffcc00 32%, #34c759 50%, #00c7be 66%, #5856d6 82%, #af52de 100%); background-size: 200% 100%; box-shadow: 0 2px 6px rgba(0,0,0,0.22); text-shadow: 0 1px 1px rgba(0,0,0,0.25); animation: amsShine 3.5s linear infinite; }
.ams-badge .ms { font-size: 13px; line-height: 1; }
@keyframes amsShine { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }
.pc-body { padding: 2px 4px 4px 4px; }
.pc-name { font-size: 13px; font-weight: 700; line-height: 1.25; color: #18181b; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; min-height: 32px; }
.pc-code { font-size: 11px; color: var(--muted); margin-top: 2px; }
.pc-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 6px; }
.pc-stock { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.pc-stock-ok    { background: var(--success-soft); color: #166534; }
.pc-stock-empty { background: #fee2e2; color: #991b1b; }
/* Три стани обліку — маленькі бейджі під ціною/кількістю на карточці товару. */
.pc-stages { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.pc-stage-ready, .pc-stage-asm, .pc-stage-packed {
  font-size: 10.5px; font-weight: 600; padding: 2px 6px; border-radius: 5px;
  display: inline-flex; align-items: center; gap: 2px;
}
.pc-stages .ms { font-size: 12px; }
/* Іконки в заголовках табличного вигляду товарів */
.ivt-hico { font-size: 15px; vertical-align: -3px; }
.pc-stage-ready  { background: color-mix(in oklab, var(--warning) 12%, transparent); color: #92400e; }
.pc-stage-asm    { background: color-mix(in oklab, #3b82f6 12%, transparent); color: #1e40af; }
.pc-stage-packed { background: var(--success-soft); color: #166534; }
.pc-price { font-size: 14px; font-weight: 800; color: #18181b; }

/* ── Товари: перемикач вигляду картки/таблиця ── */
.inv-view-toggle {
  display: inline-flex; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; background: var(--bg-surface);
}
.ivt-btn {
  border: 0; background: transparent; padding: 6px 12px; cursor: pointer;
  color: var(--text-muted); display: inline-flex; align-items: center;
}
.ivt-btn.active { background: var(--brand); color: #fff; }
.ivt-btn:not(.active):hover { background: var(--bg-surface-2); }

/* ── Товари: табличний вигляд ── */
.inv-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.inv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inv-table th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; padding: 9px 10px; white-space: nowrap;
  background: var(--bg-surface-2); color: var(--text-muted);
  font-size: 11.5px; font-weight: 700; text-transform: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.inv-table th:hover { color: var(--text); }
.inv-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.inv-table tbody tr { cursor: pointer; transition: background .1s ease; }
.inv-table tbody tr:hover { background: var(--bg-surface-2); }
.inv-table tbody tr:last-child td { border-bottom: 0; }
.ivt-photo {
  width: 36px; height: 36px; border-radius: 8px; object-fit: cover;
  display: block; background: var(--bg-surface-2);
}
.ivt-photo--none {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-disabled);
}
.ivt-name { font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ivt-code { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.ivt-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Числові колонки (4+: стани/час/вага/ціни) — по центру, разом із заголовками. */
.inv-table th:nth-child(n+4), .inv-table td:nth-child(n+4) { text-align: center; }
.ivt-zero { color: var(--text-disabled); }
.ivt-packed { color: #166534; font-weight: 700; }
.ivt-asm    { color: #1e40af; font-weight: 700; }
.ivt-ready  { color: #92400e; font-weight: 700; }
.ivt-price  { font-weight: 700; }
.ivt-total td { background: var(--bg-surface-2); border-top: 2px solid var(--border); }
.pc-tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.pc-tag { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.pc-tag-blue   { background: #dbeafe; color: #1d4ed8; }
.pc-tag-purple { background: #ede9fe; color: #6d28d9; }

/* Превью пластин у списку товарів — рядок маленьких thumbnail'ів. */
.pc-plates-strip { margin-top: 6px; display: flex; gap: 3px; flex-wrap: wrap; }
.pc-plate-thumb { width: 28px; height: 28px; border-radius: 6px; object-fit: contain; background: var(--bg-muted, #f4f4f5); border: 1px solid rgba(0,0,0,0.06); display: flex; align-items: center; justify-content: center; gap: 2px; padding: 2px; box-sizing: border-box; }
.pc-plate-thumb--more { font-size: 10px; font-weight: 700; color: var(--text-muted, #71717a); background: var(--bg-muted, #f4f4f5); }
.pc-plate-thumb--dots { background: var(--bg-muted, #f4f4f5); }
.pc-plate-dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.15); flex-shrink: 0; }

.queue-item { background: var(--surface); border-radius: 14px; padding: 12px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid rgba(0,0,0,0.04); }
/* Плоский список черги (редизайн: без пріоритет-бакетів) */
.queue-flat { display: flex; flex-direction: column; }
.qi-inplan {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; color: var(--success);
  padding: 5px 10px; border-radius: 8px;
  background: var(--success-soft, #dcfce7);
}
.qi-top { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.qi-img { width: 56px; height: 56px; flex-shrink: 0; border-radius: 10px; overflow: hidden; background: #f4f4f5; }
.qi-img .pc-img, .qi-img .pc-img-placeholder { width: 56px; height: 56px; border-radius: 10px; }
.qi-info { flex: 1; min-width: 0; }
.qi-name { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qi-counts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.qi-badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.qi-plan   { background: #e0e7ff; color: #3730a3; }
.qi-done   { background: var(--success-soft); color: #166534; }
.qi-remain { background: #fef3c7; color: #92400e; }
.qi-time { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; align-items: center; gap: 4px; }
.qi-time .ms { font-size: 14px; color: var(--blue); }
.qi-readiness { margin-top: 8px; }
.qi-readiness-label { font-size: 11.5px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 4px; }
.qi-readiness-label .qi-readiness-active { color: var(--muted); font-weight: 400; }
.qi-readiness-bar { height: 6px; border-radius: 3px; background: var(--bg-surface-2, #f1f5f9); overflow: hidden; margin: 4px 0 2px; }
.qi-readiness-bar > div { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #2563eb, #16a34a); transition: width .4s ease; }
.qi-readiness-eta { font-size: 11px; color: var(--muted); }
.qi-actions { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.qi-actions .btn, .qi-actions .btn-outline { padding: 8px 12px; font-size: 13px; }
.qi-actions .btn-outline { background: #fff; color: var(--brand); border: 1px solid #93c5fd; }
.qi-breakdown { margin-top: 8px; padding: 6px 8px; background: #f0f4ff; border-radius: 8px; }
.qi-bd-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; font-size: 11px; }
.qi-bd-name { color: #3730a3; font-weight: 600; }
.qi-bd-detail { color: #6b7280; font-weight: 500; }
.ams-badge.ams-badge-inline { position: static; padding: 2px 6px 2px 5px; font-size: 10px; }
.ams-badge.ams-badge-inline .ms { font-size: 11px; }

/* Drag-and-drop pr\u0456\u043e\u0440\u0438\u0442\u0435\u0442\u0438 \u0447\u0435\u0440\u0433\u0438 (3 \u0431\u0430\u043a\u0435\u0442\u0438) */
.queue-bucket { border-radius: 14px; padding: 10px; margin-bottom: 12px; border: 1.5px dashed transparent; transition: border-color .15s, background .15s; }
.queue-bucket-head { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; padding: 4px 6px 8px; }
.queue-bucket-head .ms { font-size: 18px; }
.queue-bucket-title { flex: 1; }
.queue-bucket-count { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,0.06); color: #18181b; font-weight: 600; }
.queue-bucket-empty { font-size: 11px; color: var(--muted); padding: 6px 8px; }
.queue-bucket-high   { background: #fef2f2; border-color: #fecaca; }
.queue-bucket-high   .queue-bucket-head .ms, .queue-bucket-high   .queue-bucket-title { color: #b91c1c; }
.queue-bucket-normal { background: #f8fafc; border-color: #e2e8f0; }
.queue-bucket-normal .queue-bucket-head .ms, .queue-bucket-normal .queue-bucket-title { color: #334155; }
.queue-bucket-low    { background: #f3f4f6; border-color: #d4d4d8; }
.queue-bucket-low    .queue-bucket-head .ms, .queue-bucket-low    .queue-bucket-title { color: #6b7280; }
.queue-bucket--drag-over { border-color: var(--brand); background: rgba(34,197,94,0.08); }

.queue-item[draggable="true"] { cursor: grab; }
.queue-item[draggable="true"]:active { cursor: grabbing; }
.qi-dragging { opacity: 0.45; transform: scale(0.98); }
.qi-drag { display: flex; align-items: center; justify-content: center; width: 24px; flex-shrink: 0; color: #a1a1aa; cursor: grab; user-select: none; }
.qi-drag .ms { font-size: 22px; }
.qi-drag:active { cursor: grabbing; }

.qi-prio-btn { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; cursor: pointer; line-height: 1.4; }
.qi-prio-high   { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.qi-prio-normal { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.qi-prio-low    { background: #f3f4f6; color: #4b5563; border-color: #e5e7eb; }
.qi-prio-btn:hover { filter: brightness(0.97); }

.queue-add-row { display: flex; gap: 10px; align-items: center; padding: 8px; border-bottom: 1px solid #f4f4f5; }
.queue-add-row .pc-img, .queue-add-row .pc-img-placeholder { width: 44px; height: 44px; border-radius: 8px; flex-shrink: 0; }
.queue-add-info { flex: 1; min-width: 0; }
.queue-add-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-add-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-add-qty { width: 48px; padding: 6px 4px; border: 1px solid #e4e4e7; border-radius: 8px; font-size: 14px; text-align: center; font-family: inherit; }
/* Клікабельний рядок + степер −/+ у модалці «Додати у чергу» */
.queue-add-row { cursor: pointer; transition: background .1s ease; border-radius: 8px; }
.queue-add-row:hover { background: var(--bg-surface-2, #f4f4f5); }
.queue-add-row--sel { background: var(--brand-soft, #eef2ff); }
.queue-add-row--sel:hover { background: var(--brand-soft, #eef2ff); }
.queue-add-stepper { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.qas-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border, #e4e4e7); background: var(--bg-surface, #fff);
  font-size: 16px; font-weight: 700; cursor: pointer; color: var(--text, #18181b);
  display: inline-flex; align-items: center; justify-content: center;
}
.qas-btn:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft, #eef2ff); }
.qas-btn:disabled { opacity: .35; cursor: not-allowed; }
/* number-input спінери ховаємо — степер їх замінює */
.queue-add-qty::-webkit-outer-spin-button, .queue-add-qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.queue-add-qty { -moz-appearance: textfield; appearance: textfield; }

/* Розгортання окремих пластин товару — «замовити саме цю деталь». */
.queue-add-expand {
  display: inline-flex; align-items: center; gap: 2px; margin-top: 2px;
  border: none; background: transparent; color: var(--brand); cursor: pointer;
  font-size: 11px; font-weight: 600; padding: 2px 0;
}
.queue-add-expand .ms { font-size: 15px; }
.queue-add-expand:hover { text-decoration: underline; }
.queue-add-plate-row {
  display: flex; gap: 8px; align-items: center; padding: 6px 8px 6px 40px;
  border-bottom: 1px solid #f4f4f5; cursor: pointer;
  background: var(--bg-surface-2, #fafafa); border-radius: 8px;
  transition: background .1s ease;
}
.queue-add-plate-row:hover { background: var(--brand-soft, #eef2ff); }
.queue-add-plate-thumb {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 6px;
  background: var(--bg-surface, #fff); display: flex; align-items: center; justify-content: center;
  color: var(--text-disabled, #a1a1aa); overflow: hidden;
}
.queue-add-plate-thumb img { width: 100%; height: 100%; object-fit: contain; }
/* Тач-цілі в модалці «Додати у чергу» — на телефоні степер −/+ і кнопка
   розгортання деталей потребують більшої зони натискання, ніж під мишу. */
@media (max-width: 480px) {
  .qas-btn { width: 36px; height: 36px; }
  .queue-add-qty { width: 40px; padding: 8px 4px; }
  .queue-add-expand { padding: 6px 0; font-size: 12px; }
  .queue-add-expand .ms { font-size: 17px; }
}

.stats-list { background: var(--surface); border-radius: 14px; padding: 4px; border: 1px solid rgba(0,0,0,0.04); }
.stats-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #f4f4f5; }
.stats-row:last-child { border-bottom: none; }
.stats-qty { font-size: 14px; font-weight: 800; color: var(--blue); padding: 4px 10px; background: #dbeafe; border-radius: 8px; }

.formula-card { background: var(--surface); border-radius: 14px; padding: 16px; margin-bottom: 12px; border: 1px solid rgba(0,0,0,0.04); }
.formula-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.formula-row label { flex: 1; font-size: 13px; font-weight: 600; }
.formula-row input { width: 100px; padding: 8px 10px; border: 1px solid #e4e4e7; border-radius: 8px; font-size: 14px; text-align: right; font-family: inherit; }
.formula-row .unit { font-size: 12px; color: var(--muted); min-width: 50px; }
.formula-preview { margin-top: 10px; padding: 10px 12px; background: linear-gradient(135deg, rgba(22,163,74,0.06), rgba(99,102,241,0.04)); border-radius: 10px; font-size: 13px; color: #3730a3; font-family: 'Courier New', monospace; }

.order-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.order-card .order-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; gap: 12px; }
.order-card .order-id { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 11px; color: var(--muted); }
.order-card .order-ttn { font-family: ui-monospace, SFMono-Regular, monospace; font-weight: 700; font-size: 14px; color: var(--text); }
.order-card .order-cust { font-size: 13px; color: var(--text-soft); margin-top: 4px; }
.order-card .order-items { font-size: 12px; color: var(--muted); margin-top: 6px; }
.order-card .order-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.status-pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.4; }
.status-new       { background: var(--brand-soft); color: #166534; border: 1px solid #bbf7d0; }
.status-paid      { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.status-printing  { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.status-packed    { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }
.status-shipped   { background: #cffafe; color: #155e75; border: 1px solid #a5f3fc; }
.status-delivered { background: var(--success-soft); color: var(--text); border: 1px solid #86efac; }
.status-cancelled { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; text-decoration: line-through; }
.status-returned  { background: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db; }

.printer-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.printer-card .printer-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.printer-card .printer-name { font-weight: 700; font-size: 15px; color: var(--text); }

.plan-card { background: linear-gradient(135deg, var(--brand-soft) 0%, #ffffff 100%); border: 1px solid #bbf7d0; border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.plan-card .plan-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.plan-card .plan-printer { font-weight: 700; font-size: 15px; color: var(--text); }
.plan-card .plan-load { font-size: 12px; color: #166534; font-weight: 600; }
.plan-card .plan-bar { height: 6px; background: rgba(22,163,74,0.12); border-radius: 3px; margin-bottom: 12px; overflow: hidden; }
.plan-card .plan-bar > div { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand)); border-radius: 3px; }
.plate-job { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 13px; }
.plate-job .pj-name { font-weight: 600; color: var(--text); display: block; }
.plate-job .pj-product { font-size: 11px; color: var(--muted); }
.plate-job .pj-time { font-weight: 700; color: #166534; font-size: 13px; white-space: nowrap; }
.plate-job-check { width: 22px; height: 22px; border: 2px solid var(--brand); border-radius: 6px; flex-shrink: 0; margin-right: 10px; cursor: pointer; background: #fff; display: inline-flex; align-items: center; justify-content: center; }
.plate-job-check.checked { background: var(--brand); color: #fff; }
.plate-job-check.checked::after { content: "✓"; font-size: 14px; font-weight: 700; }

/* ── Farm board: «Завантажити пластик» ───────────────────────────────────── */
.load-filament { background:#fff; border:1px dashed #bbf7d0; border-radius:10px; padding:8px 10px; margin-bottom:10px; }
.load-filament-title { font-size:11px; font-weight:700; color:#166534; text-transform:uppercase; letter-spacing:.3px; margin-bottom:6px; }
.load-filament-chips { display:flex; flex-wrap:wrap; gap:6px; }
.fil-chip { display:inline-flex; align-items:center; gap:6px; background:#f0fdf4; border:1px solid var(--border); border-radius:8px; padding:4px 8px; font-size:12px; }
.fil-dot { width:12px; height:12px; border-radius:50%; border:1px solid rgba(0,0,0,.15); flex-shrink:0; }
.fil-name { font-weight:600; color:var(--text); }
.fil-grams { font-weight:700; color:#166534; }
.fil-chip-ok   { font-size:10px; color:var(--brand); }
.fil-chip-low  { font-size:10px; color:#d97706; font-weight:700; }
.fil-chip-warn { font-size:10px; color:var(--danger); font-weight:700; }

/* ── Gcode per-model row ─────────────────────────────────────────────────── */
.gcode-model-row { display:flex; align-items:center; gap:6px; background:#fff; border:1px solid var(--border); border-radius:8px; padding:6px 8px; font-size:12px; }
.gcode-model-name { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--text); }

/* ── Farm board: рядок пластини ──────────────────────────────────────────── */
.plate-row-sched { display:flex; align-items:center; gap:10px; background:#fff; border:1px solid var(--border); border-radius:10px; padding:8px 10px; margin-bottom:6px; }
.plate-thumb { width:48px; height:48px; object-fit:cover; border-radius:8px; flex-shrink:0; background:#f4f4f5; }
.plate-thumb-empty { display:flex; align-items:center; justify-content:center; color:#cbd5e1; }
.plate-thumb-empty .ms { font-size:22px; }
.plate-row-body { flex:1; min-width:0; }
.plate-row-name { font-weight:600; font-size:13px; color:var(--text); }
.plate-row-x { color:var(--brand); font-weight:700; }
.plate-row-product { font-size:11px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.plate-row-fils { display:flex; flex-wrap:wrap; gap:8px; margin-top:3px; }
.plate-fil { display:inline-flex; align-items:center; gap:3px; font-size:11px; color:#52525b; }
.plate-row-time { text-align:right; flex-shrink:0; }
.plate-row-time .prt-total { font-weight:700; color:#166534; font-size:13px; white-space:nowrap; }
.sched-launch-btn { background:var(--brand); color:#fff; border:none; border-radius:8px; width:34px; height:34px; display:flex; align-items:center; justify-content:center; cursor:pointer; margin-top:4px; transition:background .15s; }
.sched-launch-btn:hover:not(:disabled) { background:var(--brand-hover); }
.sched-file-ok   { display:inline-flex; align-items:center; gap:3px; font-size:10px; color:var(--brand); font-weight:600; }
.sched-file-warn { display:inline-flex; align-items:center; gap:3px; font-size:10px; color:#b91c1c; font-weight:600; }
.sched-file-ok .ms,.sched-file-warn .ms { font-size:12px; }

/* ── Paired thumbnails (фото товару + скріншот пластини) ─────────────────── */
.plate-thumbs-pair { display:flex; gap:3px; flex-shrink:0; }
.plate-thumb-mini { width:42px; height:42px; object-fit:contain; border-radius:6px; background:#f4f4f5; border:1px solid #e5e7eb; }
.plate-thumb-mini.plate-thumb-empty { display:flex; align-items:center; justify-content:center; color:#cbd5e1; }
.plate-thumb-mini.plate-thumb-empty .ms { font-size:18px; }

/* ── Drag-and-drop пластин ───────────────────────────────────────────────── */
.plate-row-sched { cursor:grab; transition:transform .1s, opacity .1s; }
.plate-row-sched:active { cursor:grabbing; }
.plate-row-sched.sched-dragging { opacity:.4; transform:scale(.98); }
.plate-row-sched .drag-handle { color:#9ca3af; font-size:18px; cursor:grab; flex-shrink:0; touch-action:none; user-select:none; }
.plate-row-sched:hover .drag-handle { color:#6b7280; }
.plan-card.sched-drop-target { background:linear-gradient(135deg, var(--border) 0%, var(--brand-soft) 100%); border-color:var(--brand); box-shadow:inset 0 0 0 2px var(--brand); }

/* ── Camera error overlay ──────────────────────────────────────────────── */
.live-cam-error { background:#fef2f2; padding:12px; flex-direction:column; gap:6px; }
.live-cam-err-msg { font-size:10px; color:#b91c1c; text-align:center; line-height:1.3; max-width:200px; word-wrap:break-word; }

/* Плавна заміна кадру камери — без чорного "блимання" */
.live-cam { transition: opacity .25s ease; }

/* ── Кнопка TV у toolbar ─────────────────────────────────────────────────── */
.live-tv-btn { display:inline-flex; align-items:center; gap:4px; background:#0f172a; color:#fff; border:none; border-radius:8px; padding:6px 12px; font-weight:600; cursor:pointer; font-size:13px; margin-left:8px; transition:background .15s; }
.live-tv-btn:hover { background:#1e293b; }
.live-tv-btn .ms { font-size:18px; }

/* ── TV wall (full-screen dashboard з усіма камерами) ────────────────────── */
#live-tv-wall { position:fixed; inset:0; z-index:99999; background:#000; display:flex; flex-direction:column; color:#fff; font-family:Inter,sans-serif; }
.tv-toolbar { display:flex; align-items:center; gap:16px; padding:10px 16px; background:#0b1220; border-bottom:1px solid #1e293b; flex-shrink:0; }
.tv-toolbar .tv-clock { font-size:24px; font-weight:700; font-variant-numeric:tabular-nums; color:var(--brand); }
.tv-toolbar .tv-title { font-size:14px; color:#cbd5e1; font-weight:600; flex:1; }
.tv-toolbar .tv-close { background:rgba(255,255,255,.1); border:none; color:#fff; width:36px; height:36px; border-radius:50%; cursor:pointer; font-size:20px; }
.tv-toolbar .tv-close:hover { background:rgba(255,255,255,.2); }

.tv-grid { flex:1; display:grid; gap:6px; padding:6px; overflow:hidden; grid-auto-rows:1fr; }
.tv-card { display:flex; flex-direction:column; background:#0f172a; border-radius:8px; overflow:hidden; position:relative; min-height:0; }
.tv-cam-wrap { flex:1; position:relative; background:#000; min-height:0; display:flex; align-items:center; justify-content:center; overflow:hidden; }
.tv-cam-img { width:100%; height:100%; object-fit:cover; display:block; transition:opacity .25s; }
.tv-cam-empty { color:#475569; display:flex; align-items:center; justify-content:center; flex-direction:column; }
.tv-state { position:absolute; top:6px; left:6px; background:var(--brand); color:#fff; padding:2px 8px; border-radius:6px; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.5px; }
.tv-info { display:flex; justify-content:space-between; align-items:center; padding:6px 10px; background:rgba(11,18,32,.95); flex-shrink:0; }
.tv-info .tv-name { font-weight:700; font-size:14px; }
.tv-info .tv-prog { font-size:12px; color:#94a3b8; font-variant-numeric:tabular-nums; }
.tv-bar { height:3px; background:rgba(255,255,255,.08); flex-shrink:0; }
.tv-bar > div { height:100%; background:var(--brand); transition:width .3s ease; }

/* ── Історія друку ──────────────────────────────────────────────────────── */
.history-filters { display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-bottom:10px; }
.hist-chip { background:#f3f4f6; border:1px solid #e5e7eb; border-radius:8px; padding:5px 12px; cursor:pointer; font-size:12px; font-weight:600; color:#475569; }
.hist-chip.active { background:#0f172a; color:#fff; border-color:#0f172a; }
.hist-chip.hist-ok.active  { background:var(--brand); border-color:var(--brand); }
.hist-chip.hist-def.active { background:var(--danger); border-color:var(--danger); }
.hist-chip.hist-err.active { background:var(--warning); border-color:var(--warning); }
.hist-chip.hist-cnl.active { background:#6b7280; border-color:#6b7280; }
.history-summary { display:flex; gap:14px; flex-wrap:wrap; padding:10px 14px; background:#f9fafb; border-radius:8px; margin-bottom:12px; font-size:13px; }
.history-row { display:flex; align-items:flex-start; gap:10px; background:#fff; border:1px solid var(--border); border-radius:10px; padding:10px 12px; margin-bottom:6px; }
.history-row-body { flex:1; min-width:0; }
.history-row-head { display:flex; align-items:center; gap:8px; margin-bottom:4px; }
.history-status { background:var(--brand); color:#fff; padding:2px 8px; border-radius:6px; font-size:11px; font-weight:700; }
.history-row-name { font-weight:600; font-size:14px; color:var(--text); }
.history-defect-btn { background:#fef2f2; color:#b91c1c; border:1px solid #fecaca; border-radius:8px; padding:6px 10px; cursor:pointer; font-size:12px; font-weight:600; flex-shrink:0; display:inline-flex; align-items:center; gap:3px; }
.history-defect-btn:hover { background:#fee2e2; }

/* ── Обслуговування ─────────────────────────────────────────────────────── */
.maint-card { background:#fff; border:1px solid var(--border); border-radius:12px; padding:14px; margin-bottom:14px; }
.maint-head { display:flex; justify-content:space-between; align-items:flex-start; gap:10px; margin-bottom:12px; padding-bottom:10px; border-bottom:1px solid var(--border); flex-wrap:wrap; }
.maint-printer { font-weight:700; font-size:16px; color:var(--text); }
.maint-alert-green  { color:var(--brand); font-weight:600; font-size:13px; }
.maint-alert-yellow { color:#d97706; font-weight:600; font-size:13px; }
.maint-alert-red    { color:#dc2626; font-weight:700; font-size:13px; }
.maint-row { display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px dashed #f1f5f9; }
.maint-row:last-child { border-bottom:none; }
.maint-row.overdue { background:linear-gradient(90deg, #fef2f2 0%, transparent 60%); border-radius:8px; padding:8px 10px; }
.maint-row.soon    { background:linear-gradient(90deg, #fffbeb 0%, transparent 60%); border-radius:8px; padding:8px 10px; }
.maint-row-info { flex:1; min-width:0; }
.maint-row-name { font-weight:600; font-size:14px; color:var(--text); }
.maint-bar { height:5px; background:#f1f5f9; border-radius:3px; margin-top:6px; overflow:hidden; }
.maint-bar > div { height:100%; border-radius:3px; transition:width .3s; }
.maint-done-btn { background:#f0fdf4; color:#166534; border:1px solid #bbf7d0; border-radius:8px; padding:6px 10px; cursor:pointer; font-size:12px; font-weight:600; flex-shrink:0; display:inline-flex; align-items:center; gap:3px; }
.maint-done-btn:hover { background:var(--success-soft); }
.plan-card.plan-card-reserved { background:linear-gradient(135deg, #fef3c7 0%, #fef9c3 100%); border-color:#fde68a; opacity:.85; }

/* ── Live калькулятор у формі товару ────────────────────────────────────── */
.prod-live-summary { background:linear-gradient(135deg, var(--brand-soft) 0%, #f0fdf4 100%); border:1px solid #bbf7d0; border-radius:10px; padding:10px 12px; font-size:13px; display:flex; flex-direction:column; gap:5px; }
.prod-live-summary > div { line-height:1.4; }
.prod-live-summary > div > span:first-child { margin-right:6px; }

/* ── Помилки принтерів ──────────────────────────────────────────────────── */
.err-top-codes { display:flex; align-items:center; gap:8px; flex-wrap:wrap; padding:10px; background:#fef2f2; border:1px solid #fecaca; border-radius:10px; margin-bottom:12px; }
.err-top-codes .err-top-title { font-size:12px; font-weight:700; color:#b91c1c; }
.err-code-chip { background:#fff; border:1px solid #fca5a5; border-radius:6px; padding:4px 10px; cursor:pointer; font-size:12px; color:#b91c1c; font-weight:600; }
.err-code-chip:hover { background:#fee2e2; }
.err-filters { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:14px; }
.err-row { display:flex; align-items:flex-start; gap:10px; background:#fff; border:1px solid #fecaca; border-left:4px solid #ef4444; border-radius:10px; padding:10px 12px; margin-bottom:6px; }
.err-row.resolved { border-color:var(--border); border-left-color:var(--brand); opacity:.7; }
.err-row-body { flex:1; min-width:0; }
.err-row-head { display:flex; align-items:center; gap:8px; margin-bottom:4px; }
.err-code { background:#b91c1c; color:#fff; padding:2px 10px; border-radius:6px; font-size:12px; font-weight:700; font-variant-numeric:tabular-nums; }
.err-printer { font-size:13px; color:var(--text); margin-bottom:3px; }
.err-message { font-size:12px; color:#b91c1c; font-style:italic; }
.err-snapshot { width:80px; height:60px; object-fit:cover; border-radius:6px; flex-shrink:0; background:#f4f4f5; cursor:pointer; transition:transform .15s; }
.err-snapshot:hover { transform:scale(1.05); }
.err-snapshot-empty { display:flex; align-items:center; justify-content:center; color:#cbd5e1; cursor:default; }
.err-resolved-badge { background:var(--border); color:#166534; padding:2px 8px; border-radius:6px; font-size:11px; font-weight:700; }
.err-resolve-btn { background:#f0fdf4; color:#166534; border:1px solid #bbf7d0; border-radius:8px; padding:6px 10px; cursor:pointer; font-size:12px; font-weight:600; flex-shrink:0; display:inline-flex; align-items:center; gap:3px; }
.err-resolve-btn:hover { background:var(--success-soft); }

/* ── Аналітика ──────────────────────────────────────────────────────────── */
.ana-tabs { display:flex; gap:4px; border-bottom:1px solid var(--border); margin-bottom:14px; flex-wrap:wrap; }
.ana-tab { background:transparent; border:none; padding:8px 14px; cursor:pointer; font-size:14px; color:#6b7280; font-weight:600; border-bottom:2px solid transparent; transition:.15s; }
.ana-tab:hover { color:#0f172a; }
.ana-tab.active { color:#0f172a; border-bottom-color:#0f172a; }
.ana-period-tabs { display:flex; gap:6px; margin-bottom:14px; flex-wrap:wrap; }
.ana-period { background:#f4f4f5; border:1px solid #e5e7eb; border-radius:8px; padding:5px 12px; cursor:pointer; font-size:12px; font-weight:600; color:#475569; }
.ana-period.active { background:#0f172a; color:#fff; border-color:#0f172a; }
.ana-kpi-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr)); gap:10px; margin-bottom:18px; }
.ana-kpi { background:#fff; border:1px solid var(--border); border-left:4px solid var(--brand); border-radius:10px; padding:12px; }
.ana-kpi-icon { font-size:18px; }
.ana-kpi-val { font-size:22px; font-weight:800; color:var(--text); }
.ana-kpi-label { font-size:11px; color:#6b7280; text-transform:uppercase; letter-spacing:.3px; }
.ana-section { margin-bottom:24px; background:#fff; border:1px solid var(--border); border-radius:12px; padding:14px; }
.ana-h { font-size:14px; font-weight:700; color:var(--text); margin-bottom:10px; }
.ana-bars { display:flex; gap:6px; align-items:flex-end; height:140px; overflow-x:auto; padding-bottom:4px; }
.ana-bar-col { display:flex; flex-direction:column; align-items:center; gap:4px; min-width:46px; }
.ana-bar-track { height:100px; width:24px; background:#f1f5f9; border-radius:4px; position:relative; overflow:hidden; display:flex; align-items:flex-end; }
.ana-bar-fill { width:100%; background:var(--brand); border-radius:4px 4px 0 0; transition:height .3s; }
.ana-bar-label { font-size:10px; color:#6b7280; }
.ana-bar-val { font-size:10px; color:var(--brand); font-weight:700; }
.ana-printer-row { display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px dashed #f1f5f9; flex-wrap:wrap; }
.ana-printer-row:last-child { border-bottom:none; }
.ana-printer-name { flex:1; font-size:13px; min-width:200px; }
.ana-printer-stats { display:flex; gap:12px; font-size:12px; color:#475569; flex-wrap:wrap; }
.ana-product-row { display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px dashed #f1f5f9; }
.ana-product-rank { width:28px; height:28px; background:#0f172a; color:#fff; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:12px; flex-shrink:0; }
.ana-product-name { flex:1; font-size:13px; }
.ana-product-stats { display:flex; gap:10px; font-size:12px; color:#475569; flex-wrap:wrap; }
.ana-formula { background:#f9fafb; border-radius:8px; padding:12px; font-size:13px; line-height:1.6; }
.ana-econ-card { border:1px solid var(--border); border-radius:10px; padding:12px; margin-bottom:10px; background:#fafafa; }
.ana-econ-head { font-size:14px; margin-bottom:8px; }
.ana-econ-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(120px, 1fr)); gap:8px; }
.ana-econ-item { background:#fff; padding:8px 10px; border-radius:6px; }
.ana-econ-label { font-size:10px; color:#6b7280; text-transform:uppercase; }
.ana-econ-val { font-size:15px; font-weight:700; color:var(--text); }
.ana-fil-row { display:flex; align-items:center; gap:10px; padding:10px 12px; background:#fff; border-left:4px solid var(--brand); border-radius:8px; margin-bottom:6px; box-shadow:0 1px 2px rgba(0,0,0,.04); }
.ana-fil-dot { width:24px; height:24px; border-radius:50%; border:2px solid #fff; box-shadow:0 0 0 1px rgba(0,0,0,.1); flex-shrink:0; }
.ana-fil-info { flex:1; min-width:0; }
.ana-fil-name { font-size:13px; }
.ana-fil-days { font-weight:700; font-size:13px; flex-shrink:0; white-space:nowrap; }

.login-card { max-width: 380px; margin: 5vh auto; background: #fff; border-radius: 20px; box-shadow: 0 8px 32px rgba(22,163,74,0.12); padding: 32px 28px; text-align: center; }
.login-card h1 { font-size: 22px; margin: 16px 0 8px; font-weight: 800; color: var(--text); }
.login-card p { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.login-step { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin: 16px 0; text-align: left; }
.login-step .step-num { background: var(--blue); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-right: 8px; vertical-align: middle; }
.login-step .step-text { font-size: 13px; color: var(--text-soft); vertical-align: middle; }
.login-code { background: var(--bg-soft); padding: 8px 14px; border-radius: 10px; display: inline-block; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 18px; font-weight: 700; color: var(--blue-dark); letter-spacing: 4px; }

.desktop-only { display: none; }
.mobile-only  { display: block; }

.desktop-shell { display: block; min-height: 100vh; }

/* Sidebar — фон/бордюри/текст через токени.
   Light: світло-сірий фон з темним текстом і brand акцентом на активному.
   Dark : майже-чорний фон з освітленим текстом (через [data-theme="dark"] правила нижче). */
.desktop-sidebar {
  display: none;
  background: var(--bg-surface);
  color: var(--text-secondary);
  padding: 20px 12px;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  /* z-index 200 > modal-overlay (100) — щоб сайдбар лишався клікабельним
     поки відкрита модалка. Користувач може перемикати вкладки не закриваючи її. */
  z-index: 200;
}
.desktop-sidebar .sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 18px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 12px;
}
.desktop-sidebar .sidebar-brand .logo-box-sm { width: 32px; height: 32px; box-shadow: none; }
.desktop-sidebar .sidebar-logo-img {
  width: 36px; height: 36px; border-radius: 9px; object-fit: contain;
  background: var(--brand-soft); padding: 4px;
  box-shadow: var(--shadow-xs);
}
.desktop-sidebar .sidebar-brand .brand-title {
  color: var(--text); font-weight: 800; font-size: 16px;
}
.desktop-sidebar .sidebar-brand .brand-sub {
  color: var(--text-muted); font-size: 11px;
}
.desktop-sidebar .nav-item-d {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500; font-size: 14px;
  background: transparent; border: none; width: 100%;
  cursor: pointer; text-align: left;
  transition: background .15s ease, color .15s ease;
  font-family: inherit;
}
.desktop-sidebar .nav-item-d:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.desktop-sidebar .nav-item-d.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.desktop-sidebar .nav-item-d .ms { font-size: 20px; }
.desktop-sidebar .sidebar-spacer { flex: 1; }
.desktop-sidebar .sidebar-user {
  padding: 10px 12px;
  border-top: 1px solid var(--border-soft);
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
}
.desktop-sidebar .sidebar-logout {
  margin: 4px 8px 10px 8px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color .15s, border-color .15s, background .15s;
}
.desktop-sidebar .sidebar-logout:hover {
  color: var(--danger);
  border-color: var(--danger-soft);
  background: var(--danger-soft);
}

.desktop-main { background: var(--bg); min-height: 100vh; padding: 0; overflow-x: hidden; }
.desktop-main .section.active { padding: 16px; padding-bottom: 96px; }

.desktop-topbar {
  display: none;
  position: sticky;
  top: 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 10;
}
.desktop-topbar h2 { margin: 0; font-size: 18px; font-weight: 700; color: var(--text); }
.desktop-topbar .topbar-actions { display: flex; align-items: center; gap: 8px; }

body:not(.layout-desktop) .desktop-sidebar { display: none !important; }
body:not(.layout-desktop) .desktop-topbar  { display: none !important; }
body:not(.layout-desktop) .desktop-shell   { display: block !important; }
body:not(.layout-desktop) .mobile-header   { display: flex !important; }
body:not(.layout-desktop) .mobile-nav      { display: flex !important; }

body.layout-desktop { padding-bottom: 0; }

body.layout-desktop .desktop-only { display: block; }
body.layout-desktop .mobile-only  { display: none; }

body.layout-desktop .mobile-header { display: none !important; }
body.layout-desktop .mobile-nav    { display: none !important; }

body.layout-desktop .desktop-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
body.layout-desktop .desktop-sidebar { display: flex; }
body.layout-desktop .desktop-topbar  { display: flex; }

body.layout-desktop .desktop-main .section       { padding: 24px 32px; max-width: 1280px; margin: 0 auto; }
body.layout-desktop .desktop-main .section.active { padding-bottom: 48px; }

body.layout-desktop .grid-cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
body.layout-desktop .grid-cards > .card { margin-bottom: 0; }
body.layout-desktop #section-orders .grid-cards { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
body.layout-desktop #section-orders .order-card { max-width: 560px; }
/* Менші, компактні картки на ПК (auto-fill, мін 160px) */
body.layout-desktop .product-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
body.layout-desktop .pc-card { padding: 6px; }
body.layout-desktop .pc-img-wrap { margin-bottom: 6px; border-radius: 8px; }
body.layout-desktop .pc-name { font-size: 12px; min-height: 32px; line-height: 1.25; }
body.layout-desktop .pc-price { font-size: 13px; }

body.layout-desktop .modal-overlay { align-items: center; }
body.layout-desktop .modal-content { border-radius: 20px; max-width: 640px; }
body.layout-desktop .modal-content.modal-wide { max-width: 880px; }
body.layout-desktop .modal-handle { display: none; }

.btn-layout-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  font-family: 'Material Symbols Rounded';
  font-size: 20px;
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  line-height: 1;
  flex-shrink: 0;
}
/* ============================================================
   v4: Photo Gallery (no cropping, multi-photo)
   ============================================================ */
body.gallery-open { overflow: hidden; }
.gallery-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.gallery-stage {
  position: relative;
  max-width: 96vw; max-height: 80vh;
  display: flex; align-items: center; justify-content: center;
}
.gallery-img {
  max-width: 96vw; max-height: 80vh;
  width: auto; height: auto;
  object-fit: contain; display: block;
  border-radius: 8px;
}
.gallery-counter {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 14px; font-weight: 600;
  background: rgba(0,0,0,0.45); padding: 4px 12px; border-radius: 16px;
}
.gallery-close {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255,255,255,0.15); color: #fff; border: 0;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.15); color: #fff; border: 0;
  width: 48px; height: 48px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.gallery-nav-prev { left: -64px; }
.gallery-nav-next { right: -64px; }
@media (max-width: 768px) {
  .gallery-nav-prev { left: 8px; }
  .gallery-nav-next { right: 8px; }
}
.gallery-thumbs {
  display: flex; gap: 6px; margin-top: 16px; padding: 0 16px;
  overflow-x: auto; max-width: 96vw;
}
.gallery-thumb {
  flex: 0 0 auto; width: 56px; height: 56px;
  background: #222; border: 2px solid transparent; border-radius: 6px;
  padding: 0; cursor: pointer; overflow: hidden;
}
.gallery-thumb.active { border-color: var(--brand); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ============================================================
   v4: Notifications Bell + Dropdown
   ============================================================ */
.notif-bell { position: relative; }
.notif-bell-btn {
  position: relative; background: transparent; border: 0; padding: 6px;
  cursor: pointer; border-radius: 8px;
}
.notif-bell-btn:hover { background: #f4f4f5; }
.notif-badge {
  position: absolute; top: 0; right: 0;
  background: var(--danger); color: #fff;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; font-size: 11px; font-weight: 700; line-height: 18px;
  display: flex; align-items: center; justify-content: center;
}
.notif-dropdown {
  position: fixed; top: 60px; right: 16px; z-index: 1000;
  width: 380px; max-width: 96vw; max-height: 70vh;
  background: #fff; border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.16);
  overflow: hidden; display: flex; flex-direction: column;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid #f4f4f5;
}
.notif-title { font-weight: 700; }
.notif-mark-all {
  background: transparent; border: 0; color: var(--brand); font-size: 12px;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.notif-mark-all:hover { background: #f0fdf4; }
.notif-list { overflow-y: auto; max-height: 60vh; }
.notif-empty { padding: 32px 16px; text-align: center; color: #71717a; }
.notif-item {
  padding: 12px 16px; border-bottom: 1px solid #f4f4f5;
  cursor: pointer;
}
.notif-item:hover { background: #f4f4f5; }
.notif-item-unread { background: #eff6ff; }
.notif-item-unread:hover { background: #dbeafe; }
.notif-item-title { font-weight: 600; font-size: 14px; }
.notif-item-body { font-size: 12px; color: #52525b; margin-top: 2px; }
.notif-item-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px;
}
.notif-time { font-size: 11px; color: #a1a1aa; }
.notif-action {
  background: transparent; border: 1px solid var(--brand); color: var(--brand);
  padding: 2px 8px; border-radius: 6px; font-size: 11px; cursor: pointer;
}

/* ============================================================
   v4: Manager Order Form
   ============================================================ */
.source-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.form-collapse {
  border: 1px solid #e4e4e7; border-radius: 10px; padding: 6px 12px; margin-bottom: 10px;
  background: #fafafa;
}
.form-collapse > summary {
  cursor: pointer; font-weight: 600; padding: 6px 0;
  font-size: 13px; color: #52525b;
  display: flex; align-items: center; gap: 6px;
  list-style: none;
}
.form-collapse > summary::-webkit-details-marker { display: none; }
.form-collapse > summary::before {
  content: '›'; display: inline-block; transform: rotate(0deg); transition: transform 0.15s;
  font-weight: 700; color: #a1a1aa;
}
.form-collapse[open] > summary::before { transform: rotate(90deg); }
.form-collapse[open] { background: #fff; }

.totals-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding: 10px 12px; background: #f9fafb; border-radius: 10px;
  border: 1px solid #e4e4e7;
}
.totals-grid > div { display: flex; flex-direction: column; align-items: center; }
.totals-grid .lbl { font-size: 11px; color: #71717a; }
.totals-grid .val { font-size: 14px; font-weight: 700; color: #18181b; }
.totals-grid > div:last-child .val { color: var(--brand); }

.ord-item-row {
  display: grid; grid-template-columns: 44px 1fr auto auto 28px;
  gap: 8px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid #f4f4f5;
}
.ord-item-img img, .ord-item-img > div { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }
.ord-item-name { font-size: 13px; font-weight: 600; }
.ord-item-code {
  background: #f4f4f5; color: #52525b; font-size: 10px;
  padding: 1px 5px; border-radius: 4px; font-family: monospace;
}
.ord-item-stock { font-size: 11px; color: #71717a; }
.ord-item-qty {
  display: flex; align-items: center; gap: 4px;
  background: #f4f4f5; border-radius: 6px; padding: 2px;
}
.ord-item-qty .qty-btn {
  width: 24px; height: 24px; border: 0; background: #fff; border-radius: 4px;
  cursor: pointer; font-weight: 700;
}
.ord-item-qty input {
  width: 36px; text-align: center; border: 0; background: transparent;
  font-weight: 700; font-size: 13px;
}
.ord-item-price {
  display: flex; align-items: center; gap: 2px;
}
.ord-item-price input {
  width: 72px; padding: 4px 6px; border: 1px solid #e4e4e7; border-radius: 6px;
  font-size: 13px; text-align: right;
}
.ord-item-currency { font-size: 12px; color: #71717a; }
.ord-item-del {
  width: 28px; height: 28px; border: 0; background: transparent; cursor: pointer;
  color: var(--danger); display: flex; align-items: center; justify-content: center;
}

.extra-photos-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
}
.extra-photo-cell {
  position: relative; aspect-ratio: 1;
  border-radius: 6px; overflow: hidden; background: #f4f4f5;
}
.extra-photo-cell img { width: 100%; height: 100%; object-fit: cover; }
.extra-photo-del {
  position: absolute; top: 2px; right: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; border: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.extra-photo-del .ms { font-size: 16px; }

.empty-state-sm {
  padding: 16px; text-align: center; color: #71717a;
  background: #f9fafb; border-radius: 8px; font-size: 13px;
}

.prod-pick-list { max-height: 60vh; overflow-y: auto; }
.prod-pick-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px; border: 0;
  border-bottom: 1px solid #f4f4f5;
  background: #fff; cursor: pointer; text-align: left;
}
.prod-pick-row:hover { background: #f9fafb; }
.prod-pick-img img, .prod-pick-img > div { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }
.prod-pick-name { font-size: 13px; font-weight: 600; }
.prod-pick-meta { font-size: 11px; color: #71717a; display: flex; gap: 8px; align-items: center; }
.prod-pick-code {
  background: #f4f4f5; color: #52525b; font-size: 10px;
  padding: 1px 5px; border-radius: 4px; font-family: monospace;
}
.prod-pick-price { color: var(--brand); font-weight: 600; }

/* ============================================================
   v4: Printer Ship
   ============================================================ */
.ship-list { display: flex; flex-direction: column; gap: 12px; }
.ship-card {
  background: #fff; border: 1px solid #e4e4e7; border-radius: 12px;
  padding: 12px;
}
.ship-card-compact { padding: 8px 12px; }
.ship-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.ship-card-id { font-weight: 700; font-family: monospace; }
.ship-card-meta { display: flex; gap: 6px; align-items: center; }
.ship-source {
  background: #dbeafe; color: #1e40af; padding: 2px 8px;
  border-radius: 12px; font-size: 11px; font-weight: 600;
}
.ship-status {
  padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600;
}
.status-new       { background: #f4f4f5; color: #52525b; }
.status-paid      { background: #fef3c7; color: #92400e; }
.status-printing  { background: #ede9fe; color: #5b21b6; }
.status-packed    { background: #dbeafe; color: #1e40af; }
.status-shipped   { background: var(--border); color: #065f46; }
.status-delivered { background: var(--border); color: #065f46; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.status-returned  { background: #fee2e2; color: #991b1b; }

.ship-card-ttn {
  font-family: monospace; font-size: 12px; color: #52525b;
  margin-bottom: 8px; display: flex; align-items: center; gap: 4px;
}
.ship-item-row {
  display: grid; grid-template-columns: 44px 1fr auto;
  gap: 8px; align-items: center; padding: 6px 0;
}
.ship-item-img img, .ship-item-img > div { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }
.ship-item-name { font-size: 13px; font-weight: 600; }
.ship-item-qty { font-size: 14px; font-weight: 700; color: var(--brand); }
.ship-card-money {
  display: flex; gap: 12px; margin: 6px 0; font-size: 12px; color: #52525b;
}
.ship-card-actions {
  display: flex; gap: 8px; align-items: center; justify-content: flex-end;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid #f4f4f5;
}

.barcode-wrap {
  background: #fff; padding: 12px; border-radius: 8px;
  border: 1px solid #e4e4e7;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.barcode-svg { width: 100%; max-width: 480px; }

.ship-info-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  padding: 10px; background: #f9fafb; border-radius: 8px;
  margin-top: 12px;
}
.ship-info-grid > div {
  display: flex; flex-direction: column;
}
.ship-info-grid .lbl { font-size: 11px; color: #71717a; }
.ship-info-grid .val { font-size: 13px; font-weight: 600; }

.ship-photos-row { display: flex; justify-content: center; margin: 10px 0; }
.ship-items-block { margin: 10px 0; }

.ship-caption-block { margin-top: 12px; }
.ship-caption-block textarea {
  width: 100%; min-height: 80px; padding: 8px;
  border: 1px solid #e4e4e7; border-radius: 8px;
  font-family: monospace; font-size: 12px; resize: vertical;
  background: #f9fafb;
}

.ship-stock-q {
  margin-top: 12px; padding: 12px; background: #fef3c7; border-radius: 8px;
}
.ship-stock-options { display: flex; gap: 8px; margin-top: 8px; }
.ship-stock-options .btn { flex: 1; }

/* ============================================================
   v4: Admin Panel Extended
   ============================================================ */
.admin-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  border-bottom: 1px solid #e4e4e7; padding-bottom: 0;
}
.admin-tab {
  padding: 10px 16px; border: 0; background: transparent; cursor: pointer;
  font-weight: 600; color: #71717a;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.admin-tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.settings-group {
  border: 1px solid #e4e4e7; border-radius: 8px;
  padding: 8px 12px; margin-bottom: 12px;
}
.settings-group > summary {
  cursor: pointer; font-weight: 700; padding: 6px 0;
  display: flex; align-items: center; gap: 6px;
}
.settings-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  padding: 10px 0; border-top: 1px solid #f4f4f5;
  align-items: center;
}
.settings-row .lbl { font-weight: 600; font-size: 13px; }
.settings-row .settings-key {
  font-family: monospace; font-size: 11px; color: #52525b;
  background: #f4f4f5; padding: 2px 6px; border-radius: 4px;
}
.settings-input input,
.settings-input select,
.settings-input textarea { width: 100%; }
.settings-row-missing { opacity: 0.5; }

.users-list { display: flex; flex-direction: column; gap: 8px; }
.user-row {
  background: #fff; border: 1px solid #e4e4e7; border-radius: 8px;
  padding: 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 12px;
  align-items: center;
}
.user-name { font-weight: 700; font-size: 14px; }
.user-meta { margin-top: 4px; }
.user-controls { display: flex; gap: 8px; }
.user-control { display: flex; flex-direction: column; gap: 2px; }
.user-control select { min-width: 120px; padding: 4px 8px; font-size: 12px; }

.activity-filter {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 12px;
}
.activity-list { display: flex; flex-direction: column; gap: 6px; }
.activity-row {
  display: grid; grid-template-columns: 32px 1fr auto;
  gap: 10px; align-items: center;
  background: #fff; border: 1px solid #e4e4e7; border-radius: 8px;
  padding: 10px;
}
.activity-icon {
  width: 32px; height: 32px; border-radius: 6px; background: #f4f4f5;
  display: flex; align-items: center; justify-content: center;
}
.activity-summary { font-size: 13px; font-weight: 600; }
.activity-meta { font-size: 11px; color: #71717a; margin-top: 2px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }
.activity-changes-pre {
  background: #f9fafb; padding: 10px; border-radius: 8px;
  font-family: monospace; font-size: 11px;
  max-height: 60vh; overflow: auto; white-space: pre-wrap;
}

.pager {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 16px 0;
}

.section-subtitle {
  font-weight: 700; font-size: 14px; color: #52525b;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 0; margin-bottom: 8px;
}

.pc-tag-red { background: #fee2e2; color: #991b1b; }
.pc-tag-green { background: var(--border); color: #065f46; }
.pc-tag-blue { background: #dbeafe; color: #1e40af; }
.pc-tag-purple { background: #ede9fe; color: #5b21b6; }
.pc-tag {
  display: inline-block; padding: 1px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 600;
}

.prod-img-sm {
  width: 44px; height: 44px; object-fit: cover; border-radius: 6px;
}

@media print {
  body.layout-desktop .desktop-sidebar,
  .mobile-nav, .mobile-header, .desktop-topbar,
  .notif-dropdown, .modal-overlay > .modal-content > div:first-child {
    display: none !important;
  }
}

/* Grouped queue item — N однакових товарів в одну картку. */
.queue-item-grouped {
  background: #fafafa;
  border: 1px solid #e4e4e7;
  border-left: 3px solid #2563eb;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
.queue-item-grouped > div > button[onclick*="collapsed"] {
  transition: transform .15s ease;
}
.queue-item-grouped:has(.collapsed) > div > button[onclick*="collapsed"] span.ms {
  transform: rotate(0deg);
}
.queue-item-grouped > div:not(.collapsed):not([class*="collapsed"]) ~ div button span.ms {
  transform: rotate(180deg);
}
.collapsed { display: none; }

/* Product card — multi-select checkbox для batch slicing. */
.pc-card { position: relative; }
.pc-batch-cb {
  position: absolute; top: 6px; left: 6px; z-index: 5;
  width: 18px; height: 18px; cursor: pointer;
  accent-color: #7c3aed;
  opacity: 0; transition: opacity .15s;
}
.pc-card:hover .pc-batch-cb,
.pc-card.pc-card-selected .pc-batch-cb { opacity: 1; }
.pc-card-selected {
  outline: 3px solid #7c3aed;
  outline-offset: -3px;
  background: #faf5ff;
}

/* ============================================================
   Economics Dashboard
   ============================================================ */
.econ-periods { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.econ-period {
  padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 600;
  background: #fff; border: 1px solid #e4e4e7; color: #71717a; cursor: pointer;
  transition: all .15s;
}
.econ-period:hover  { background: #f4f4f5; color: #18181b; }
.econ-period.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.econ-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px; margin-bottom: 18px;
}
.econ-kpi {
  background: #fff; border: 1px solid #e4e4e7; border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
.econ-kpi-label { font-size: 11px; color: #71717a; text-transform: uppercase; letter-spacing: .5px; }
.econ-kpi-val   { font-size: 24px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }

.econ-section {
  background: #fff; border: 1px solid #e4e4e7; border-radius: 12px;
  padding: 14px 16px; margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
.econ-h {
  font-size: 13px; font-weight: 700; color: #18181b; margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: .5px;
}

.econ-cost-bar {
  display: flex; height: 14px; border-radius: 7px; overflow: hidden;
  background: #f4f4f5;
}
.econ-cost-bar > div { height: 100%; transition: width .25s ease; }
.econ-cost-legend {
  display: flex; gap: 14px; margin-top: 10px; flex-wrap: wrap;
  font-size: 12px; color: #52525b;
}
.econ-cost-legend .dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  vertical-align: middle; margin-right: 5px;
}

.econ-chart {
  display: flex; gap: 4px; height: 140px; padding: 6px 0;
  align-items: flex-end;
}
.econ-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 26px; }
.econ-bar-stack { width: 100%; height: 110px; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; }
.econ-bar-rev { background: #0ea5e9; border-radius: 2px 2px 0 0; min-height: 1px; }
.econ-bar-prf { background: var(--brand); min-height: 1px; }
.econ-bar-lbl { font-size: 9px; color: #71717a; }

.econ-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.econ-table th {
  text-align: left; padding: 8px 6px; font-weight: 600; color: #71717a;
  border-bottom: 1px solid #e4e4e7; font-size: 11px; text-transform: uppercase; letter-spacing: .3px;
}
.econ-table td { padding: 8px 6px; border-bottom: 1px solid #f4f4f5; vertical-align: middle; }
.econ-table tr:hover td { background: #fafafa; }

.econ-formula-box { background: #f9fafb; border-color: #f4f4f5; }

/* ============================================================
   Onboarding Tour
   ============================================================ */
.tour-overlay {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(15,23,42,.55);
  animation: cpFade .2s ease-out;
}
.tour-card {
  position: fixed; z-index: 10000;
  background: #fff; color: #18181b;
  border-radius: 14px; padding: 18px 20px;
  width: 340px; max-width: calc(100vw - 32px);
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  animation: tourCardIn .22s cubic-bezier(.16,1,.3,1);
}
@keyframes tourCardIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
.tour-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.tour-body  { font-size: 13px; line-height: 1.55; color: #3f3f46; }
.tour-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px;
}
.tour-count { font-size: 11px; color: #71717a; }
.tour-actions { display: flex; gap: 8px; }
.tour-actions button {
  border: none; padding: 7px 14px; border-radius: 8px;
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.tour-skip { background: transparent; color: #71717a; }
.tour-skip:hover { background: #f4f4f5; color: #18181b; }
.tour-next, .tour-done {
  background: linear-gradient(180deg, var(--brand), var(--brand)); color: #fff;
}
.tour-next:hover, .tour-done:hover {
  background: linear-gradient(180deg, var(--brand), var(--brand-hover));
}

/* ============================================================
   Cmd+K Command Palette
   ============================================================ */
#cp-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  animation: cpFade .15s ease-out;
}
@keyframes cpFade { from { opacity: 0; } to { opacity: 1; } }
.cp-modal {
  width: 100%; max-width: 600px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: cpSlide .2s cubic-bezier(.16, 1, .3, 1);
}
@keyframes cpSlide { from { opacity: 0; transform: translateY(-12px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.cp-search-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid #f4f4f5;
}
.cp-search-icon { font-size: 20px; color: #71717a; }
.cp-input {
  flex: 1; min-width: 0;
  border: none; outline: none;
  font-size: 16px; font-family: inherit; color: #18181b;
  background: transparent;
}
.cp-input::placeholder { color: #a1a1aa; }
.cp-kbd {
  background: #f4f4f5; color: #71717a;
  padding: 2px 6px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
  border: 1px solid #e4e4e7;
}
.cp-results {
  flex: 1; overflow-y: auto;
  max-height: 50vh;
  padding: 6px;
}
.cp-empty {
  padding: 30px; text-align: center;
  color: #a1a1aa; font-size: 13px;
}
.cp-group-title {
  font-size: 11px; font-weight: 700; color: #71717a;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 8px 12px 4px;
}
.cp-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 8px;
  cursor: pointer;
  transition: background .12s ease;
}
.cp-row:hover, .cp-row.cp-active {
  background: #f0fdf4;
}
.cp-row.cp-active { box-shadow: inset 0 0 0 1px #bbf7d0; }
.cp-icon {
  font-size: 22px; color: var(--brand);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: #f0fdf4; border-radius: 8px;
  flex-shrink: 0;
}
.cp-thumb {
  width: 36px; height: 36px; border-radius: 8px;
  object-fit: cover; flex-shrink: 0;
  background: #f4f4f5;
}
.cp-row-body { flex: 1; min-width: 0; }
.cp-row-label {
  font-size: 14px; font-weight: 600; color: #18181b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cp-row-sub {
  font-size: 12px; color: #71717a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cp-footer {
  display: flex; gap: 16px; justify-content: center;
  padding: 8px 14px;
  border-top: 1px solid #f4f4f5;
  font-size: 11px; color: #71717a;
}
.cp-footer kbd {
  background: #f4f4f5; color: #71717a;
  padding: 1px 5px; border-radius: 3px;
  font-size: 10px; margin-right: 3px;
  border: 1px solid #e4e4e7;
}

/* ============================================================
   Schedule V2 — Kanban
   ============================================================ */
.sv2-toolbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.sv2-stats { margin-left: auto; display: flex; gap: 12px; font-size: 13px; }
.sv2-stats .text-muted { color: #71717a; }

.sv2-board {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px;
  scroll-snap-type: x proximity;
}
.sv2-col {
  flex: 0 0 280px; min-height: 60vh;
  background: #fafafa; border: 1px solid #e4e4e7; border-radius: 12px;
  display: flex; flex-direction: column;
  scroll-snap-align: start;
  transition: background .15s ease, border-color .15s ease;
}
.sv2-col.sv2-drop-target { background: var(--success-soft); border-color: var(--brand); }
.sv2-col-head {
  padding: 10px 12px; border-bottom: 1px solid #e4e4e7;
  display: flex; flex-direction: column; gap: 4px;
  background: #fff; border-radius: 12px 12px 0 0;
}
.sv2-col-head-inbox { background: #f0f9ff; }
.sv2-col-title { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.sv2-col-count {
  margin-left: auto; padding: 2px 8px; border-radius: 8px;
  background: #f4f4f5; font-size: 11px; font-weight: 700; color: #52525b;
}
.sv2-col-sub { font-size: 11px; color: #71717a; }
.sv2-ams-row { display: flex; gap: 4px; flex-wrap: wrap; }
.sv2-ams-chip {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.4);
}
.sv2-col-load { font-size: 11px; color: #71717a; }
.sv2-col-bar { height: 4px; background: #f4f4f5; border-radius: 2px; margin-top: 3px; overflow: hidden; }
.sv2-col-bar > div { height: 100%; background: linear-gradient(90deg, #2563eb, var(--brand)); transition: width .25s ease; }
.sv2-col-body { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.sv2-col-empty {
  text-align: center; font-size: 12px; color: #a1a1aa; padding: 30px 12px;
  border: 2px dashed #e4e4e7; border-radius: 10px;
}

.sv2-card {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 8px; padding: 8px;
  background: #fff; border-radius: 8px; cursor: grab;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
  transition: transform .12s ease, box-shadow .15s ease;
}
.sv2-card:hover { box-shadow: 0 4px 12px rgba(15,23,42,0.08); }
.sv2-card:active { cursor: grabbing; }
.sv2-card.sv2-dragging { opacity: .4; }
.sv2-card-thumb { width: 40px; height: 40px; border-radius: 6px; overflow: hidden; background: #f4f4f5; }
.sv2-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sv2-thumb-empty { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: #d4d4d8; }
.sv2-card-body { min-width: 0; }
.sv2-card-name { font-weight: 600; font-size: 12px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv2-card-x { background: #2563eb; color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 4px; font-weight: 700; }
.sv2-card-plate { font-size: 10px; color: #71717a; margin-top: 1px; }
.sv2-card-fils { display: flex; gap: 3px; margin-top: 3px; }
.sv2-fil-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
}
.sv2-match { display: inline-flex; align-items: center; gap: 3px; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.sv2-match-ok   { background: var(--success-soft); color: var(--brand-hover); }
.sv2-match-swap { background: #fef3c7; color: #92400e; }

.sv2-card-actions {
  display: flex; flex-direction: column; gap: 2px; align-items: center;
}
.sv2-btn {
  width: 22px; height: 22px; border-radius: 5px; border: 1px solid #e4e4e7;
  background: #fff; cursor: pointer; font-size: 12px; font-weight: 700; color: #52525b;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  transition: background .12s ease;
}
.sv2-btn:hover { background: #f4f4f5; }
.sv2-btn-launch { background: var(--brand); color: #fff; border-color: var(--brand); width: 28px; height: 22px; }
.sv2-btn-launch:hover { background: var(--brand-hover); }
.sv2-btn-del { color: var(--danger); border-color: #fecaca; }
.sv2-btn-del:hover { background: #fef2f2; }

/* ============================================================
   Stats Page Styles
   ============================================================ */
.stats-page-toggle {
  display: inline-flex; gap: 4px; background: #f4f4f5; border-radius: 8px; padding: 2px; margin-bottom: 16px;
}
.stats-toggle-btn {
  padding: 4px 12px; border: none; background: transparent;
  font-size: 12px; font-weight: 600; border-radius: 6px; cursor: pointer;
  color: var(--muted); font-family: inherit; transition: all 0.15s;
}
.stats-toggle-btn.active {
  background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stats-page-summary {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px;
}
.stats-page-card {
  background: #fff; border-radius: 14px; padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); border: 1px solid rgba(0,0,0,0.04);
  position: relative; overflow: hidden;
}
.stats-page-card-primary { border-left: 4px solid var(--brand); }
.stats-page-card-success { border-left: 4px solid var(--brand); }
.stats-page-card-blue { border-left: 4px solid #3b82f6; }
.stats-page-card-icon { margin-bottom: 6px; }
.stats-page-card-icon .ms { font-size: 24px; color: var(--brand); }
.stats-page-card-success .stats-page-card-icon .ms { color: var(--brand); }
.stats-page-card-blue .stats-page-card-icon .ms { color: var(--info); }
.stats-page-card-value { font-size: 22px; font-weight: 800; color: var(--text); }
.stats-page-card-label { font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 500; }
.stats-page-chart-wrap {
  background: #fff; border-radius: 14px; padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); border: 1px solid rgba(0,0,0,0.04);
  margin-bottom: 20px;
}
.stats-page-chart-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.stats-page-chart {
  display: flex; align-items: flex-end; gap: 6px; height: 140px;
}
.stats-bar-col {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end; height: 100%;
}
.stats-bar {
  width: 100%; min-width: 8px; background: var(--border); border-radius: 4px 4px 0 0;
  transition: height 0.3s ease;
}
.stats-bar-current { background: linear-gradient(180deg, var(--brand), var(--brand)); }
.stats-bar-label { font-size: 8px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.stats-bar-val { font-size: 8px; color: var(--muted); margin-bottom: 2px; white-space: nowrap; }
.stats-table {
  background: #fff; border-radius: 14px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); border: 1px solid rgba(0,0,0,0.04);
}
.stats-table-title {
  font-size: 15px; font-weight: 700; padding: 14px 16px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid #f4f4f5;
}
.stats-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats-table th {
  text-align: left; padding: 10px 12px; font-weight: 600;
  color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; background: #fafafa; border-bottom: 1px solid #f4f4f5;
}
.stats-table td { padding: 10px 12px; border-bottom: 1px solid #f4f4f5; }
.stats-table tr:last-child td { border-bottom: none; }
.stats-table tr:hover td { background: #f9fafb; }
.stats-td-money { font-weight: 700; color: var(--text); }
.stats-td-profit { font-weight: 700; color: var(--brand); }

body.layout-desktop .stats-page-summary { grid-template-columns: repeat(4, 1fr); }
body.layout-desktop .stats-page-chart { height: 200px; }

/* Order card item thumbnails */
.order-items-v2 { margin-top: 6px; }
.ord-item-row {
  display: flex; align-items: center; gap: 8px; padding: 3px 0;
}
.ord-item-thumb {
  width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0;
}
.ord-item-thumb-placeholder {
  background: #f4f4f5; display: flex; align-items: center; justify-content: center;
}
.ord-item-name { font-size: 12px; color: var(--muted); }

/* Spool color summary */
.spool-color-summary {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}
.spool-color-block {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-radius: 10px; padding: 8px 12px;
  border: 1px solid rgba(0,0,0,0.04); box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  min-width: 120px;
}
.spool-color-name { font-size: 13px; font-weight: 600; color: var(--text); }
.spool-color-meta { font-size: 11px; color: var(--muted); }

/* Spool cards — wider grid on desktop */
body.layout-desktop #section-spools .grid-cards {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* Витратні матеріали — картки на вкладці «Склад → Витратні матеріали». */
.consumable-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px;
}
.consumable-card {
  background: var(--surface); border-radius: 12px; padding: 8px;
  border: 1px solid rgba(0,0,0,0.04); box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex; flex-direction: column;
}
.consumable-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.consumable-card:active { transform: scale(0.97); }
.consumable-card--low { border-color: #fecaca; }
.consumable-thumb {
  width: 100%; aspect-ratio: 1 / 1; object-fit: contain; border-radius: 8px;
  background: #f4f4f5; margin-bottom: 6px;
}
.consumable-thumb--empty {
  display: flex; align-items: center; justify-content: center; color: #d4d4d8;
}
.consumable-thumb--empty .ms { font-size: 32px; }
.consumable-card-body { padding: 0 2px; }
.consumable-name { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.25; }
.consumable-qty { font-size: 12px; color: var(--muted); margin-top: 2px; }
.consumable-box-badge { font-size: 11px; color: var(--muted); margin-top: 2px; }
.consumable-cost { font-size: 11px; color: var(--muted); margin-top: 1px; }
.consumable-qty--low { color: #dc2626; font-weight: 700; }

/* ============================================================
   Telegram Mini App — compact design (only inside real Telegram)
   ============================================================ */
body.is-telegram {
  --bg: #f8faf9;
}
body.is-telegram .mobile-header {
  padding: 8px 12px;
}
body.is-telegram .mobile-header .text-lg {
  font-size: 15px;
}
body.is-telegram .mobile-nav {
  padding: 4px 4px 10px;
}
body.is-telegram .nav-item {
  padding: 4px 6px;
  font-size: 9px;
  min-width: 44px;
}
body.is-telegram .nav-item .ms { font-size: 20px; }
body.is-telegram .section.active {
  padding: 12px;
  padding-bottom: 80px;
}
body.is-telegram .section-title {
  font-size: 18px;
  margin-bottom: 10px;
}
body.is-telegram .card {
  padding: 10px 12px;
  border-radius: 12px;
}
body.is-telegram .order-card {
  padding: 10px 12px;
  border-radius: 12px;
}
body.is-telegram .btn { padding: 11px 16px; font-size: 13px; border-radius: 10px; }
body.is-telegram .btn-sm { padding: 6px 10px; font-size: 11px; }
body.is-telegram .modal-content {
  padding: 16px;
  border-radius: 16px 16px 0 0;
}

/* =====================================================================
   PLATE FORM — color picker (swatch grid), screenshot drop, animations
   ===================================================================== */

.plate-form .input { transition: border-color 0.16s ease, box-shadow 0.16s ease; }
.plate-form .input:focus { outline: none; border-color: var(--green, var(--brand)); box-shadow: 0 0 0 3px rgba(22,163,74,0.12); }

/* Plate form grid — top row */
.pf-grid-top {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1fr;
  gap: 8px;
}
@media (max-width: 480px) {
  .pf-grid-top { grid-template-columns: 1fr 1fr; }
  .pf-grid-top > div:first-child { grid-column: 1 / -1; }
}
/* Plate time summary badge */
.pf-time-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-hover);
  margin-top: 4px;
}

.filament-card {
  background: #fafafa;
  border: 1px solid #f4f4f5;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.filament-card:hover { border-color: #e4e4e7; background: #fff; }
.filament-card__row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filament-card__mat { width: 78px; min-width: 78px; }
.filament-card__color {
  flex: 1 1 160px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
  color: #18181b;
  text-align: left;
}
.filament-card__color:hover { border-color: var(--brand); }
.filament-card__color:active { transform: scale(0.98); }
.filament-card__color-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filament-card__weight { width: 90px; min-width: 90px; }
.filament-card__del {
  background: #fef2f2;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}
.filament-card__del:hover { background: #fee2e2; transform: scale(1.05); }

.color-swatch__dot {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.color-swatch__dot--inline { width: 18px; height: 18px; }
.color-swatch__dot--custom {
  background: linear-gradient(135deg, #f4f4f5, #e4e4e7);
  border-style: dashed;
}

.color-picker-pop {
  margin-top: 8px;
  padding: 10px;
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 12px;
  animation: pickerFadeIn 0.18s ease-out;
}
@keyframes pickerFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.color-picker-pop__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.color-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  background: #fff;
  border: 1.5px solid #f4f4f5;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
  min-height: 78px;
}
.color-swatch:hover { border-color: var(--brand); background: #f0fdf4; transform: translateY(-1px); }
.color-swatch:active { transform: scale(0.96); }
.color-swatch--selected { border-color: var(--brand); background: #f0fdf4; box-shadow: 0 0 0 2px rgba(22,163,74,0.18); }
.color-swatch .color-swatch__dot { width: 28px; height: 28px; }
.color-swatch__check { font-size: 16px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.35); }
.color-swatch__label {
  font-size: 11px;
  font-weight: 600;
  color: #18181b;
  text-align: center;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.color-swatch__weight { font-size: 9px; color: #71717a; }
.color-swatch--custom .color-swatch__label { color: #52525b; }

.color-custom-form {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px; padding-top: 10px; border-top: 1px solid #f4f4f5;
}
.color-custom-form input[type="color"] {
  width: 36px; height: 36px; padding: 0; border: 1.5px solid #e4e4e7;
  border-radius: 8px; cursor: pointer; flex: none;
}
.color-custom-form input[type="text"] { flex: 1; min-width: 0; }
.color-custom-form .btn { flex: none; width: auto; padding: 0 14px; }

/* Компактний попап швидкої зміни кольору філаменту (список рядків, а не
   картковий грід — картки з великими відступами не вписувались у вузький
   floating-попап «Пластини»). */
.pm-color-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px;
}
.pm-color-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  text-align: left;
  font-size: 12.5px;
  color: var(--text);
}
.pm-color-item:hover { background: var(--bg-surface-2, #f4f4f5); }
.pm-color-item--selected { background: #f0fdf4; }
.pm-color-dot {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}
.pm-color-dot--custom {
  background: linear-gradient(135deg, #f4f4f5, #e4e4e7);
  border-style: dashed;
  display: inline-flex; align-items: center; justify-content: center;
}
.pm-color-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-weight: 600;
}
.pm-color-weight { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.pm-color-check { color: var(--brand); font-size: 16px; flex-shrink: 0; }

/* Plate screenshot drop zone */
.plate-screenshot-drop {
  position: relative;
  border: 2px dashed #d4d4d8;
  border-radius: 14px;
  background: #fafafa;
  padding: 14px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color 0.18s ease, background 0.18s ease;
  outline: none;
}
.plate-screenshot-drop:focus { border-color: var(--brand); background: #f0fdf4; }
.plate-screenshot-drop--over { border-color: var(--brand); background: #f0fdf4; border-style: solid; }
.plate-screenshot-drop img {
  max-width: 100%;
  max-height: 260px;
  border-radius: 10px;
  display: block;
}
.plate-screenshot-empty { text-align: center; }
.plate-screenshot-pick { margin-top: 10px; width: auto !important; padding: 6px 12px !important; font-size: 12px !important; }
.plate-screenshot-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #fff;
  border: 1px solid #fecaca;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.plate-screenshot-remove:hover { background: #fef2f2; transform: scale(1.08); }

/* Кнопки/інпути — більш плавні переходи */
.btn { transition: background 0.16s ease, transform 0.1s ease, box-shadow 0.16s ease; }
.btn:active { transform: scale(0.985); }
.input { transition: border-color 0.16s ease, box-shadow 0.16s ease; }

/* ===== G-code drop zone ===== */
.gcode-drop-zone {
  border: 2px dashed #d4d4d8;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  color: #71717a;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 10px;
}
.gcode-drop-zone:hover,
.gcode-drop-zone.drag-over { border-color: var(--brand); background: #f0fdf4; }
.gcode-drop-zone .ms { font-size: 32px; color: #a1a1aa; display: block; margin-bottom: 4px; }
.gcode-attached {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 10px;
}
.gcode-attached .ms { color: var(--brand); font-size: 20px; }
.gcode-attached .name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gcode-attached .remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #dc2626;
  font-size: 18px;
}

/* ============================================================
 * Printer Control modal (showPrinterControl) — спільні класи замість
 * інлайн-стилів на кожній кнопці/рядку.
 * ============================================================ */
.pc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pc-status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pc-status-dot--ok    { background: #16a34a; }
.pc-status-dot--warn  { background: #f59e0b; }
.pc-status-dot--err   { background: #ef4444; }
.pc-status-dot--idle  { background: #71717a; }
.pc-head-name { font-size: 15px; font-weight: 700; }
.pc-status-badge { margin-left: auto; font-size: 11px; font-weight: 600; color: #fff; padding: 3px 9px; border-radius: 8px; }
.pc-status-badge--ok   { background: #16a34a; }
.pc-status-badge--warn { background: #f59e0b; }
.pc-status-badge--err  { background: #ef4444; }
.pc-status-badge--idle { background: #71717a; }

.pc-cur-card { background: var(--bg-surface-2); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.pc-cur-file { font-weight: 600; font-size: 13px; word-break: break-all; }
.pc-progress-track { height: 8px; background: var(--bg-hover); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.pc-progress-fill { height: 100%; background: linear-gradient(90deg, #2563eb, #16a34a); transition: width 0.3s ease; }
.pc-cur-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.pc-cur-error { font-size: 11px; color: #ef4444; margin-top: 6px; }
.pc-idle-card { background: var(--bg-surface-2); border-radius: 10px; padding: 14px; text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 10px; }

.pc-controls { display: flex; gap: 8px; margin-bottom: 14px; }
.pc-control-btn {
  flex: 1; padding: 13px 6px; border-radius: 10px; font-size: 13px; font-weight: 700;
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  gap: 5px; color: #fff; transition: filter 0.15s ease, transform 0.1s ease;
}
.pc-control-btn:hover { filter: brightness(1.08); }
.pc-control-btn:active { transform: scale(0.97); }
.pc-control-btn--finish { background: #16a34a; }
.pc-control-btn--pause  { background: #f59e0b; }
.pc-control-btn--stop   { background: #ef4444; }
.pc-controls-empty { flex: 1; text-align: center; color: var(--text-muted); font-size: 12px; padding: 10px; }

.pc-queue-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 6px; }
.pc-queue-card { display: flex; gap: 10px; align-items: center; background: var(--bg-surface-2); border-radius: 10px; padding: 10px; margin-bottom: 14px; }
.pc-queue-thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: contain; flex-shrink: 0; }
.pc-queue-thumb--placeholder { background: var(--bg-hover); display: flex; align-items: center; justify-content: center; }
.pc-queue-info { flex: 1; min-width: 0; }
.pc-queue-name { font-weight: 600; font-size: 13px; }
.pc-queue-sub { font-size: 11px; color: var(--text-muted); }

.pc-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.pc-tab-btn {
  flex: 1; border-radius: 8px; padding: 8px; font-size: 12px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-surface); color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.pc-tab-btn.active { border-color: var(--brand); background: var(--brand); color: #fff; }

/* ============================================================
 * Live Printers Dashboard (Bambu)
 * ============================================================ */

.live-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.live-search { max-width: 220px; }
.live-chips { display:flex; gap:6px; flex-wrap:wrap; flex:1; }
.live-chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border, #e4e4e7);
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.live-chip.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.live-chip-num {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.85;
}
.live-size-toggle { display:flex; gap:4px; }
.live-size-toggle button {
  background:#fff;
  border:1px solid var(--border, #e4e4e7);
  border-radius:8px;
  cursor:pointer;
  padding:4px 8px;
}
.live-size-toggle button.active {
  background:var(--brand);
  color:#fff;
  border-color:var(--brand);
}

.live-grid {
  display: grid;
  gap: 12px;
}
.live-grid-sm { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.live-grid-md { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.live-grid-lg { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }

.live-card {
  background: #fff;
  border: 1px solid var(--border, #e4e4e7);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.live-cam-box {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
  overflow: hidden;
}
.live-cam {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.live-cam-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  background:
    repeating-linear-gradient(45deg, #1f2937 0 6px, #111827 6px 12px);
}
.live-cam-placeholder .ms { font-size: 48px; opacity: 0.4; }

.live-state-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.live-card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.live-name { font-weight: 700; font-size: 14px; }
.live-job  { font-size: 12px; color: #4b5563; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.live-progress-wrap {
  height: 8px;
  background: #f3f4f6;
  border-radius: 999px;
  overflow: hidden;
}
.live-progress-bar { height: 100%; transition: width 0.4s ease; }
.live-progress-text { font-size: 11px; color: #6b7280; }
.live-layers { font-size: 11px; color: #6b7280; }
.live-temps  { font-size: 11px; color: #4b5563; display: flex; align-items: center; gap: 2px; }
.live-temps .ms { font-size: 14px; vertical-align: middle; }

.live-error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 8px;
}

.live-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.live-actions .btn-sm {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  padding: 6px 8px;
  border: 1px solid var(--border, #e4e4e7);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.live-actions .btn-sm .ms { font-size: 16px; }
.live-actions .live-btn-pause  { background: #fef3c7; border-color: #fcd34d; }
.live-actions .live-btn-resume { background: var(--border); border-color: #6ee7b7; }
.live-actions .live-btn-stop   { background: #fee2e2; border-color: #fca5a5; }
.live-actions .live-btn-print  { background: var(--brand); color: #fff; border-color: var(--brand); }

/* search results inside print-modal */
.lp-row {
  padding: 8px 10px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  font-size: 13px;
}
.lp-row:hover { background:#f9fafb; }
.lp-row:last-child { border-bottom: none; }

/* connection mode badges in admin printers list */
.prn-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin: 12px 0 6px;
  font-weight: 700;
}
.prn-mode {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: middle;
}
.prn-mode-lan   { background:#dbeafe; color:#1e40af; }
.prn-mode-cloud { background:#ede9fe; color:#5b21b6; }
.prn-mode-off   { background:#f3f4f6; color:#6b7280; }

/* ============================================================
   DASHBOARD (стартова сторінка для admin)
   ============================================================ */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.dash-kpi {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 14px;
  padding: 16px;
  transition: box-shadow .15s, transform .15s;
}
.dash-kpi:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.08); transform: translateY(-1px); }
.dash-kpi-head { display:flex; align-items:center; gap:6px; margin-bottom:8px; }
.dash-kpi-head .ms { font-size: 18px; }
.dash-kpi-label { font-size: 12px; color: #71717a; font-weight: 600; }
.dash-kpi-value { font-size: 28px; font-weight: 800; color: #0f172a; line-height: 1.2; }
.dash-kpi-value .dash-kpi-of { font-size: 14px; color: #a1a1aa; font-weight: 500; }
.dash-kpi-sub { font-size: 11px; color: #71717a; margin-top: 4px; }

.dash-section { margin-top: 20px; }
.dash-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: #0f172a;
  margin-bottom: 10px;
}

.dash-active-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}
.dash-active-card {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
}
.dash-active-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); transform: translateY(-1px); }
.dash-active-img {
  position: relative;
  width: 100%;
  height: 120px;
  background: #f4f4f5;
  display: flex; align-items: center; justify-content: center;
}
.dash-active-img img { width: 100%; height: 100%; object-fit: contain; }
.dash-active-progress {
  position: absolute; bottom: 0; left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand));
  transition: width .3s;
}
.dash-active-body { padding: 10px; }
.dash-active-name { font-size: 13px; font-weight: 700; }
.dash-active-sub { font-size: 11px; color: #71717a; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-active-meta { font-size: 11px; color: var(--brand); margin-top: 4px; font-weight: 600; }

.dash-fil-list {
  display: flex; flex-direction: column; gap: 4px;
}
.dash-fil-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  font-size: 13px;
}
.dash-fil-critical { border-left: 3px solid #ef4444; }
.dash-fil-warn     { border-left: 3px solid #f59e0b; }
.dash-fil-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; border: 1px solid #e4e4e7; }
.dash-fil-name { flex: 1; }
.dash-fil-weight { font-weight: 700; color: var(--danger); font-size: 12px; }

/* ── Product forecast блок на дашборді ──────────────────────────────── */
.dash-forecast-list { display: flex; flex-direction: column; gap: 6px; }
.dash-forecast-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--surface, #fff);
  border: 1px solid var(--border-soft, #e4e4e7);
  border-radius: 10px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.dash-forecast-row:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
.dash-forecast-urg-out  { border-left: 3px solid #ef4444; background: rgba(239,68,68,0.04); }
.dash-forecast-urg-low  { border-left: 3px solid #f59e0b; background: rgba(245,158,11,0.04); }
.dash-forecast-urg-soon { border-left: 3px solid #fbbf24; }
.dash-forecast-urg-ok   { border-left: 3px solid var(--brand, #409039); }
.dash-forecast-photo { width: 44px; height: 44px; border-radius: 8px; object-fit: contain; background: var(--bg-muted, #f4f4f5); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.dash-forecast-photo--empty .ms { font-size: 22px; color: var(--text-disabled, #d4d4d8); }
.dash-forecast-body { flex: 1; min-width: 0; }
.dash-forecast-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-forecast-code { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.dash-forecast-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.dash-forecast-meta b { color: var(--text); font-weight: 700; }
.dash-forecast-urg { font-size: 11px; font-weight: 600; flex-shrink: 0; padding: 4px 8px; border-radius: 6px; background: var(--bg-muted, #f4f4f5); }
.dash-fil-warn .dash-fil-weight { color: var(--warning); }

/* ============================================================
   Drop-зони у формі товару (фото / .3mf)
   ============================================================ */
.prod-form-drop {
  position: relative;
  width: 100%;
  min-height: 110px;
  background: #fafafa;
  border: 2px dashed #d4d4d8;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .15s;
  outline: none;
  overflow: hidden;
}
.prod-form-drop:hover { background: #f4f4f5; border-color: #a1a1aa; }
.prod-form-drop:focus { background: #f4f4f5; border-color: var(--info); }
.prod-form-drop.drop-over {
  background: #eff6ff;
  border-color: var(--info);
  border-style: solid;
}
.prod-form-drop-empty {
  text-align: center;
  padding: 16px;
  pointer-events: none;
}
.prod-form-drop-img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}
.prod-form-drop-filled {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  text-align: left;
}
.prod-form-drop-filled .truncate {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.prod-form-drop-remove {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(255,255,255,0.95);
  border: 1px solid #e4e4e7;
  border-radius: 50%;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
}

/* ============================================================
   Розшифровка помилок принтерів — блок «Як виправити»
   ============================================================ */
.err-help {
  margin-top: 8px;
  padding: 8px 10px 8px 12px;
  background: #fef3c7;
  border-radius: 8px;
  font-size: 12px;
  color: #78350f;
}
.err-help-title {
  display: flex; align-items: center; gap: 6px;
  font-weight: 700; margin-bottom: 4px;
}
.err-help-cat {
  background: rgba(0,0,0,0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  margin-left: auto;
}
.err-help-steps {
  margin: 4px 0 0 0;
  padding-left: 20px;
  line-height: 1.5;
}
.err-help-steps li { margin-bottom: 2px; }
.err-help-unknown {
  background: #f9fafb;
  color: #6b7280;
  border-left: 3px solid #d4d4d8;
  font-size: 11px;
}

/* ============================================================================
   Theme switcher button + dark-theme polish (Farm Manager style)
   ============================================================================ */
.nav-item-theme {
  /* Виглядає менше від основних — секція "налаштування інтерфейсу" */
  font-size: 12px;
  opacity: 0.85;
  margin-top: 6px;
}
.nav-item-theme:hover { opacity: 1; }
.theme-btn-label {
  font-weight: 600;
}

/* ============================================================================
   Glassmorphism + покращена тінь для модалок / sidebar / dashboard
   ============================================================================ */
.modal-content {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

/* Sidebar — sticky, з blur ефектом якщо браузер підтримує */
.desktop-sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
}

/* Dashboard KPI картки — підняті, з brand-tinted accent */
.dash-kpi {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.dash-kpi:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--brand-soft-hover);
}
.dash-kpi-head .ms { color: var(--brand); }
.dash-kpi-value { color: var(--text); }
.dash-kpi-of { color: var(--text-muted); }
.dash-kpi-sub { color: var(--text-muted); }

/* Active live cards у dashboard — з зеленим прогрес-баром */
.dash-active-progress {
  background: linear-gradient(90deg, var(--brand), var(--brand-hover));
}

/* ============================================================================
   П.8.3 — РЕДИЗАЙН КЛЮЧОВИХ КОМПОНЕНТІВ (Farm Manager style)
   Перевизначення поверх старих правил — лагідно зробити їх сучаснішими.
   ============================================================================ */

/* --- Live-картка принтера: великі скріни, "статус-капсула", glow ---------- */
.live-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.live-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.live-cam-box { background: #000; }
.live-state-badge {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 10px;
  font-size: 10.5px;
}

/* Прогрес-бар у фірмовому градієнті */
.live-progress-wrap { background: var(--bg-surface-2); }
.live-progress-bar {
  background: linear-gradient(90deg, var(--brand), var(--brand-hover));
  box-shadow: 0 0 8px var(--brand-soft);
}
.live-progress-text { color: var(--text-muted); }
.live-layers { color: var(--text-muted); }
.live-temps  { color: var(--text-secondary); }

.live-error-banner {
  background: var(--danger-soft);
  border: 1px solid transparent;
  color: var(--danger);
}

.live-actions .btn-sm {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
}
.live-actions .btn-sm:hover {
  background: var(--bg-hover);
  border-color: var(--brand);
  color: var(--brand);
}

/* --- Sidebar пункти: активний пункт - вертикальна brand-полоска ----------- */
.nav-item-d {
  position: relative;
  border-radius: var(--radius-md);
  font-weight: 600;
  color: var(--text-secondary);
}
.nav-item-d.active {
  background: var(--brand-soft);
  color: var(--brand);
}
.nav-item-d.active::before {
  content: '';
  position: absolute;
  left: -10px; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--brand);
  border-radius: 2px;
}
.nav-item-d .ms { color: inherit; }

/* --- Mobile bottom-nav: збільшити tap-target, дати скляний фон ------------ */
.mobile-nav {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.nav-item.active { color: var(--brand); }
.nav-item.active .ms { color: var(--brand); }

/* --- Кнопки --------------------------------------------------------------- */
.btn {
  background: var(--brand);
  color: var(--text-inverse);
  border: 1px solid var(--brand);
  border-radius: var(--radius-md);
  font-weight: 600;
  padding: 10px 16px;
}
.btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn:active { background: var(--brand-active); }
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--brand);
  color: var(--brand);
}
.btn-success { background: var(--brand); border-color: var(--brand); }
.btn-success:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { filter: brightness(0.95); }

/* --- Inputs --------------------------------------------------------------- */
.input,
input[type="text"], input[type="number"], input[type="email"], input[type="password"],
input[type="url"], input[type="search"], textarea, select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.input:focus,
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--shadow-focus);
}

.input-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  display: block;
}

/* --- Modal — більше повітря, мʼякіша тінь --------------------------------- */
.modal-content {
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.modal-titlebar {
  border-bottom: 1px solid var(--border-soft);
}
.modal-title-text {
  font-weight: 700;
  color: var(--text);
}
.modal-close-x {
  border-radius: var(--radius-md);
  color: var(--text-muted);
  background: transparent;
  border: none;
}
.modal-close-x:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* --- Section title — мʼякший, з brand іконкою ----------------------------- */
.section-title {
  color: var(--text);
  font-weight: 800;
  font-size: 22px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title .ms {
  color: var(--brand);
  font-size: 26px;
}

/* --- Stat-cards у dashboard / inventory: brand-tinted ----------------------*/
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.stat-card .value { color: var(--text); font-weight: 800; }
.stat-card .label { color: var(--text-muted); font-size: 11px; }
.stat-card-blue  { background: var(--info-soft); border-color: transparent; }
.stat-card-blue  .value { color: var(--info); }
.stat-card-green { background: var(--brand-soft); border-color: transparent; }
.stat-card-green .value { color: var(--brand); }

/* --- Сітка карток ----------------------------------------------------------*/
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

/* --- Product card (інвентар) ---------------------------------------------- */
.pc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.pc-card:hover {
  border-color: var(--brand);
}
.pc-card-selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.pc-name { color: var(--text); }
.pc-code { color: var(--text-muted); }
.pc-price { color: var(--brand); font-weight: 700; }
.pc-stock-ok    { color: var(--success); font-weight: 600; }
.pc-stock-empty { color: var(--danger); font-weight: 600; }

/* --- AMS badge -------------------------------------------------------------*/
.ams-badge {
  background: var(--brand);
  color: var(--text-inverse);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  font-weight: 700;
}

/* --- Toast ---------------------------------------------------------------- */
.toast {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 12px 16px;
}

/* --- Skeleton ------------------------------------------------------------- */
.skeleton-card {
  background: var(--bg-surface-2);
  border-radius: var(--radius-md);
}

/* --- Empty state — приємніший ------------------------------------------ */
.empty-state {
  background: var(--bg-surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state .ms {
  color: var(--brand);
  opacity: 0.5;
  font-size: 48px;
}

/* --- Дрібнички для dark-теми: тіні мʼякіші --------------------------------- */
[data-theme="dark"] .modal-content { backdrop-filter: blur(24px); }
[data-theme="dark"] .live-cam-box  { background: #000; }
[data-theme="dark"] .live-cam-placeholder {
  background: repeating-linear-gradient(45deg, #1f2937 0 6px, #161b22 6px 12px);
}

/* --- TV walls / sales / analytics tweaks --------------------------------- */
[data-theme="dark"] .section-title { color: var(--text); }

/* ──────────────────────────────────────────────────────────────────────────
   КАСКАДНІ HOVER ефекти — м'якіше за дефолт, з brand-glow на dark
   ────────────────────────────────────────────────────────────────────────── */
.pc-card:hover, .live-card:hover, .printer-card:hover, .order-card:hover, .dash-kpi:hover {
  border-color: var(--brand);
}
[data-theme="dark"] .pc-card:hover,
[data-theme="dark"] .live-card:hover,
[data-theme="dark"] .dash-kpi:hover {
  box-shadow: 0 0 0 1px var(--brand), 0 12px 24px rgba(0, 0, 0, 0.4);
}

/* ============================================================================
   П.8.4 — MOBILE-FIRST уточнення (Bambu Farm Manager погано адаптований під мобілки —
   тут точно перекриваємо, щоб усе на мобілці виглядало охайно).
   ============================================================================ */
@media (max-width: 768px) {
  /* Більше відступів від країв на тачі */
  body { padding-bottom: 80px; }
  .desktop-shell { padding: 8px 10px; }

  /* Section title — менший і компактніший на мобілці */
  .section-title { font-size: 18px; padding-bottom: 8px; margin-bottom: 12px; }
  .section-title .ms { font-size: 22px; }

  /* Dashboard KPI — повна ширина, без grid */
  .dash-kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dash-kpi { padding: 12px; }
  .dash-kpi-value { font-size: 22px; }
  .dash-kpi-label { font-size: 11px; }

  /* Live grid — 1 колонка на телефоні (картки великі бо камера) */
  .grid-cards { grid-template-columns: 1fr; gap: 10px; }

  /* Product cards — 2 колонки, компактно */
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* Модалки на мобілці — bottom sheet */
  .modal-content {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 92vh;
  }

  /* Drop-зони на мобілці — більший tap-area */
  .prod-form-drop { min-height: 100px; }

  /* Mobile bottom-nav: збільшити для пальців */
  .nav-item-scan { transform: scale(1.05); }

  /* Adminка — фільтри в стовпчик */
  .err-filters { flex-direction: column; align-items: stretch; gap: 6px; }
  .err-filters select { width: 100% !important; }

  /* Active live cards на мобілці — 1 колонка */
  .dash-active-grid { grid-template-columns: 1fr; }

  /* Buttons: великий tap target */
  .btn, .btn-sm { min-height: 40px; }

  /* Schedule v2 Kanban — горизонтальний скрол замість стискання */
  [class*="schedv2-printer-col"], .sv2-col {
    min-width: 280px;
  }
}

/* Дуже малі телефони (≤ 380px) — extra compact */
@media (max-width: 380px) {
  .dash-kpi-grid { grid-template-columns: 1fr; }
  .product-grid  { grid-template-columns: 1fr; }
  .stat-card { padding: 10px; }
  .stat-card .value { font-size: 20px; }
}

/* Tablet 769-1024 — двоколонковий grid Live */
@media (min-width: 769px) and (max-width: 1024px) {
  .grid-cards    { grid-template-columns: repeat(2, 1fr); }
  .product-grid  { grid-template-columns: repeat(3, 1fr); }
}

/* Великі моніки 1440+ — 4 колонки live */
@media (min-width: 1440px) {
  .grid-cards   { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* ============================================================================
   Schedule v2 — нові елементи UI (групи, фільтри, статуси, size modes)
   ============================================================================ */

/* Toolbar: дві строки — actions + filters */
.sv2-tb-row {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-soft);
}
.sv2-tb-row:first-child { border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg); }
.sv2-tb-filters {
  background: var(--bg-app);
  border-bottom: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}
.sv2-stat-ok   { color: var(--brand);   font-weight: 600; }
.sv2-stat-warn { color: var(--warning); font-weight: 600; }

/* Search */
.sv2-search {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  flex: 1; min-width: 220px;
}
.sv2-search input {
  border: none; outline: none; background: transparent;
  flex: 1; font-size: 13px; color: var(--text);
}
.sv2-search .ms { color: var(--text-muted); }
.sv2-search button {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); padding: 0;
}
.sv2-search button:hover { color: var(--text); }

/* Select dropdowns у фільтрах */
.sv2-select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  min-width: 130px;
}
.sv2-select:focus { border-color: var(--brand); outline: none; }

/* Size toggle (compact / normal / large) */
.sv2-size-toggle {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.sv2-size-btn {
  background: transparent; border: none; padding: 6px 8px;
  cursor: pointer; color: var(--text-muted);
  border-right: 1px solid var(--border);
}
.sv2-size-btn:last-child { border-right: none; }
.sv2-size-btn.active { background: var(--brand-soft); color: var(--brand); }
.sv2-size-btn:hover { background: var(--bg-hover); }

/* Group container (модель принтера: A1, P1, X1, H2D) */
.sv2-group {
  display: flex; flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex-shrink: 0;
}
.sv2-group-head {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
  font-size: 13px;
  color: var(--text);
}
.sv2-group-head:hover { background: var(--bg-hover); }
.sv2-group-chev { color: var(--text-muted); font-size: 18px; }
.sv2-group-count {
  margin-left: 4px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px; font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
}
.sv2-group-body {
  display: flex; gap: 8px;
  padding: 8px;
  overflow-x: auto;
}

/* Sticky inbox колонка зліва */
.sv2-col-inbox {
  position: sticky; left: 0; z-index: 5;
  background: var(--bg-surface);
  box-shadow: 4px 0 8px rgba(0,0,0,0.04);
}
[data-theme="dark"] .sv2-col-inbox {
  box-shadow: 4px 0 12px rgba(0,0,0,0.3);
}

/* Стан принтера у колонці (printing / idle / error) */
.sv2-col-state-row { margin-top: 4px; }
.sv2-state {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}
.sv2-state-printing { background: var(--brand-soft);   color: var(--brand); }
.sv2-state-idle     { background: var(--neutral-soft); color: var(--text-muted); }
.sv2-state-error    { background: var(--danger-soft);  color: var(--danger); }

/* Завантаженість: кольорові пороги */
.sv2-load-ok   .sv2-col-bar > div { background: linear-gradient(90deg, var(--brand), #56d364); }
.sv2-load-warn .sv2-col-bar > div { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.sv2-load-over .sv2-col-bar > div { background: linear-gradient(90deg, var(--danger), #f97316); }
.sv2-overflow-badge {
  background: var(--danger-soft); color: var(--danger);
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: var(--radius-sm);
  margin-left: 6px;
}
.sv2-col-load-text { display: flex; align-items: center; }

/* Резерв принтера */
.sv2-reserve {
  margin-top: 6px;
  font-size: 11px;
  background: var(--warning-soft);
  color: var(--warning);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Match-state на картках */
.sv2-card-match-ok   { box-shadow: inset 3px 0 0 var(--brand); }
.sv2-card-match-swap { box-shadow: inset 3px 0 0 var(--warning); }
[data-theme="dark"] .sv2-card-match-ok   { box-shadow: inset 3px 0 0 var(--brand), 0 0 0 1px rgba(95,191,72,0.2); }
[data-theme="dark"] .sv2-card-match-swap { box-shadow: inset 3px 0 0 var(--warning), 0 0 0 1px rgba(227,179,65,0.2); }

/* Облік частин — секція "Частини" */
.parts-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
  padding: 12px; background: var(--bg-surface); border-radius: 12px;
  border: 1px solid var(--border);
}
.parts-search {
  display: flex; align-items: center; gap: 6px;
  flex: 1 1 200px; min-width: 180px;
  padding: 6px 10px; background: var(--bg-surface-2); border-radius: 8px;
  border: 1px solid var(--border);
}
.parts-search .ms { font-size: 16px; color: var(--text-muted); }
.parts-search input { border: none; background: transparent; outline: none; flex: 1; color: var(--text); font-size: 13px; }
.parts-select {
  padding: 6px 10px; background: var(--bg-surface-2); border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; color: var(--text); cursor: pointer;
}
.parts-group-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.parts-group-toggle input { cursor: pointer; }

.parts-stats { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; padding: 0 4px; }
.parts-stat { font-size: 12px; color: var(--text-muted); }
.parts-stat b { font-size: 18px; color: var(--text); margin-right: 4px; }
.parts-stat-ok b { color: var(--brand); }
.parts-stat-warn b { color: var(--warning); }
.parts-stat-total b { color: var(--text); }
.parts-stat-eject-off { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.parts-stat-eject-off b { color: var(--danger); }
.parts-stat-eject-off:hover { color: var(--text); }

.parts-empty { padding: 30px; text-align: center; color: var(--text-muted); background: var(--bg-surface); border-radius: 12px; }

/* Грід групований за товаром */
.parts-grouped { display: flex; flex-direction: column; gap: 12px; }
.parts-group { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.parts-group-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background 0.15s;
}
.parts-group-head:hover { background: var(--bg-surface-3, var(--bg-surface)); }
.parts-prod-photo { width: 48px; height: 48px; border-radius: 8px; object-fit: contain; flex-shrink: 0; background: var(--bg-surface); }
.parts-prod-photo--empty { display: flex; align-items: center; justify-content: center; color: var(--text-disabled); }
.parts-prod-photo--empty .ms { font-size: 28px; }
.parts-group-info { flex: 1; min-width: 0; }
.parts-group-name { font-weight: 700; font-size: 15px; }
.parts-group-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.parts-code { font-family: monospace; padding: 1px 6px; background: var(--bg-surface); border-radius: 4px; font-size: 10px; }
.parts-can-assemble { color: var(--brand); font-weight: 600; }
.parts-group-stock { text-align: right; font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.parts-group-stock b { display: block; font-size: 22px; color: var(--brand); }

.parts-plates-row {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px; padding: 10px;
}

/* Витратні матеріали (кільця/гвинти тощо) прикріплені до збірки товару —
   окремий рядок під плитами, той самий стиль карток. */
.parts-cons-row {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 0 10px 10px;
  border-top: 1px dashed var(--border);
  margin-top: 2px; padding-top: 10px;
}
.parts-cons-chip {
  display: flex; align-items: center; gap: 8px; position: relative;
  background: var(--bg-surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 26px 6px 8px; cursor: pointer; min-width: 160px;
}
.parts-cons-chip--low { border-color: var(--warning); background: var(--warning-soft); }
.parts-cons-chip img, .parts-cons-chip .ms { width: 30px; height: 30px; border-radius: 6px; flex: none; object-fit: cover; }
.parts-cons-chip .ms { display: flex; align-items: center; justify-content: center; background: var(--bg-surface); color: var(--text-muted); font-size: 16px; }
.parts-cons-chip-body { min-width: 0; }
.parts-cons-chip-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.parts-cons-chip-stock { font-size: 10.5px; color: var(--text-muted); }
.parts-cons-chip-del {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; border: none; background: transparent; color: var(--text-muted);
  border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.parts-cons-chip-del:hover { background: var(--danger-soft); color: var(--danger); }
.parts-cons-attach {
  display: flex; align-items: center; gap: 4px; border: 1px dashed var(--border);
  border-radius: 10px; background: transparent; color: var(--text-muted);
  font-size: 12px; font-weight: 600; padding: 6px 12px; cursor: pointer;
}
.parts-cons-attach:hover { border-color: var(--brand); color: var(--brand); }
.parts-plate-card {
  display: flex; flex-direction: column;
  background: var(--bg-surface-2);
  border: 1px solid var(--border); border-radius: 12px;
  transition: all 0.15s;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.parts-plate-card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.08); }
.parts-plate-clickable { display: flex; gap: 8px; padding: 8px; cursor: pointer; }
.parts-plate-actions {
  display: flex; gap: 4px; padding: 4px 8px 8px; border-top: 1px solid var(--border);
  background: var(--bg-surface);
}
.parts-adj-btn {
  flex: 1; padding: 4px 0; border-radius: 6px; font-size: 14px;
  font-weight: 600; cursor: pointer; border: 1px solid var(--border);
  background: var(--bg-surface-2); color: var(--text);
  transition: all 0.1s;
}
.parts-adj-btn:hover { background: var(--bg-surface-3, var(--bg-surface-2)); }
.parts-adj-minus { color: var(--danger); }
.parts-adj-minus:hover { background: rgba(227, 65, 65, 0.1); border-color: var(--danger); }
.parts-adj-plus { color: var(--brand); }
.parts-adj-plus:hover { background: rgba(64, 144, 57, 0.1); border-color: var(--brand); }
.parts-adj-more { flex: 0 0 32px; color: var(--text-muted); }
.parts-adj-edit { flex: 0 0 32px; color: #1d4ed8; }
.parts-adj-edit:hover { background: #eff6ff; border-color: #1d4ed8; }
.parts-plate-thumb { width: 56px; height: 56px; border-radius: 6px; object-fit: contain; flex-shrink: 0; background: var(--bg-surface); }
.parts-plate-thumb--empty { display: flex; align-items: center; justify-content: center; color: var(--text-disabled); }
.parts-plate-thumb--empty .ms { font-size: 26px; }
.parts-plate-body { flex: 1; min-width: 0; }
.parts-plate-prod { font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.parts-plate-name { font-weight: 600; font-size: 12px; line-height: 1.25; }
.parts-fil-row { display: flex; gap: 2px; margin-top: 4px; }
.parts-fil-dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.15); }
.parts-plate-meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.parts-plate-count {
  text-align: right; flex-shrink: 0; display: flex; flex-direction: column;
  align-items: flex-end; justify-content: center;
}
.parts-plate-num { font-size: 22px; font-weight: 800; line-height: 1; }
.parts-plate-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; }
.parts-plate-date { font-size: 9px; color: var(--text-muted); margin-top: 2px; }
.parts-stock-ok .parts-plate-num { color: var(--brand); }
.parts-stock-low .parts-plate-num { color: var(--warning); }
.parts-stock-empty .parts-plate-num { color: var(--text-disabled); }
.parts-stock-empty { opacity: 0.7; }

/* Плоска таблиця */
.parts-table-wrap { overflow-x: auto; background: var(--bg-surface); border-radius: 12px; border: 1px solid var(--border); }
.parts-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.parts-table thead th {
  text-align: left; padding: 10px; background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border); font-size: 11px;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px;
}
.parts-table tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s; }
.parts-table tbody tr:hover { background: var(--bg-surface-2); }
.parts-table tbody tr:last-child { border-bottom: none; }
.parts-table tbody td { padding: 8px 10px; vertical-align: middle; }
.parts-row-thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: contain; background: var(--bg-surface-2); }
.parts-row-thumb--empty { display: flex; align-items: center; justify-content: center; color: var(--text-disabled); }
.parts-row-thumb--empty .ms { font-size: 18px; }
.parts-code-inline { font-family: monospace; font-size: 10px; color: var(--text-muted); }
.parts-table .parts-stock-ok b { color: var(--brand); }
.parts-table .parts-stock-low b { color: var(--warning); }
.parts-table .parts-stock-empty { opacity: 0.6; }

/* ETA на колонці плану — коли закінчиться вся черга. */
.sv2-col-eta {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sv2-col-eta.sv2-eta-ok {
  background: rgba(64, 144, 57, 0.08);
  color: var(--brand);
}
.sv2-col-eta.sv2-eta-over {
  background: rgba(227, 65, 65, 0.1);
  color: var(--danger);
  font-weight: 600;
}
[data-theme="dark"] .sv2-col-eta.sv2-eta-ok   { background: rgba(95, 191, 72, 0.12); }
[data-theme="dark"] .sv2-col-eta.sv2-eta-over { background: rgba(245, 100, 100, 0.15); }

/* Sidebar status panel — мінідашборд принтерів. */
.sidebar-printer-status {
  margin: 8px 8px 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 12px;
}
.sidebar-printer-status:hover { background: var(--bg-surface-3, var(--bg-surface)); }
.sidebar-printer-status .sps-loading { color: var(--text-muted); text-align: center; }
.sidebar-printer-status .sps-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}
.sidebar-printer-status .sps-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.sidebar-printer-status .sps-row-warn .sps-count { color: var(--danger); font-weight: 700; }
.sidebar-printer-status .sps-row-muted { opacity: 0.65; }
.sidebar-printer-status .sps-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sidebar-printer-status .sps-dot-printing { background: var(--brand); animation: sps-pulse 1.8s ease-in-out infinite; }
.sidebar-printer-status .sps-dot-idle     { background: #94a3b8; }
.sidebar-printer-status .sps-dot-error    { background: var(--danger); }
.sidebar-printer-status .sps-dot-offline  { background: #475569; }
.sidebar-printer-status .sps-icon { font-size: 15px; flex-shrink: 0; }
.sidebar-printer-status .sps-icon-printing { color: var(--brand); }
.sidebar-printer-status .sps-icon-idle     { color: #94a3b8; }
.sidebar-printer-status .sps-icon-error    { color: var(--danger); }
.sidebar-printer-status .sps-icon-offline  { color: #475569; }
.sidebar-printer-status .sps-label { flex: 1; color: var(--text); }
.sidebar-printer-status .sps-count { font-weight: 700; color: var(--text); }
@keyframes sps-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(64,144,57,0.45); }
  50%      { opacity: 0.7; box-shadow: 0 0 0 4px rgba(64,144,57,0); }
}

/* Картка з активним print_job — зелена обводка + бейдж знизу. */
.sv2-card-printing {
  box-shadow: 0 0 0 2px var(--brand) inset, 0 4px 14px rgba(64, 144, 57, 0.25);
  background: rgba(64, 144, 57, 0.06);
  cursor: default;
}
.sv2-card-printing:hover { box-shadow: 0 0 0 2px var(--brand) inset, 0 6px 18px rgba(64, 144, 57, 0.35); }
.sv2-card-active-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
[data-theme="dark"] .sv2-card-printing {
  background: rgba(95, 191, 72, 0.08);
  box-shadow: 0 0 0 2px var(--brand) inset, 0 4px 14px rgba(95, 191, 72, 0.2);
}

/* Кнопка split на кардці */
.sv2-btn-split { color: var(--warning); }
.sv2-btn-split:hover { background: rgba(227, 179, 65, 0.15); }

/* Кнопки на активній кардці (друкується): «Надруковано» / «Передрукувати» */
.sv2-btn-done {
  flex: 1; background: var(--brand); color: #fff !important;
  border-color: var(--brand); font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.sv2-btn-done:hover { filter: brightness(1.08); }
.sv2-btn-reprint {
  color: var(--warning); border-color: var(--warning);
}
.sv2-btn-reprint:hover { background: rgba(227, 179, 65, 0.15); }

/* Size modes — впливає на padding/thumb size карток */
.sv2-size-compact .sv2-card { padding: 6px 8px; gap: 4px; }
.sv2-size-compact .sv2-card-name { font-size: 12px; }
.sv2-size-compact .sv2-card-plate { font-size: 10px; }
.sv2-size-compact .sv2-card-actions { gap: 2px; }
.sv2-size-compact .sv2-col { width: 220px; min-width: 220px; }

.sv2-size-large .sv2-card { padding: 12px; }
.sv2-size-large .sv2-card-thumb { width: 64px; height: 64px; }
.sv2-size-large .sv2-col { width: 320px; min-width: 320px; }

/* Стандартні розміри колонок коли не в group-body */
.sv2-col {
  width: 260px;
  min-width: 260px;
  flex-shrink: 0;
}
.sv2-board {
  display: flex;
  gap: 12px;
  padding: 12px;
  overflow-x: auto;
  align-items: flex-start;
}

/* Dark theme — головки колонок */
[data-theme="dark"] .sv2-col-head-inbox { background: var(--bg-surface-2); }
[data-theme="dark"] .sv2-col,
[data-theme="dark"] .sv2-group,
[data-theme="dark"] .sv2-toolbar { background: var(--bg-surface); border-color: var(--border); }

/* ============================================================================
   Dashboard — повна сторінка з fleet, sparklines, activity, health
   ============================================================================ */

/* Fleet grid — мініатюри всіх принтерів */
.dash-fleet-counts {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-left: 10px; font-size: 11px;
}
.dash-fleet-c {
  padding: 2px 8px; border-radius: var(--radius-pill);
  font-weight: 600;
}
.dash-fleet-c-printing { background: var(--brand-soft);   color: var(--brand); }
.dash-fleet-c-idle     { background: var(--neutral-soft); color: var(--text-muted); }
.dash-fleet-c-error    { background: var(--danger-soft);  color: var(--danger); }
.dash-fleet-c-reserved { background: var(--info-soft);    color: var(--info); }
.dash-fleet-c-offline  { background: var(--neutral-soft); color: var(--text-disabled); }

.dash-fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.dash-fleet-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}
.dash-fleet-bubble:hover { border-color: var(--brand); transform: translateY(-1px); }
.dash-fleet-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  position: absolute; top: 10px; right: 10px;
  box-shadow: 0 0 0 3px var(--bg-surface);
}
.dash-fleet-printing .dash-fleet-dot {
  animation: dash-pulse 1.8s ease-in-out infinite;
}
@keyframes dash-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--bg-surface), 0 0 0 0 var(--brand-soft); }
  50%      { box-shadow: 0 0 0 3px var(--bg-surface), 0 0 0 5px transparent; }
}
.dash-fleet-name {
  font-size: 13px; font-weight: 600;
  color: var(--text);
  padding-right: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dash-fleet-meta {
  font-size: 11px; color: var(--text-muted);
  margin-top: 2px;
}
.dash-fleet-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px; background: var(--bg-surface-2);
}
.dash-fleet-bar > div { height: 100%; transition: width .3s; }
.dash-fleet-printing { background: linear-gradient(180deg, var(--bg-surface) 0%, rgba(64,144,57,0.04) 100%); }
[data-theme="dark"] .dash-fleet-printing { background: linear-gradient(180deg, var(--bg-surface) 0%, rgba(95,191,72,0.06) 100%); }
.dash-fleet-error    { border-color: var(--danger); }
.dash-fleet-error .dash-fleet-meta { color: var(--danger); font-weight: 600; }
/* Некритичні коди (закінчився філамент тощо) — жовтий, не червоний, щоб не
   плутати «зверни увагу» з «щось апаратно зламалось». */
.dash-fleet-warn      { border-color: #f59e0b; }
.dash-fleet-warn .dash-fleet-meta { color: #f59e0b; font-weight: 600; }

/* ── Прогноз перевантаження по кольору (Фаза 2 Smart Scheduling) ─────── */
.dash-color-forecast { display: flex; flex-direction: column; gap: 8px; }
.dash-cf-row {
  display: flex; gap: 12px; align-items: center;
  padding: 12px; border-radius: 12px; border: 1px solid;
  background: var(--bg-surface);
}
.dash-cf-warn { border-color: #f59e0b; background: rgba(245,158,11,0.06); }
.dash-cf-crit { border-color: #ef4444; background: rgba(239,68,68,0.06); }
.dash-cf-swatch {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(0,0,0,0.15);
}
.dash-cf-info { flex: 1; min-width: 0; }
.dash-cf-title { font-weight: 700; font-size: 13px; }
.dash-cf-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* KPI sparkline у 4-й картці */
.dash-kpi-sparkline { margin-top: 4px; }

/* 2-колоночний блок (recent activity + low fil) */
.dash-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}
@media (max-width: 900px) {
  .dash-2col { grid-template-columns: 1fr; }
}

/* Activity list */
.dash-activity-list {
  display: flex; flex-direction: column; gap: 6px;
}
.dash-activity-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12px;
}
.dash-activity-icon {
  font-size: 18px;
  color: var(--brand);
  flex-shrink: 0;
  margin-top: 1px;
}
.dash-activity-body { flex: 1; min-width: 0; }
.dash-activity-text {
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.dash-activity-meta {
  font-size: 10px; color: var(--text-muted);
  margin-top: 2px;
}

/* System health rail */
.dash-health-rail {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 12px;
  margin-top: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 11px;
}
.dash-health-item {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  cursor: default;
}
.dash-health-item[onclick] { cursor: pointer; transition: opacity var(--transition-fast); }
.dash-health-item[onclick]:hover { opacity: 0.85; }
.dash-health-ok   { background: var(--brand-soft);   color: var(--brand); }
.dash-health-warn { background: var(--warning-soft); color: var(--warning); }
.dash-health-crit { background: var(--danger-soft);  color: var(--danger); }

/* Mobile compactness for dashboard */
@media (max-width: 768px) {
  .dash-fleet-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .dash-fleet-bubble { padding: 8px 10px; }
  .dash-health-rail { font-size: 10px; padding: 8px; }
  .dash-section-title { flex-wrap: wrap; }
  .dash-section-title .btn { font-size: 10px; padding: 4px 8px; }
}

/* ============================================================================
   Snapshots Timeline Viewer — модалка з кадрами друку
   ============================================================================ */
.snap-hero {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.snap-hero img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.snap-hero-overlay {
  position: absolute; top: 12px; left: 12px;
}
.snap-phase {
  color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  text-transform: uppercase; letter-spacing: 0.04em;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.snap-info {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--bg-surface-2);
  border-radius: var(--radius-md);
}
.snap-info-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px;
}
.snap-time { color: var(--text); font-weight: 600; }
.snap-counter { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.snap-progress-row {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px;
}
.snap-progress-bar {
  flex: 1; height: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.snap-progress-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-hover));
  transition: width 0.3s ease;
}
.snap-progress-pct {
  font-size: 12px; font-weight: 700; color: var(--brand);
  min-width: 36px; text-align: right;
}
.snap-meta {
  margin-top: 6px;
  font-size: 11px; color: var(--text-muted);
}

.snap-nav {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
}
.snap-nav-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
}
.snap-nav-btn:hover:not(:disabled) {
  border-color: var(--brand); color: var(--brand);
}
.snap-nav-btn:disabled {
  opacity: 0.3; cursor: not-allowed;
}
.snap-slider {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  background: transparent;
}
.snap-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--bg-surface-2);
  border-radius: var(--radius-pill);
}
.snap-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: var(--brand);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  margin-top: -5px;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--brand);
}

.snap-strip {
  margin-top: 10px;
  display: flex; gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.snap-thumb {
  position: relative;
  flex-shrink: 0;
  width: 80px; height: 50px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  background: #000;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}
.snap-thumb img {
  width: 100%; height: 100%; object-fit: contain;
}
.snap-thumb.active {
  transform: scale(1.04);
}
.snap-thumb-dot {
  position: absolute; bottom: 3px; right: 3px;
  width: 8px; height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
}

/* ============================================================================
   Quick-print через QR
   ============================================================================ */
.qp-plate {
  background: var(--bg-surface-2);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.qp-plate-head { margin-bottom: 8px; }
.qp-printers {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.qp-pr-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.qp-pr-btn:hover:not(:disabled) {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.qp-pr-btn:disabled {
  opacity: 0.5; cursor: not-allowed;
}
.qp-pr-state {
  font-size: 10px; color: var(--text-muted);
}

/* ============================================================================
   Thermal label preview (для друку наклейок 58/80мм)
   ============================================================================ */
.lbl-paper {
  background: #fff;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 4mm;
  margin: 0 auto;
  font-family: -apple-system, sans-serif;
  color: #000;
}
.lbl-qr-wrap {
  text-align: center;
  margin-bottom: 2mm;
}
.lbl-qr-wrap img {
  width: 32mm; height: 32mm;
}
.lbl-lines { text-align: center; }
.lbl-title { font-size: 14px; font-weight: 800; line-height: 1.15; margin: 2px 0; }
.lbl-ttn   { font-size: 16px; font-weight: 800; font-family: ui-monospace, monospace; letter-spacing: 0.04em; }
.lbl-items { font-size: 12px; font-weight: 600; line-height: 1.3; white-space: pre-line; margin-top: 4px; }
.lbl-meta  { font-size: 11px; color: #444; }
.lbl-id    { font-size: 10px; color: #777; margin-top: 4px; }

/* Кнопка «надрукувати частини» на картці частини (parts.js → План). */
.parts-adj-print { color: var(--brand); border-color: var(--brand) !important; }
.parts-adj-print:hover { background: var(--brand-soft) !important; }

/* Кнопка ⏱ охолодження перед скиданням — підсвічена коли задано своє значення. */
.parts-adj-eject-set { color: var(--info); border-color: var(--info) !important; font-weight: 700; }

/* Бейдж-кнопка автоскиду на картці частини — клік перемикає увімкнено/вимкнено
 * напряму, без модалки (тонке налаштування часу/температури лишається в «⋯»). */
.parts-eject-badge {
  display: inline-flex; align-items: center; gap: 3px; margin-top: 4px;
  font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer; transition: all 0.12s;
  background: var(--brand-soft); color: var(--brand);
}
.parts-eject-badge .ms { font-size: 11px; }
.parts-eject-badge:hover { transform: translateY(-1px); filter: brightness(0.96); }
.parts-eject-badge.off { background: var(--bg-surface-2); color: var(--text-muted); border-color: var(--border); }
.parts-eject-badge.off:hover { color: var(--danger); border-color: var(--danger); }

/* ============================================================================
   Стрічки «Нещодавно» — Dashboard + Parts
   ============================================================================ */

/* Dashboard — горизонтальна стрічка нещодавно відкритих товарів */
.dash-recent-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.dash-recent-strip::-webkit-scrollbar { display: none; }

.dash-recent-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  width: 76px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 6px 7px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  line-height: 1.25;
  word-break: break-word;
}
.dash-recent-chip:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.dash-recent-chip img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.dash-recent-chip .ms {
  font-size: 28px;
  color: var(--text-muted);
}

/* Parts — горизонтальна стрічка нещодавно друкованих плит */
.parts-recent-wrap {
  margin-bottom: 14px;
}
.parts-recent-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.parts-recent-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.parts-recent-strip::-webkit-scrollbar { display: none; }

.parts-recent-chip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
  width: 108px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 8px 7px;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.parts-recent-chip:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.parts-recent-chip img {
  width: 100%;
  height: 52px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  margin-bottom: 3px;
}
.parts-recent-chip .ms {
  font-size: 28px;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.parts-recent-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.parts-recent-sub {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.parts-recent-when {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}
