/* Frime design system · components.css
 * Стили примитивов (v0.5) и TopBar (v0.6).
 * Все цвета — через токены из design-tokens.css. НЕ хардкодить.
 */

/* ============================================================
 * Icon (Phosphor font, .ph / .ph-fill)
 * `.f-icon` — hook для querySelector и layout-поправок;
 * font-family даёт сам Phosphor через .ph / .ph-fill.
 * ============================================================ */
.f-icon {
  display: inline-block;
  vertical-align: -0.125em;
  line-height: 1;
  flex-shrink: 0;
}

/* ============================================================
 * Button (.f-btn)
 * ============================================================ */
.f-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
  letter-spacing: 0;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
  user-select: none;
}
.f-btn:focus-visible { outline: none; box-shadow: var(--f-ring); }
.f-btn:disabled { opacity: .5; cursor: not-allowed; }

/* sizes */
.f-btn-xs { height: 22px; padding: 3px 8px;  font-size: 11px; gap: 4px; }
.f-btn-sm { height: 28px; padding: 5px 10px; font-size: 12px; gap: 6px; }
.f-btn-md { height: 34px; padding: 7px 14px; font-size: 13px; gap: 8px; }

/* variants
 * Специфичность .f-btn.f-btn-* (2 класса) нужна, чтобы перебить
 * Tailwind preflight `[type=button] { background-color: initial }` (1 класс-атрибут).
 */
.f-btn.f-btn-primary {
  background: var(--f-accent);
  color: var(--f-accent-on);
  border-color: var(--f-accent);
}
.f-btn.f-btn-primary:hover:not(:disabled) {
  background: var(--f-accent-hover);
  border-color: var(--f-accent-hover);
}

.f-btn.f-btn-secondary {
  background: var(--f-surface);
  color: var(--f-text);
  border-color: var(--f-border-strong);
}
.f-btn.f-btn-secondary:hover:not(:disabled) { background: var(--f-surface-alt); }

.f-btn.f-btn-ghost {
  background: transparent;
  color: var(--f-text-muted);
  border-color: transparent;
}
.f-btn.f-btn-ghost:hover:not(:disabled) {
  background: var(--f-surface-alt);
  color: var(--f-text);
}

.f-btn.f-btn-soft {
  background: var(--f-accent-soft);
  color: var(--f-accent-text);
  border-color: transparent;
}
.f-btn.f-btn-soft:hover:not(:disabled) { background: var(--f-accent-soft-hover); }

.f-btn.f-btn-danger {
  background: var(--f-surface);
  color: var(--f-danger);
  border-color: var(--f-border);
}
.f-btn.f-btn-danger:hover:not(:disabled) { background: var(--f-danger-soft); }

/* иконки внутри кнопки — наследуют цвет, размер задаёт inline style из renderIcon */
.f-btn .ph { line-height: 1; }

/* ============================================================
 * Badge (.f-badge)
 * ============================================================ */
.f-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* sizes */
.f-badge-xs { padding: 1px 6px;  font-size: 10px; }
.f-badge-sm { padding: 2px 8px;  font-size: 11px; }
.f-badge-md { padding: 4px 10px; font-size: 12px; }

/* soft tones */
.f-badge-soft.f-badge-neutral {
  background: var(--f-surface-alt);
  color: var(--f-text-muted);
  border-color: var(--f-border);
}
.f-badge-soft.f-badge-accent  { background: var(--f-accent-soft);  color: var(--f-accent-text); }
.f-badge-soft.f-badge-success { background: var(--f-success-soft); color: var(--f-success); }
.f-badge-soft.f-badge-warning { background: var(--f-warning-soft); color: var(--f-warning); }
.f-badge-soft.f-badge-danger  { background: var(--f-danger-soft);  color: var(--f-danger); }
.f-badge-soft.f-badge-info    { background: var(--f-info-soft);    color: var(--f-info); }

/* solid tones */
.f-badge-solid.f-badge-neutral { background: var(--f-text-muted); color: var(--f-surface); }
.f-badge-solid.f-badge-accent  { background: var(--f-accent);     color: var(--f-accent-on); }
.f-badge-solid.f-badge-success { background: var(--f-success);    color: #fff; }
.f-badge-solid.f-badge-warning { background: var(--f-warning);    color: #fff; }
.f-badge-solid.f-badge-danger  { background: var(--f-danger);     color: #fff; }
.f-badge-solid.f-badge-info    { background: var(--f-info);       color: #fff; }

/* ============================================================
 * Card (.f-card)
 * ============================================================ */
.f-card {
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-md);
  box-shadow: var(--f-shadow-sm);
  overflow: hidden;
  color: var(--f-text);
}
.f-card-flush { box-shadow: none; }

/* ============================================================
 * KVRow (.f-kv)
 * ============================================================ */
.f-kv {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--f-divider);
}
.f-kv-last { border-bottom: none; }
.f-kv-k {
  color: var(--f-text-muted);
  flex-shrink: 0;
}
.f-kv-v {
  color: var(--f-text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  /* Значение занимает всё свободное место справа от ключа, выравнивается
     по правому краю. Длинные значения переносятся, а не обрезаются. */
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ============================================================
 * FilterChip (.f-chip)
 * ============================================================ */
.f-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-sm);
  color: var(--f-text);
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
  transition: background-color .15s, border-color .15s;
}
.f-chip:hover { background: var(--f-surface-alt); }
.f-chip:focus-visible { outline: none; box-shadow: var(--f-ring); }
.f-chip-label { color: var(--f-text-muted); }
.f-chip-value { font-weight: 500; }

/* ============================================================
 * TopBar (.f-topbar)
 * ============================================================ */
.f-topbar {
  border-bottom: 1px solid var(--f-border);
  background: var(--f-surface);
  padding: 10px 20px;
}
.f-topbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.f-topbar-title-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.f-topbar-crumb {
  font-size: 12px;
  color: var(--f-text-subtle);
}
.f-topbar-crumb--link {
  text-decoration: none;
  cursor: pointer;
  transition: color .12s ease-out;
}
.f-topbar-crumb--link:hover {
  color: var(--f-text);
  text-decoration: underline;
}
.f-topbar-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 8px;
  border-radius: var(--r-sm, 6px);
  background: transparent;
  text-decoration: none;
  flex-shrink: 0;
  transition: background .12s ease-out;
}
.f-topbar-back:hover {
  background: var(--f-surface-alt);
}
.f-topbar-title {
  font-size: 14px;
  color: var(--f-text);
  font-weight: 600;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.f-topbar-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.f-topbar-filters {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* ============================================================
 * Text color utilities
 * ============================================================ */
.f-text         { color: var(--f-text); }
.f-text-muted   { color: var(--f-text-muted); }
.f-text-subtle  { color: var(--f-text-subtle); }

/* frime-components v0.5+0.6 complete */

/* ============================================================
 * PinModal (v0.8)
 * ============================================================ */
.f-pin-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: f-pin-fade-in .15s ease-out;
}
@keyframes f-pin-fade-in {
  from { opacity: 0 }
  to   { opacity: 1 }
}
.f-pin-modal {
  width: min(420px, calc(100vw - 32px));
  background: var(--f-surface);
  color: var(--f-text);
  border: 1px solid var(--f-border);
  border-radius: var(--r-md);
  box-shadow: var(--f-shadow-lg);
  overflow: hidden;
  animation: f-pin-pop-in .18s ease-out;
  outline: none;
}
@keyframes f-pin-pop-in {
  from { opacity: 0; transform: scale(.96) }
  to   { opacity: 1; transform: scale(1) }
}
.f-pin-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--f-divider);
  display: flex;
  align-items: center;
  gap: 8px;
}
.f-pin-head-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--f-text);
}
.f-pin-head-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--f-text-subtle);
  padding: 4px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.f-pin-head-close:hover {
  background: var(--f-surface-alt);
  color: var(--f-text);
}
.f-pin-body {
  padding: 18px;
}
.f-pin-subtitle {
  font-size: 12px;
  color: var(--f-text-muted);
  margin-bottom: 14px;
  text-align: center;
}
.f-pin-summary {
  margin-bottom: 16px;
  padding: 10px 12px;
  background: var(--f-surface-alt);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--f-text);
}
.f-pin-dots {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 18px 0;
}
.f-pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--f-border-strong);
  transition: all .15s;
}
.f-pin-dot-filled {
  background: var(--f-accent);
  border-color: var(--f-accent);
}
.f-pin-error {
  color: var(--f-danger);
  font-size: 11.5px;
  text-align: center;
  margin-top: 8px;
  min-height: 16px;
}
.f-pin-shake {
  animation: f-pin-shake .3s ease-in-out;
}
@keyframes f-pin-shake {
  0%, 100% { transform: translateX(0) }
  25%      { transform: translateX(-6px) }
  75%      { transform: translateX(6px) }
}
.f-pin-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 18px;
}
.f-pin-key {
  height: 54px;
  min-width: 48px;
  background: var(--f-surface-alt);
  border: 1px solid var(--f-border);
  border-radius: var(--r-md);
  font-size: 18px;
  font-weight: 500;
  color: var(--f-text);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  cursor: pointer;
  transition: background-color .1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.f-pin-key:hover {
  background: var(--f-surface);
}
.f-pin-key:active {
  background: var(--f-border);
}
.f-pin-key:disabled {
  opacity: 0;
  pointer-events: none;
}
.f-pin-key-icon {
  font-size: 22px;
}
.f-pin-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--f-divider);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: var(--f-bg);
}

/* ============================================================
 * Context Menu (.f-ctx-*)
 * Popover-меню с Promise-API (showContextMenu → id|null).
 * ============================================================ */
.f-ctx-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: transparent;
}
.f-ctx-menu {
  position: absolute;
  min-width: 180px;
  max-width: 280px;
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-md);
  box-shadow: var(--f-shadow-lg);
  padding: 4px;
  overflow: hidden;
  font-size: 12px;
  color: var(--f-text);
  animation: f-ctx-in 0.12s ease-out;
}
@keyframes f-ctx-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.f-ctx-header {
  padding: 6px 10px 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--f-text-subtle);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.f-ctx-divider {
  height: 1px;
  background: var(--f-divider);
  margin: 4px 0;
}
.f-ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: var(--f-text);
  cursor: pointer;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  line-height: 1;
}
.f-ctx-item:hover:not(:disabled),
.f-ctx-item.f-ctx-focus:not(:disabled) { background: var(--f-surface-alt); }
.f-ctx-item:disabled { opacity: .4; cursor: not-allowed; }
.f-ctx-icon {
  font-size: 16px !important;
  color: var(--f-text-subtle);
  flex-shrink: 0;
  width: 16px;
}
.f-ctx-label { flex: 1; min-width: 0; }
.f-ctx-shortcut {
  font-size: 10px;
  color: var(--f-text-subtle);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
.f-ctx-chevron {
  font-size: 14px !important;
  color: var(--f-text-subtle);
}
.f-ctx-danger { color: var(--f-danger); }
.f-ctx-danger .f-ctx-icon { color: var(--f-danger); }
.f-ctx-danger:hover:not(:disabled),
.f-ctx-danger.f-ctx-focus:not(:disabled) { background: var(--f-danger-soft); }

/* ============================================================
 * Sidebar (Frime v2)
 * ============================================================ */
.f-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--f-surface-sunken);
  border-right: 1px solid var(--f-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  color: var(--f-text);
  overflow: hidden;
  /* Transition в обе стороны (expanded ↔ rail). */
  transition: width 280ms cubic-bezier(.22, 1, .36, 1);
}

.f-sidebar-head {
  padding: 12px 12px 8px;
  flex-shrink: 0;
  position: relative;
}

.f-venue-picker {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: inherit;
  transition: background-color .15s;
}
.f-venue-picker.clickable:hover { background: var(--f-surface-alt); }
.f-venue-picker[disabled],
.f-venue-picker.static { cursor: default; }

.f-brand-badge {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--f-accent);
  color: var(--f-accent-on);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.3px;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.f-venue-info { flex: 1; min-width: 0; }
.f-venue-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--f-text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.f-venue-sub {
  font-size: 10px;
  color: var(--f-text-subtle);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.f-search-trigger {
  margin-top: 6px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-sm);
  font-size: 11px;
  color: var(--f-text-subtle);
  font-family: inherit;
  cursor: pointer;
  transition: background-color .15s;
}
.f-search-trigger:hover { background: var(--f-surface-alt); }
.f-search-trigger-label { flex: 1; text-align: left; }

.f-kbd {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  padding: 1px 4px;
  border: 1px solid var(--f-border);
  border-radius: 3px;
  color: var(--f-text-subtle);
  background: var(--f-surface-alt);
}

.f-sidebar-nav {
  flex: 1;
  padding: 4px 8px 8px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}
.f-sidebar-nav::-webkit-scrollbar { width: 4px; }
.f-sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.f-sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .08);
  border-radius: 4px;
}
.dark .f-sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .08); }

.f-nav-group { margin-bottom: 8px; }
.f-nav-group-title {
  padding: 8px 8px 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--f-text-subtle);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.f-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  margin: 1px 0;
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--f-text-muted);
  font-weight: 450;
  background: transparent;
  text-decoration: none;
  transition: background-color .12s, color .12s;
}
.f-nav-item .ph {
  font-size: 15px;
  color: var(--f-text-subtle);
  flex-shrink: 0;
}
.f-nav-item-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 160ms ease, max-width 240ms cubic-bezier(.22, 1, .36, 1);
  opacity: 1;
  max-width: 240px;
}
.f-nav-item:hover {
  background: var(--f-surface-alt);
  color: var(--f-text);
}
.f-nav-item-active {
  background: var(--f-accent-soft);
  color: var(--f-accent-text);
  font-weight: 600;
}
.f-nav-item-active .ph { color: var(--f-accent-text); }
.f-nav-item-active:hover { background: var(--f-accent-soft-hover); color: var(--f-accent-text); }

/* Trailing decorations inside .f-nav-item: числовой счётчик, pill-бейдж, точка-индикатор */
.f-nav-item-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--f-text-subtle);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.f-nav-item-pill {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--f-accent-text);
  background: var(--f-accent-soft);
  padding: 1px 7px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
  line-height: 1.3;
}
.f-nav-item-active .f-nav-item-pill { background: rgba(90, 26, 36, .12); }
.dark .f-nav-item-active .f-nav-item-pill { background: rgba(217, 160, 168, .18); }
.f-nav-item-dot {
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--f-warning);
  flex-shrink: 0;
}

.f-sidebar-foot {
  flex-shrink: 0;
  padding: 10px;
  border-top: 1px solid var(--f-border);
  position: relative;
}

.f-user-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: inherit;
  padding: 4px;
  border-radius: var(--r-sm);
  transition: background-color .12s;
}
.f-user-row:hover { background: var(--f-surface-alt); }

.f-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--f-chart-2), var(--f-chart-4));
  background-size: cover;
  background-position: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.f-user-info { flex: 1; min-width: 0; }
