/* ══════════════════════════════════════════════════════════════════════════════
   Каталог номенклатур v2 — главные стили
   Дизайн: premium, kari brand (#a01671), light/dark, mobile-first
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ───────────────────────────────────────────────── */
:root {
  --brand:          #a01671;
  --brand-dark:     #7d1059;
  --brand-light:    #c41f8d;
  --brand-faint:    rgba(160, 22, 113, 0.08);
  --brand-faint2:   rgba(160, 22, 113, 0.15);

  /* Light theme */
  --bg:             #f5f5f7;
  --surface:        #ffffff;
  --surface2:       #f8f8fb;
  --border:         rgba(0,0,0,0.09);
  --border-strong:  rgba(0,0,0,0.15);
  --text:           #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary:  #aeaeb2;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg:      0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;
  --radius-xl:      24px;
  --header-h:       64px;
  --nav-h:          64px;
  --sidebar-w:      240px;
  --transition:     0.2s ease;
}

[data-theme="dark"] {
  --bg:             #0d0d0d;
  --surface:        #1a1a1a;
  --surface2:       #222222;
  --border:         rgba(255,255,255,0.08);
  --border-strong:  rgba(255,255,255,0.14);
  --text:           #f0f0f2;
  --text-secondary: #a0a0a6;
  --text-tertiary:  #5a5a60;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.35);
  --shadow-lg:      0 12px 40px rgba(0,0,0,0.5);
}

/* ── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--header-h);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 16px;
  transition: background var(--transition);
}
[data-theme="dark"] .app-header {
  background: rgba(13,13,13,0.85);
}
.header-logo {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.header-logo img {
  height: 32px; width: auto; object-fit: contain;
}
[data-theme="dark"] .header-logo img {
  filter: brightness(0) invert(1) sepia(1) saturate(3) hue-rotate(280deg);
}
.header-logo-text {
  font-size: 17px; font-weight: 600; letter-spacing: -0.2px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-search {
  flex: 1; max-width: 480px; position: relative;
}
.header-search input {
  width: 100%;
  height: 38px;
  padding: 0 16px 0 40px;
  border-radius: 20px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface2);
  color: var(--text);
  font-size: 15px;
  transition: all var(--transition);
  outline: none;
}
.header-search input:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-faint);
}
.header-search .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-tertiary); pointer-events: none;
  width: 18px; height: 18px;
}
.header-actions {
  display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0;
}
.btn-icon {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  background: transparent;
}
.btn-icon:hover {
  background: var(--brand-faint);
  color: var(--brand);
}
.btn-icon svg { width: 20px; height: 20px; }

/* ── Sections tabs ───────────────────────────────────────────────────────── */
.sections-bar {
  position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 190;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
  padding: 0 16px;
  height: 48px;
}
.sections-bar::-webkit-scrollbar { display: none; }
.section-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 0 16px;
  height: 48px;
  font-size: 14px; font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all var(--transition);
  cursor: pointer;
  background: none; border-radius: 0;
}
.section-tab:hover { color: var(--brand); }
.section-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app-body {
  display: flex;
  padding-top: calc(var(--header-h) + 48px);
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  padding: 24px 0;
  position: sticky;
  top: calc(var(--header-h) + 48px);
  height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  scrollbar-width: thin;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.sidebar-section { padding: 0 12px 12px; }
.sidebar-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  color: var(--text-tertiary); text-transform: uppercase;
  padding: 8px 8px 6px;
}
.filter-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 8px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition);
  gap: 8px;
}
.filter-item:hover { background: var(--brand-faint); color: var(--brand); }
.filter-item.active { background: var(--brand-faint2); color: var(--brand); font-weight: 600; }
.filter-item-name { font-size: 14px; flex: 1; }
.filter-item-count {
  font-size: 12px; color: var(--text-tertiary);
  background: var(--surface2); border-radius: 20px;
  padding: 1px 7px; font-weight: 500; min-width: 24px; text-align: center;
}
.filter-item.active .filter-item-count {
  background: var(--brand-faint2); color: var(--brand);
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 24px;
}

/* ── Catalog toolbar ─────────────────────────────────────────────────────── */
.catalog-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.catalog-count {
  font-size: 14px; color: var(--text-secondary);
}
.catalog-count strong { color: var(--text); }

