/* ======= Кастомные стили Freezer Manager ======= */

/* Nunito (self-hosted, без Google Fonts CDN) */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/static/fonts/nunito-800-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/static/fonts/nunito-800-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('/static/fonts/nunito-900-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('/static/fonts/nunito-900-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122;
}

/* Design tokens (handoff: редизайн шапки и фильтров) */
:root {
  --brand-teal: #0E8C8B;
  --text-primary: #16323D;
  --text-secondary: #5A7884;
  --text-faint: #7E9AA4;
  --text-faintest: #9BB2BA;
  --page-bg: #EEF4F6;
  --surface: #fff;
  --border: #DCE7EB;
  --border-strong: #D2DFE3;
  --border-soft: #E1EAED;
  --border-hover: #B7CDD3;
  --danger: #DC2F38;
  --danger-bg: #FCE7E8;
  --warning: #C9781A;
  --warning-bg: #FBEDD6;

  /* Статус продукта (таблица/карточки) */
  --pill-expired-text: #B4232B;
  --pill-expired-bg: #FCE7E8;
  --dot-expired: #E0414A;
  --pill-soon-text: #8A5800;
  --pill-soon-bg: #FBEDD6;
  --dot-soon: #E39A2B;
  --pill-ok-text: #2A7D58;
  --pill-ok-bg: #E9F3EE;
  --dot-ok: #3FB683;
  --pill-none-text: #7E9AA4;
  --pill-none-bg: #EEF3F4;
  --dot-none: #C5D5DA;
  --scoroport-text: #4A52C9;
  --scoroport-bg: #E9EAFB;
  --category-band-bg: #DCEAEC;
  --category-band-border: #C6D9DD;
  --table-head-bg: #F4F8F9;
  --ui-text-primary: 16px;
  --ui-text-secondary: 13px;
  --ui-text-compact: 12px;
  --ui-text-input: 16px;
  --ui-weight-regular: 400;
  --ui-weight-medium: 600;
  --ui-weight-strong: 700;
  --ui-weight-page: 800;
}

/* Шапка (header / navbar) */
.app-navbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  min-height: 64px;
}
.app-brand {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  text-decoration: none;
}
.app-brand-logo {
  height: 42px;
  width: auto;
}
.app-brand-word {
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 900;
  font-size: 34px;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: -4px;
}
.app-brand-po { color: var(--text-primary); }
.app-brand-polochkam { color: var(--brand-teal); }

@media (max-width: 360px) {
  .app-brand-logo { height: 32px; }
  .app-brand-word { font-size: 24px; }
}
.app-nav .nav-link {
  color: var(--text-secondary);
  font-weight: 600;
}
.app-nav .nav-link.active {
  color: var(--text-primary);
  font-weight: 700;
}
.app-nav .nav-link:hover {
  color: var(--brand-teal);
}

/* Правая группа шапки: навигация + CTA вместе (desktop) */
.app-header-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

/* CTA "Добавить продукт" и иконка корзины в шапке */
.app-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-teal);
  color: #fff;
  border: none;
  border-radius: 11px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.app-add-btn:hover {
  background: #0B7574;
  color: #fff;
}
.app-add-btn-plus {
  font-size: 16px;
  line-height: 1;
}
@media (max-width: 480px) {
  .app-add-btn { padding: 9px 12px; }
  .app-add-btn-label { display: none; }
}

/* Нижнее меню (телефон) — на десктопе скрыто */
.app-bottom-nav { display: none; }
.app-bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 1;
  padding: 9px 0 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-faint);
  text-decoration: none;
}
.app-bottom-nav-item.active { color: var(--brand-teal); }
.app-bottom-nav-item svg { width: 22px; height: 22px; }
.app-bottom-nav-fab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  text-decoration: none;
}
.app-bottom-nav-fab-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--brand-teal);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  line-height: 1;
  margin-top: -20px;
  box-shadow: 0 6px 16px rgba(14, 140, 139, 0.45);
}
.app-bottom-nav-fab-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--brand-teal);
}