.f-user-name {
  font-size: 11.5px;
  color: var(--f-text);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.f-user-role {
  font-size: 10px;
  color: var(--f-text-subtle);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.f-sidebar-devtools {
  border-top: 1px solid var(--f-border);
  padding: 6px 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.f-sidebar-devtools-label {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--f-danger);
  line-height: 1;
  flex-shrink: 0;
}
.f-sidebar-devtools select {
  background: transparent;
  border: none;
  font-size: 11px;
  color: var(--f-text-muted);
  flex: 1;
  min-width: 0;
  padding: 0;
  cursor: pointer;
}
.f-sidebar-devtools select:focus {
  outline: none;
  box-shadow: var(--f-ring);
}
.f-sidebar-devtools-add {
  color: var(--f-danger);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.f-sidebar-devtools-add:hover { background: var(--f-danger-soft); }

/* Sidebar head row: поиск + колокольчик уведомлений */
.f-sidebar-head-row {
  margin-top: 6px;
  display: flex;
  align-items: stretch;
  gap: 6px;
  position: relative;
}
.f-sidebar-head-row .f-search-trigger { margin-top: 0; flex: 1; min-width: 0; }
.f-notif-bell {
  position: relative;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-sm);
  color: var(--f-text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: background-color .15s, color .15s;
}
.f-notif-bell:hover { background: var(--f-surface-alt); color: var(--f-text); }
.f-notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  background: var(--f-danger);
  border: 2px solid var(--f-surface-sunken);
  border-radius: var(--r-pill);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.f-notif-anchor { position: absolute; left: 0; top: 100%; margin-top: 4px; z-index: 50; }

/* ============================================================
 * Sidebar rail mode — когда пользователь находится в настройках.
 * Схлопывает .f-sidebar до 56px. Transition width — на .f-sidebar;
 * внутренние элементы плавно растворяются через opacity+max-width.
 * ============================================================ */
body[data-sidebar-mode="rail"] .f-sidebar { width: var(--sidebar-rail-w); }

/* Shared transition props для «скрываемых» частей сайдбара */
.f-venue-info,
.f-nav-item-label,
.f-nav-item-pill,
.f-nav-item-count,
.f-user-info,
.f-sidebar-head-row,
.f-nav-group-title {
  transition: opacity 140ms ease, max-width 260ms cubic-bezier(.22, 1, .36, 1),
              margin 260ms cubic-bezier(.22, 1, .36, 1), padding 260ms cubic-bezier(.22, 1, .36, 1);
}

/* ВАЖНО: все правила rail-режима scoped к .f-sidebar — чтобы не затрагивать
   .f-subnav (второй сайдбар настроек использует те же классы .f-nav-item
   / .f-nav-group-title / .f-nav-item-label и должен оставаться раскрытым). */
body[data-sidebar-mode="rail"] .f-sidebar .f-venue-info,
body[data-sidebar-mode="rail"] .f-sidebar .f-nav-item-label,
body[data-sidebar-mode="rail"] .f-sidebar .f-nav-item-pill,
body[data-sidebar-mode="rail"] .f-sidebar .f-nav-item-count,
body[data-sidebar-mode="rail"] .f-sidebar .f-user-info {
  opacity: 0;
  max-width: 0;
  margin: 0;
  pointer-events: none;
}

/* Service блоки, которые нужно свернуть по высоте (не только ширине) */
body[data-sidebar-mode="rail"] .f-sidebar .f-sidebar-head-row,
body[data-sidebar-mode="rail"] .f-sidebar .f-nav-group-title {
  opacity: 0;
  max-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
}
.f-sidebar-head-row,
.f-sidebar .f-nav-group-title { max-height: 40px; overflow: hidden; }

body[data-sidebar-mode="rail"] .f-sidebar .f-sidebar-head {
  padding: 10px 0;
  display: flex;
  justify-content: center;
  transition: padding 260ms cubic-bezier(.22, 1, .36, 1);
}
body[data-sidebar-mode="rail"] .f-sidebar .f-venue-picker {
  width: auto;
  padding: 4px;
  justify-content: center;
  gap: 0;
}
body[data-sidebar-mode="rail"] .f-sidebar .f-venue-picker > .ph,
body[data-sidebar-mode="rail"] .f-sidebar #venue-selector-dropdown,
body[data-sidebar-mode="rail"] .f-sidebar .f-sidebar-devtools { display: none; }

body[data-sidebar-mode="rail"] .f-sidebar .f-nav-group { margin-bottom: 4px; }
body[data-sidebar-mode="rail"] .f-sidebar .f-sidebar-nav { padding: 6px 6px 8px; }

body[data-sidebar-mode="rail"] .f-sidebar .f-nav-item {
  justify-content: center;
  padding: 9px 0;
  gap: 0;
  position: relative;
  transition: background-color .12s, color .12s, padding 240ms cubic-bezier(.22, 1, .36, 1), gap 240ms cubic-bezier(.22, 1, .36, 1);
}
.f-nav-item { transition: background-color .12s, color .12s, padding 240ms cubic-bezier(.22, 1, .36, 1), gap 240ms cubic-bezier(.22, 1, .36, 1); }

body[data-sidebar-mode="rail"] .f-sidebar .f-nav-item-dot {
  position: absolute;
  top: 6px;
  right: 10px;
  margin-left: 0;
}

body[data-sidebar-mode="rail"] .f-sidebar .f-sidebar-foot { padding: 8px 6px; transition: padding 260ms cubic-bezier(.22, 1, .36, 1); }
body[data-sidebar-mode="rail"] .f-sidebar .f-user-row { justify-content: center; padding: 4px; gap: 0; }
body[data-sidebar-mode="rail"] .f-sidebar .f-user-row > .ph { display: none; }

/* CSS-only tooltip в rail-режиме. Появляется справа от пункта при hover.
   Scope к .f-sidebar — в .f-subnav tooltip не нужен, там полные label'ы. */
body[data-sidebar-mode="rail"] .f-sidebar .f-nav-item[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--f-text);
  color: var(--f-bg);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: var(--f-shadow);
  z-index: 100;
  pointer-events: none;
  font-weight: 500;
}
/* Tooltip не должен обрезаться overflow:hidden сайдбара */
body[data-sidebar-mode="rail"] .f-sidebar { overflow: visible; }
body[data-sidebar-mode="rail"] .f-sidebar .f-sidebar-nav { overflow-x: visible; }

@media (prefers-reduced-motion: reduce) {
  .f-sidebar,
  .f-venue-info,
  .f-nav-item-label,
  .f-nav-item-pill,
  .f-nav-item-count,
  .f-user-info,
  .f-sidebar-head-row,
  .f-nav-group-title,
  .f-nav-item { transition: none !important; }
}

/* ============================================================
 * Settings sub-sidebar — вторая колонка рядом с rail-сайдбаром,
 * содержит разделы настроек (Структура / Интеграции / Уведомления ...).
 * ============================================================ */
.f-subnav {
  width: var(--subnav-w);
  flex-shrink: 0;
  background: var(--f-surface-alt);
  border-right: 1px solid var(--f-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  color: var(--f-text);
  overflow: hidden;
}
.f-subnav-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--f-divider);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-shrink: 0;
}
.f-subnav-title { font-weight: 700; font-size: 15px; letter-spacing: -.01em; line-height: 1.2; }
.f-subnav-sub { font-size: 11.5px; color: var(--f-text-subtle); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-subnav-exit {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--f-text-muted);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}
.f-subnav-exit:hover { background: var(--f-surface); color: var(--f-text); }

.f-subnav-search { padding: 10px 12px 8px; flex-shrink: 0; }
.f-subnav-search .f-search-trigger { margin-top: 0; }

.f-subnav-body {
  padding: 4px 8px 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.f-subnav-body::-webkit-scrollbar { width: 6px; }
.f-subnav-body::-webkit-scrollbar-thumb { background: var(--f-border-strong); border-radius: 6px; }

/* ============================================================
 * Global focus-visible для v2-интерактивов
 * Унифицированное кольцо фокуса (--f-ring) для клавиатурной навигации.
 * ============================================================ */
.f-nav-item:focus-visible,
.f-user-row:focus-visible,
.f-search-trigger:focus-visible,
.f-venue-picker:focus-visible,
.f-notif-bell:focus-visible,
.f-modal-close:focus-visible,
.f-pin-head-close:focus-visible,
.f-fdp-day:focus-visible,
.f-fdp-preset:focus-visible,
.f-fdp-nav-btn:focus-visible,
.f-fdp-compare:focus-visible,
.f-ctx-item:focus-visible,
.f-menu-subtab:focus-visible,
.f-settings-day:focus-visible,
.f-settings-menu-item:focus-visible,
.f-stop-cat-btn:focus-visible,
.f-chip-check:focus-visible,
.f-tile:focus-visible,
.f-topbar-back:focus-visible,
.f-topbar-crumb--link:focus-visible,
.f-subnav-exit:focus-visible {
  outline: none;
  box-shadow: var(--f-ring);
}

/* Reduced motion: отключить анимации если пользователь просит */
@media (prefers-reduced-motion: reduce) {
  .f-btn, .f-chip, .f-notif-bell, .f-nav-item, .f-user-row, .f-venue-picker,
  .f-search-trigger, .f-menu-card, .f-editor-card, .f-menu-subtab,
  .f-settings-day, .f-settings-menu-item, .f-chip-check, .f-tile {
    transition: none !important;
  }
  .f-ctx-menu, .f-pin-backdrop, .f-pin-modal,
  .f-modal-backdrop, .f-modal,
  .f-fdp, .f-areachart--animate, .f-pin-shake,
  .f-menu-list-loading .ph {
    animation: none !important;
  }
}

/* =========================================================================
   Dashboard v2 — sections, cards, charts
   ========================================================================= */

/* Dashboard layout */
.f-dash-root { padding: 16px; overflow: auto; flex: 1; min-height: 0; }
.f-dash-kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
/* Grid items с min-width: auto расширяются из-за intrinsic content
 * (sparkline 80px, длинный value_fmt). min-width: 0 + overflow: hidden
 * — гарантия что все колонки одинаковой ширины. */
.f-dash-kpi-strip > * { min-width: 0; overflow: hidden; }
/* Одинаковая высота всех карточек независимо от наличия sparkline
 * в foot. 108px = head 20px + margin 6 + value 24 + margin 6 + foot
 * 22 + padding 12*2 + border 2 = ~108px. */
.f-dash-kpi-strip > .f-card { min-height: 108px; }
.f-dash-main-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.f-dash-left-col, .f-dash-right-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* KPI card */
.f-kpi-card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.f-kpi-card-label { font-size: 11px; color: var(--f-text-muted); }
.f-kpi-card-value { font-size: 20px; font-weight: 600; letter-spacing: -0.4px; font-variant-numeric: tabular-nums; color: var(--f-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-kpi-card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; min-height: 22px; }
.f-kpi-card-sub { font-size: 10.5px; color: var(--f-text-subtle); }

/* Sparkline — фикс размер. Без этого SVG с display:block внутри flex-контейнера
 * может "растянуться" по ширине колонки, а высота пересчитаться по viewBox-
 * пропорциям → первая карточка становится выше остальных. */
.f-sparkline { width: 80px; height: 22px; flex: 0 0 auto; }

/* Revenue chart card */
.f-rev-chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.f-rev-chart-title { font-size: 13px; font-weight: 600; color: var(--f-text); }
.f-rev-chart-sub { font-size: 11px; color: var(--f-text-subtle); margin-top: 1px; }
.f-rev-chart-legend { display: flex; gap: 12px; font-size: 11px; }
.f-rev-chart-legend-item { display: flex; align-items: center; gap: 4px; color: var(--f-text-muted); }
.f-rev-chart-dot { width: 8px; height: 8px; border-radius: 2px; }

/* BarChart — группированные столбики "Выручка по часам" */
.f-barchart { position: relative; width: 100%; display: block; }
.f-barchart-grid {
  position: absolute; left: 0; right: 0; top: 0; bottom: 24px;
  display: flex; flex-direction: column; justify-content: space-between;
  pointer-events: none;
}
.f-barchart-gridline { border-top: 1px solid var(--f-divider); height: 0; }
.f-barchart-bars {
  display: flex; align-items: flex-end; gap: 4px;
  height: 100%; padding-bottom: 24px;
  position: relative;
}
.f-barchart-slot {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
  height: 100%;
  position: relative;
}
.f-barchart-slot-bars {
  flex: 1; width: 100%;
  position: relative;
  display: flex; justify-content: center; align-items: flex-end;
}
.f-barchart-bar-secondary {
  position: absolute; bottom: 0; left: 8%; right: 8%;
  background: var(--f-border); border-radius: 2px;
  min-height: 0;
}
.f-barchart-bar-primary {
  position: relative; width: 50%;
  background: var(--f-accent); border-radius: 2px;
  min-height: 0;
  z-index: 1;
}
.f-barchart-label {
  position: absolute; bottom: 0;
  font-size: 9px; color: var(--f-text-subtle);
  white-space: nowrap;
  transform: translateY(16px);
}

/* AreaChart — SVG line chart с area fill */
.f-areachart {
  overflow: visible;
}
.f-areachart text {
  user-select: none;
  pointer-events: none;
}

/* Orders live table */
.f-orders-card-head { padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--f-divider); }
.f-orders-title { font-size: 13px; font-weight: 600; color: var(--f-text); }
.f-orders-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.f-orders-table thead tr { background: var(--f-surface-alt); color: var(--f-text-muted); }
.f-orders-table th { text-align: left; padding: 6px 12px; font-weight: 500; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--f-border); white-space: nowrap; }
.f-orders-table td { padding: 7px 12px; border-bottom: 1px solid var(--f-divider); }
.f-orders-table tr:last-child td { border-bottom: none; }
.f-orders-time { font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--f-text-muted); font-size: 11px; }
.f-orders-num { font-weight: 500; color: var(--f-accent-text); }
.f-orders-muted { color: var(--f-text-muted); }
.f-orders-tabular { font-variant-numeric: tabular-nums; }

/* Shift block */
.f-shift-card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.f-shift-title { font-size: 13px; font-weight: 600; color: var(--f-text); }
.f-shift-meta { font-size: 10.5px; color: var(--f-text-subtle); }
.f-shift-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--f-divider); }
.f-shift-row:last-child { border-bottom: none; }
.f-shift-pos { width: 52px; font-size: 11px; color: var(--f-text-muted); }
.f-shift-avatars { flex: 1; display: flex; gap: 3px; flex-wrap: wrap; }
.f-shift-avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--f-surface-alt); border: 1px solid var(--f-border); display: flex; align-items: center; justify-content: center; font-size: 9px; color: var(--f-text-muted); flex-shrink: 0; }
.f-shift-counter { font-size: 11px; color: var(--f-text-muted); font-variant-numeric: tabular-nums; }
.f-shift-counter-warning { color: var(--f-warning); }

