/* Общие стили — XCOM Content Studio AI */
:root {
  /* Светлая тема (рабочие экраны) */
  --c-bg: #F4F5FA;
  --c-surface: #FFFFFF;
  --c-surface-2: #F0F1F7;
  --c-surface-3: #E7E9F2;
  --c-text: #0F172A;
  --c-text-2: #475569;
  --c-text-3: #94A3B8;

  /* Бренд: indigo + emerald (AI-success) + purple (magic) */
  --c-primary: #4F46E5;
  --c-primary-dark: #3730A3;
  --c-primary-light: #E0E7FF;
  --c-primary-bg: #EEF2FF;

  --c-accent: #10B981;
  --c-accent-dark: #047857;
  --c-accent-light: #D1FAE5;

  --c-magic: #A855F7;
  --c-magic-dark: #7E22CE;
  --c-magic-light: #F3E8FF;

  --c-danger: #DC2626;
  --c-danger-light: #FEE2E2;
  --c-warning: #F59E0B;
  --c-warning-light: #FEF3C7;
  --c-success: #10B981;
  --c-success-light: #D1FAE5;

  --c-border: #E2E8F0;
  --c-border-2: #CBD5E1;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10);
  --shadow-xl: 0 20px 50px rgba(15, 23, 42, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --gradient-magic: linear-gradient(135deg, #A855F7 0%, #4F46E5 100%);
  --gradient-ai: linear-gradient(135deg, #4F46E5 0%, #10B981 100%);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Helvetica Neue', Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ===== Layout ===== */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 12px;
}
.sidebar-brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--gradient-magic);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.35);
}
.sidebar-brand-title { font-weight: 700; font-size: 14px; line-height: 1.2; }
.sidebar-brand-sub { font-size: 11px; color: var(--c-text-3); margin-top: 2px; }
.sidebar-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--c-text-3); padding: 14px 10px 6px; font-weight: 600;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--c-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.1s;
}
.sidebar-link:hover { background: var(--c-surface-2); }
.sidebar-link.active { background: var(--c-primary-bg); color: var(--c-primary-dark); font-weight: 600; }
.sidebar-link-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-link-counter {
  margin-left: auto;
  background: var(--c-surface-2);
  color: var(--c-text-2);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.sidebar-link.active .sidebar-link-counter {
  background: var(--c-primary);
  color: #fff;
}
.sidebar-link-counter.red { background: var(--c-danger-light); color: var(--c-danger); }
.sidebar-link.active .sidebar-link-counter.red { background: var(--c-danger); color: #fff; }

.main { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 18px; font-weight: 700; margin: 0; }
.topbar-sub { color: var(--c-text-2); font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--c-surface-2);
}
.topbar-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gradient-magic); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}