@media (max-width: 767px) {
  /* В шапке остаётся только логотип — навигация уходит вниз */
  .app-header-right { display: none; }
  .app-navbar {
    position: sticky;
    top: 0;
    z-index: 70;
    min-height: 0;
    padding-left: 0;
    padding-right: 0;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: 6px;
    background: var(--page-bg);
    border-bottom: none;
    backdrop-filter: none;
    box-shadow: none;
  }
  .app-navbar .container {
    justify-content: flex-start !important;
    min-width: 0;
    padding-left: 24px;
    padding-right: 24px;
    padding-top: 10px;
    padding-bottom: 10px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(22, 50, 61, 0.08);
  }
  .app-navbar .app-brand {
    margin-right: 0;
    min-width: 0;
    gap: 7px;
  }
  .app-navbar .app-brand-logo {
    height: 28px;
    width: auto;
    margin-left: 0;
  }
  .app-navbar .app-brand-word {
    font-size: 22px;
    margin-bottom: -2px;
    white-space: nowrap;
  }
  .app-navbar .navbar-brand {
    min-width: 0;
  }

  .app-bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 100%;
    max-width: 540px;
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding: 6px 6px max(10px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -6px 24px rgba(22, 50, 61, 0.09);
  }

  /* запас снизу, чтобы контент не прятался под нижним меню */
  .main-content { padding-bottom: 96px; }
  .main-content > .container {
    padding-top: 0.75rem;
  }
  .main-content > .container > .container.py-4 {
    padding-top: 0 !important;
    padding-bottom: 1rem !important;
  }
  .page-title {
    font-size: 1.6rem;
    line-height: 1.05;
    margin-bottom: 1.25rem;
  }
  .footer { display: none; }
}

/* Панель поиска и фильтров */
.freezer-filterbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-row {
  display: flex;
}
.search-field-wrapper {
  position: relative;
  width: 100%;
}
.search-field {
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 11px 14px 11px 36px;
  font-size: var(--ui-text-input);
  background: var(--surface);
  color: var(--text-primary);
}
.search-field::placeholder {
  color: var(--text-primary);
  opacity: 1;
}
.search-field-wrapper .search-field {
  padding-right: 40px;
}
.search-field:focus {
  border-color: var(--brand-teal);
  box-shadow: none;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.search-field-wrapper .input-clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

/* Кнопка-триггер "Фильтры" (мобильный) */
.filters-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 46px;
  padding: 11px 14px;
  font-size: var(--ui-text-input);
  font-weight: var(--ui-weight-regular);
  color: var(--text-primary);
  background: var(--surface);
  align-self: flex-start;
}
.filters-toggle svg {
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.filters-toggle:hover {
  border-color: var(--border-hover);
}
.filters-toggle[aria-expanded="true"] {
  border-color: var(--brand-teal);
}
.filters-toggle[aria-expanded="true"] .filters-chevron {
  transform: rotate(180deg);
}
.filters-chevron {
  transition: transform 0.18s;
}
.filters-badge {
  background: var(--brand-teal);
  color: #fff;
  border-radius: 6px;
  padding: 1px 5px;
  font-size: var(--ui-text-compact);
  font-weight: var(--ui-weight-strong);
}

/* Чипы статуса */
.chips-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
/* Группа статус-фильтров: на планшете сворачивается в кнопку-выпадашку. */
.chips-group {
  position: relative;
}
/* Кнопка-триггер «Фильтры» — по умолчанию скрыта (видна только на планшете). */
.chips-dropdown-btn {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 12px;
  font-size: var(--ui-text-secondary);
  font-weight: var(--ui-weight-medium);
  white-space: nowrap;
  cursor: pointer;
}
.chips-dropdown-btn:hover { border-color: var(--border-hover); }
.chips-dropdown-badge {
  min-width: 18px;
  text-align: center;
  border-radius: 7px;
  padding: 1px 5px;
  font-size: var(--ui-text-compact);
  background: var(--brand-teal);
  color: #fff;
}
.chips-dropdown-badge[hidden] { display: none; }
.chips-dropdown-chevron { font-size: 12px; line-height: 1; color: var(--text-faint); }
.chips-group.open .chips-dropdown-chevron { transform: rotate(180deg); }
.status-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 12px;
  font-size: var(--ui-text-secondary);
  font-weight: var(--ui-weight-medium);
}
.status-chip:hover {
  border-color: var(--border-hover);
}
.chip-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-faintest);
}
.chip-count {
  min-width: 20px;
  text-align: center;
  border-radius: 7px;
  padding: 1px 6px;
  font-size: var(--ui-text-compact);
  background: #EEF3F4;
  color: #5A7884;
}
.status-chip-danger .chip-dot { background: var(--danger); }
.status-chip-warning .chip-dot { background: var(--warning); }
.status-chip-danger.active {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}
.status-chip-danger.active .chip-count {
  background: var(--danger);
  color: #fff;
}
.status-chip-warning.active {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning);
}
.status-chip-warning.active .chip-count {
  background: var(--warning);
  color: #fff;
}