/* Stop list */
.f-stop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.f-stop-title { font-size: 13px; font-weight: 600; color: var(--f-text); flex-shrink: 0; }
.f-stop-row { padding: 6px 0; font-size: 11.5px; border-bottom: 1px solid var(--f-divider); }
.f-stop-row:last-child { border-bottom: none; }
.f-stop-name { font-weight: 500; color: var(--f-text); }
.f-stop-meta { color: var(--f-text-subtle); font-size: 10.5px; margin-top: 1px; }
.f-stop-cats { display: flex; gap: 4px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
.f-stop-cats::-webkit-scrollbar { display: none; }
.f-stop-cat-btn { flex-shrink: 0; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; color: var(--f-text-subtle); background: var(--f-surface-alt); border: none; cursor: pointer; transition: background .15s, color .15s; }
.f-stop-cat-btn:hover { background: var(--f-surface); color: var(--f-text); }
.f-stop-cat-btn.active { background: var(--f-accent); color: #fff; }
.f-stop-scroll { max-height: 220px; overflow-y: auto; scrollbar-width: thin; }

/* Revenue chart tooltip */
.f-chart-tooltip { display:none; position:fixed; z-index:200; pointer-events:none; background:var(--f-surface); border:1px solid var(--f-divider); border-radius:6px; padding:6px 10px; box-shadow:0 2px 8px rgba(0,0,0,.12); min-width:80px; }
.f-chart-tip-label { font-size:10px; color:var(--f-text-subtle); margin-bottom:2px; }
.f-chart-tip-cur { font-size:12px; font-weight:600; color:var(--f-text); }
.f-chart-tip-cmp { font-size:11px; color:var(--f-text-subtle); margin-top:1px; }

/* Area chart intro animation (только при первом рендере) */
.f-areachart--animate { animation: f-chart-in 0.45s cubic-bezier(0.4,0,0.2,1) both; }
@keyframes f-chart-in {
    from { opacity: 0; transform: scaleY(0.92); transform-origin: bottom; }
    to { opacity: 1; transform: scaleY(1); }
}

/* Top items */
.f-top-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.f-top-title { font-size: 13px; font-weight: 600; color: var(--f-text); flex-shrink: 0; }
.f-top-row { padding: 5px 0; font-size: 11.5px; }
.f-top-row-head { display: flex; justify-content: space-between; margin-bottom: 3px; }
.f-top-bar { height: 3px; background: var(--f-surface-alt); border-radius: 2px; overflow: hidden; }
.f-top-bar-fill { height: 100%; background: var(--f-accent); border-radius: 2px; transition: width .3s ease; }

/* TopBar meta (правая сторона filters row — "Обновлено HH:mm · авто") */
.f-topbar-meta {
  font-size: 11px;
  color: var(--f-text-subtle);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* TopBar tabs (ряд табов под title-row, подчёркнутые вкладки) */
.f-topbar-tabs {
  display: flex;
  align-items: center;
  margin-top: 6px;
  margin-left: -4px;
}

/* TopBar c табами — нижний padding убираем у корня, чтобы tab-underline сидел на границе */
.f-topbar--with-tabs > .f-topbar-row { padding-bottom: 0; }
/* Filters-ряд под tabs отделён divider'ом сверху + собственный отступ */
.f-topbar-filters--with-tabs {
  border-top: 1px solid var(--f-divider);
  margin-top: 0;
  padding-top: 10px;
}

/* Segmented control — pill (default) */
.f-seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--f-surface-alt);
  border: 1px solid var(--f-border);
  border-radius: var(--r-sm);
}

.f-seg-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  font-size: 12px;
  line-height: 1;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background-color .15s, color .15s, border-color .15s;
  letter-spacing: 0;
  background: transparent;
  color: var(--f-text-muted);
  font-weight: 500;
}

.f-seg-btn--active {
  background: var(--f-accent-soft);
  color: var(--f-accent-text);
  font-weight: 600;
}

.f-seg-btn:hover:not(.f-seg-btn--active) {
  background: var(--f-surface);
  color: var(--f-text);
}

.f-seg-btn:focus-visible {
  outline: none;
  box-shadow: var(--f-ring);
}

/* Segmented — underline-variant (для табов TopBar по дизайн-макету) */
.f-seg--underline {
  background: transparent;
  border: none;
  padding: 0;
  gap: 0;
  border-radius: 0;
}
.f-seg--underline .f-seg-btn {
  padding: 8px 14px 9px;
  font-size: 12.5px;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.f-seg--underline .f-seg-btn--active {
  background: transparent;
  color: var(--f-accent-text);
  border-bottom-color: var(--f-accent);
  font-weight: 600;
}
.f-seg--underline .f-seg-btn:hover:not(.f-seg-btn--active) {
  background: transparent;
  color: var(--f-text);
}

/* Empty state */
.f-dash-empty { padding: 40px 20px; text-align: center; color: var(--f-text-subtle); font-size: 12px; }

/* Responsive: KPI-strip на узких экранах */
@media (max-width: 1280px) {
  .f-dash-kpi-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .f-dash-kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .f-dash-main-grid { grid-template-columns: 1fr; }
}

/* ============================================================
 * FrimeDatePicker (.f-fdp*)
 * Макет: presets (160px) + calendars (2 месяца). Используется из
 * frontend/js/components/FrimeDatePicker.js.
 * ============================================================ */
.f-fdp-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: transparent;
}

.f-fdp {
  position: absolute;
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-md);
  box-shadow: var(--f-shadow-lg);
  display: flex;
  overflow: hidden;
  font-size: 12px;
  color: var(--f-text);
  animation: f-fdp-in .12s ease-out;
  max-width: calc(100vw - 32px);
}
@keyframes f-fdp-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.f-fdp-presets {
  width: 160px;
  flex-shrink: 0;
  border-right: 1px solid var(--f-divider);
  padding: 10px 0;
  background: var(--f-surface-sunken);
  display: flex;
  flex-direction: column;
}
.f-fdp-preset {
  padding: 7px 14px;
  font-size: 12px;
  color: var(--f-text);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  border-left: 2px solid transparent;
  font-family: inherit;
  transition: background-color .1s;
}
.f-fdp-preset:hover { background: var(--f-surface-alt); }
.f-fdp-preset-active {
  background: var(--f-accent-soft);
  color: var(--f-accent-text);
  font-weight: 600;
  border-left-color: var(--f-accent);
}
.f-fdp-preset-divider {
  border-top: 1px solid var(--f-divider);
  margin: 6px 0 0;
}
.f-fdp-preset-title {
  padding: 10px 14px 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--f-text-subtle);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.f-fdp-compare {
  padding: 5px 14px;
  font-size: 12px;
  color: var(--f-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.f-fdp-compare:hover { color: var(--f-text); }

.f-fdp-calendars {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.f-fdp-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.f-fdp-nav-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--f-text-muted);
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-family: inherit;
}
.f-fdp-nav-btn:hover {
  background: var(--f-surface-alt);
  color: var(--f-text);
}
.f-fdp-input {
  width: 92px;
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid var(--f-accent);
  border-radius: 6px;
  color: var(--f-text);
  background: var(--f-accent-soft);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.f-fdp-days-count {
  font-size: 11px;
  color: var(--f-text-subtle);
  flex: 1;
}

.f-fdp-months {
  display: flex;
  gap: 20px;
}
.f-fdp-month-title {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 10px;
  color: var(--f-text);
}
.f-fdp-grid {
  display: grid;
  grid-template-columns: repeat(7, 32px);
  gap: 2px;
}
.f-fdp-dow {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--f-text-subtle);
  text-transform: uppercase;
  padding: 4px 0;
}
.f-fdp-day {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--f-text);
  cursor: pointer;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.f-fdp-day:hover:not(.f-fdp-day-in-range):not(.f-fdp-day-start):not(.f-fdp-day-end):not(.f-fdp-day-empty) {
  background: var(--f-surface-alt);
}
.f-fdp-day-weekend { color: var(--f-text-subtle); }
.f-fdp-day-in-range {
  background: var(--f-accent-soft);
  color: var(--f-accent-text);
  border-radius: 0;
}
.f-fdp-day-start {
  background: var(--f-accent);
  color: var(--f-accent-on);
  font-weight: 700;
  border-radius: 6px 0 0 6px;
}
.f-fdp-day-end {
  background: var(--f-accent);
  color: var(--f-accent-on);
  font-weight: 700;
  border-radius: 0 6px 6px 0;
}
.f-fdp-day-start.f-fdp-day-end { border-radius: 6px; }
.f-fdp-day-empty { cursor: default; }

.f-fdp-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--f-divider);
}
.f-fdp-hint {
  font-size: 11px;
  color: var(--f-text-subtle);
}
.f-fdp-hint kbd {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--f-border);
  border-radius: 3px;
  background: var(--f-surface-alt);
  color: var(--f-text-subtle);
}
.f-fdp-actions {
  display: flex;
  gap: 6px;
}

@media (max-width: 640px) {
  .f-fdp {
    flex-direction: column;
    max-height: calc(100vh - 32px);
    overflow: auto;
  }
  .f-fdp-presets {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--f-divider);
    flex-direction: row;
    flex-wrap: wrap;
  }
  .f-fdp-months { flex-direction: column; }
}


/* ──────────────────────────────────────────────────────────────────────
   Универсальная модалка (Frime v2) — .f-modal / .f-modal-backdrop
   Используется для CRUD и форм (budget, seg-config и т.п.).
   Структура:
     <div class="f-modal-backdrop">
       <div class="f-modal">
         <div class="f-modal-head"><div class="f-modal-icon"/><div class="f-modal-title-wrap">
             <h3 class="f-modal-title"/><div class="f-modal-subtitle"/>
           </div><button class="f-modal-close"/></div>
         <div class="f-modal-body">...</div>
         <div class="f-modal-footer"><button/><button/></div>
       </div>
     </div>
   ────────────────────────────────────────────────────────────────────── */

.f-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: f-modal-fade-in .15s ease-out;
}
@keyframes f-modal-fade-in {
  from { opacity: 0 }
  to   { opacity: 1 }
}

.f-modal {
  width: 100%;
  max-width: 620px;
  max-height: calc(100vh - 32px);
  background: var(--f-surface);
  color: var(--f-text);
  border: 1px solid var(--f-border);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35), 0 8px 20px rgba(0, 0, 0, .2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: f-modal-pop-in .18s ease-out;
}
.f-modal--wide { max-width: 760px; }
.f-modal--narrow { max-width: 460px; }
@keyframes f-modal-pop-in {
  from { opacity: 0; transform: scale(.96) }
  to   { opacity: 1; transform: scale(1) }
}

.f-modal-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--f-divider);
}
.f-modal-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--f-accent-soft);
  color: var(--f-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.f-modal-icon .ph { font-size: 20px; color: var(--f-accent); }
.f-modal-title-wrap { flex: 1; min-width: 0; }
.f-modal-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--f-text);
  margin: 0;
}
.f-modal-subtitle {
  font-size: 12px;
  color: var(--f-text-muted);
  margin-top: 3px;
  line-height: 1.4;
}
.f-modal-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.f-modal-close {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--f-text-subtle);
  transition: background .15s, color .15s;
}
.f-modal-close:hover { background: var(--f-surface-alt); color: var(--f-text); }
.f-modal-close .ph { font-size: 18px; }

.f-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
}

.f-modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-top: 1px solid var(--f-divider);
  background: var(--f-surface-alt);
}
.f-modal-footer-spacer { flex: 1; }

/* Inline inputs in modal (form field) */
.f-modal-field {
  display: flex;
  align-items: center;
  gap: 10px;
}
.f-modal-field-label {
  flex: 1;
  min-width: 0;
}
.f-modal-field-label-main {
  font-size: 12px;
  color: var(--f-text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.f-modal-field-label-hint {
  font-size: 10px;
  color: var(--f-text-subtle);
  margin-top: 1px;
}
.f-modal-field-input {
  position: relative;
  width: 160px;
  flex-shrink: 0;
}
/* Double-class selector (specificity 0,0,2,0) чтобы победить Tailwind forms
   preflight (`[type="number"]` → 0,0,1,0 — та же, но декларируется раньше и
   reset имеет `padding: 8px 12px; font-size: 16px`). */
.f-modal-input.f-modal-input {
  width: 100%;
  /* Базовый padding — без суффикса. Когда есть suffix-блок, правый padding
     увеличивается правилом ниже (`:has`). */
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.4;
  text-align: right;
  border: 1px solid var(--f-border);
  border-radius: 7px;
  background: var(--f-surface);
  color: var(--f-text);
  font-variant-numeric: tabular-nums;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  box-shadow: none;
}
/* Когда рядом есть suffix-блок — оставляем ему место справа, чтобы цифра
   не заезжала под серый бейдж. */
.f-modal-field-input:has(> .f-modal-input-suffix) .f-modal-input.f-modal-input {
  padding-right: 44px;
}
.f-modal-input.f-modal-input:focus {
  border-color: var(--f-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--f-accent) 15%, transparent);
}
.f-modal-input-suffix {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--f-text-subtle);
  pointer-events: none;
  border-left: 1px solid var(--f-divider);
  background: var(--f-surface-alt);
  border-radius: 0 6px 6px 0;
}

.f-modal-section {
  margin-bottom: 18px;
}
.f-modal-section:last-child { margin-bottom: 0; }
.f-modal-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--f-text-subtle);
  margin-bottom: 10px;
}
.f-modal-section-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.f-modal-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.f-modal-kpi-cell label {
  display: block;
  font-size: 11px;
  color: var(--f-text-muted);
  margin-bottom: 4px;
}
.f-modal-kpi-cell .f-modal-field-input {
  width: 100%;
}
/* Base .f-modal-input уже обрабатывает padding через :has(suffix). */

.f-modal-month-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: 3px;
  background: var(--f-surface-alt);
  border-radius: 7px;
  padding: 2px;
}
.f-modal-month-nav button {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  color: var(--f-text-subtle);
}
.f-modal-month-nav button:hover { background: var(--f-surface); color: var(--f-text); }
.f-modal-month-nav .ph { font-size: 14px; }
.f-modal-month-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--f-text);
  min-width: 110px;
  text-align: center;
  letter-spacing: .1px;
}

/* ─── Public Menu List · карточки меню (Шаг 2 v2-миграции публичных меню) ─── */
.f-menu-list-root {
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
  background: var(--f-bg);
}
.f-menu-list-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 16px 16px 40px;
}
/* Для редактора (3-колоночный layout) не нужен верхний скролл */
.f-menu-list-content--no-scroll {
  overflow: hidden;
  padding: 0;
}
.f-menu-list-loading,
.f-menu-list-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 60px 24px; color: var(--f-text-subtle); text-align: center;
}
.f-menu-list-loading { flex-direction: row; padding: 40px; }
.f-menu-list-loading .ms { animation: f-spin 1.2s linear infinite; }
@keyframes f-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

.f-menu-list-empty-title {
  font-size: 14px; font-weight: 600; color: var(--f-text); margin-top: 4px;
}
.f-menu-list-empty-sub { font-size: 12px; color: var(--f-text-subtle); max-width: 400px; }

.f-menu-list-section-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.f-menu-list-section-label {
  font-size: 11px; font-weight: 600; color: var(--f-text-subtle);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.f-menu-list-section-count {
  font-size: 11px; color: var(--f-text-subtle);
  font-variant-numeric: tabular-nums;
}
.f-menu-list-section-divider {
  flex: 1; height: 1px; background: var(--f-divider);
}

.f-menu-list-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; margin-bottom: 24px;
}
@media (max-width: 1280px) { .f-menu-list-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 960px)  { .f-menu-list-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .f-menu-list-grid { grid-template-columns: 1fr; } }

