/* ── Table wrapper ───────────────────────────────────────────────────────── */
.fr-table-wrap {
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 1px 4px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.04);
}

/* ── Main table ──────────────────────────────────────────────────────────── */
.fr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: 'Onest', sans-serif;
  table-layout: fixed;
}
.ft-th {
  background: rgba(241,245,249,.98);
  font-size: 10px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .7px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap;
  cursor: pointer; user-select: none;
}
.ft-th:first-child { border-radius: 12px 0 0 0; }
.ft-th:last-child  { border-radius: 0 12px 0 0; }
.ft-th:hover { color: var(--text); background: rgba(235,240,246,.98); }
.ft-th.active { color: #059669; }
.ft-th-center { text-align: center; }

.fr-row {
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .08s;
}
.fr-row:last-child { border-bottom: none; }
.fr-row:hover td { background: rgba(5,150,105,.025); }
.fr-row td {
  padding: 10px 10px; vertical-align: middle;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Status — левая полоска */
.fr-row.expired  td:first-child { border-left: 3px solid #dc2626; padding-left: 7px; }
.fr-row.expiring td:first-child { border-left: 3px solid #ea580c; padding-left: 7px; }
.fr-row.low      td:first-child { border-left: 3px solid #3b82f6; padding-left: 7px; }

/* Col widths */
.ft-logo  { width: 52px; text-align: center; }
.ft-name  { width: 180px; font-weight: 600; color: var(--text); text-align: left; }
.ft-brand { width: 160px; text-align: left; }
.ft-unit  { width: 36px; text-align: center; color: var(--text-3); font-size: 11px; }
.ft-qty   { width: 90px; text-align: center; }
.ft-days  { width: 72px; text-align: center; }
.ft-exp   { width: 80px; text-align: center; font-size: 12px; }
.ft-store { width: 110px; text-align: center; }
.ft-price { width: 60px; text-align: center; font-size: 12px; color: var(--text-2); }
.ft-kbju  { width: 74px; text-align: center; overflow: visible; position: relative; z-index: 10; }

/* th центрирование через override */
th.ft-name  { text-align: left; }
th.ft-brand { text-align: left; }
th.ft-store { text-align: center; }
th.ft-price { text-align: center; }

/* Store и Price — содержимое центрировано */
td.ft-store .store-cell { justify-content: center; }
td.ft-price { text-align: center; }

/* Category / subcat rows */
.fr-cat-row td {
  padding: 0; background: rgba(248,247,245,.95) !important;
  cursor: default; border-bottom: 1px solid var(--border);
}
.fr-cat-row:first-child td { border-top: none; }
.fr-cat-inner {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
}
.fr-cat-label {
  font-size: 10px; font-weight: 700; color: #059669;
  text-transform: uppercase; letter-spacing: .08em;
  background: rgba(5,150,105,.08); border-radius: 20px;
  padding: 2px 10px; display: inline-block;
}
.fr-subcat-row td {
  padding: 4px 12px 4px 28px;
  background: rgba(248,247,245,.6) !important;
  cursor: default; border-bottom: 1px solid var(--border);
}
.fr-subcat-label {
  font-size: 10px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .05em;
}

/* ── Brand cell styling ──────────────────────────────────────────────────── */
.brand-cell {
  display: flex; align-items: center; gap: 8px;
  overflow: hidden; min-height: 36px;
}
.brand-logo-slot {
  width: 80px; min-width: 80px; height: 28px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: flex-end;
  overflow: hidden;
}
.brand-logo-slot img {
  height: 28px; width: auto; max-width: 80px; object-fit: contain; display: block;
}
.brand-logo-slot div {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
}
.brand-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1; flex: 1;
}
.brand-badge {
  font-size: 10px; font-weight: 600; color: #059669;
  background: rgba(5,150,105,.08); border-radius: 4px;
  padding: 1px 5px; flex-shrink: 0;
}

/* ── Store cell ──────────────────────────────────────────────────────────── */
.store-cell {
  display: flex; align-items: center; gap: 5px; overflow: hidden;
}
.store-name {
  font-size: 12px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Days badge with gradient ────────────────────────────────────────────── */
.days-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px; white-space: nowrap;
}
.days-badge.ok       { background: #dcfce7; color: #059669; }
.days-badge.warn     { background: #fef3c7; color: #d97706; }
.days-badge.expiring { background: #ffedd5; color: #ea580c; }
.days-badge.expired  { background: #fee2e2; color: #dc2626; }

/* Срок — цветной текст */
.exp-ok       { color: #059669; font-weight: 500; }
.exp-warn     { color: #d97706; font-weight: 500; }
.exp-expiring { color: #ea580c; font-weight: 600; }
.exp-expired  { color: #dc2626; font-weight: 700; }

/* ── Qty controls ────────────────────────────────────────────────────────── */
.fi-qty { display: flex; align-items: center; gap: 3px; justify-content: center; }
.fi-qty-btn {
  width: 20px; height: 20px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .1s; line-height: 1; flex-shrink: 0;
}
.fi-qty-btn:hover { background: var(--border); }
.fi-qty-val {
  font-size: 11px; font-weight: 600; color: var(--text);
  min-width: 28px; text-align: center;
}

/* ── Category colors ─────────────────────────────────────────────────────── */
.cat-Молочка   { background: #60a5fa; }
.cat-Мясо      { background: #f87171; }
.cat-Рыба      { background: #34d399; }
.cat-Хлеб      { background: #fbbf24; }
.cat-Напитки   { background: #818cf8; }
.cat-Бакалея   { background: #fb923c; }
.cat-Консервы  { background: #a78bfa; }
.cat-Сладости  { background: #f472b6; }
.cat-Заморозка { background: #93c5fd; }
.cat-Овощи     { background: #4ade80; }
.cat-Яйца      { background: #fde68a; }
.cat-Соусы     { background: #fdba74; }
.cat-default   { background: #d1d5db; }

/* ── Favicon logos ───────────────────────────────────────────────────────── */
.favicon-logo {
  flex-shrink: 0; object-fit: contain;
  background: var(--surface);
}

/* ── Cat-sort button in header ───────────────────────────────────────────── */
.fr-cat-sort-btn {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--text-3); padding: 0; line-height: 1;
  transition: color .12s; display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; font-family: 'Onest',sans-serif;
}
.fr-cat-sort-btn:hover { color: #059669; }
.fr-cat-sort-btn.active { color: #059669; }

/* ── Category row — collapse ─────────────────────────────────────────────── */
.fr-cat-row { cursor: pointer !important; }
.fr-cat-row td { cursor: pointer !important; }
.fr-cat-row:hover td { background: rgba(5,150,105,.04) !important; }
.fr-cat-emoji { font-size: 14px; flex-shrink: 0; }
.fr-cat-count {
  font-size: 10px; font-weight: 600; color: var(--text-3);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 1px 6px; margin-left: 4px;
}
.fr-cat-arrow { font-size: 9px; color: var(--text-3); margin-left: auto; padding-right: 6px; }

/* ── Search AC wrapper ───────────────────────────────────────────────────── */
.fridge-search-wrap { position: relative; flex: 1; max-width: 380px; }
.fridge-search-wrap .fridge-search { max-width: 100%; width: 100%; }
/* ── Store / Brand logo images ───────────────────────────────────────────── */
.store-logo-img {
  height: 28px; width: auto; max-width: 100px;
  object-fit: contain; border-radius: 3px; flex-shrink: 0;
  display: block;
}
.brand-logo-img {
  height: 28px; width: auto; max-width: 80px;
  object-fit: contain; border-radius: 3px; flex-shrink: 0;
  display: block;
}
@media (max-width: 960px) {
  .fridge-main { grid-template-columns: 1fr; }
}

/* ── Превью фото при наведении ───────────────────────────────────────────── */
.fr-img-preview {
  position: fixed; z-index: 99998; display: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px;
  box-shadow: 0 8px 32px rgba(15,23,42,.18);
  pointer-events: none;
}

/* ── Consumed action buttons ─────────────────────────────────────────────── */
.consumed-action-btn {
  height: 22px; padding: 0 6px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--bg);
  font-size: 11px; cursor: pointer; color: var(--text-2);
  display: flex; align-items: center; transition: background .1s;
  white-space: nowrap; flex-shrink: 0;
}
.consumed-action-btn:hover { background: var(--border); }
.consumed-undo-btn { color: #dc2626; border-color: #fca5a5; }
.consumed-undo-btn:hover { background: #fee2e2; }

/* ── Бренд и магазин — увеличенный шрифт ────────────────────────────────── */
.brand-name { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-name { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-cell { display: flex; align-items: center; gap: 7px; overflow: hidden; }
.store-cell { display: flex; align-items: center; gap: 7px; overflow: hidden; }

/* ── logo-wrap ───────────────────────────────────────────────────────────── */
.logo-wrap { flex-shrink: 0; position: relative; cursor: default; }

/* ── п.7: субкатегория кликабельная ─────────────────────────────────────── */
.fr-subcat-clickable { cursor: pointer !important; }
.fr-subcat-clickable:hover td { background: rgba(5,150,105,.06) !important; }
.fr-subcat-inner {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 28px;
}

/* ── п.9: КБЖУ до цены и магазина — z-index для popup ───────────────────── */
.ft-kbju { width: 74px; text-align: center; overflow: visible; position: relative; z-index: 10; }

/* ── п.5: бренд — логотип и текст строго по центру вертикали ────────────── */
.brand-cell { display: flex; align-items: center; gap: 6px; overflow: hidden; min-height: 32px; }
.brand-name { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1; }

/* ── п.10: список покупок — поле ввода ниже ─────────────────────────────── */
.sl-panel-drawer .shopping-add-row { padding-top: 16px !important; }

/* ── п.3: кнопка новой субкатегории ─────────────────────────────────────── */
#df-subcat-save { display: block; }
/* ══ п.6: группировка одинаковых ══════════════════════════════════════════ */
.fr-group-badge {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 10px; font-weight: 700; color: #059669;
  background: rgba(5,150,105,.1); border: 1px solid rgba(5,150,105,.2);
  border-radius: 10px; padding: 1px 6px; cursor: pointer;
  transition: background .1s; flex-shrink: 0;
}
.fr-group-badge:hover { background: rgba(5,150,105,.2); }
.fr-row-child td { background: rgba(5,150,105,.02) !important; }
.fr-row-child td:first-child { padding-left: 20px !important; border-left: 3px solid rgba(5,150,105,.2); }

/* ── Кнопка "Съел" в таблице ─────────────────────────────────────────────── */
.ft-consume { width: 32px; text-align: center; padding: 0 4px !important; }
.fr-consume-btn {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--border-strong); background: transparent;
  color: var(--text-3); font-size: 11px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .12s; flex-shrink: 0; margin: 0 auto;
}
.fr-consume-btn:hover { border-color: #059669; background: #059669; color: #fff; }

/* ── Размер упаковки ─────────────────────────────────────────────────────── */
.ft-pkg-size { width: 60px; text-align: center; font-size: 11px; color: var(--text-3); }