/* Селекты фильтров */
.selects-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.select-pair {
  display: flex;
  gap: 12px;
}
.select-field { flex: 1; }
.select-field .form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.select-field .form-select {
  border: 1px solid var(--border-strong);
  border-radius: 11px;
}

/* Мобильная раскрываемая панель */
.filters-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (max-width: 767px) {
  .freezer-filterbar {
    gap: 6px;
  }
  .chips-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .status-chip { width: 100%; }
  .chip-count { margin-left: auto; }
  .filters-panel:not(.open) { display: none; }
  .select-pair {
    flex-direction: column;
    gap: 10px;
  }
  .filters-panel {
    padding: 12px;
    gap: 12px;
  }
}

@media (min-width: 768px) {
  .filters-toggle { display: none; }
  .freezer-filterbar {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 14px;
  }
  /* Поиск фиксирован; при очень узком экране может сжиматься до min-width */
  .search-row { width: 260px; flex: 0 1 260px; min-width: 140px; }
  .filters-panel {
    border: none;
    padding: 0;
    background: transparent;
    flex: 1 1 auto;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 14px;
  }
  .selects-row {
    flex-direction: row;
    align-items: center;
    margin-left: auto;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    min-width: 0;
    gap: 8px;
  }
  /* На десктопе лейблы у селектов скрыты — как в макете */
  .select-field .form-label { display: none; }
  /* Три правых поля одной ширины (не даём «Категории» растягиваться под
     самую длинную опцию). Равномерно сжимаются при нехватке места, длинные
     названия обрезаются нативным "...". */
  .select-category,
  .select-freezer,
  .select-drawer {
    flex: 0 0 150px;
    width: 150px;
    min-width: 0;
  }
  .select-pair {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
    min-width: 0;
  }
  .select-field .form-select {
    display: block;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .status-chip { white-space: nowrap; }
}

/* Планшет: два статус-чипа сворачиваются в кнопку «Фильтры» с выпадашкой,
   чтобы освободить место селектам Категория/Морозилка/Ящик. */
@media (min-width: 768px) and (max-width: 1299px) {
  .chips-dropdown-btn { display: inline-flex; }
  .chips-group .chips-row {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 60;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 8px 24px rgba(22, 50, 61, 0.12);
  }
  .chips-group.open .chips-row { display: flex; }
  .chips-group .status-chip { width: 100%; }
  .chips-group .chip-count { margin-left: auto; }
}

/* Широкий десктоп: места хватает — чипы в строку с числами, кнопка скрыта. */
@media (min-width: 1300px) {
  .chips-row { flex-wrap: nowrap; flex-shrink: 0; }
}

/* Узкий планшет (портрет): фиксированные 150px не влезают — разрешаем трём
   полям сжиматься одинаково, чтобы не было горизонтального переполнения. */
@media (min-width: 768px) and (max-width: 1023px) {
  .selects-row {
    flex: 1 1 auto;
    min-width: 0;
  }
  .select-pair {
    flex: 1 1 auto;
    min-width: 0;
  }
  .select-category,
  .select-freezer,
  .select-drawer {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
  }
}

@media (max-width: 767px) {
  .selects-row,
  .select-pair,
  .select-field,
  .select-field .form-select {
    width: 100%;
    min-width: 0;
  }
}

/* Карточка-обёртка таблицы продуктов */
.products-table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(22, 50, 61, 0.04);
}
.products-table-card .products-table {
  margin-bottom: 0;
}
.products-table thead th {
  border-bottom: none !important;
}
.products-table .category-header td {
  background-color: var(--category-band-bg) !important;
  border-top: 1px solid var(--category-band-border);
  border-bottom: 1px solid var(--category-band-border);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
}
.category-count {
  font-size: 0.95em;
  color: #5E7E87;
  font-weight: 600;
  margin-left: 4px;
}
.products-table tbody tr:not(.category-header) td {
  border-top: 1px solid #EEF3F4;
}
.product-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-left: 8px;
}
.product-name-text {
  font-family: system-ui, sans-serif;
  font-weight: var(--ui-weight-regular);
  color: var(--text-primary);
}