/* Menu card */
.f-menu-card {
  display: flex; flex-direction: column;
  border-radius: var(--r-md, 10px);
  border: 1px solid var(--f-border);
  background: var(--f-surface);
  overflow: hidden;
  text-decoration: none; color: inherit;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.f-menu-card:hover {
  border-color: var(--f-border-strong);
  box-shadow: var(--f-shadow);
  transform: translateY(-1px);
}
.f-menu-card-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.1;      /* portrait ratio как в гостевом /pub (.menu-card__img-wrap) */
  background-color: var(--f-surface-alt);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.f-menu-card-chip-type {
  position: absolute; top: 10px; left: 10px;
  padding: 3px 8px 3px 6px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--r-sm, 6px);
  display: flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; color: #2a1a14;
}
.f-menu-card-badge-public {
  position: absolute; top: 10px; right: 10px;
  padding: 3px 8px;
  color: #fff;
  border-radius: var(--r-sm, 6px);
  font-size: 9.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
  display: flex; align-items: center; gap: 3px;
}
.f-menu-card-emoji {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 64px; line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
  pointer-events: none;
}
.f-menu-card-badge-story {
  position: absolute; bottom: 10px; right: 10px;
  padding: 3px 7px 3px 5px;
  background: rgba(232, 176, 72, 0.95);
  color: #2a1a14;
  border-radius: var(--r-sm, 6px);
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  display: flex; align-items: center; gap: 3px;
}
.f-menu-card-body {
  padding: 10px 12px 12px;
  display: flex; flex-direction: column; flex: 1; min-width: 0;
}
.f-menu-card-name {
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.2px;
  margin-bottom: 2px;
  color: var(--f-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.f-menu-card-schedule {
  font-size: 11px; color: var(--f-text-subtle);
  margin-bottom: 8px;
}
.f-menu-card-stats {
  display: flex; gap: 12px;
  margin-bottom: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--f-divider);
}
.f-menu-card-stat-label {
  font-size: 9.5px; color: var(--f-text-subtle);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.f-menu-card-stat-value {
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
  color: var(--f-text);
}
.f-menu-card-footer {
  margin-top: auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; flex-wrap: wrap;
}
.f-menu-card-updated {
  font-size: 10px; color: var(--f-text-subtle);
}
.f-menu-card-iiko {
  margin-top: 8px;
  padding: 4px 8px;
  background: var(--f-surface-alt);
  border-radius: var(--r-sm, 6px);
  font-size: 10.5px; color: var(--f-text-muted);
  display: flex; align-items: center; gap: 5px;
}
.f-menu-card-iiko span {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Create card */
.f-menu-card-create {
  all: unset;
  box-sizing: border-box;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 280px;
  border-radius: var(--r-md, 10px);
  border: 1.5px dashed var(--f-border);
  background: transparent;
  color: var(--f-text-muted);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.f-menu-card-create:hover {
  border-color: var(--f-accent);
  background: var(--f-surface-alt);
  color: var(--f-accent);
}
.f-menu-card-create .ms {
  color: var(--f-text-subtle);
  margin-bottom: 6px;
}
.f-menu-card-create:hover .ms {
  color: var(--f-accent);
}
.f-menu-card-create-title { font-size: 12px; font-weight: 500; }
.f-menu-card-create-sub { font-size: 10.5px; color: var(--f-text-subtle); margin-top: 2px; }

/* Sub-tabs (в filters-зоне TopBar) */
.f-menu-subtabs {
  display: flex; gap: 6px; align-items: center;
}
.f-menu-subtab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  font-size: 11.5px; font-weight: 500;
  color: var(--f-text-muted);
  background: transparent;
  border: 1px solid var(--f-border);
  border-radius: var(--r-sm, 6px);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.f-menu-subtab:hover {
  border-color: var(--f-border-strong);
  background: var(--f-surface-alt);
  color: var(--f-text);
}
.f-menu-subtab.is-active {
  color: var(--f-accent-text);
  background: var(--f-accent-soft);
  border-color: var(--f-accent-soft-hover);
}
.f-menu-subtab.is-disabled { opacity: 0.45; cursor: not-allowed; }
.f-menu-subtab.is-disabled:hover { background: transparent; border-color: var(--f-border); color: var(--f-text-muted); }
.f-menu-subtab-count {
  color: var(--f-text-subtle);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.f-menu-subtab.is-active .f-menu-subtab-count { color: var(--f-accent-text); }

/* Dark mode overrides */
.dark .f-menu-card-chip-type {
  background: rgba(26, 24, 21, 0.92);
  color: var(--f-text);
}

/* ─── Modal v2 (backdrop + panel) ─────────────────────────────────────── */
.f-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(26, 24, 21, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 110;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; transition: opacity 0.2s ease;
}
.f-modal-backdrop.is-open { opacity: 1; }
.f-modal-backdrop.is-hidden { display: none; }

.f-modal-panel {
  width: 100%; max-width: 720px; max-height: 90vh;
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-lg, 14px);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  transform: scale(0.96); opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
/* Item Detail с phone-preview требует больше ширины (cover слева + form справа) */
#menu-item-panel { max-width: 920px !important; }

/* Headerless modal: close-кнопка плавает в правом верхнем углу panel */
.f-modal-panel--headerless .f-modal-body { padding-top: 18px; }
.f-modal-close--floating {
  position: absolute !important;
  top: 10px; right: 10px;
  z-index: 10;
  width: 32px; height: 32px;
  background: var(--f-surface) !important;
  border: 1px solid var(--f-border) !important;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(26,24,21,0.12);
  display: flex; align-items: center; justify-content: center;
}
.f-modal-close--floating:hover {
  background: var(--f-surface-alt) !important;
  color: var(--f-text) !important;
}
.f-modal-panel { position: relative; }
.f-modal-backdrop.is-open .f-modal-panel { transform: scale(1); opacity: 1; }

.f-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--f-divider);
  flex-shrink: 0;
}
.f-modal-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--f-text);
}
.f-modal-title .ms { color: var(--f-accent); }
.f-modal-close {
  all: unset;
  padding: 6px;
  border-radius: var(--r-sm, 6px);
  color: var(--f-text-subtle); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.f-modal-close:hover { background: var(--f-surface-alt); color: var(--f-text); }

.f-modal-body {
  flex: 1; overflow-y: auto; padding: 18px;
}
.f-modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--f-divider);
  flex-shrink: 0;
  background: var(--f-surface-alt);
}

/* ─── Form primitives (label/input/select/switch) ─────────────────────── */
.f-form-field { display: flex; flex-direction: column; gap: 4px; }
.f-form-label {
  font-size: 10px; font-weight: 600;
  color: var(--f-text-subtle);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.f-form-help { font-size: 11px; color: var(--f-text-subtle); margin-top: 2px; }

.f-input, .f-select, .f-textarea {
  box-sizing: border-box;
  font-family: inherit;
  width: 100%;
  padding: 0 12px;
  height: 34px;
  font-size: 12.5px;
  line-height: 1;
  color: var(--f-text);
  background: var(--f-surface);
  border: 1px solid var(--f-border) !important;
  border-radius: var(--r-md, 10px) !important;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  appearance: none !important; -webkit-appearance: none !important;
  outline: none;
}
.f-input:hover, .f-select:hover, .f-textarea:hover { border-color: var(--f-border-strong); }
.f-input:focus, .f-select:focus, .f-textarea:focus {
  outline: none;
  border-color: var(--f-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--f-accent) 15%, transparent);
}
.f-input::placeholder { color: var(--f-text-ph); }
.f-textarea {
  height: auto; min-height: 80px;
  padding: 10px 12px; line-height: 1.4;
  resize: vertical;
}
.f-select {
  padding-right: 28px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%238f8a7e' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  cursor: pointer;
}

/* Читаемые и согласованные native-типы: time/date/number — одинаковая высота и скругление */
.f-input[type="time"],
.f-input[type="date"],
.f-input[type="datetime-local"],
.f-input[type="number"] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 32px;
}
.f-input[readonly] {
  background: var(--f-surface-alt);
  color: var(--f-text-muted);
  cursor: default;
}
.f-input[readonly]:hover { border-color: var(--f-border); }

/* Legacy Tailwind внутри f-modal-body (Item Detail 1364 строк — пока не переверстан целиком) */
/* Скрываем встроенные close-кнопки — у нас общий close в f-modal-header */
.f-modal-body .absolute.top-4.right-4.z-10 { display: none; }

/* Перекраска google-blue → var(--f-accent) только внутри модалки */
.f-modal-body .bg-google-blue,
.f-modal-body .hover\:bg-blue-600:hover,
.f-modal-body .hover\:bg-blue-700:hover { background-color: var(--f-accent) !important; color: #fff !important; }
.f-modal-body .text-google-blue { color: var(--f-accent) !important; }
.f-modal-body .border-google-blue { border-color: var(--f-accent) !important; }

/* ─── Шаги 11-13: глобальный v2-override для legacy overlays меню ─────────
   Story Constructor, BL Builder, Merge, Stop List, Go List,
   Branding, Promotions, Category Settings, iiko Sync Info.
   Они ещё в старой Tailwind-вёрстке — но визуально должны выглядеть v2.
*/
#menu-overlays .bg-google-blue,
#menu-overlays .hover\:bg-blue-600:hover,
#menu-overlays .hover\:bg-blue-700:hover {
  background-color: var(--f-accent) !important;
  color: #fff !important;
}
#menu-overlays .text-google-blue { color: var(--f-accent) !important; }
#menu-overlays .border-google-blue { border-color: var(--f-accent) !important; }
#menu-overlays .ring-google-blue { --tw-ring-color: var(--f-accent) !important; }
#menu-overlays .focus\:ring-google-blue:focus { --tw-ring-color: var(--f-accent) !important; }
#menu-overlays .bg-blue-50 { background-color: var(--f-accent-soft) !important; }
#menu-overlays .text-blue-600,
#menu-overlays .text-blue-500,
#menu-overlays .text-blue-400 { color: var(--f-accent) !important; }

/* Backdrop: поменять чёрный на warm-tone accent backdrop */
#menu-overlays .fixed.inset-0.bg-black\/50,
#menu-overlays .fixed.inset-0.bg-black\/60 {
  background-color: rgba(26, 24, 21, 0.55) !important;
  backdrop-filter: blur(4px) !important;
  -webkit-backdrop-filter: blur(4px) !important;
}

/* Панели модалок: мягче rounded, корректный border */
#menu-overlays [class*="rounded-2xl"] { border-radius: var(--r-lg, 14px) !important; }
#menu-overlays [class*="rounded-xl"] { border-radius: var(--r-md, 10px) !important; }

/* Input/textarea внутри любого modal-overlay меню — единый v2-стиль */
#menu-overlays input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
#menu-overlays textarea,
#menu-overlays select:not(.cs-hidden-native) {
  border-radius: var(--r-md, 10px) !important;
  border-color: var(--f-border) !important;
  background-color: var(--f-surface) !important;
  color: var(--f-text) !important;
}
#menu-overlays input:focus,
#menu-overlays textarea:focus,
#menu-overlays select:focus {
  border-color: var(--f-accent) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--f-accent) 15%, transparent) !important;
  outline: none !important;
}

/* Legacy CustomSelect в v2-окружении: подогнать trigger под f-input размеры */
.f-modal-body .cs-trigger,
.f-modal-body .cs-wrapper button.cs-trigger,
.cs-wrapper button.cs-trigger {
  box-sizing: border-box;
  height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
  line-height: 1;
  border-radius: var(--r-md, 10px);
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  color: var(--f-text);
}
.f-modal-body .cs-trigger:hover { border-color: var(--f-border-strong); }
.f-modal-body .cs-trigger:focus-visible {
  outline: none;
  border-color: var(--f-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--f-accent) 15%, transparent);
}

/* Switch (toggle) */
.f-switch {
  position: relative;
  display: inline-block;
  width: 34px; height: 20px;
  flex-shrink: 0;
}
.f-switch input {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.f-switch-track {
  position: absolute; inset: 0;
  background: var(--f-border-strong);
  border-radius: 999px;
  transition: background 0.15s ease;
  cursor: pointer;
}
.f-switch-track::before {
  content: '';
  position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.15s ease;
}
.f-switch input:checked + .f-switch-track { background: var(--f-accent); }
.f-switch input:checked + .f-switch-track::before { transform: translateX(14px); }
.f-switch input:focus-visible + .f-switch-track {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--f-accent) 25%, transparent);
}

/* Switch "row" — toggle + label + sublabel */
.f-switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}
.f-switch-row-label {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
}
.f-switch-row-label .ms { color: var(--f-text-subtle); }
.f-switch-row-title {
  font-size: 12.5px; font-weight: 500; color: var(--f-text);
}
.f-switch-row-sub {
  display: block;
  font-size: 10.5px; color: var(--f-text-subtle);
  margin-top: 1px;
}
.f-switch-row + .f-switch-row { border-top: 1px solid var(--f-divider); }