.content { padding: 24px; flex: 1; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13.5px;
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--c-surface-2); }
.btn-primary {
  background: var(--c-primary); color: #fff; border-color: var(--c-primary);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); }
.btn-accent { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.btn-accent:hover { background: var(--c-accent-dark); border-color: var(--c-accent-dark); }
.btn-magic {
  background: var(--gradient-magic); color: #fff; border: none;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.30);
}
.btn-magic:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(168, 85, 247, 0.40); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--c-primary); }
.btn-ghost:hover { background: var(--c-primary-bg); }
.btn-danger { background: var(--c-danger); color: #fff; border-color: var(--c-danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: var(--c-surface-2); color: var(--c-text-2);
}
.badge-primary { background: var(--c-primary-light); color: var(--c-primary-dark); }
.badge-accent { background: var(--c-accent-light); color: var(--c-accent-dark); }
.badge-magic { background: var(--c-magic-light); color: var(--c-magic-dark); }
.badge-danger { background: var(--c-danger-light); color: var(--c-danger); }
.badge-warning { background: var(--c-warning-light); color: #92400E; }
.badge-success { background: var(--c-success-light); color: var(--c-accent-dark); }
.badge-1c { background: #E0F2FE; color: #0369A1; }
.badge-ai {
  background: var(--gradient-magic); color: #fff;
  box-shadow: 0 2px 6px rgba(168, 85, 247, 0.25);
}
.badge-dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; display: inline-block;
}

/* ===== Cards ===== */
.card {
  background: var(--c-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
  padding: 16px;
}
.card-flat { box-shadow: none; }

/* ===== Form ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--c-text-2); }
.field-label .required { color: var(--c-danger); }
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-bg);
}
.input-readonly {
  background: #F8FAFC; color: var(--c-text-2); border-color: var(--c-border);
}
.input-1c {
  background: #F0F9FF; border-color: #BAE6FD; color: #075985;
}
.input-ai {
  background: linear-gradient(135deg, #F5F3FF 0%, #ECFEFF 100%);
  border-color: #C4B5FD;
}
.textarea { resize: vertical; min-height: 80px; }

/* ===== Tabs ===== */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--c-border);
  padding: 0 0 0 4px;
}
.tab {
  padding: 10px 16px;
  font-size: 13.5px; font-weight: 600;
  color: var(--c-text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.tab:hover { color: var(--c-text); }
.tab.active {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
}
.tab .tab-count {
  margin-left: 6px; font-size: 11px;
  background: var(--c-surface-2); color: var(--c-text-2);
  padding: 1px 7px; border-radius: 999px;
}
.tab.active .tab-count { background: var(--c-primary-bg); color: var(--c-primary-dark); }

/* ===== Stats ===== */
.stat-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.stat {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.stat-label { font-size: 12px; color: var(--c-text-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 28px; font-weight: 800; margin-top: 4px; }
.stat-delta { font-size: 12px; margin-top: 4px; font-weight: 600; }
.stat-delta.up { color: var(--c-success); }
.stat-delta.down { color: var(--c-danger); }

/* ===== AI Block ===== */
.ai-suggestion {
  border-radius: var(--radius-md);
  border: 1px solid #C4B5FD;
  background: linear-gradient(135deg, #F5F3FF 0%, #ECFEFF 100%);
  padding: 14px 16px;
  display: flex; gap: 12px; align-items: flex-start;
}
.ai-suggestion-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--gradient-magic); color: #fff;
  display: grid; place-items: center; font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.30);
}
.ai-suggestion-title {
  font-size: 13px; font-weight: 700; margin-bottom: 3px;
  display: flex; align-items: center; gap: 8px;
}
.ai-suggestion-body { font-size: 13px; color: var(--c-text-2); line-height: 1.5; }
.ai-suggestion-actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== Tables ===== */
.table-wrap {
  background: var(--c-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 11px 14px; font-weight: 600; font-size: 11.5px;
  color: var(--c-text-2); text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #FAFBFE; }

/* ===== Toggle ===== */
.toggle {
  position: relative; display: inline-block;
  width: 36px; height: 20px;
  background: var(--c-border-2); border-radius: 999px;
  cursor: pointer; transition: background 0.15s;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.15s;
}
.toggle.on { background: var(--c-primary); }
.toggle.on::after { transform: translateX(16px); }

/* ===== Utils ===== */
.row { display: flex; gap: 12px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.muted { color: var(--c-text-2); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.bold { font-weight: 700; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
.hidden { display: none !important; }

/* ===== Toasts ===== */
.toast-host {
  position: fixed; right: 24px; bottom: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--c-text);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
  max-width: 360px;
  display: flex; align-items: center; gap: 10px;
}
.toast.ok { background: var(--c-accent); }
.toast.err { background: var(--c-danger); }
.toast.ai { background: var(--gradient-magic); }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 100;
  display: grid; place-items: center;
  padding: 20px;
  animation: fade-in 0.15s ease-out;
}
.modal {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  max-width: 560px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modal-in 0.2s ease-out;
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: 12px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 18px 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--c-border);
  display: flex; gap: 8px; justify-content: flex-end;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Progress ===== */
.progress {
  height: 6px;
  background: var(--c-surface-2);
  border-radius: 999px; overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--gradient-ai);
  border-radius: 999px;
  transition: width 0.3s;
}
.progress-magic .progress-bar { background: var(--gradient-magic); }

/* ===== Spinner ===== */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Demo bar (across all working screens) ===== */
.demo-bar {
  background: linear-gradient(135deg, #1E1B4B 0%, #4C1D95 100%);
  color: #fff;
  padding: 9px 24px;
  font-size: 12.5px;
  display: flex; align-items: center; gap: 10px;
}
.demo-bar a { color: #fff; text-decoration: underline; }
.demo-bar .badge-ai { font-size: 10px; padding: 2px 7px; }

/* ======================================
   АДАПТИВНОСТЬ
   ====================================== */

/* Hamburger button (mobile sidebar trigger) */
.burger {
  display: none;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  cursor: pointer;
  align-items: center; justify-content: center;
  font-size: 18px;
  padding: 0;
}
.burger:active { background: var(--c-border); }

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 50;
}
.sidebar-overlay.on { display: block; }

/* TABLET — sidebar становится узким (icons-only) */
@media (max-width: 1180px) {
  .app { grid-template-columns: 64px 1fr; }
  .sidebar { padding: 12px 8px; }
  .sidebar-brand-title,
  .sidebar-brand-sub,
  .sidebar-section-title { display: none; }
  .sidebar-brand { justify-content: center; padding: 4px 0 14px; }
  .sidebar-link { justify-content: center; padding: 10px 0; position: relative; }
  .sidebar-link span:not(.sidebar-link-icon):not(.sidebar-link-counter) { display: none; }
  .sidebar-link-counter {
    position: absolute; top: 4px; right: 4px;
    margin: 0; min-width: 18px; font-size: 9px; padding: 1px 4px;
  }
  .sidebar-link-icon { font-size: 20px; }
}

/* MOBILE — sidebar выезжает overlay'ом по клику на burger */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 260px;
    z-index: 51;
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
    padding: 18px 14px;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-brand-title,
  .sidebar-brand-sub,
  .sidebar-section-title { display: block; }
  .sidebar-brand { justify-content: flex-start; padding: 4px 6px 18px; }
  .sidebar-link { justify-content: flex-start; padding: 9px 10px; }
  .sidebar-link span { display: inline; }
  .sidebar-link-counter {
    position: static;
    margin-left: auto; min-width: auto; font-size: 11px; padding: 2px 7px;
  }
  .sidebar-link-icon { font-size: 16px; }
  .burger { display: inline-flex; }

  .topbar { padding: 10px 14px; gap: 8px; }
  .topbar h1 { font-size: 16px; }
  .topbar-sub { font-size: 11px; }
  .topbar-user { padding: 3px 8px 3px 3px; }
  .topbar-user > div:not(.topbar-avatar) { display: none; }

  .content { padding: 14px; }

  /* Demo-бар компактнее */
  .demo-bar { padding: 7px 14px; font-size: 11.5px; flex-wrap: wrap; gap: 6px; }
  .demo-bar > span:not(.badge-ai) { font-size: 11px; }

  /* Stats — 2 в ряд */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat-value { font-size: 22px; }

  /* Toasts — снизу */
  .toast-host { right: 8px; left: 8px; bottom: 8px; }
  .toast { max-width: none; }

  /* Modal на mobile — почти full */
  .modal { max-height: 95vh; }
  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }

  /* Tabs — горизонтальный скролл */
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .tabs::-webkit-scrollbar { height: 0; }
  .tab { white-space: nowrap; padding: 9px 12px; font-size: 12.5px; }

  /* Table — обернуть в скролл-контейнер */
  .table-wrap { overflow-x: auto; }
  .table { min-width: 600px; }

  /* Catalog — 2 карточки в ряд на mobile */
  .catalog-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .product-card-name { font-size: 11.5px; }

  /* Drawer — fullscreen */
  .drawer { width: 100vw; }
  .drawer-header { padding: 12px 14px; gap: 8px; }
  .drawer-title-name { font-size: 13px; }
  .drawer-title-id { font-size: 10px; }
  .drawer-body { padding: 14px; }
  .drawer-tabs { padding: 0 14px; }
  .drawer-tab { padding: 9px 12px; font-size: 12px; }
  .drawer-footer { padding: 10px 14px; gap: 6px; flex-wrap: wrap; }
  .drawer-footer .btn { font-size: 11.5px; padding: 6px 10px; }
  .drawer-footer .spacer { display: none; }

  /* AI panel блоки в drawer */
  .ai-suggestion { padding: 12px; gap: 10px; }
  .ai-suggestion-icon { width: 26px; height: 26px; font-size: 13px; }
  .ai-suggestion-title { font-size: 12.5px; flex-wrap: wrap; gap: 6px; }
  .ai-suggestion-body { font-size: 12px; }

  /* Form rows — все в одну колонку */
  .field-row { grid-template-columns: 1fr !important; gap: 10px; }
}

/* MOBILE-SMALL — мелкие телефоны */
@media (max-width: 500px) {
  .catalog-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .product-card-img { aspect-ratio: 1; }
  .product-card-body { padding: 8px 10px; gap: 3px; }
  .product-card-name {
    font-size: 11px;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
  .product-card-id { font-size: 9.5px; }
  .product-card-meta .price { font-size: 12px; }
  .stat-grid { grid-template-columns: 1fr; }
}

/* ===== Product image (для каталога и карточек заявок) ===== */
.product-img {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1;
  width: 100%;
}
.product-img svg {
  width: 75%; height: 75%;
  filter: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.10));
}
.product-img.product-img-sm svg { width: 60%; height: 60%; }

/* ===== Каталог карточек ===== */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.catalog-grid.compact { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

/* List-view — строчный режим со ВСЕЙ инфой в одну строку */
.catalog-grid.list-view {
  grid-template-columns: 1fr !important;
  gap: 6px;
}
.catalog-grid.list-view .product-card {
  display: grid;
  grid-template-columns: 60px 1fr auto auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 8px 12px;
}
.catalog-grid.list-view .product-card:hover { transform: none; }
.catalog-grid.list-view .product-card-img {
  width: 56px; height: 56px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--c-border);
  overflow: hidden;
}
.catalog-grid.list-view .product-card-img img {
  padding: 4px !important;
}
.catalog-grid.list-view .product-card-badges {
  position: static;
  flex-direction: row;
  margin-top: 2px;
}
.catalog-grid.list-view .product-card-body {
  padding: 0;
  flex-direction: column;
  min-width: 0;
}
.catalog-grid.list-view .product-card-name {
  -webkit-line-clamp: 1;
  line-clamp: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13.5px;
}
.catalog-grid.list-view .product-card-id { font-size: 10.5px; }
.catalog-grid.list-view .product-card-meta { padding-top: 0; }
.catalog-grid.list-view .product-card-mp-row { gap: 3px; }
.catalog-grid.list-view .product-card-meta .price { font-size: 14px; white-space: nowrap; }
.catalog-grid.list-view .list-status { font-size: 11.5px; white-space: nowrap; }
.catalog-grid.list-view .list-brand {
  font-size: 11.5px; color: var(--c-text-3);
  white-space: nowrap;
  max-width: 120px; overflow: hidden; text-overflow: ellipsis;
}

@media (max-width: 900px) {
  .catalog-grid.list-view .product-card {
    grid-template-columns: 50px 1fr auto;
  }
  .catalog-grid.list-view .product-card .list-brand,
  .catalog-grid.list-view .product-card .product-card-mp-row,
  .catalog-grid.list-view .product-card .list-status {
    display: none;
  }
}

/* View toggle */
.view-toggle {
  display: inline-flex;
  background: var(--c-surface-2);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.view-toggle-btn {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--c-text-2);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}
.view-toggle-btn.active {
  background: var(--c-surface);
  color: var(--c-primary);
  box-shadow: var(--shadow-sm);
}

.product-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; flex-direction: column;
}
.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--c-primary);
}
.product-card.active {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-bg);
}
.product-card-img {
  position: relative;
  width: 100%;
  aspect-ratio: 1.1;
  overflow: hidden;
}
.product-card-img .product-img {
  border-radius: 0;
  aspect-ratio: auto;
  height: 100%;
}
.product-card-badges {
  position: absolute; top: 8px; left: 8px; right: 8px;
  display: flex; flex-wrap: wrap; gap: 4px;
}
.product-card-body { padding: 10px 12px 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.product-card-id {
  font-family: ui-monospace, monospace;
  font-size: 10.5px; color: var(--c-text-3);
  letter-spacing: 0.03em;
}
.product-card-name {
  font-size: 12.5px; font-weight: 600; line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--c-text-2);
  margin-top: auto; padding-top: 4px;
}
.product-card-meta .price {
  font-weight: 700; font-size: 13px; color: var(--c-text);
}
.product-card-mp-row { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.mp-rating-chip {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 10.5px; padding: 1px 5px;
  border-radius: 4px; font-weight: 700;
}
.mp-rating-chip.h { background: var(--c-success-light); color: var(--c-accent-dark); }
.mp-rating-chip.m { background: var(--c-warning-light); color: #92400E; }
.mp-rating-chip.l { background: var(--c-danger-light); color: var(--c-danger); }
.mp-rating-chip.n { background: var(--c-surface-2); color: var(--c-text-3); }

/* AI-score */
.ai-score-circle {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 800;
  background: var(--c-success-light); color: var(--c-accent-dark);
}
.ai-score-circle.m { background: var(--c-warning-light); color: #92400E; }
.ai-score-circle.l { background: var(--c-danger-light); color: var(--c-danger); }

/* ===== Drawer карточки справа ===== */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.40);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.drawer-overlay.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: min(720px, 92vw);
  background: var(--c-surface);
  box-shadow: -20px 0 60px rgba(15, 23, 42, 0.15);
  z-index: 91;
  transform: translateX(100%);
  transition: transform 0.25s ease-out;
  display: flex; flex-direction: column;
}
.drawer.on { transform: translateX(0); }
.drawer-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: 12px;
}
.drawer-title-block { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.drawer-title-id { font-family: ui-monospace, monospace; font-size: 11px; color: var(--c-text-3); }
.drawer-title-name {
  font-size: 15px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawer-nav { display: flex; gap: 4px; }
.drawer-body {
  flex: 1; overflow-y: auto;
  padding: 18px;
}
.drawer-tabs {
  display: flex; gap: 2px;
  padding: 0 18px;
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto;
  background: var(--c-surface);
}
.drawer-tabs::-webkit-scrollbar { height: 0; }
.drawer-tab {
  padding: 10px 14px;
  font-size: 12.5px; font-weight: 600;
  color: var(--c-text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  cursor: pointer;
}
.drawer-tab:hover { color: var(--c-text); }
.drawer-tab.active { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.drawer-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-2);
  display: flex; gap: 8px; align-items: center;
}

/* ===== Batch cards (для inbox) ===== */
.batch-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 18px;
  cursor: pointer;
  transition: all 0.15s;
}
.batch-card:hover {
  border-color: var(--c-primary);
  box-shadow: var(--shadow-md);
}
.batch-card.priority-high { border-left: 4px solid var(--c-danger); }
.batch-card.priority-medium { border-left: 4px solid var(--c-warning); }
.batch-card.priority-low { border-left: 4px solid var(--c-success); }
.batch-progress {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 0;
}
.batch-progress .progress { flex: 1; height: 8px; }
.batch-progress-text { font-size: 11.5px; color: var(--c-text-2); }

/* Source pills */
.source-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.source-pill.sync_1c { background: #DBEAFE; color: #1D4ED8; }
.source-pill.excel { background: #DCFCE7; color: #15803D; }
.source-pill.mp_request { background: var(--c-magic-light); color: var(--c-magic-dark); }
.source-pill.qa_batch { background: var(--c-warning-light); color: #92400E; }
.source-pill.mp_recovery { background: var(--c-danger-light); color: var(--c-danger); }
.source-pill.qa_excel { background: var(--c-accent-light); color: var(--c-accent-dark); }

/* Counter chip */
.counter-chip {
  display: inline-flex; align-items: baseline; gap: 4px;
  padding: 3px 10px;
  background: var(--c-surface-2);
  border-radius: 999px;
  font-size: 12px;
}
.counter-chip strong { font-size: 14px; }

/* Toolbar */
.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
}

/* Empty product image — placeholder для отсутствующих фото */
.product-img.empty {
  background: var(--c-surface-2);
  border: 1px dashed var(--c-border-2);
  display: grid; place-items: center;
  color: var(--c-text-3); font-size: 11px;
}

/* Catalog filters sidebar */
.cat-filters {
  padding: 14px;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex; flex-direction: column; gap: 12px;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
}
.cat-filter-group { display: flex; flex-direction: column; gap: 4px; }
.cat-filter-title {
  font-size: 11px; font-weight: 700;
  color: var(--c-text-3); text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.cat-filter-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--c-text);
}
.cat-filter-item:hover { background: var(--c-surface-2); }
.cat-filter-item.active { background: var(--c-primary-bg); color: var(--c-primary-dark); font-weight: 600; }
.cat-filter-item-count {
  margin-left: auto;
  font-size: 11px; color: var(--c-text-3);
}
.cat-filter-item.child { padding-left: 22px; font-size: 12.5px; }

/* ==============================================================
   АДАПТИВНОСТЬ — финальный блок, override компонентных стилей
   (должен идти ПОСЛЕ всех компонентных правил из-за CSS cascade)
   ============================================================== */

/* TABLET — sidebar становится узким (icons-only) */
@media (max-width: 1180px) {
  .app { grid-template-columns: 64px 1fr !important; }
}

/* MOBILE — sidebar выезжает overlay'ом */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr !important; }

  /* Каталог — 2 в ряд */
  .catalog-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }

  /* Drawer fullscreen */
  .drawer { width: 100vw !important; }

  /* Batch grid в inbox */
  .batch-actions-grid { grid-template-columns: 1fr 1fr !important; }
  .batch-mini-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important; }

  /* Kanban в lead */
  .kanban { grid-template-columns: 1fr !important; }
  .activity-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .team-grid { grid-template-columns: 1fr !important; }

  /* Stats grid */
  .stat-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* QA проверки */
  .check-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* MP cards */
  .mp-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Все field-row в одну колонку */
  .field-row { grid-template-columns: 1fr !important; }
  .field-row.cols-3 { grid-template-columns: 1fr !important; }
}

/* MOBILE-SMALL — мелкие телефоны */
@media (max-width: 500px) {
  .catalog-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .stat-grid { grid-template-columns: 1fr !important; }
  .mp-grid { grid-template-columns: 1fr !important; }
  .check-grid { grid-template-columns: 1fr 1fr !important; }
  .batch-actions-grid { grid-template-columns: 1fr !important; }
}

/* CRITICAL: main grid-item не должен раздуваться от min-content */
.main { min-width: 0; overflow-x: hidden; }

@media (max-width: 900px) {
  /* На mobile прячем длинные spans в demo-bar и оставляем только важное */
  .demo-bar { flex-wrap: wrap !important; overflow: hidden; }
  .demo-bar > span:not(.badge-ai):not(:first-child):not(:last-child) { display: none !important; }
  .demo-bar > span:last-child { font-size: 10.5px; }
  .topbar { overflow: hidden; min-width: 0; }
  .topbar h1 { font-size: 14px !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-sub { display: none !important; }
}