/* Статус-пилюля и точка */
.status-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: var(--ui-text-secondary);
  font-weight: var(--ui-weight-medium);
  white-space: nowrap;
}
.status-pill.pill-expired { background: var(--pill-expired-bg); color: var(--pill-expired-text); }
.status-pill.pill-soon { background: var(--pill-soon-bg); color: var(--pill-soon-text); }
.status-pill.pill-ok { background: var(--pill-ok-bg); color: var(--pill-ok-text); }
.status-pill.pill-none { background: var(--pill-none-bg); color: var(--pill-none-text); }

.row-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.row-dot.dot-expired { background: var(--dot-expired); }
.row-dot.dot-soon { background: var(--dot-soon); }
.row-dot.dot-ok { background: var(--dot-ok); }
.row-dot.dot-none { background: var(--dot-none); }

.scoroport-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--scoroport-text);
  background: var(--scoroport-bg);
  padding: 2px 6px;
  border-radius: 5px;
}

/* Кнопка и меню действий */
.action-menu-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}
.action-menu-btn:focus,
.action-menu-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(14, 140, 139, 0.16);
  border-color: var(--brand-teal);
}
.action-menu-btn:hover {
  background: #F2F8F8;
  color: var(--brand-teal);
}
.action-menu-btn:active {
  background: #E8F2F3;
}
.action-cell .dropdown-menu,
.product-card .dropdown-menu {
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(22, 50, 61, 0.18);
  padding: 6px;
}
.action-cell .dropdown-menu .dropdown-item,
.product-card .dropdown-menu .dropdown-item {
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
}

/* Мобильные карточки продуктов */
.product-cards { display: flex; flex-direction: column; gap: 18px; }
.product-cards .category-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 2px 9px;
}
.product-cards .category-group-title .name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.product-cards .category-group-title .count {
  font-size: 12px;
  color: var(--text-faintest);
}
.product-cards .category-group-title .rule {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.product-cards-list { display: flex; flex-direction: column; gap: 10px; }
.product-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px 14px 18px;
  box-shadow: 0 1px 2px rgba(22, 50, 61, 0.04);
}
.product-card .card-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 14px 0 0 14px;
}
.product-card .card-bar.dot-expired { background: var(--dot-expired); }
.product-card .card-bar.dot-soon { background: var(--dot-soon); }
.product-card .card-bar.dot-ok { background: var(--dot-ok); }
.product-card .card-bar.dot-none { background: var(--dot-none); }
.product-card .card-top {
  min-width: 0;
}
.product-card .card-name-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.product-card .card-title-side {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1 1 auto;
}
.product-card .card-name {
  font-family: system-ui, sans-serif;
  font-weight: 400;
  font-size: 16px;
  color: var(--text-primary);
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.product-card .card-name-row .card-qty {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
}
.product-card .card-meta {
  display: flex;
  align-items: center;
  margin-top: 7px;
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 0;
}
.product-card .card-meta .location {
  min-width: 0;
  flex: 1;
}
.product-card .card-support-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.product-card .card-notes {
  margin-top: 6px;
  font-size: 12.5px;
  color: #8AA1A9;
  font-style: italic;
}
.product-card .card-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 11px;
  gap: 12px;
}