/* Tile grid (выбор варианта — тип меню, и т.п.) */
.f-tile-grid {
  display: grid; gap: 8px;
}
.f-tile-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.f-tile-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.f-tile {
  all: unset;
  box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 8px;
  border: 1px solid var(--f-border);
  border-radius: var(--r-sm, 6px);
  font-size: 11.5px; font-weight: 500; color: var(--f-text-muted);
  background: var(--f-surface);
  cursor: pointer;
  text-align: center;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.f-tile:hover {
  background: var(--f-surface-alt);
  border-color: var(--f-border-strong);
  color: var(--f-text);
}
.f-tile.is-active {
  background: var(--f-accent-soft);
  border-color: var(--f-accent-soft-hover);
  color: var(--f-accent-text);
}
.f-tile .ms { font-size: 20px; color: inherit; }

/* Chip-multiselect (для glass/spirit categories) */
.f-chip-group {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.f-chip-check {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px;
  font-size: 11px; font-weight: 500; color: var(--f-text-muted);
  background: var(--f-surface-alt);
  border: 1px solid var(--f-border);
  border-radius: var(--r-sm, 6px);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.f-chip-check:hover { border-color: var(--f-border-strong); color: var(--f-text); }
.f-chip-check.is-active {
  background: var(--f-accent-soft);
  border-color: var(--f-accent-soft-hover);
  color: var(--f-accent-text);
}
.f-chip-check input { display: none; }

/* Form divider-section */
.f-form-section {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--f-divider);
}
.f-form-section-title {
  font-size: 10px; font-weight: 700; color: var(--f-text-subtle);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* В Item Detail секции рисуем как мягкие карточки — визуально выделяют v2 */
.f-item-detail-right .f-form-section {
  background: var(--f-surface-alt);
  border-radius: var(--r-md, 10px);
  padding: 12px 14px;
  margin-top: 10px;
  border-top: none;
}
.f-item-detail-right .f-form-section:first-of-type { margin-top: 14px; }
.f-item-detail-right .f-form-section-title {
  color: var(--f-accent-text);
  margin-bottom: 10px;
}

/* Delete action (в конце формы) */
.f-form-delete {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--f-divider);
}
.f-form-delete-btn {
  all: unset;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%;
  padding: 7px 12px;
  font-size: 12px; font-weight: 500;
  color: var(--f-danger);
  border-radius: var(--r-sm, 6px);
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.12s ease;
}
.f-form-delete-btn:hover { background: var(--f-danger-soft); }

/* ─── Menu Editor v2 (3-колоночный редактор) ─────────────────────────── */
.f-editor-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 60px; color: var(--f-text-subtle);
}
.f-editor-loading .ms { animation: f-spin 1.2s linear infinite; }

.f-editor-root {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  background: var(--f-bg);
}
.f-editor-sidebar {
  width: 240px; flex-shrink: 0;
  border-right: 1px solid var(--f-border);
  background: var(--f-surface);
  overflow-y: auto;
  padding-bottom: 12px;
  min-height: 0;
}
.f-editor-center {
  flex: 1 1 auto; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--f-bg);
}
.f-editor-items-header { flex-shrink: 0; }
.f-editor-inspector {
  width: 320px; flex-shrink: 0;
  border-left: 1px solid var(--f-border);
  background: var(--f-surface);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
@media (max-width: 1280px) {
  .f-editor-inspector { width: 280px; }
  .f-editor-sidebar { width: 220px; }
}
@media (max-width: 1100px) {
  .f-editor-inspector { display: none; }
}
@media (max-width: 860px) {
  .f-editor-sidebar { display: none; }
}

/* Sidebar: sections */
.f-editor-side-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 6px;
  font-size: 10px; font-weight: 600; color: var(--f-text-subtle);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.f-editor-side-add {
  all: unset;
  color: var(--f-text-subtle);
  cursor: pointer;
  padding: 2px; border-radius: var(--r-sm, 6px);
}
.f-editor-side-add:hover { background: var(--f-surface-alt); color: var(--f-text); }
.f-editor-side-divider {
  height: 1px; background: var(--f-divider); margin: 8px 12px;
}
.f-editor-side-empty {
  padding: 12px 14px; font-size: 11.5px; color: var(--f-text-subtle);
  text-align: center;
}

/* Category tree */
.f-editor-cat-list { padding-bottom: 6px; }
.f-editor-cat {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px 8px 24px;
  font-size: 12.5px; font-weight: 450; color: var(--f-text-muted);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s ease, color 0.1s ease;
}
.f-editor-cat:hover { background: var(--f-surface-alt); color: var(--f-text); }
.f-editor-cat.is-active {
  background: var(--f-accent-soft);
  border-left-color: var(--f-accent);
  color: var(--f-accent-text);
  font-weight: 600;
}
.f-editor-cat.is-hidden { opacity: 0.55; }
.f-editor-cat-drag {
  position: absolute; left: 6px;
  color: var(--f-text-subtle); opacity: 0.4;
}
.f-editor-cat:hover .f-editor-cat-drag { opacity: 0.85; }
.f-editor-cat-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.f-editor-cat-count {
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: inherit;
  opacity: 0.8;
}
.f-editor-cat-settings {
  all: unset; cursor: pointer; color: inherit; opacity: 0;
  padding: 2px; border-radius: var(--r-sm, 6px);
  transition: opacity 0.12s ease, background 0.12s ease;
}
.f-editor-cat:hover .f-editor-cat-settings { opacity: 0.6; }
.f-editor-cat-settings:hover { opacity: 1 !important; background: var(--f-surface); }

/* Items area header */
.f-editor-items-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--f-divider);
  background: var(--f-surface);
  flex-shrink: 0;
}
.f-editor-items-title {
  font-size: 13.5px; font-weight: 600; color: var(--f-text);
}

.f-editor-items-list {
  flex: 1; overflow-y: auto;
}

/* Grid вид позиций (карточки) */
.f-editor-items-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  align-content: start;
}
.f-editor-items-list { min-height: 0; }
.f-editor-card {
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-md, 10px);
  overflow: hidden;
  display: flex; flex-direction: column;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.08s ease;
}
.f-editor-card:hover {
  border-color: var(--f-border-strong);
  box-shadow: var(--f-shadow);
  transform: translateY(-1px);
}
.f-editor-card.is-selected {
  border-color: var(--f-accent);
  box-shadow: 0 0 0 2px var(--f-accent-soft-hover);
}
/* Скрытые/архивные — полупрозрачные + desaturate, чтобы сразу видно */
.f-editor-card.is-dimmed {
  opacity: 0.5;
  filter: grayscale(0.4);
}
.f-editor-card.is-dimmed:hover,
.f-editor-card.is-dimmed.is-selected {
  opacity: 0.85;
  filter: grayscale(0);
}
/* В стопе — не затеняем, но обводка красная чтобы сразу бросалось в глаза */
.f-editor-card.is-stopped {
  border-color: var(--f-danger);
  box-shadow: 0 0 0 1px var(--f-danger-soft-h, var(--f-danger-soft));
}
.f-editor-card.is-stopped.is-selected {
  border-color: var(--f-danger);
  box-shadow: 0 0 0 2px var(--f-danger-soft);
}
/* Ribbon-бейдж слева сверху на cover'e: «В стопе» / «Скрыто» / «В архиве» */
.f-editor-card-ribbon {
  position: absolute;
  top: 8px; left: 8px;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px 3px 6px;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  color: #fff;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.f-editor-card-ribbon--danger { background: var(--f-danger); }
.f-editor-card-ribbon--muted  { background: rgba(26, 24, 21, 0.78); }

.f-editor-card-cover {
  position: relative;
  aspect-ratio: 1 / 1;         /* квадрат для kitchen/special и др. */
  background-size: cover;
  background-position: center;
  background-color: var(--f-surface-alt);
  overflow: hidden;
}
/* Для бутылок (bar/wine) — вертикальный кадр + contain, чтобы вписывалась целая бутылка */
.f-editor-card--portrait .f-editor-card-cover {
  aspect-ratio: 3 / 4;
  background-size: contain;
  background-repeat: no-repeat;
}
.f-editor-card-emoji {
  font-size: 48px;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.25));
  pointer-events: none;
}
.f-editor-card-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  pointer-events: none;
}
.f-editor-card-placeholder-hint {
  font-size: 9.5px; font-weight: 600;
  color: rgba(255,255,255,0.8);
  text-transform: uppercase; letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.f-editor-card-badge {
  position: absolute; top: 6px; right: 6px;
  color: #fff;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.f-editor-card-actions {
  position: absolute; bottom: 6px; right: 6px;
  display: flex; gap: 4px;
  opacity: 0; transition: opacity 0.12s ease;
}
.f-editor-card:hover .f-editor-card-actions { opacity: 1; }
.f-editor-card-iconbtn {
  all: unset;
  width: 28px; height: 28px;
  background: #fff;
  color: #1a1815;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.f-editor-card-iconbtn:hover { background: var(--f-accent-soft); color: var(--f-accent); }
.f-editor-card-actions {
  opacity: 1 !important;
  display: flex !important;
  z-index: 2;
}
.f-editor-card-iconbtn {
  background: #fff !important;
  color: #1a1815 !important;
  opacity: 1 !important;
}
.f-editor-card-body {
  padding: 10px 12px 12px;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 80px;
}
.f-editor-card-name {
  font-size: 13px; font-weight: 600; color: var(--f-text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.f-editor-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto; gap: 6px;
}
.f-editor-card-price {
  font-size: 12px; font-weight: 700;
  color: var(--f-accent);
  font-variant-numeric: tabular-nums;
}

/* Subcategory header (Абсент / Ром / …) */
.f-editor-subcat-header {
  grid-column: 1 / -1;
  padding: 14px 0 6px;
  font-size: 11px; font-weight: 700;
  color: var(--f-text-subtle);
  text-transform: uppercase; letter-spacing: 0.4px;
  border-top: 1px solid var(--f-divider);
  margin-top: 8px;
}
.f-editor-subcat-header:first-child { border-top: none; margin-top: 0; padding-top: 4px; }
.f-editor-subcat-count {
  color: var(--f-text-subtle); font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.f-editor-items-grid-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 24px;
  display: flex; flex-direction: column;
  gap: 4px;
}
/* Nested grid внутри flex-column scroll-контейнера: не растягиваем по высоте,
   не сжимаем — высота определяется содержимым, вертикальный скролл делает
   родительский .f-editor-items-grid-scroll. Без этого все nested-grid'ы делят
   высоту через flex-shrink и схлопывают карточки в «полоски». */
.f-editor-items-grid--nested {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  overflow: visible;
  padding: 0;
  min-height: 0;
}
.f-editor-items-list .f-editor-subcat-header {
  padding: 14px 16px 6px;
}

/* Toggle вид списка/карточек */
.f-editor-viewmode {
  display: inline-flex;
  background: var(--f-surface-alt);
  border-radius: var(--r-md, 10px);
  padding: 2px;
}
.f-editor-viewmode-btn {
  all: unset;
  padding: 5px 8px;
  color: var(--f-text-subtle);
  cursor: pointer;
  border-radius: var(--r-sm, 6px);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.f-editor-viewmode-btn:hover { color: var(--f-text); }
.f-editor-viewmode-btn.is-on {
  background: var(--f-surface);
  color: var(--f-accent);
  box-shadow: var(--shadow-sm);
}
.f-editor-items-empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 40px; color: var(--f-text-subtle);
  text-align: center;
}

/* Item row */
.f-editor-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 10px 8px;
  border-bottom: 1px solid var(--f-divider);
  background: var(--f-bg);
  transition: background 0.1s ease;
}
.f-editor-row:hover { background: var(--f-surface-alt); }
.f-editor-row.is-dimmed {
  background: var(--f-surface-sunken);
  opacity: 0.55;
}
.f-editor-row.is-dimmed:hover { opacity: 0.9; }
.f-editor-row.is-stopped {
  box-shadow: inset 3px 0 0 var(--f-danger);
}
.f-editor-row.is-stopped .f-editor-row-price {
  color: var(--f-danger);
}
.f-editor-row-drag {
  color: var(--f-text-subtle); cursor: grab;
  opacity: 0.4;
}
.f-editor-row:hover .f-editor-row-drag { opacity: 0.85; }
.f-editor-row-photo {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: var(--r-sm, 6px);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: var(--f-text-subtle);
}
.f-editor-row-photo.has-image {
  background-color: var(--f-surface-alt);
}
.f-editor-row-photo.is-empty {
  border: 1.5px dashed var(--f-border);
}
/* Для бутылок (bar/wine) — contain, чтобы бутылка целиком помещалась в 44×44 */
.f-editor-row-photo--portrait {
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-color: var(--f-surface-alt);
}
.f-editor-row-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.f-editor-row-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--f-text);
}
.f-editor-row-title > span:first-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.f-editor-row-meta {
  font-size: 10.5px; color: var(--f-text-subtle);
  display: flex; gap: 8px; align-items: center;
}
.f-editor-row-price {
  color: var(--f-text); font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.f-editor-row-warn {
  color: var(--f-warning);
}
.f-editor-row-meta-mini { color: var(--f-text-subtle); }
.f-editor-row-actions {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
  opacity: 0.6; transition: opacity 0.12s ease;
}
.f-editor-row:hover .f-editor-row-actions { opacity: 1; }

/* Inspector (Шаг 4 placeholder) */
.f-editor-inspector-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--f-divider);
  flex-shrink: 0;
}
.f-editor-inspector-eyebrow {
  font-size: 10px; font-weight: 600; color: var(--f-text-subtle);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.f-editor-inspector-title {
  font-size: 13px; font-weight: 600; color: var(--f-text); margin-top: 2px;
}
.f-editor-inspector-empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 40px 20px;
  text-align: center; color: var(--f-text-subtle);
  font-size: 11.5px;
}
.f-editor-side-storylist {
  padding: 2px 0;
}

/* BL editor view — legacy IDs #menu-categories-list и #menu-items-area */
.f-editor-bl-cats { padding: 6px 0 12px; min-height: 60px; }
.f-editor-bl-area {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 24px;
  background: var(--f-bg);
}
.f-editor-sidebar--bl { padding: 0; }
.f-editor-bl-cats > * { margin: 0 6px 4px; }

/* Row: selected (для inspector) */
.f-editor-row.is-selected {
  background: var(--f-accent-soft);
  box-shadow: inset 2px 0 0 var(--f-accent);
}
.f-editor-row.is-selected:hover { background: var(--f-accent-soft); }

/* Inspector body */
.f-editor-inspector-body {
  padding: 14px; display: flex; flex-direction: column; gap: 14px;
}
.f-editor-inspector-actions {
  display: flex; gap: 6px; justify-content: center;
}

/* Phone-preview card */
.f-editor-phone {
  background: #fff;
  border: 1px solid var(--f-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  color: #1a1815;
}
.f-editor-phone-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 0.95;
  background: var(--f-surface-alt);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.f-editor-phone-cover img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
/* Portrait-вариант для вин/бара — бутылки вписываются целиком (contain) */
.f-editor-phone--portrait .f-editor-phone-cover {
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, var(--f-surface-alt), var(--f-surface-sunken));
}
.f-editor-phone--portrait .f-editor-phone-cover img {
  object-fit: contain;
  padding: 10px;
  background: transparent;
}
.f-editor-phone-emoji {
  font-size: 60px; line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}
.f-editor-phone-body {
  padding: 14px 16px 16px;
}
.f-editor-phone-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 19px; font-weight: 600;
  color: #47141D;
  text-align: center;
  letter-spacing: 0.2px;
  line-height: 1.2;
}
.f-editor-phone-subtitle {
  font-size: 11px; color: #6b665c;
  text-align: center;
  margin-top: 4px;
}
.f-editor-phone-desc {
  font-size: 11.5px; color: #3a3732;
  margin-top: 10px;
  line-height: 1.45;
  text-align: center;
}
.f-editor-phone-badges {
  display: flex; justify-content: center; gap: 6px;
  margin-top: 10px; flex-wrap: wrap;
}
.f-editor-phone-price {
  display: flex; align-items: center; justify-content: center;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid #ece9e2;
  font-size: 22px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #1a1815;
}

/* Dark mode: phone-preview остаётся светлым (имитирует гостевой лендинг) */

/* ─── Item Detail v2 (Шаг 6a regular + legacy wrap wine/spirit/bar) ───── */
.f-item-detail-root {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  align-items: flex-start;
}
@media (max-width: 720px) {
  .f-item-detail-root { grid-template-columns: 1fr; }
}

.f-item-detail-left { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; }
.f-item-detail-right { min-width: 0; }
.f-item-detail-title {
  font-size: 18px; font-weight: 700; color: var(--f-text);
  margin: 0 0 8px; line-height: 1.25;
  word-break: break-word;
}