/* ── Card Grid ───────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

/* ── Item Card ───────────────────────────────────────────────────────────── */
.item-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  opacity: 0;
  animation: fadeUp 0.35s ease forwards;
}
.item-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-faint2);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.item-card__photo {
  aspect-ratio: 4/3;
  background: var(--surface2);
  position: relative; overflow: hidden;
}
.item-card__photo img {
  width: 100%; height: 100%; object-fit: contain;
  padding: 8px;
  transition: transform 0.3s ease;
}
.item-card:hover .item-card__photo img { transform: scale(1.04); }
.item-card__no-photo {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  color: var(--text-tertiary); font-size: 13px;
}
.item-card__no-photo svg { width: 40px; height: 40px; opacity: 0.3; }

.item-card__badges {
  position: absolute; top: 8px; right: 8px;
  display: flex; flex-direction: column; gap: 4px; align-items: flex-end;
}
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-comment {
  background: rgba(255, 149, 0, 0.15);
  color: #c07800;
  backdrop-filter: blur(8px);
}
[data-theme="dark"] .badge-comment {
  background: rgba(255, 149, 0, 0.2);
  color: #ffb830;
}
.badge-photos {
  background: rgba(160, 22, 113, 0.12);
  color: var(--brand);
  backdrop-filter: blur(8px);
}

.item-card__body {
  padding: 12px 14px 14px;
  flex: 1; display: flex; flex-direction: column; gap: 4px;
}
.item-card__id {
  font-size: 11px; font-weight: 600; letter-spacing: 0.5px;
  color: var(--brand); text-transform: uppercase;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.item-card__name {
  font-size: 14px; font-weight: 500;
  color: var(--text); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.item-card__category {
  font-size: 12px; color: var(--text-tertiary);
  margin-top: auto; padding-top: 6px;
}

/* ── Skeleton Loader ─────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}
.skeleton-card__photo { aspect-ratio: 4/3; }
.skeleton-card__body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.skeleton-line { height: 12px; }
.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-line.long { width: 95%; }

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; margin-top: 32px; flex-wrap: wrap;
}
.page-btn {
  min-width: 36px; height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px; font-weight: 500;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.page-btn:hover { border-color: var(--brand); color: var(--brand); }
.page-btn.active {
  background: var(--brand); border-color: var(--brand);
  color: #fff; font-weight: 600;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 80px 20px;
  color: var(--text-secondary);
}
.empty-state__icon { font-size: 48px; margin-bottom: 16px; }
.empty-state__title { font-size: 20px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state__desc { font-size: 15px; }

/* ── Mobile bottom nav ───────────────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  height: var(--nav-h);
  padding: 0 8px env(safe-area-inset-bottom);
}
[data-theme="dark"] .bottom-nav {
  background: rgba(13,13,13,0.92);
}
.bottom-nav-items {
  display: flex; height: 100%; align-items: center; justify-content: space-around;
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 12px; border-radius: var(--radius-md);
  color: var(--text-tertiary); font-size: 11px; font-weight: 500;
  transition: all var(--transition); cursor: pointer;
  background: none;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--brand); }
.bottom-nav-item.active svg { stroke: var(--brand); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.visible { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.2s ease;
}
.modal-overlay.visible .modal { transform: scale(1) translateY(0); }
.modal-header {
  padding: 20px 24px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface2); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: all var(--transition);
}
.modal-close:hover { background: var(--brand-faint); color: var(--brand); }
.modal-body { padding: 20px 24px 24px; }
.modal-input {
  width: 100%; height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong);
  background: var(--surface2);
  color: var(--text); font-size: 15px;
  outline: none; transition: all var(--transition);
  margin-top: 12px;
}
.modal-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-faint); background: var(--surface); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 20px; border-radius: var(--radius-md);
  font-size: 15px; font-weight: 600;
  transition: all var(--transition); cursor: pointer;
  border: none;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(160,22,113,0.3);
}
.btn-primary:hover { background: var(--brand-dark); box-shadow: 0 4px 14px rgba(160,22,113,0.4); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--surface2); color: var(--text);
  border: 1.5px solid var(--border-strong);
}
.btn-secondary:hover { background: var(--brand-faint); border-color: var(--brand); color: var(--brand); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── Item page ───────────────────────────────────────────────────────────── */
.item-page {
  padding-top: var(--header-h);
  max-width: 1000px; margin: 0 auto; padding-left: 24px; padding-right: 24px;
}
.item-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-secondary); padding: 16px 0 0;
}
.item-breadcrumb a:hover { color: var(--brand); }
.item-breadcrumb-sep { color: var(--text-tertiary); }