@media (min-width: 768px) {
  .product-cards { display: none; }
}
@media (max-width: 767px) {
  .products-table-card { display: none; }
}

/* Кнопки бренд-системы (формы, страницы категорий/морозилок, модалки) */
.btn-brand {
  background: var(--brand-teal);
  color: #fff;
  border: none;
  border-radius: 11px;
  font-weight: 700;
}
.btn-brand:hover,
.btn-brand:focus {
  background: #0B7574;
  color: #fff;
}
.btn-outline-neutral {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  font-weight: 600;
}
.btn-outline-neutral:hover,
.btn-outline-neutral:focus {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* Поля и селекты форм по дизайн-токенам (везде, кроме .search-field — у неё своя разметка) */
.form-control,
.form-select {
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  color: var(--text-primary);
}
.form-control:focus,
.form-select:focus {
  border-color: var(--brand-teal);
  box-shadow: none;
}
.form-label {
  color: var(--text-secondary);
  font-weight: 600;
}

/* Светлая карточка-таблица (для категорий/морозилок/сроков хранения) */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(22, 50, 61, 0.04);
}
.table-card table {
  margin-bottom: 0;
}

/* Белая карточка-панель для форм (добавление/редактирование) */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(22, 50, 61, 0.04);
  margin-bottom: 24px;
}

/* Чистая таблица ящиков внутри form-card (без table-bordered) */
.drawers-table th,
.drawers-table td {
  border-top: 1px solid var(--border);
  border-bottom: none;
}
.drawers-table thead th {
  border-top: none;
}

/* Единый стиль иконок действий в таблицах (вместо эмодзи) */
.action-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 14px;
  vertical-align: middle;
  text-decoration: none;
}
.action-icon-btn:hover {
  background: #F2F8F8;
  color: var(--brand-teal);
}
.action-icon-btn:focus,
.action-icon-btn:focus-visible,
.drawer-del-btn:focus,
.drawer-del-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(14, 140, 139, 0.16);
  border-color: var(--brand-teal);
}
.action-icon-btn:active,
.drawer-del-btn:active {
  background: #E8F2F3;
}
.edit-icon-svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor;
  flex-shrink: 0;
}
.dropdown-item .edit-icon-svg {
  display: inline-block;
  vertical-align: -0.125em;
}
.action-icon-btn.action-icon-danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
.action-icon-btn.action-icon-danger:focus,
.action-icon-btn.action-icon-danger:focus-visible,
.drawer-del-btn:focus,
.drawer-del-btn:focus-visible {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 47, 56, 0.14);
}
.action-icon-btn.action-icon-danger:active,
.drawer-del-btn:active {
  background: #FDECED;
}
.modal-close-btn {
  margin-left: auto;
  opacity: 1;
}

/* Кнопка-ссылка "+ Добавить ..." (категория/морозилка) */
.add-entity-btn {
  border-radius: 11px;
  padding: 12px 24px;
  font-weight: 600;
}
.add-entity-plus {
  font-size: 16px;
  line-height: 1;
  margin-right: 2px;
}
.flex-spacer { flex: 1; }

/* Кнопка сброса всех фильтров */
.filter-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.filter-reset-btn:hover {
  color: var(--danger);
}

/* Строка с кнопкой «Фильтры» + «Сбросить» (только мобильный) */
.filter-mobile-row {
  gap: 8px;
  justify-content: space-between;
  min-width: 0;
}
.filter-mobile-row .filters-toggle {
  flex: 1 1 auto;
  min-width: 0;
}
.filter-mobile-row .filter-reset-btn {
  flex-shrink: 0;
  font-size: 12px;
  gap: 4px;
}