/* Скрыть встроенные top-cover и close-кнопки legacy wine/spirit/bar/merged */
.f-item-detail-right--legacy .absolute.top-4.right-4.z-10,
.f-item-detail-right--legacy .absolute.top-4.right-4 { display: none !important; }
.f-item-detail-right--legacy > div > .relative.h-56,
.f-item-detail-right--legacy > div > .relative.overflow-hidden.h-56,
.f-item-detail-right--legacy .flex.gap-5.p-6.pb-0 > div:first-child { display: none !important; }
/* Убрать избыточные paddings оригинала т.к. wrap уже даёт gap */
.f-item-detail-right--legacy > div > .p-6 { padding: 0 !important; }
.f-item-detail-right--legacy > div > .flex.gap-5.p-6 { padding: 0 !important; gap: 0 !important; }

/* Phone-preview — имитация как увидит гость на /pub */
.f-item-phone {
  background: #fff;
  border: 1px solid var(--f-border);
  border-radius: var(--r-lg, 14px);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  color: #1a1815;
}
.f-item-phone-cover {
  position: relative; width: 100%;
  aspect-ratio: 1 / 1.05;
  background: var(--f-surface-alt);
  overflow: hidden;
}
.f-item-phone-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Portrait-вариант для вин/бара — бутылки вписываются целиком (contain) */
.f-item-phone--portrait .f-item-phone-cover {
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, var(--f-surface-alt), var(--f-surface-sunken));
}
.f-item-phone--portrait .f-item-phone-cover img {
  object-fit: contain;
  padding: 10px;
  background: transparent;
}
.f-item-phone-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.2));
}
.f-item-phone-body { padding: 14px 14px 16px; }
.f-item-phone-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 19px; font-weight: 600;
  color: #47141D;
  text-align: center;
  line-height: 1.2; letter-spacing: 0.2px;
}
.f-item-phone-subtitle {
  font-size: 11px; color: #6b665c;
  text-align: center; margin-top: 4px;
}
.f-item-phone-desc {
  font-size: 11.5px; color: #3a3732;
  text-align: center; line-height: 1.45;
  margin-top: 10px;
}
.f-item-phone-badges {
  display: flex; justify-content: center; gap: 6px;
  margin-top: 10px; flex-wrap: wrap;
}
.f-item-phone-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px; font-weight: 600;
  background: var(--f-accent-soft); color: var(--f-accent-text);
  border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.f-item-phone-badge--hit { background: var(--f-warning-soft); color: var(--f-warning); }
.f-item-phone-price {
  display: flex; justify-content: center;
  font-size: 22px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--f-text);
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--f-divider);
}

.f-item-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.1;
  border-radius: var(--r-md, 10px);
  overflow: hidden;
  background: var(--f-surface-alt);
}
.f-item-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.f-item-cover-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 72px; font-weight: 700; opacity: 0.25;
}
.f-item-cover-overlay {
  position: absolute; top: 10px; left: 10px;
  padding: 3px 7px;
  color: #fff; font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  border-radius: var(--r-sm, 6px);
  display: inline-flex; align-items: center; gap: 3px;
}

.f-item-cover-controls {
  display: flex; flex-wrap: wrap; gap: 4px;
}

/* Price line */
.f-item-detail-priceline {
  display: flex; align-items: center; gap: 10px;
}
.f-item-hero-toggle {
  all: unset;
  padding: 4px;
  border-radius: var(--r-sm, 6px);
  color: var(--f-text-subtle);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.f-item-hero-toggle:hover { background: var(--f-surface-alt); }
.f-item-hero-toggle.is-on { color: var(--f-warning); background: var(--f-warning-soft); }

.f-item-price {
  font-size: 18px; font-weight: 700;
  color: var(--f-accent);
  font-variant-numeric: tabular-nums;
}
.f-item-meta {
  font-size: 11px; color: var(--f-text-subtle);
  margin-top: 2px;
}

.f-item-description-orig {
  font-size: 12.5px; color: var(--f-text-muted);
  line-height: 1.5;
}
.f-item-details-summary {
  font-size: 11.5px; font-weight: 500;
  color: var(--f-accent);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 0;
}
.f-item-details-summary:hover { text-decoration: underline; }
.f-item-details-summary::-webkit-details-marker { display: none; }
.f-item-details-summary::marker { content: ''; }

/* БЖУ grid */
.f-item-bju-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.f-item-bju-card {
  background: var(--f-surface-alt);
  border-radius: var(--r-sm, 6px);
  padding: 8px 6px;
  text-align: center;
}
.f-item-bju-val {
  font-size: 14px; font-weight: 700;
  color: var(--f-text);
  font-variant-numeric: tabular-nums;
}
.f-item-bju-lbl {
  font-size: 9px; color: var(--f-text-subtle);
  text-transform: uppercase; letter-spacing: 0.4px;
  margin-top: 1px;
}

/* Allergen & tag chips */
.f-item-allergen-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 8px;
  font-size: 11px; font-weight: 500;
  color: var(--f-danger);
  background: var(--f-danger-soft);
  border-radius: var(--r-sm, 6px);
}
.f-item-tag-chip {
  display: inline-flex; padding: 3px 8px;
  font-size: 11px; font-weight: 500;
  border-radius: var(--r-sm, 6px);
}

/* ─── Public Menu Settings v2 (Шаг 8) ─────────────────────────────────── */
.f-settings-root {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  padding: 16px;
  align-items: flex-start;
}
@media (max-width: 1000px) { .f-settings-root { grid-template-columns: 220px 1fr; } }
@media (max-width: 768px)  { .f-settings-root { grid-template-columns: 1fr; } }

.f-settings-picker {
  position: sticky; top: 0;
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-md, 10px);
  padding: 10px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}
.f-settings-picker-title {
  font-size: 10px; font-weight: 700; color: var(--f-text-subtle);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px; padding: 0 4px;
}
.f-settings-picker-list { display: flex; flex-direction: column; gap: 4px; }
.f-settings-menu-item {
  display: block;
  padding: 8px 10px;
  border-radius: var(--r-sm, 6px);
  border: 1px solid transparent;
  background: transparent;
  text-decoration: none;
  color: var(--f-text-muted);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.f-settings-menu-item:hover { background: var(--f-surface-alt); color: var(--f-text); }
.f-settings-menu-item.is-active {
  background: var(--f-accent-soft);
  border-color: var(--f-accent-soft-hover);
  color: var(--f-accent-text);
}
.f-settings-menu-name {
  font-size: 12.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.f-settings-menu-meta {
  font-size: 10.5px; color: var(--f-text-subtle); margin-top: 2px;
}
.f-settings-menu-item.is-active .f-settings-menu-meta { color: var(--f-accent-text); opacity: 0.75; }

.f-settings-cards {
  display: flex; flex-direction: column; gap: 12px;
  min-width: 0;
}

.f-settings-card {
  padding: 0;
  border: 1px solid var(--f-border);
  border-radius: var(--r-md, 10px);
  background: var(--f-surface);
  overflow: visible;     /* CustomSelect dropdown не должен обрезаться */
}
.f-settings-card-header {
  border-top-left-radius: var(--r-md, 10px);
  border-top-right-radius: var(--r-md, 10px);
}
.f-settings-card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--f-divider);
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
}
.f-settings-card-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--f-text);
}
.f-settings-card-sub { font-size: 11px; color: var(--f-text-subtle); }
.f-settings-card-body {
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 12px;
}

/* Days checkbox group */
.f-settings-days {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.f-settings-day {
  display: flex; align-items: center; justify-content: center;
  padding: 8px 4px;
  border: 1px solid var(--f-border);
  border-radius: var(--r-sm, 6px);
  background: var(--f-surface);
  color: var(--f-text-muted);
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.f-settings-day input { display: none; }
.f-settings-day:hover { background: var(--f-surface-alt); color: var(--f-text); }
.f-settings-day.is-on {
  background: var(--f-accent-soft);
  border-color: var(--f-accent-soft-hover);
  color: var(--f-accent-text);
}

/* ─── Menu Sync 3d (Шаг 10) ────────────────────────────────────────── */
.f-sync-root {
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.f-sync-kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 900px) { .f-sync-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .f-sync-kpis { grid-template-columns: 1fr; } }

.f-sync-kpi {
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-md, 10px);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.f-sync-kpi.is-warn {
  border-color: var(--f-danger);
  background: var(--f-danger-soft);
}
.f-sync-kpi-label {
  font-size: 10px; font-weight: 700; color: var(--f-text-subtle);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.f-sync-kpi-value {
  font-size: 22px; font-weight: 700; color: var(--f-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-top: 4px;
}
.f-sync-kpi-sub {
  font-size: 11px; color: var(--f-text-subtle);
  margin-top: 2px;
}

.f-sync-connection {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--f-surface-alt);
  border-radius: var(--r-sm, 6px);
}
.f-sync-connection-icon {
  width: 32px; height: 32px;
  background: var(--f-surface);
  border-radius: var(--r-sm, 6px);
  display: flex; align-items: center; justify-content: center;
  color: var(--f-accent);
}
.f-sync-connection-name { font-size: 12.5px; font-weight: 600; color: var(--f-text); }
.f-sync-connection-meta {
  font-size: 10.5px; color: var(--f-text-subtle); margin-top: 2px;
}

.f-sync-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
.f-sync-log-table th,
.f-sync-log-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--f-divider);
  vertical-align: middle;
}
.f-sync-log-table th {
  font-size: 10px; font-weight: 700; color: var(--f-text-subtle);
  text-transform: uppercase; letter-spacing: 0.4px;
  background: var(--f-surface-alt);
}
.f-sync-log-row.is-err { background: color-mix(in srgb, var(--f-danger-soft) 40%, transparent); }
.f-sync-log-row.is-warn { background: color-mix(in srgb, var(--f-warning-soft) 40%, transparent); }

/* Cover preview в карточке настроек */
.f-settings-cover-preview {
  width: 160px; height: 200px;
  border-radius: var(--r-md, 10px);
  background-size: cover; background-position: center;
  background-color: var(--f-surface-alt);
  border: 1px solid var(--f-border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Modifier groups */
.f-item-modgroup {
  background: var(--f-surface-alt);
  border-radius: var(--r-sm, 6px);
  padding: 8px 10px;
}
.f-item-modgroup-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 600; color: var(--f-text);
  margin-bottom: 4px;
}
.f-item-modgroup-items {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.f-item-modchip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  font-size: 10.5px;
  background: var(--f-surface);
  color: var(--f-text-muted);
  border: 1px solid var(--f-border);
  border-radius: 999px;
}
.f-item-modchip b { color: var(--f-accent); font-weight: 600; }

/* Status table */
.f-editor-status-table {
  display: flex; flex-direction: column;
}
.f-editor-status-title {
  font-size: 10px; font-weight: 700; color: var(--f-text-subtle);
  text-transform: uppercase; letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.f-editor-status-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--f-divider);
  font-size: 11.5px;
}
.f-editor-status-row:last-child { border-bottom: none; }
.f-editor-status-label { color: var(--f-text-muted); }
.f-editor-status-value { font-weight: 500; }


/* Merge-mode selection highlighting (исправление UX 2026-04-22) */
.f-editor-row.is-merge-selected {
    background: var(--f-accent-soft);
    box-shadow: inset 3px 0 0 var(--f-accent);
}
.f-editor-row.is-merge-selected:hover { background: var(--f-accent-soft); }
.f-editor-card.is-merge-selected {
    border-color: var(--f-accent);
    box-shadow: 0 0 0 2px var(--f-accent), 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}
.f-editor-card.is-merge-selected::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--f-accent-soft);
    opacity: 0.2;
    pointer-events: none;
    border-radius: inherit;
}
.f-editor-card.is-merge-selected .f-editor-card-cover::before {
    content: "\f26b";  /* check */
    font-family: "Material Symbols Outlined";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px; height: 28px;
    background: var(--f-accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    z-index: 3;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* ============================================================
 * Settings · Структура v2 — KPI-ленточка, грид, карточки секций/должностей.
 * Макет: .agent/design-mockups/settings-v2.html
 * ============================================================ */

.f-struct-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
@media (max-width: 900px) {
    .f-struct-stats { grid-template-columns: repeat(2, 1fr); }
}

.f-stat {
    background: var(--f-surface);
    border: 1px solid var(--f-border);
    border-radius: var(--r-lg);
    padding: 14px 16px;
    box-shadow: var(--f-shadow-sm);
}
.f-stat-label {
    font-size: 11px;
    color: var(--f-text-subtle);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}
.f-stat-value {
    font-size: 22px;
    font-weight: 600;
    margin-top: 4px;
    letter-spacing: -.02em;
    color: var(--f-text);
}
.f-stat-hint {
    font-size: 11.5px;
    color: var(--f-text-subtle);
    margin-top: 2px;
}
.f-stat-trend-up { color: var(--f-success); }
.f-stat-trend-down { color: var(--f-danger); }

.f-struct-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
}
@media (max-width: 1100px) {
    .f-struct-grid { grid-template-columns: 1fr; }
}

.f-sections-card .f-card-body { padding: 8px; }

.f-section-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background 120ms;
    position: relative;
    color: var(--f-text);
}
.f-section-row:hover { background: var(--f-surface-alt); }
.f-section-row.f-section-active { background: var(--f-accent-soft); }
.f-section-row.f-section-active .f-section-name { color: var(--f-accent-text); font-weight: 600; }
.f-section-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--f-surface-alt);
    color: var(--f-text-muted);
    flex-shrink: 0;
}
.f-section-row.f-section-active .f-section-icon {
    background: var(--f-accent);
    color: var(--f-accent-on);
}
.f-section-icon .ph { font-size: 18px; color: inherit; }

.f-section-name { font-size: 13.5px; font-weight: 500; }
.f-section-meta { font-size: 11px; color: var(--f-text-subtle); margin-top: 2px; }
.f-section-count {
    margin-left: auto;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--f-text-muted);
    background: var(--f-surface-alt);
    padding: 2px 8px;
    border-radius: var(--r-pill);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.f-section-row.f-section-active .f-section-count {
    background: rgba(90, 26, 36, .08);
    color: var(--f-accent-text);
}
.dark .f-section-row.f-section-active .f-section-count {
    background: rgba(217, 160, 168, .18);
}

.f-section-actions {
    display: none;
    gap: 2px;
    margin-left: 4px;
}
.f-section-row:hover .f-section-actions,
.f-section-row.f-section-active .f-section-actions {
    display: inline-flex;
}

.f-add-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    margin-top: 4px;
    border-radius: var(--r-md);
    border: 1px dashed var(--f-border-strong);
    background: transparent;
    color: var(--f-text-muted);
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    transition: all 120ms;
    width: 100%;
}
.f-add-section:hover {
    border-color: var(--f-accent);
    color: var(--f-accent-text);
    background: var(--f-accent-soft);
}
.f-add-section .ph { font-size: 16px; }

/* Positions card */
.f-pos-card { display: flex; flex-direction: column; }
.f-pos-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--f-divider);
    background: var(--f-surface-alt);
    flex-wrap: wrap;
}
.f-input {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--f-border);
    background: var(--f-surface);
    border-radius: var(--r-md);
    font-size: 13px;
    color: var(--f-text);
    min-width: 220px;
}
.f-input input {
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    color: inherit;
    flex: 1;
    min-width: 0;
}
.f-input .ph { color: var(--f-text-placeholder); font-size: 17px; }