.item-layout {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 32px; padding: 20px 0 40px;
}

/* Gallery */
.item-gallery { position: sticky; top: calc(var(--header-h) + 16px); }
.gallery-main {
  aspect-ratio: 1/1;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  position: relative;
}
.gallery-main img {
  width: 100%; height: 100%; object-fit: contain; padding: 16px;
  user-select: none;
}
.gallery-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.9); backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text); transition: all var(--transition); cursor: pointer;
}
[data-theme="dark"] .gallery-arrow { background: rgba(30,30,30,0.9); }
.gallery-arrow:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.gallery-arrow.prev { left: 10px; }
.gallery-arrow.next { right: 10px; }
.gallery-arrow svg { width: 16px; height: 16px; }
.gallery-dots {
  display: flex; justify-content: center; gap: 6px; margin-top: 12px;
}
.gallery-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border-strong); transition: all var(--transition); cursor: pointer;
}
.gallery-dot.active { background: var(--brand); width: 18px; border-radius: 3px; }
.gallery-thumbs {
  display: flex; gap: 8px; margin-top: 12px;
}
.gallery-thumb {
  width: 64px; height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden; cursor: pointer;
  border: 2px solid transparent; transition: all var(--transition);
  background: var(--surface2); flex-shrink: 0;
}
.gallery-thumb.active { border-color: var(--brand); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.gallery-no-photo {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  color: var(--text-tertiary); font-size: 14px;
}
.gallery-no-photo svg { width: 56px; height: 56px; opacity: 0.25; }

/* Item info */
.item-info { display: flex; flex-direction: column; gap: 0; }
.item-info__id {
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  color: var(--brand); text-transform: uppercase; margin-bottom: 8px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.item-info__name {
  font-size: 26px; font-weight: 700; line-height: 1.25;
  letter-spacing: -0.3px; color: var(--text); margin-bottom: 8px;
}
.item-info__category {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px;
  background: var(--surface2); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-secondary); margin-bottom: 20px;
}

.info-section {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.info-section__label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 8px;
}
.info-section__text {
  font-size: 15px; color: var(--text); line-height: 1.6;
}

/* Comment block */
.comment-block {
  display: flex; gap: 12px;
  background: rgba(255, 149, 0, 0.07);
  border: 1px solid rgba(255, 149, 0, 0.2);
  border-left: 3px solid #ff9500;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 16px 0;
}
[data-theme="dark"] .comment-block {
  background: rgba(255, 149, 0, 0.08);
  border-color: rgba(255, 149, 0, 0.25);
}
.comment-block__icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.comment-block__label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: #c07800; margin-bottom: 4px;
}
[data-theme="dark"] .comment-block__label { color: #ffb830; }
.comment-block__text { font-size: 14px; color: var(--text); line-height: 1.5; }

/* Export from item page */
.btn-export-item {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 16px; padding: 10px 16px;
  border-radius: var(--radius-md); border: 1.5px solid var(--border-strong);
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  transition: all var(--transition); width: 100%;
  background: none; cursor: pointer;
}
.btn-export-item:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-faint); }
.btn-export-item.active {
  background: var(--brand-faint2); border-color: var(--brand); color: var(--brand);
}

/* Suggest photo button */
.suggest-photo-btn {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 12px; padding: 10px 16px;
  border-radius: var(--radius-md); border: 1.5px dashed var(--border-strong);
  color: var(--text-secondary); font-size: 14px;
  transition: all var(--transition); width: 100%;
  background: none;
}
.suggest-photo-btn:hover {
  border-color: var(--brand); color: var(--brand); background: var(--brand-faint);
}