/* ===== Страница «Категории» — карточки категорий ===== */
.category-search-bar {
  max-width: 540px;
}
.category-search-field-wrap {
  position: relative;
}
.category-search-icon {
  font-size: 16px;
}
.category-search-clear {
  height: 24px;
}
.cat-columns {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
@media (min-width: 1100px) {
  .cat-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 24px;
  }
}
.cat-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cat-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(22, 50, 61, 0.04);
}
.cat-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 10px 16px;
  background: var(--surface);
}
.cat-section-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
}
.cat-section-trigger {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.cat-toggle-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(13, 148, 136, 0.08);
  color: var(--accent-strong);
  flex-shrink: 0;
  transition: background-color 0.2s ease, transform 0.2s ease;
}
.cat-toggle-btn:hover {
  background: rgba(13, 148, 136, 0.14);
}
.cat-toggle-btn[aria-expanded="true"] {
  background: rgba(13, 148, 136, 0.16);
}
.cat-section-trigger i {
  font-size: 12px;
  transition: transform 0.2s ease;
}
.cat-section-trigger[aria-expanded="true"] .cat-toggle-btn i {
  transform: rotate(180deg);
}
.cat-section-title {
  font-family: system-ui, sans-serif;
  font-weight: var(--ui-weight-strong);
  font-size: 16px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.cat-section-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.cat-sublist {
  border-top: 1px solid var(--border);
  background: #FBFDFD;
}
.cat-section.is-expanded {
  border-color: #C6D9DD;
  box-shadow: 0 4px 14px rgba(22, 50, 61, 0.06);
}
.cat-section.is-expanded .cat-sublist {
  display: block;
}
.cat-subrow {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 16px;
  border-top: 1px solid #F0F5F6;
}
.cat-subrow:first-child {
  border-top: 0;
}
.cat-submarker {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #C7DADF;
  flex-shrink: 0;
}
.cat-name,
.drawer-name,
.trash-name {
  font-family: system-ui, sans-serif;
  font-weight: var(--ui-weight-regular);
  color: var(--text-primary);
  font-size: 16px;
}
.cat-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #F4F8F9;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  padding: 2px 5px 2px 8px;
  flex-shrink: 0;
}
.cat-badge-label {
  font-size: var(--ui-text-compact);
  color: var(--text-faint);
}
.cat-badge-value {
  background: #fff;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: var(--ui-text-compact);
  font-weight: var(--ui-weight-medium);
  color: var(--text-primary);
  min-width: 32px;
  text-align: center;
}
.cat-search-empty-state {
  padding: 28px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 15px;
}
@media (max-width: 768px) {
  .category-search-bar {
    max-width: none;
  }
  .cat-section-head {
    padding: 10px 14px;
    min-height: 56px;
  }
  .cat-section-actions {
    justify-content: flex-end;
  }
  .cat-section-main {
    gap: 8px;
  }
  .cat-toggle-btn {
    width: 26px;
    height: 26px;
  }
  .cat-subrow {
    flex-wrap: wrap;
    min-height: 44px;
    padding: 6px 14px;
  }
}

/* ===== Страница «Морозилки» — карточки морозилок ===== */
.freezer-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
@media (min-width: 1100px) {
  .freezer-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}