.f-pos-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    background: var(--f-surface);
    border: 1px solid var(--f-border);
    color: var(--f-text-muted);
    border-radius: var(--r-pill);
    cursor: pointer;
    transition: all 120ms;
    font-family: inherit;
}
.f-pos-chip:hover { border-color: var(--f-border-strong); }
.f-pos-chip.f-pos-chip-active {
    background: var(--f-accent-soft);
    color: var(--f-accent-text);
    border-color: transparent;
}

.f-pos-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.f-pos-table thead th {
    text-align: left;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--f-text-subtle);
    padding: 12px 16px;
    background: var(--f-surface);
    border-bottom: 1px solid var(--f-divider);
}
.f-pos-table thead th.f-num { text-align: right; }
.f-pos-table thead th.f-ctr { text-align: center; }
.f-pos-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--f-divider);
    vertical-align: middle;
    color: var(--f-text);
}
.f-pos-table tbody tr { transition: background 100ms; }
.f-pos-table tbody tr:hover { background: var(--f-surface-alt); }
.f-pos-table td.f-num { text-align: right; font-variant-numeric: tabular-nums; }
.f-pos-table td.f-ctr { text-align: center; }

/* Action buttons in table row — show only on hover */
.f-pos-table .f-row-actions { opacity: 0; transition: opacity 120ms; }
.f-pos-table tbody tr:hover .f-row-actions { opacity: 1; }

.f-drag-handle { color: var(--f-text-placeholder); cursor: grab; font-size: 18px; }

/* ============================================================
 * Settings · Integrations v2 — каталог карточек.
 * ============================================================ */
.f-int-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-lg);
  box-shadow: var(--f-shadow-sm);
  margin-bottom: 16px;
}

.f-int-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.f-int-card {
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: border-color 140ms, box-shadow 140ms, transform 140ms;
  box-shadow: var(--f-shadow-sm);
}
.f-int-card:hover {
  border-color: var(--f-border-strong);
  box-shadow: var(--f-shadow);
  transform: translateY(-1px);
}

.f-int-head { display: flex; align-items: center; gap: 12px; }
.f-int-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: -.02em;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}
.f-int-logo--saby { background: #1e5de6; }
.f-int-logo--iiko { background: #ff3e2e; }
.f-int-logo--z5r  { background: #0b9467; }
.f-int-logo--pwa  { background: #6b4ec2; }
.f-int-logo--apns { background: #1a1815; }
.f-int-logo--share{ background: #c2705a; }
.f-int-logo .ph { font-size: 20px; color: #fff; }

.f-int-title { font-weight: 600; font-size: 14px; color: var(--f-text); }
.f-int-subtitle { font-size: 11.5px; color: var(--f-text-subtle); margin-top: 2px; }
.f-int-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  background: var(--f-surface-alt);
  color: var(--f-text-muted);
  border-radius: var(--r-pill);
  flex-shrink: 0;
}
.f-int-status--ok      { background: var(--f-success-soft); color: var(--f-success); }
.f-int-status--error   { background: var(--f-danger-soft);  color: var(--f-danger); }
.f-int-status--pending { background: var(--f-warning-soft); color: var(--f-warning); }

.f-int-body {
  font-size: 12.5px;
  color: var(--f-text-muted);
  line-height: 1.5;
  flex: 1;
}

.f-int-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--f-divider);
  font-size: 11.5px;
  color: var(--f-text-subtle);
}
.f-int-meta { display: inline-flex; gap: 6px; align-items: center; }

.f-int-detail { display: flex; flex-direction: column; }

/* ============================================================
 * FormModal — универсальная модалка-форма (FormModal.js).
 * Переиспользует существующие .f-modal / .f-modal-head / .f-modal-close
 * / .f-modal-body / .f-modal-footer, добавляет поля с префиксом f-fm-.
 * ============================================================ */
/* Double-class specificity + !important — в проекте есть существующие
   .f-modal-body, .f-input/.f-select/.f-modal-input правила, Tailwind
   preflight и @tailwindcss/forms. Чтобы наши поля гарантированно
   отображались — !important на display/width/box-sizing. */
.f-fm-scroll { flex: 1 1 auto !important; overflow-y: auto !important; padding: 22px 24px !important; }
.f-fm-form.f-fm-form { display: flex !important; flex-direction: column !important; gap: 18px !important; width: 100% !important; margin: 0 !important; padding: 0 !important; }

.f-fm-row.f-fm-row { display: flex !important; flex-direction: column !important; gap: 6px !important; align-items: stretch !important; width: 100% !important; }

.f-fm-label.f-fm-label {
  display: block !important;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--f-text);
  letter-spacing: 0;
  text-transform: none;
  margin: 0 0 2px 0;
  line-height: 1.4;
}
.f-fm-req.f-fm-req { color: var(--f-danger); font-weight: 700; margin-left: 2px; }

/* Базовые input/select — явные box-sizing, высота, радиус.
   !important — защита от Tailwind forms preflight и legacy .f-input правил. */
.f-fm-input.f-fm-input {
  box-sizing: border-box !important;
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  padding: 10px 14px !important;
  font-size: 14px !important;
  line-height: 1.4 !important;
  border: 1px solid var(--f-border) !important;
  border-radius: var(--r-md) !important;
  background: var(--f-surface) !important;
  color: var(--f-text) !important;
  outline: none !important;
  transition: border-color .15s, box-shadow .15s, background .15s !important;
  font-family: inherit !important;
  font-weight: 400 !important;
  box-shadow: var(--f-shadow-sm) !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  margin: 0 !important;
  text-align: left !important;
  height: auto !important;
  min-height: 40px !important;
}
.f-fm-input.f-fm-input:hover { border-color: var(--f-border-strong); }
.f-fm-input.f-fm-input:focus {
  border-color: var(--f-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--f-accent) 15%, transparent);
}
.f-fm-input.f-fm-input::placeholder { color: var(--f-text-placeholder); opacity: 1; }
select.f-fm-input.f-fm-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b665c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.f-fm-hint.f-fm-hint { font-size: 12px; color: var(--f-text-subtle); margin: 0; }

/* Checkbox row: [x] label · hint */
.f-fm-check.f-fm-check {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  cursor: pointer;
  user-select: none;
  padding: 12px 14px !important;
  border: 1px solid var(--f-border) !important;
  border-radius: var(--r-md) !important;
  background: var(--f-surface) !important;
  transition: border-color .15s, background .15s;
  width: 100% !important;
  box-sizing: border-box !important;
  margin: 0 !important;
}
.f-fm-check.f-fm-check:hover { border-color: var(--f-border-strong); background: var(--f-surface-alt); }
.f-fm-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--f-accent);
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}
.f-fm-check-text { font-size: 14px; color: var(--f-text); font-weight: 500; }
.f-fm-check-hint {
  font-size: 12px;
  color: var(--f-text-subtle);
  margin-left: auto;
  text-align: right;
}

/* Native <dialog>::backdrop для затемнения */
dialog.f-modal::backdrop {
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
dialog.f-modal { border: 1px solid var(--f-border); padding: 0; }
dialog.f-modal[open] { display: flex; }

/* FormModal: дефолтная ширина 520px (medium) — комфортнее чем narrow=460
   для форм с 3+ полями, но всё ещё фокус-minimal. */
dialog.f-fm-dialog.f-fm-dialog.f-fm-dialog--medium { max-width: 520px; }
/* Body: явный padding (переопределяем общий .f-modal-body с text-align:right) */
dialog.f-fm-dialog .f-modal-body {
  padding: 22px 24px;
  text-align: left;
  overflow-y: auto;
}
/* Footer — чуть плотнее */
dialog.f-fm-dialog .f-modal-footer {
  padding: 14px 24px;
}

/* ============================================================
 * KPI · Bases v2 (см. .agent/design-mockups/kpi-v2.html)
 * Только токены var(--f-*). Поддержка темной темы — через токены.
 * ============================================================ */

.kpi-bases-v2 {
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--f-text);
}

/* ── Explainer block ──────────────────────────────────────── */
.kpi-bv2-explainer {
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-md);
  box-shadow: var(--f-shadow-sm);
  overflow: hidden;
}
.kpi-bv2-explainer-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 14px 18px;
  border-bottom: 1px solid var(--f-divider);
  background: var(--f-accent-soft);
}
.kpi-bv2-explainer-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: var(--f-accent);
  color: var(--f-accent-on);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-bv2-explainer-text { flex: 1; min-width: 0; }
.kpi-bv2-explainer-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--f-accent-text);
  margin-bottom: 4px;
}
.kpi-bv2-explainer-body {
  font-size: 12px;
  color: var(--f-accent-text);
  line-height: 1.55;
  opacity: .85;
}
.kpi-bv2-video-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  height: 26px;
  background: transparent;
  color: var(--f-accent-text);
  border: 1px solid color-mix(in srgb, var(--f-accent) 25%, transparent);
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.kpi-bv2-video-btn:hover { background: color-mix(in srgb, var(--f-accent) 8%, transparent); }

/* ── Type cards grid (4 типа баз) ──────────────────────────── */
.kpi-bv2-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.kpi-bv2-type-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid var(--f-divider);
}
.kpi-bv2-type-card:last-child { border-right: none; }

.kpi-bv2-type-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.kpi-bv2-type-card-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
/* Solid tone for type-card icon */
.kpi-bv2-tone-solid-success { background: var(--f-success); }
.kpi-bv2-tone-solid-info    { background: var(--f-info); }
.kpi-bv2-tone-solid-warning { background: var(--f-warning); }
.kpi-bv2-tone-solid-accent  { background: var(--f-accent); color: var(--f-accent-on); }

.kpi-bv2-type-card-title { font-size: 12.5px; font-weight: 600; color: var(--f-text); }
.kpi-bv2-type-card-sub   { font-size: 10px; color: var(--f-text-subtle); margin-top: 1px; }
.kpi-bv2-type-card-what  { font-size: 11px; color: var(--f-text-muted); line-height: 1.5; }

.kpi-bv2-formula {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  background: var(--f-surface-alt);
  padding: 4px 8px;
  border-radius: var(--r-xs);
  color: var(--f-text-muted);
  align-self: flex-start;
  white-space: nowrap;
}

.kpi-bv2-type-card-example {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--f-text-subtle);
  line-height: 1.4;
}

.kpi-bv2-type-card-filters {
  font-size: 10px;
  color: var(--f-text-subtle);
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: baseline;
}
.kpi-bv2-filters-label { margin-right: 2px; }
.kpi-bv2-filter-chip {
  display: inline-block;
  background: var(--f-surface-alt);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--f-text-muted);
  font-size: 10px;
  line-height: 1.4;
}

/* Адаптация: 2x2 на узких */
@media (max-width: 900px) {
  .kpi-bv2-type-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-bv2-type-card:nth-child(2) { border-right: none; }
  .kpi-bv2-type-card:nth-child(-n+2) { border-bottom: 1px solid var(--f-divider); }
}
@media (max-width: 540px) {
  .kpi-bv2-type-grid { grid-template-columns: 1fr; }
  .kpi-bv2-type-card { border-right: none; border-bottom: 1px solid var(--f-divider); }
  .kpi-bv2-type-card:last-child { border-bottom: none; }
}

/* ── Table card (использует .f-card, локальные правки минимальны) ─ */
.kpi-bv2-table-card { padding: 0; }
.kpi-bv2-table-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--f-divider);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.kpi-bv2-table-head-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--f-text);
}
.kpi-bv2-table-head-sub {
  color: var(--f-text-subtle);
  font-weight: 400;
}
.kpi-bv2-table-head-right { display: flex; gap: 6px; align-items: center; }

.kpi-bv2-table-scroll { overflow-x: auto; }

.kpi-bv2-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  color: var(--f-text);
}
.kpi-bv2-table thead tr {
  background: var(--f-surface-alt);
}
.kpi-bv2-table thead th {
  padding: 8px 14px;
  text-align: left;
  font-weight: 500;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--f-text-subtle);
  white-space: nowrap;
}
.kpi-bv2-table thead .kpi-bv2-th-value { text-align: right; }
.kpi-bv2-table thead .kpi-bv2-th-usage { text-align: center; }
.kpi-bv2-table thead .kpi-bv2-th-actions { width: 80px; }

.kpi-bv2-table tbody tr.kpi-bv2-row {
  border-top: 1px solid var(--f-divider);
  transition: background-color .12s ease;
}
.kpi-bv2-table tbody tr.kpi-bv2-row:hover { background: var(--f-surface-alt); }

.kpi-bv2-table tbody td {
  padding: 10px 14px;
  vertical-align: middle;
}
.kpi-bv2-cell-name .kpi-bv2-name-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.kpi-bv2-row-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
/* Soft tone for row-icon: bg = soft tint, color = full */
.kpi-bv2-tone-success { background: var(--f-success-soft); color: var(--f-success); }
.kpi-bv2-tone-info    { background: var(--f-info-soft);    color: var(--f-info); }
.kpi-bv2-tone-warning { background: var(--f-warning-soft); color: var(--f-warning); }
.kpi-bv2-tone-accent  { background: var(--f-accent-soft);  color: var(--f-accent-text); }

.kpi-bv2-name { font-weight: 500; color: var(--f-text); }
.kpi-bv2-cell-source { font-size: 11.5px; color: var(--f-text-muted); }
.kpi-bv2-muted { color: var(--f-text-subtle); }

.kpi-bv2-cell-value { text-align: right; font-variant-numeric: tabular-nums; }
.kpi-bv2-value-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--f-text);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--f-accent) 40%, transparent);
  text-underline-offset: 2px;
}
.kpi-bv2-value-btn:hover { color: var(--f-accent-text); }
.kpi-bv2-value-empty { color: var(--f-text-subtle); }

.kpi-bv2-cell-usage { text-align: center; }
.kpi-bv2-not-used { color: var(--f-text-subtle); font-size: 11px; }

.kpi-bv2-cell-actions { text-align: right; white-space: nowrap; }
.kpi-bv2-row-actions { display: inline-flex; gap: 2px; justify-content: flex-end; }

.kpi-bv2-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--f-text-subtle);
  font-size: 13px;
}

.kpi-bv2-excl-badge {
  display: inline-block;
  background: var(--f-warning-soft);
  color: var(--f-warning);
  border-radius: var(--r-xs);
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
}