/* ── Search dropdown ─────────────────────────────────────────────────────── */
.search-results-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden; z-index: 300;
  max-height: 360px; overflow-y: auto;
}
.search-result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--brand-faint); }
.search-result-img {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  object-fit: contain; background: var(--surface2);
  flex-shrink: 0; padding: 4px;
}
.search-result-info { flex: 1; min-width: 0; }
.search-result-id { font-size: 11px; font-weight: 700; color: var(--brand); font-family: monospace; }
.search-result-name { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-cat { font-size: 12px; color: var(--text-tertiary); }
.search-empty { padding: 20px; text-align: center; color: var(--text-tertiary); font-size: 14px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  z-index: 600; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
@media (min-width: 769px) {
  .toast-container { bottom: 24px; }
}
.toast {
  padding: 12px 20px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  background: var(--text); color: var(--bg);
  animation: toastIn 0.25s ease, toastOut 0.25s ease 3.75s forwards;
  pointer-events: all;
}
.toast.success { background: #00b877; color: #fff; }
.toast.error   { background: #e03131; color: #fff; }
@keyframes toastIn  { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; } }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar { width: 200px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (max-width: 768px) {
  :root { --header-h: 56px; }

  .sections-bar { height: 44px; padding: 0 8px; }
  .section-tab  { padding: 0 12px; font-size: 13px; height: 44px; }

  .app-body { padding-top: calc(var(--header-h) + 44px); padding-bottom: var(--nav-h); }
  .sidebar  { display: none; }
  .main-content { padding: 16px; }

  .card-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

  .bottom-nav { display: block; }

  .item-layout { grid-template-columns: 1fr; gap: 20px; }
  .item-page { padding-left: 16px; padding-right: 16px; }
  .item-gallery { position: static; }
  .item-info__name { font-size: 22px; }

  .header-search { display: none; }
  .header-logo-text { font-size: 15px; }
}

@media (max-width: 480px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .item-card__name { font-size: 13px; }
}

/* ── Analog links ────────────────────────────────────────────────────────── */
.analog-line {
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
  font-size: 14px;
}
.analog-line:last-child { border-bottom: none; }

.analog-link {
  display: inline-flex;
  align-items: center;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-faint);
  border: 1px solid var(--brand-faint2);
  border-radius: 6px;
  padding: 1px 8px;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
}
.analog-link:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(160, 22, 113, 0.25);
}

/* ── Stub section tab ────────────────────────────────────────────────────── */
.section-tab.stub {
  opacity: 0.5;
  cursor: not-allowed;
  position: relative;
}
.section-tab.stub::after {
  content: 'скоро';
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: var(--text-tertiary);
  color: var(--surface);
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: 4px;
}

/* ── Stub section empty state ────────────────────────────────────────────── */
.stub-state {
  text-align: center;
  padding: 80px 20px;
  grid-column: 1 / -1;
}
.stub-state__icon { font-size: 56px; margin-bottom: 16px; }
.stub-state__title {
  font-size: 22px; font-weight: 700;
  color: var(--text); margin-bottom: 8px;
}
.stub-state__desc {
  font-size: 15px; color: var(--text-secondary);
  max-width: 360px; margin: 0 auto;
}
.stub-state__badge {
  display: inline-block;
  margin-top: 16px;
  padding: 6px 16px;
  border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 13px; color: var(--text-tertiary);
}

/* ── Export mode ─────────────────────────────────────────────────────────── */

/* Кнопка "Экспорт" в тулбаре */
.btn-export-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  font-size: 13px; font-weight: 500;
  border: 1.5px solid var(--border-strong);
  background: var(--surface); color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap;
  transition: all var(--transition);
}
.btn-export-toggle:hover { border-color: var(--brand); color: var(--brand); }
.btn-export-toggle.active {
  background: var(--brand); border-color: var(--brand);
  color: #fff;
}

/* Тулбар — flex row */
.catalog-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* Чекбокс на карточке */
.item-card__checkbox {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.9);
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s ease;
  pointer-events: none;
}
.item-card__checkbox.checked {
  background: var(--brand);
  border-color: var(--brand);
}
.item-card__checkbox.checked::after {
  content: '';
  width: 5px; height: 9px;
  border: 2px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg) translateY(-1px);
  display: block;
}

/* Выбранная карточка */
.item-card.selected { box-shadow: 0 0 0 2px var(--brand), var(--shadow-md); }

/* Режим экспорта — карточки не переходят */
body.export-mode .item-card { cursor: default; }
body.export-mode .item-card:hover { transform: none; }
body.export-mode .item-card { cursor: pointer; }

/* Плавающая панель экспорта */
.export-bar {
  position: fixed; bottom: -80px; left: 50%; transform: translateX(-50%);
  z-index: 999;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  transition: bottom 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}
/* Desktop: плавает над контентом снизу */
.export-bar.visible { bottom: 24px; }