.freezer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(22, 50, 61, 0.04);
}
.freezer-card-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 14px 16px;
  background: var(--category-band-bg);
  border-bottom: 1px solid var(--border);
}
.freezer-card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.freezer-card-edit-topline {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.freezer-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}
.freezer-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.freezer-card-edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.freezer-icon {
  color: var(--brand-teal);
  font-size: 16px;
  flex-shrink: 0;
}
.freezer-name {
  font-family: system-ui, sans-serif;
  font-weight: var(--ui-weight-strong);
  font-size: 16px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.freezer-desc {
  font-size: var(--ui-text-secondary);
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 26px;
}
.freezer-name-input {
  flex: 1;
  font-weight: var(--ui-weight-strong);
  font-size: var(--ui-text-input);
  max-width: 360px;
}
.freezer-card-editbody {
  padding: 14px 16px;
}
.freezer-empty-state {
  padding: 18px 16px;
  border-top: 1px solid #F0F5F6;
  color: var(--text-faint);
  font-size: 14px;
}
.drawer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-top: 1px solid #F0F5F6;
}
.freezer-card-editbody .drawer-row {
  padding: 8px 0;
}
.drawer-num {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: #F4F8F9;
  border: 1px solid var(--border-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.drawer-num-add {
  background: transparent;
  border-style: dashed;
  color: var(--brand-teal);
}
.drawer-name {
  flex: 1;
}
.drawer-name-input {
  flex: 1;
}
.drawer-pos-input {
  width: 90px;
  flex-shrink: 0;
}
.drawer-del-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: #fff;
  color: var(--text-faintest);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.drawer-del-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
.add-drawer-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 16px;
  border: none;
  border-top: 1px dashed var(--border);
  background: #FAFCFC;
  color: var(--brand-teal);
  font-size: var(--ui-text-secondary);
  font-weight: var(--ui-weight-medium);
  text-decoration: none;
}
.add-drawer-link:hover {
  background: #F2F8F8;
  color: var(--brand-teal);
}

/* ===== Страница «Корзина» — карточка-список ===== */
.trash-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(22, 50, 61, 0.04);
}
.trash-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-top: 1px solid #F0F5F6;
}
.trash-info {
  min-width: 0;
  flex: 1;
}
.trash-title-row {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.trash-name {
  font-size: 16px;
  display: block;
  min-width: 0;
  flex: 1 1 auto;
}
.trash-qty {
  color: var(--text-primary);
  font-weight: var(--ui-weight-medium);
  white-space: nowrap;
  flex-shrink: 0;
}
.trash-qty-desktop { display: none; }
@media (min-width: 901px) {
  .trash-qty-mobile { display: none; }
  .trash-qty-desktop {
    display: block;
    min-width: 60px;
    text-align: right;
  }
}
.trash-meta {
  font-size: var(--ui-text-secondary);
  color: var(--text-faintest);
  min-width: 0;
  display: block;
  margin-top: 3px;
}
.trash-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}
.trash-actions-row .trash-restore-btn {
  flex-shrink: 0;
}
@media (min-width: 901px) {
  .trash-title-row {
    align-items: baseline;
  }
  .trash-title-row .trash-name {
    flex: 0 1 auto;
  }
  .trash-meta {
    margin-top: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
.trash-restore-btn {
  flex-shrink: 0;
  font-size: var(--ui-text-secondary);
  font-weight: var(--ui-weight-medium);
  color: var(--brand-teal);
  background: #E4F1F0;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
}
.trash-restore-btn:hover {
  opacity: 0.85;
}
@media (max-width: 900px) {
  .trash-row {
    display: block;
    padding: 14px 16px;
  }
  .trash-name {
    min-width: 0;
  }
  .trash-meta {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.4;
  }
  .trash-actions-row {
    margin-top: 10px;
  }
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem 0;
    background: transparent;
    color: var(--text-faint);
    margin-top: 2rem;
  }

  /* Категорийная строка */

  .categories-table thead th,
  .shelf-life-table thead th {
    height: 56px;
    vertical-align: middle;
  }

  /* Ячейки действий */
  td.action-cell {
    text-align: center;
    white-space: nowrap;
  }
  
  /* Адаптивность */
  @media (max-width: 768px) {
    .products-table {
      display: block;
      overflow-x: auto;
    }
  }
  
  /* Стили для кнопки сброса поиска */
.input-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
    background: none !important;
    border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

  .clear-icon {
    transition: transform 0.2s, stroke 0.2s;
    stroke: #888;
  }

  .input-clear-btn:hover .clear-icon {
    transform: rotate(90deg);
    stroke: #0d6efd;
  }

/* Статистика в одну строку */
.stats p {
  display: inline-block;
  margin-right: 2rem;
}
.products-total-summary {
  margin-bottom: 0.75rem;
}
.products-total-summary p {
  margin: 0;
}

  /* ======= Унифицированные стили для модальных окон ======= */
  
  /* Общие стили для кнопок в модальных окнах */
  .modal-footer .btn:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.6);
  }

  .modal-footer .btn-danger:focus {
    box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.6);
  }
  
  /* Минимальная ширина для модальных окон */
  .modal-dialog {
    min-width: 300px;
  }
  