/* ── Row "more" menu (popover) ─────────────────────────────── */
.kpi-bv2-row-menu {
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-sm);
  box-shadow: var(--f-shadow-lg);
  padding: 4px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kpi-bv2-row-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--r-xs);
  background: transparent;
  border: none;
  color: var(--f-text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.kpi-bv2-row-menu-item:hover { background: var(--f-surface-alt); }

/* ── Details row (toggle под основной строкой) ─────────────── */
.kpi-bv2-details-row td { padding: 0; background: var(--f-surface-alt); }
.kpi-bv2-details {
  padding: 12px 14px;
  border-bottom: 1px solid var(--f-divider);
}
.kpi-bv2-details-loading {
  padding: 12px 14px;
  border-bottom: 1px solid var(--f-divider);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--f-text-muted);
  font-size: 12px;
}
.kpi-bv2-details-error {
  color: var(--f-danger);
  font-size: 12px;
}
.kpi-bv2-details-summary {
  font-size: 11px;
  font-weight: 500;
  color: var(--f-text-muted);
  margin-bottom: 8px;
}
.kpi-bv2-details-scroll {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--f-border);
  border-radius: var(--r-sm);
  background: var(--f-surface);
}
.kpi-bv2-details-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.kpi-bv2-details-table thead { position: sticky; top: 0; background: var(--f-surface-alt); z-index: 1; }
.kpi-bv2-details-table thead th {
  padding: 6px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--f-text-subtle);
  letter-spacing: .4px;
  border-bottom: 1px solid var(--f-divider);
}
.kpi-bv2-details-table tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--f-divider);
  color: var(--f-text-muted);
}
.kpi-bv2-details-table tbody tr:last-child td { border-bottom: none; }
.kpi-bv2-details-table .kpi-bv2-details-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--f-text);
  font-weight: 500;
}
.kpi-bv2-details-empty {
  text-align: center;
  padding: 20px;
  color: var(--f-text-subtle);
  font-size: 11px;
}

.kpi-bv2-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--f-border);
  border-top-color: var(--f-accent);
  animation: spin 1s linear infinite;
}

/* ── KPI Schema Editor (full-page) ───────────────────────────────────── */

@keyframes kpi-blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.kpi-editor-canvas {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.kpi-editor-input {
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--f-border);
  background: var(--f-surface);
  color: var(--f-text);
  font-size: 12px;
  font-family: inherit;
}
.kpi-editor-input:focus {
  outline: none;
  border-color: var(--f-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--f-accent) 14%, transparent);
}

.kpi-editor-label {
  font-size: 10px;
  color: var(--f-text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
  font-weight: 600;
  display: block;
}

.kpi-palette-item:hover,
.kpi-palette-op:hover {
  background: var(--f-surface-alt) !important;
  border-color: var(--f-border-strong);
}

.kpi-rule-card {
  padding: 10px;
  border: 1px solid var(--f-border);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.kpi-rule-card .kpi-editor-input {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
}

.kpi-editor-skeleton {
  padding: 28px;
  text-align: center;
  color: var(--f-text-subtle);
  font-size: 12px;
}

/* Scoped layout for SchemaEditorView (Phase 2.3) */
.kpi-schema-editor {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--f-bg);
}
.kpi-schema-editor .kpi-editor-body {
  flex: 1;
  padding: 14px;
  display: grid;
  grid-template-columns: 260px 1fr 320px;
  gap: 12px;
  align-items: start;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}
.kpi-schema-editor .kpi-editor-palette,
.kpi-schema-editor .kpi-editor-preview {
  position: sticky;
  top: 12px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.kpi-schema-editor .kpi-rule-card input[type="number"] {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--f-border);
  background: var(--f-surface);
  color: var(--f-text);
  font-size: 13px;
}
.kpi-schema-editor .kpi-rule-card input[type="number"]:focus {
  outline: none;
  border-color: var(--f-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--f-accent) 14%, transparent);
}
@media (max-width: 1280px) {
  .kpi-schema-editor .kpi-editor-body {
    grid-template-columns: 240px 1fr 280px;
  }
}
@media (max-width: 1100px) {
  .kpi-schema-editor .kpi-editor-body {
    grid-template-columns: 1fr;
  }
  .kpi-schema-editor .kpi-editor-palette,
  .kpi-schema-editor .kpi-editor-preview {
    position: static;
    max-height: none;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
 * Deductions Journal (Phase 4.2) — журнал удержаний/начислений.
 * Используется в DeductionsView через mountJournal(rootEl).
 * Только токены var(--f-*).
 * ───────────────────────────────────────────────────────────────────────── */

.deductions-journal {
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* нижний отступ под sticky bulk-bar, чтобы он не перекрывал последнюю строку */
  padding-bottom: 72px;
}

/* Toolbar: search + status filter | + create / templates-edit */
.deductions-journal .dj-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.deductions-journal .dj-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 320px;
  min-width: 0;
}
.deductions-journal .dj-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.deductions-journal .dj-input {
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--f-border);
  background: var(--f-surface);
  color: var(--f-text);
  font-size: 13px;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
  min-width: 0;
}
.deductions-journal .dj-input::placeholder { color: var(--f-text-placeholder); }
.deductions-journal .dj-input:hover { border-color: var(--f-border-strong); }
.deductions-journal .dj-input:focus {
  border-color: var(--f-accent);
  box-shadow: var(--f-ring);
}
.deductions-journal .dj-search {
  flex: 1 1 240px;
  max-width: 360px;
}
.deductions-journal .dj-status-anchor {
  flex: 0 0 auto;
  min-width: 160px;
}

/* Шаблоны причин — chip-row */
.deductions-journal .dj-templates { min-height: 0; }
.deductions-journal .dj-tpl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.deductions-journal .dj-tpl-chip,
.dj-form .dj-tpl-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--f-border);
  background: var(--f-surface);
  color: var(--f-text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.deductions-journal .dj-tpl-chip:hover,
.dj-form .dj-tpl-chip:hover {
  border-color: var(--f-accent);
  background: var(--f-accent-soft);
  color: var(--f-accent-text);
}
.deductions-journal .dj-tpl-chip:focus-visible,
.dj-form .dj-tpl-chip:focus-visible {
  outline: none;
  box-shadow: var(--f-ring);
}
.deductions-journal .dj-tpl-chip .ph,
.dj-form .dj-tpl-chip .ph { font-size: 14px; line-height: 1; }
.deductions-journal .dj-tpl-amount {
  margin-left: 2px;
  color: var(--f-text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}

/* Таблица — CSS Grid (cb | дата | сотрудник | причина | сумма | статус | menu) */
.deductions-journal .dj-table-wrap {
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-lg);
  box-shadow: var(--f-shadow-sm);
  overflow: hidden;
}
.deductions-journal .dj-table {
  display: flex;
  flex-direction: column;
}
.deductions-journal .dj-tr {
  display: grid;
  grid-template-columns:
    36px            /* checkbox */
    96px            /* дата */
    minmax(180px, 1.4fr) /* сотрудник */
    minmax(220px, 2fr)   /* причина */
    120px           /* сумма */
    120px           /* статус */
    44px;           /* menu */
  align-items: center;
  gap: 0;
}
.deductions-journal .dj-td {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--f-text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deductions-journal .dj-td-cb { padding-left: 14px; padding-right: 0; }
.deductions-journal .dj-td-cb input[type="checkbox"] {
  width: 14px; height: 14px;
  accent-color: var(--f-accent);
  cursor: pointer;
}
.deductions-journal .dj-td-amount,
.deductions-journal .dj-td-status { text-align: right; justify-self: end; }
.deductions-journal .dj-td-menu  { text-align: right; padding-right: 8px; }

/* Header */
.deductions-journal .dj-th {
  background: var(--f-surface-alt);
  border-bottom: 1px solid var(--f-divider);
  color: var(--f-text-subtle);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.deductions-journal .dj-th .dj-td {
  padding-top: 8px;
  padding-bottom: 8px;
  font-weight: 500;
}

/* Row */
.deductions-journal .dj-row {
  border-top: 1px solid var(--f-divider);
  transition: background .1s ease;
  cursor: default;
}
.deductions-journal .dj-row:hover { background: var(--f-surface-alt); }
.deductions-journal .dj-row.selected,
.deductions-journal .dj-row:has(.dj-cb-row:checked) {
  background: var(--f-accent-soft);
}

/* Сотрудник: имя + позиция */
.deductions-journal .dj-staff-name {
  font-weight: 500;
  color: var(--f-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deductions-journal .dj-staff-pos {
  font-size: 11px;
  color: var(--f-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Сумма */
.deductions-journal .dj-td-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.deductions-journal .dj-amount-neg { color: var(--f-danger-text); }
.deductions-journal .dj-amount-pos { color: var(--f-success-text); }

/* Кнопка-меню в строке */
.deductions-journal .dj-row-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--f-text-muted);
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.deductions-journal .dj-row-menu-btn:hover {
  background: var(--f-surface);
  border-color: var(--f-border);
  color: var(--f-text);
}
.deductions-journal .dj-row-menu-btn:focus-visible {
  outline: none;
  box-shadow: var(--f-ring);
}

/* Поповер row-menu (рендерится в document.body, поэтому не вложен в .deductions-journal) */
.dj-row-menu {
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-md);
  box-shadow: var(--f-shadow-lg);
  padding: 4px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
}
.dj-row-menu .dj-row-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--f-text);
  font-size: 13px;
  text-align: left;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .1s ease;
}
.dj-row-menu .dj-row-menu-item:hover { background: var(--f-surface-alt); }
.dj-row-menu .dj-row-menu-item:focus-visible {
  outline: none;
  box-shadow: var(--f-ring);
}
.dj-row-menu .dj-row-menu-item .ph { color: var(--f-text-muted); }

/* Empty state */
.deductions-journal .dj-empty {
  padding: 48px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--f-surface);
  border: 1px dashed var(--f-border);
  border-radius: var(--r-lg);
  color: var(--f-text-muted);
  text-align: center;
}
.deductions-journal .dj-empty .ph { color: var(--f-text-subtle); }
.deductions-journal .dj-empty-title {
  margin: 0;
  font-size: 14px;
  color: var(--f-text);
  max-width: 360px;
}
.deductions-journal .dj-empty-actions { margin-top: 4px; }

/* Loading-состояние */
.deductions-journal .dj-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 16px;
  color: var(--f-text-muted);
  font-size: 13px;
}
.deductions-journal .dj-spin { animation: dj-spin 0.9s linear infinite; }
@keyframes dj-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Форма создания / редактор шаблонов */
.dj-form { display: flex; flex-direction: column; gap: 12px; }
.dj-form .dj-form-row { display: flex; flex-direction: column; gap: 4px; }
.dj-form .dj-form-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--f-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.dj-form .dj-input {
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--f-border);
  background: var(--f-surface);
  color: var(--f-text);
  font-size: 13px;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.dj-form .dj-input:focus {
  border-color: var(--f-accent);
  box-shadow: var(--f-ring);
}
.dj-form .dj-form-tpl-row { display: flex; flex-wrap: wrap; gap: 6px; }

.dj-tpl-editor { display: flex; flex-direction: column; gap: 8px; }
.dj-tpl-editor .dj-tpl-edit-list { display: flex; flex-direction: column; gap: 6px; }
.dj-tpl-editor .dj-tpl-edit-row {
  display: grid;
  grid-template-columns: 1.4fr 100px 1fr 32px;
  gap: 6px;
  align-items: center;
}
.dj-tpl-editor .dj-tpl-edit-row .dj-input { height: 30px; font-size: 12px; }
.dj-tpl-editor .dj-tpl-del { padding: 0; width: 28px; height: 28px; }

/* ─────────────────────────────────────────────────────────────────────────
 * f-bulkbar — sticky bulk-action bar (BulkActionBar.js).
 * Прилипает к низу окна, появляется при выборе ≥1 строки.
 * ───────────────────────────────────────────────────────────────────────── */

.f-bulkbar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--r-pill);
  box-shadow: var(--f-shadow-lg);
  padding: 6px 10px 6px 14px;
  max-width: calc(100vw - 32px);
}
.f-bulkbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 36px;
}
.f-bulkbar-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--f-text);
  font-size: 13px;
  white-space: nowrap;
}
.f-bulkbar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--f-accent);
}
.f-bulkbar-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.f-bulkbar-count { font-weight: 600; color: var(--f-text); }
.f-bulkbar-sep { color: var(--f-text-subtle); }
.f-bulkbar-summary {
  color: var(--f-text-muted);
  font-variant-numeric: tabular-nums;
}
.f-bulkbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* ── Payslip modal (Phase 5) ─────────────────────────────────────────── */

.payslip-modal {
  max-width: 720px;
  /* Гарантируем достаточную высоту, чтобы header+tabs+содержимое+итого
     помещались без визуального обрезания. Фактический предел — max-height
     из .f-modal (calc(100vh - 32px)). */
  min-height: 520px;
  height: min(86vh, 780px);
  /* Явно дублируем flex-column из .f-modal: <dialog> в некоторых сборках
     может игнорировать наследование при showModal(). */
  display: flex;
  flex-direction: column;
}

/* Header и tabs не сжимаются — body растёт и скроллится */
.payslip-modal .f-modal-head {
  flex: 0 0 auto;
  background: var(--f-surface);
}
.payslip-modal .payslip-tabs {
  flex: 0 0 auto;
  background: var(--f-surface);
}

/* Body занимает оставшееся пространство и скроллится */
.payslip-modal .payslip-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.payslip-loading {
  padding: 40px 0;
  text-align: center;
  color: var(--f-text-muted);
  font-size: 13px;
}

.payslip-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 22px 0;
  border-bottom: 1px solid var(--f-divider);
  overflow-x: auto;
}

.payslip-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 10px;
  margin-bottom: -1px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--f-text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.payslip-tab:hover { color: var(--f-text); }
.payslip-tab.is-active {
  color: var(--f-accent);
  border-bottom-color: var(--f-accent);
}
.payslip-tab-icon { font-size: 16px; }

.payslip-body {
  padding: 16px 22px 22px;
}

.payslip-section {
  margin-bottom: 18px;
}
.payslip-section:last-child { margin-bottom: 0; }

.payslip-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.payslip-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--f-text-muted);
}
.payslip-section-sum {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--f-text);
}

.payslip-section-body {
  border: 1px solid var(--f-divider);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--f-surface-alt);
}

.payslip-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--f-divider);
  font-size: 13px;
  color: var(--f-text);
}
.payslip-row:last-child { border-bottom: none; }
.payslip-row-label {
  flex: 1;
  min-width: 0;
}
.payslip-row-sub {
  font-size: 11px;
  color: var(--f-text-muted);
  margin-top: 2px;
}
.payslip-row-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
}

.payslip-pos { color: var(--f-success, #16a34a); }
.payslip-neg { color: var(--f-danger,  #dc2626); }

.payslip-link {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--f-divider);
  border-radius: 6px;
  color: var(--f-text-muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.payslip-link:hover {
  background: var(--f-accent-soft);
  color: var(--f-accent);
  border-color: var(--f-accent);
}
.payslip-link-icon { font-size: 14px; }

.payslip-empty {
  padding: 12px;
  font-size: 12px;
  color: var(--f-text-muted);
  text-align: center;
}
.payslip-empty--big {
  padding: 40px 12px;
  font-size: 13px;
}

.payslip-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 18px;
  padding: 14px 16px;
  border-top: 2px solid var(--f-text);
  border-radius: 4px;
  background: var(--f-surface-alt);
  /* Sticky итог: всегда виден внизу при длинном содержимом */
  position: sticky;
  bottom: -22px; /* компенсируем нижний padding .payslip-body (22px) */
  z-index: 1;
  box-shadow: 0 -8px 16px -8px color-mix(in srgb, var(--f-surface) 70%, transparent);
}
.payslip-total-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--f-text-muted);
}
.payslip-total-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--f-text);
}