/* Mobile: панель экспорта — внизу, над bottom nav */
@media (max-width: 768px) {
  .export-bar {
    left: 0 !important; right: 0 !important;
    transform: none !important;
    width: 100%;
    border-radius: 0;
    border-left: none; border-right: none; border-bottom: none;
    padding: 10px 16px;
    z-index: 195;
    top: auto !important;
  }
  .export-bar.visible {
    bottom: var(--nav-h) !important;
  }

  /* Когда открыт ящик фильтра — панель экспорта мутнеет и уходит на 2й план */
  #filter-drawer-overlay.visible ~ .export-bar.visible {
    opacity: 0.2;
    filter: blur(2px);
    pointer-events: none;
    transition: opacity 0.25s ease, filter 0.25s ease, bottom 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  }
}

.export-bar__info {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 500; color: var(--text);
}

.export-bar__actions { display: flex; gap: 8px; }

.export-bar__btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; transition: all var(--transition);
}
.export-bar__btn--secondary {
  background: var(--surface2); color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.export-bar__btn--secondary:hover { border-color: var(--border-strong); color: var(--text); }
.export-bar__btn--primary {
  background: var(--brand); color: #fff;
}
.export-bar__btn--primary:hover:not(:disabled) { background: var(--brand-dark); }
.export-bar__btn--primary:disabled { opacity: 0.45; cursor: default; }

/* Кнопка "+" у категории в режиме экспорта */
.filter-export-btn {
  margin-left: auto;
  width: 22px; height: 22px; flex-shrink: 0;
  display: none; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--brand-faint); color: var(--brand);
  border: 1.5px solid var(--brand-faint2);
  font-size: 16px; font-weight: 700; line-height: 1;
  cursor: pointer; transition: all var(--transition);
}
.filter-export-btn:hover { background: var(--brand); color: #fff; }
body.export-mode .filter-export-btn { display: flex; }
body.export-mode .filter-item { padding-right: 4px; }

/* ── Shelf mode ──────────────────────────────────────────────────────────── */

.shelf-mode-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: var(--radius-sm);
  cursor: pointer; margin-bottom: 2px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface2); color: var(--text-secondary);
  transition: all var(--transition);
}
.shelf-mode-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-faint); }
.shelf-mode-btn.active { background: var(--brand-faint2); border-color: var(--brand); color: var(--brand); }
.shelf-mode-btn__name { flex: 1; font-size: 14px; font-weight: 500; }
.shelf-mode-btn__count {
  font-size: 12px; color: var(--text-tertiary);
  background: var(--surface); border-radius: 20px;
  padding: 1px 7px; font-weight: 500; min-width: 24px; text-align: center;
}
.shelf-mode-btn.active .shelf-mode-btn__count { background: var(--brand-faint2); color: var(--brand); }

.filter-separator { height: 1px; background: var(--border); margin: 6px 0; }

/* Shelf items table in modal */
.shelf-items-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.shelf-items-table th {
  text-align: left; padding: 6px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--text-tertiary);
  border-bottom: 1.5px solid var(--border);
}
.shelf-items-table td {
  padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.shelf-items-table tr:last-child td { border-bottom: none; }
.shelf-qty {
  text-align: center; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--text-secondary); min-width: 48px;
}

/* ── Basket ──────────────────────────────────────────────────────────────── */

/* Badge on header basket button */
.basket-header-btn { position: relative; }
.basket-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--brand); color: #fff;
  border-radius: 9px; font-size: 11px; font-weight: 700;
  align-items: center; justify-content: center;
  pointer-events: none;
}

/* Badge on bottom-nav basket */
.bnav-basket-wrap { position: relative; display: inline-flex; }
.bnav-basket-badge {
  position: absolute; top: -4px; right: -6px;
  min-width: 16px; height: 16px; padding: 0 3px;
  background: var(--brand); color: #fff;
  border-radius: 8px; font-size: 10px; font-weight: 700;
  align-items: center; justify-content: center;
  pointer-events: none;
}

/* Basket button on item cards */
.item-card__basket-btn {
  position: absolute; bottom: 6px; right: 6px;
  width: 28px; height: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity var(--transition), background var(--transition), color var(--transition), border-color var(--transition);
  z-index: 2;
}
.item-card:hover .item-card__basket-btn { opacity: 1; }
.item-card__basket-btn.active {
  opacity: 1;
  background: var(--brand-faint2);
  border-color: var(--brand);
  color: var(--brand);
}
@media (hover: none) {
  .item-card__basket-btn { opacity: 0.75; }
}

/* Basket qty popup (bottom sheet) */
.basket-qty-backdrop {
  position: fixed; inset: 0; z-index: 299;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.basket-qty-popup {
  position: fixed; z-index: 300;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%; transform: translateX(-50%);
  width: min(380px, calc(100% - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 16px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 12px;
}
@media (min-width: 769px) { .basket-qty-popup { bottom: 32px; } }
.basket-qty-popup__name {
  font-size: 14px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.basket-qty-popup__row { display: flex; align-items: center; gap: 8px; }
.basket-qty-popup__actions { display: flex; gap: 8px; }

/* Qty stepper button (shared) */
.basket-qty-stepper {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--surface2); color: var(--text);
  font-size: 18px; font-weight: 400; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition);
}
.basket-qty-stepper:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-faint); }
.basket-qty-stepper.sm { width: 26px; height: 26px; font-size: 14px; }

/* Qty number input (shared) */
.basket-qty-input {
  flex: 1; text-align: center;
  font-size: 18px; font-weight: 600;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  background: var(--surface); color: var(--text);
  min-width: 0; -moz-appearance: textfield;
}
.basket-qty-input::-webkit-inner-spin-button,
.basket-qty-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.basket-qty-input.sm { width: 48px; font-size: 15px; padding: 4px 2px; }

/* Item page qty row */
.item-qty-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.item-qty-row .basket-qty-input { max-width: 72px; font-size: 16px; }

/* Basket modal header */
.basket-modal-header { gap: 12px; }
.basket-header-actions { display: flex; align-items: center; gap: 8px; }
.basket-clear-btn {
  padding: 5px 12px; border-radius: 8px; font-size: 13px; font-weight: 600;
  background: #ef4444; color: #fff; border: none; cursor: pointer;
  transition: background var(--transition);
}
.basket-clear-btn:hover { background: #dc2626; }

/* Basket modal — item list */
.basket-items { margin-bottom: 4px; }
.basket-section { margin-bottom: 12px; }
.basket-section__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; margin-bottom: 4px;
  background: var(--surface2); border-radius: var(--radius-sm);
  border-left: 3px solid var(--brand);
}
.basket-section__name {
  font-size: 12px; font-weight: 600;
  color: var(--text); letter-spacing: 0.02em;
}
.basket-section__count {
  font-size: 11px; font-weight: 600;
  background: var(--brand); color: #fff;
  padding: 1px 7px; border-radius: 20px;
}
.basket-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px; border-bottom: 1px solid var(--border);
}
.basket-item:last-child { border-bottom: none; }
.basket-item__photo {
  width: 48px; height: 48px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
  object-fit: contain; padding: 4px;
}
.basket-item__photo-placeholder {
  width: 48px; height: 48px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--text-tertiary);
}
.basket-item__info { flex: 1; min-width: 0; }
.basket-item__id {
  display: inline-block; font-size: 11px; font-weight: 600;
  color: var(--brand); font-family: 'SF Mono', 'Fira Code', monospace;
}
.basket-item__id:hover { text-decoration: underline; }
.basket-item__name {
  font-size: 13px; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 2px; line-height: 1.35;
}
.basket-item__qty-row { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.basket-item__qty {
  min-width: 28px; text-align: center;
  font-size: 15px; font-weight: 700; color: var(--text);
}
.basket-item__remove {
  flex-shrink: 0; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 18px; line-height: 1;
  color: var(--text-tertiary);
  transition: background var(--transition), color var(--transition);
}
.basket-item__remove:hover { background: #fee2e2; color: #ef4444; }

/* Stats row */
.basket-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.basket-stat {
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 10px 14px; display: flex; flex-direction: column; gap: 2px;
}
.basket-stat__label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-tertiary);
}
.basket-stat__value {
  font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.1;
}

.btn-link {
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--brand); padding: 0;
  text-decoration: underline; font-family: inherit;
}
.btn-link:hover { color: var(--brand-dark); }

/* Basket order form */
.basket-form {
  display: flex; flex-direction: column; gap: 10px;
}
.basket-form__title {
  font-size: 15px; font-weight: 700; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.basket-form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.basket-form__field { display: flex; flex-direction: column; gap: 4px; }
.basket-form__label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-tertiary);
}
.basket-submit-btn {
  width: 100%; margin-top: 4px; padding: 14px;
  font-size: 15px; font-weight: 700; border-radius: var(--radius);
  background: var(--brand); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background var(--transition), transform 0.1s;
}
.basket-submit-btn:hover { background: var(--brand-dark); }
.basket-submit-btn:active { transform: scale(0.98); }

/* ── Scrollbar styling ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }
